Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 848151c

Browse files
authoredFeb 24, 2025··
fixed dart format changes. (#62)
1 parent 768ba95 commit 848151c

File tree

7 files changed

+339
-311
lines changed

7 files changed

+339
-311
lines changed
 

‎google_api_availability/example/lib/main.dart

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -129,64 +129,68 @@ class _MyAppState extends State<MyApp> {
129129
Widget build(BuildContext context) {
130130
return MaterialApp(
131131
home: Scaffold(
132-
appBar: AppBar(
133-
title: const Text('Plugin example app'),
134-
),
135-
body: ListView(
136-
children: <Widget>[
137-
MaterialButton(
138-
onPressed: () => checkPlayServices(),
139-
child: const Text('Get PlayServices availability'),
140-
color: Colors.red,
132+
appBar: AppBar(title: const Text('Plugin example app')),
133+
body: ListView(
134+
children: <Widget>[
135+
MaterialButton(
136+
onPressed: () => checkPlayServices(),
137+
child: const Text('Get PlayServices availability'),
138+
color: Colors.red,
139+
),
140+
Center(
141+
child: Text(
142+
'Google Play Store status: ${_playStoreAvailability.toString().split('.').last}\n',
141143
),
142-
Center(
143-
child: Text(
144-
'Google Play Store status: ${_playStoreAvailability.toString().split('.').last}\n')),
145-
MaterialButton(
146-
onPressed: () => checkPlayServices(true),
147-
child:
148-
const Text('Get PlayServices availability with fix dialog'),
149-
color: Colors.redAccent,
144+
),
145+
MaterialButton(
146+
onPressed: () => checkPlayServices(true),
147+
child: const Text(
148+
'Get PlayServices availability with fix dialog',
150149
),
151-
Center(
152-
child: Text(
153-
'Google Play Store status: ${_playStoreAvailability.toString().split('.').last}\n')),
154-
MaterialButton(
155-
onPressed: () => makeGooglePlayServicesAvailable(),
156-
child: const Text('Make Google Play Service available'),
157-
color: Colors.red,
150+
color: Colors.redAccent,
151+
),
152+
Center(
153+
child: Text(
154+
'Google Play Store status: ${_playStoreAvailability.toString().split('.').last}\n',
158155
),
159-
const SizedBox(height: 30),
160-
MaterialButton(
161-
onPressed: () => getErrorString(),
162-
child: const Text('Get string of the error code'),
163-
color: Colors.red,
164-
),
165-
Center(child: Text('Error string: $_errorString\n')),
166-
MaterialButton(
167-
onPressed: () => isUserResolvable(),
168-
child: const Text('Error resolvable by user'),
169-
color: Colors.red,
170-
),
171-
Center(
172-
child:
173-
Text('Error resolvable by user: $_isUserResolvable\n')),
174-
MaterialButton(
175-
onPressed: () => showErrorNotification(),
176-
child: const Text('Show error notification'),
177-
color: Colors.red,
178-
),
179-
const SizedBox(height: 30),
180-
MaterialButton(
181-
onPressed: () => showErrorDialogFragment(),
182-
child: const Text('Show error dialog fragment'),
183-
color: Colors.red,
184-
),
185-
Center(
186-
child:
187-
Text('Error dialog shown: $_errorDialogFragmentShown\n')),
188-
],
189-
)),
156+
),
157+
MaterialButton(
158+
onPressed: () => makeGooglePlayServicesAvailable(),
159+
child: const Text('Make Google Play Service available'),
160+
color: Colors.red,
161+
),
162+
const SizedBox(height: 30),
163+
MaterialButton(
164+
onPressed: () => getErrorString(),
165+
child: const Text('Get string of the error code'),
166+
color: Colors.red,
167+
),
168+
Center(child: Text('Error string: $_errorString\n')),
169+
MaterialButton(
170+
onPressed: () => isUserResolvable(),
171+
child: const Text('Error resolvable by user'),
172+
color: Colors.red,
173+
),
174+
Center(
175+
child: Text('Error resolvable by user: $_isUserResolvable\n'),
176+
),
177+
MaterialButton(
178+
onPressed: () => showErrorNotification(),
179+
child: const Text('Show error notification'),
180+
color: Colors.red,
181+
),
182+
const SizedBox(height: 30),
183+
MaterialButton(
184+
onPressed: () => showErrorDialogFragment(),
185+
child: const Text('Show error dialog fragment'),
186+
color: Colors.red,
187+
),
188+
Center(
189+
child: Text('Error dialog shown: $_errorDialogFragmentShown\n'),
190+
),
191+
],
192+
),
193+
),
190194
);
191195
}
192196
}

‎google_api_availability/lib/src/google_api_availability.dart

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@ class GoogleApiAvailability {
2020
///
2121
/// Optionally, you can also show an error dialog if the connection status is
2222
/// not [SUCCESS].
23-
Future<GooglePlayServicesAvailability> checkGooglePlayServicesAvailability(
24-
[bool showDialogIfNecessary = false]) async {
23+
Future<GooglePlayServicesAvailability> checkGooglePlayServicesAvailability([
24+
bool showDialogIfNecessary = false,
25+
]) async {
2526
if (GoogleApiAvailabilityPlatform.instance == null) {
2627
throw UnsupportedError('This platform is not supported.');
2728
}

‎google_api_availability/test/google_api_availability_test.dart

Lines changed: 118 additions & 116 deletions
Original file line numberDiff line numberDiff line change
@@ -23,194 +23,196 @@ void main() {
2323
});
2424

2525
group('checkGooglePlayServicesAvailability', () {
26-
test('Should throw if no platform implementation is registered',
27-
() async {
28-
// Arrange.
29-
GoogleApiAvailabilityPlatform.removeInstance();
30-
31-
// Act & Assert.
32-
expect(
33-
googleApiAvailability.checkGooglePlayServicesAvailability,
34-
throwsA(isA<UnsupportedError>()),
35-
);
36-
});
37-
38-
test('Should receive the corresponding $GooglePlayServicesAvailability',
39-
() async {
40-
// Arrange.
41-
const availability = GooglePlayServicesAvailability.serviceDisabled;
42-
43-
when(() => googleApiAvailabilityPlatform
44-
.checkGooglePlayServicesAvailability())
45-
.thenAnswer((_) async => availability);
46-
47-
// Act.
48-
final googlePlayServiceAvailability =
49-
await googleApiAvailability.checkGooglePlayServicesAvailability();
50-
51-
// Assert.
52-
expect(
53-
googlePlayServiceAvailability,
54-
availability,
55-
);
56-
});
26+
test(
27+
'Should throw if no platform implementation is registered',
28+
() async {
29+
// Arrange.
30+
GoogleApiAvailabilityPlatform.removeInstance();
31+
32+
// Act & Assert.
33+
expect(
34+
googleApiAvailability.checkGooglePlayServicesAvailability,
35+
throwsA(isA<UnsupportedError>()),
36+
);
37+
},
38+
);
39+
40+
test(
41+
'Should receive the corresponding $GooglePlayServicesAvailability',
42+
() async {
43+
// Arrange.
44+
const availability = GooglePlayServicesAvailability.serviceDisabled;
45+
46+
when(
47+
() => googleApiAvailabilityPlatform
48+
.checkGooglePlayServicesAvailability(),
49+
).thenAnswer((_) async => availability);
50+
51+
// Act.
52+
final googlePlayServiceAvailability =
53+
await googleApiAvailability.checkGooglePlayServicesAvailability();
54+
55+
// Assert.
56+
expect(googlePlayServiceAvailability, availability);
57+
},
58+
);
5759
});
5860

5961
group('makeGooglePlayServicesAvailable', () {
60-
test('Should throw if no platform implementation is registered',
61-
() async {
62-
// Arrange.
63-
GoogleApiAvailabilityPlatform.removeInstance();
64-
65-
// Act & Assert.
66-
expect(
67-
googleApiAvailability.makeGooglePlayServicesAvailable,
68-
throwsA(isA<UnsupportedError>()),
69-
);
70-
});
62+
test(
63+
'Should throw if no platform implementation is registered',
64+
() async {
65+
// Arrange.
66+
GoogleApiAvailabilityPlatform.removeInstance();
67+
68+
// Act & Assert.
69+
expect(
70+
googleApiAvailability.makeGooglePlayServicesAvailable,
71+
throwsA(isA<UnsupportedError>()),
72+
);
73+
},
74+
);
7175
});
7276

7377
group('getErrorString', () {
74-
test('Should throw if no platform implementation is registered',
75-
() async {
76-
// Arrange.
77-
GoogleApiAvailabilityPlatform.removeInstance();
78-
79-
// Act & Assert.
80-
expect(
81-
googleApiAvailability.getErrorString,
82-
throwsA(isA<UnsupportedError>()),
83-
);
84-
});
78+
test(
79+
'Should throw if no platform implementation is registered',
80+
() async {
81+
// Arrange.
82+
GoogleApiAvailabilityPlatform.removeInstance();
83+
84+
// Act & Assert.
85+
expect(
86+
googleApiAvailability.getErrorString,
87+
throwsA(isA<UnsupportedError>()),
88+
);
89+
},
90+
);
8591

8692
test('Should receive the corresponding error string', () async {
8793
// Arrange.
8894
const expectedErrorString = 'test_error_string';
8995

90-
when(() => googleApiAvailabilityPlatform.getErrorString())
91-
.thenAnswer((_) async => expectedErrorString);
96+
when(
97+
() => googleApiAvailabilityPlatform.getErrorString(),
98+
).thenAnswer((_) async => expectedErrorString);
9299

93100
// Act.
94101
final errorString =
95102
await const GoogleApiAvailability.private().getErrorString();
96103

97104
// Assert.
98-
expect(
99-
errorString,
100-
expectedErrorString,
101-
);
105+
expect(errorString, expectedErrorString);
102106
});
103107
});
104108

105109
group('isUserResolvable', () {
106-
test('Should throw if no platform implementation is registered',
107-
() async {
108-
// Arrange.
109-
GoogleApiAvailabilityPlatform.removeInstance();
110-
111-
// Act & Assert.
112-
expect(
113-
googleApiAvailability.isUserResolvable,
114-
throwsA(isA<UnsupportedError>()),
115-
);
116-
});
110+
test(
111+
'Should throw if no platform implementation is registered',
112+
() async {
113+
// Arrange.
114+
GoogleApiAvailabilityPlatform.removeInstance();
115+
116+
// Act & Assert.
117+
expect(
118+
googleApiAvailability.isUserResolvable,
119+
throwsA(isA<UnsupportedError>()),
120+
);
121+
},
122+
);
117123

118124
test('Should receive true if the user is resolvable', () async {
119125
// Arrange.
120126
const expectedIsUserResolvable = true;
121127

122-
when(() => googleApiAvailabilityPlatform.isUserResolvable())
123-
.thenAnswer((_) async => expectedIsUserResolvable);
128+
when(
129+
() => googleApiAvailabilityPlatform.isUserResolvable(),
130+
).thenAnswer((_) async => expectedIsUserResolvable);
124131

125132
// Act.
126133
final isUserResolvable = await googleApiAvailability.isUserResolvable();
127134

128135
// Assert.
129-
expect(
130-
isUserResolvable,
131-
expectedIsUserResolvable,
132-
);
136+
expect(isUserResolvable, expectedIsUserResolvable);
133137
});
134138

135139
test('Should receive false if the user is not resolvable', () async {
136140
// Arrange.
137141
const expectedIsUserResolvable = false;
138142

139-
when(() => googleApiAvailabilityPlatform.isUserResolvable())
140-
.thenAnswer((_) async => expectedIsUserResolvable);
143+
when(
144+
() => googleApiAvailabilityPlatform.isUserResolvable(),
145+
).thenAnswer((_) async => expectedIsUserResolvable);
141146

142147
// Act.
143148
final isUserResolvable = await googleApiAvailability.isUserResolvable();
144149

145150
// Assert.
146-
expect(
147-
isUserResolvable,
148-
expectedIsUserResolvable,
149-
);
151+
expect(isUserResolvable, expectedIsUserResolvable);
150152
});
151153
});
152154

153155
group('showErrorNotification', () {
154-
test('Should throw if no platform implementation is registered',
155-
() async {
156-
// Arrange.
157-
GoogleApiAvailabilityPlatform.removeInstance();
158-
159-
// Act & Assert.
160-
expect(
161-
googleApiAvailability.showErrorNotification,
162-
throwsA(isA<UnsupportedError>()),
163-
);
164-
});
156+
test(
157+
'Should throw if no platform implementation is registered',
158+
() async {
159+
// Arrange.
160+
GoogleApiAvailabilityPlatform.removeInstance();
161+
162+
// Act & Assert.
163+
expect(
164+
googleApiAvailability.showErrorNotification,
165+
throwsA(isA<UnsupportedError>()),
166+
);
167+
},
168+
);
165169
});
166170

167171
group('showErrorDialogFragment', () {
168-
test('Should throw if no platform implementation is registered',
169-
() async {
170-
// Arrange.
171-
GoogleApiAvailabilityPlatform.removeInstance();
172-
173-
// Act & Assert.
174-
expect(
175-
googleApiAvailability.showErrorDialogFragment,
176-
throwsA(isA<UnsupportedError>()),
177-
);
178-
});
172+
test(
173+
'Should throw if no platform implementation is registered',
174+
() async {
175+
// Arrange.
176+
GoogleApiAvailabilityPlatform.removeInstance();
177+
178+
// Act & Assert.
179+
expect(
180+
googleApiAvailability.showErrorDialogFragment,
181+
throwsA(isA<UnsupportedError>()),
182+
);
183+
},
184+
);
179185

180186
test('Should receive false when dialog should not be shown', () async {
181187
// Arrange.
182188
const expectedShowDialogFragment = false;
183189

184-
when(() => googleApiAvailabilityPlatform.showErrorDialogFragment())
185-
.thenAnswer((_) async => expectedShowDialogFragment);
190+
when(
191+
() => googleApiAvailabilityPlatform.showErrorDialogFragment(),
192+
).thenAnswer((_) async => expectedShowDialogFragment);
186193

187194
// Act.
188195
final showErrorDialogFragment =
189196
await googleApiAvailability.showErrorDialogFragment();
190197

191198
// Assert.
192-
expect(
193-
expectedShowDialogFragment,
194-
showErrorDialogFragment,
195-
);
199+
expect(expectedShowDialogFragment, showErrorDialogFragment);
196200
});
197201

198202
test('Should receive true when dialog should be shown', () async {
199203
// Arrange.
200204
const expectedShowDialogFragment = true;
201205

202-
when(() => googleApiAvailabilityPlatform.showErrorDialogFragment())
203-
.thenAnswer((_) async => expectedShowDialogFragment);
206+
when(
207+
() => googleApiAvailabilityPlatform.showErrorDialogFragment(),
208+
).thenAnswer((_) async => expectedShowDialogFragment);
204209

205210
// Act.
206211
final showErrorDialogFragment =
207212
await googleApiAvailability.showErrorDialogFragment();
208213

209214
// Assert.
210-
expect(
211-
expectedShowDialogFragment,
212-
showErrorDialogFragment,
213-
);
215+
expect(expectedShowDialogFragment, showErrorDialogFragment);
214216
});
215217
});
216218
});

‎google_api_availability_android/example/lib/main.dart

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -131,64 +131,68 @@ class _MyAppState extends State<MyApp> {
131131
Widget build(BuildContext context) {
132132
return MaterialApp(
133133
home: Scaffold(
134-
appBar: AppBar(
135-
title: const Text('Plugin example app'),
136-
),
137-
body: ListView(
138-
children: <Widget>[
139-
MaterialButton(
140-
onPressed: () => checkPlayServices(),
141-
color: Colors.red,
142-
child: const Text('Get PlayServices availability'),
134+
appBar: AppBar(title: const Text('Plugin example app')),
135+
body: ListView(
136+
children: <Widget>[
137+
MaterialButton(
138+
onPressed: () => checkPlayServices(),
139+
color: Colors.red,
140+
child: const Text('Get PlayServices availability'),
141+
),
142+
Center(
143+
child: Text(
144+
'Google Play Store status: ${_playStoreAvailability.toString().split('.').last}\n',
143145
),
144-
Center(
145-
child: Text(
146-
'Google Play Store status: ${_playStoreAvailability.toString().split('.').last}\n')),
147-
MaterialButton(
148-
onPressed: () => checkPlayServices(true),
149-
color: Colors.redAccent,
150-
child:
151-
const Text('Get PlayServices availability with fix dialog'),
146+
),
147+
MaterialButton(
148+
onPressed: () => checkPlayServices(true),
149+
color: Colors.redAccent,
150+
child: const Text(
151+
'Get PlayServices availability with fix dialog',
152152
),
153-
Center(
154-
child: Text(
155-
'Google Play Store status: ${_playStoreAvailability.toString().split('.').last}\n')),
156-
MaterialButton(
157-
onPressed: () => makeGooglePlayServicesAvailable(),
158-
color: Colors.red,
159-
child: const Text('Make Google Play Service available'),
153+
),
154+
Center(
155+
child: Text(
156+
'Google Play Store status: ${_playStoreAvailability.toString().split('.').last}\n',
160157
),
161-
const SizedBox(height: 30),
162-
MaterialButton(
163-
onPressed: () => getErrorString(),
164-
color: Colors.red,
165-
child: const Text('Get string of the error code'),
166-
),
167-
Center(child: Text('Error string: $_errorString\n')),
168-
MaterialButton(
169-
onPressed: () => isUserResolvable(),
170-
color: Colors.red,
171-
child: const Text('Error resolvable by user'),
172-
),
173-
Center(
174-
child:
175-
Text('Error resolvable by user: $_isUserResolvable\n')),
176-
MaterialButton(
177-
onPressed: () => showErrorNotification(),
178-
color: Colors.red,
179-
child: const Text('Show error notification'),
180-
),
181-
const SizedBox(height: 30),
182-
MaterialButton(
183-
onPressed: () => showErrorDialogFragment(),
184-
color: Colors.red,
185-
child: const Text('Show error dialog fragment'),
186-
),
187-
Center(
188-
child:
189-
Text('Error dialog shown: $_errorDialogFragmentShown\n')),
190-
],
191-
)),
158+
),
159+
MaterialButton(
160+
onPressed: () => makeGooglePlayServicesAvailable(),
161+
color: Colors.red,
162+
child: const Text('Make Google Play Service available'),
163+
),
164+
const SizedBox(height: 30),
165+
MaterialButton(
166+
onPressed: () => getErrorString(),
167+
color: Colors.red,
168+
child: const Text('Get string of the error code'),
169+
),
170+
Center(child: Text('Error string: $_errorString\n')),
171+
MaterialButton(
172+
onPressed: () => isUserResolvable(),
173+
color: Colors.red,
174+
child: const Text('Error resolvable by user'),
175+
),
176+
Center(
177+
child: Text('Error resolvable by user: $_isUserResolvable\n'),
178+
),
179+
MaterialButton(
180+
onPressed: () => showErrorNotification(),
181+
color: Colors.red,
182+
child: const Text('Show error notification'),
183+
),
184+
const SizedBox(height: 30),
185+
MaterialButton(
186+
onPressed: () => showErrorDialogFragment(),
187+
color: Colors.red,
188+
child: const Text('Show error dialog fragment'),
189+
),
190+
Center(
191+
child: Text('Error dialog shown: $_errorDialogFragmentShown\n'),
192+
),
193+
],
194+
),
195+
),
192196
);
193197
}
194198
}

‎google_api_availability_android/lib/src/google_api_availability_android.dart

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ import 'package:google_api_availability_platform_interface/google_api_availabili
55
/// An Android implementation of [GoogleApiAvailabilityPlatform] that used method channels.
66
class GoogleApiAvailabilityAndroid extends GoogleApiAvailabilityPlatform {
77
static const MethodChannel _methodChannel = MethodChannel(
8-
'flutter.baseflow.com/google_api_availability_android/methods');
8+
'flutter.baseflow.com/google_api_availability_android/methods',
9+
);
910

1011
/// Registers this class as the default instance of [GoogleApiAvailabilityPlatform].
1112
static void registerWith() {
@@ -17,8 +18,9 @@ class GoogleApiAvailabilityAndroid extends GoogleApiAvailabilityPlatform {
1718
/// Optionally, you can also show an error dialog if the connection status is
1819
/// not [GooglePlayServicesAvailability.success].
1920
@override
20-
Future<GooglePlayServicesAvailability> checkGooglePlayServicesAvailability(
21-
[bool showDialogIfNecessary = false]) async {
21+
Future<GooglePlayServicesAvailability> checkGooglePlayServicesAvailability([
22+
bool showDialogIfNecessary = false,
23+
]) async {
2224
final availability = await _methodChannel.invokeMethod(
2325
'checkPlayServicesAvailability',
2426
<String, bool>{'showDialog': showDialogIfNecessary},
@@ -57,8 +59,9 @@ class GoogleApiAvailabilityAndroid extends GoogleApiAvailabilityPlatform {
5759
/// Determines whether an error can be resolved via user action.
5860
@override
5961
Future<bool> isUserResolvable() async {
60-
final isUserResolvable =
61-
await _methodChannel.invokeMethod('isUserResolvable');
62+
final isUserResolvable = await _methodChannel.invokeMethod(
63+
'isUserResolvable',
64+
);
6265

6366
if (isUserResolvable == null) {
6467
return false;
@@ -84,8 +87,9 @@ class GoogleApiAvailabilityAndroid extends GoogleApiAvailabilityPlatform {
8487
/// non-[ConnectionResult] value. Returns false otherwise.
8588
@override
8689
Future<bool> showErrorDialogFragment() async {
87-
final showErrorDialogFragment =
88-
await _methodChannel.invokeMethod('showErrorDialogFragment');
90+
final showErrorDialogFragment = await _methodChannel.invokeMethod(
91+
'showErrorDialogFragment',
92+
);
8993

9094
if (showErrorDialogFragment == null) {
9195
return false;

‎google_api_availability_android/test/google_api_availability_android_test.dart

Lines changed: 85 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -8,87 +8,98 @@ void main() {
88
TestWidgetsFlutterBinding.ensureInitialized();
99

1010
group('checkGooglePlayServiceAvailability', () {
11-
test('Should receive the corresponding GooglePlayServiceAvailability',
12-
() async {
13-
// Arrange
14-
const availability = GooglePlayServicesAvailability.serviceDisabled;
15-
16-
MethodChannelMock(
17-
channelName:
18-
'flutter.baseflow.com/google_api_availability_android/methods',
19-
method: 'checkPlayServicesAvailability',
20-
result: availability.value,
21-
);
22-
23-
// Act
24-
final googlePlayServiceAvailability = await GoogleApiAvailabilityAndroid()
25-
.checkGooglePlayServicesAvailability();
26-
27-
// Assert
28-
expect(googlePlayServiceAvailability, availability);
29-
});
30-
3111
test(
32-
'Should receive GooglePlayServiceAvailability.unknown when availability is null',
33-
() async {
34-
// Arrange
35-
const availability = null;
12+
'Should receive the corresponding GooglePlayServiceAvailability',
13+
() async {
14+
// Arrange
15+
const availability = GooglePlayServicesAvailability.serviceDisabled;
16+
17+
MethodChannelMock(
18+
channelName:
19+
'flutter.baseflow.com/google_api_availability_android/methods',
20+
method: 'checkPlayServicesAvailability',
21+
result: availability.value,
22+
);
23+
24+
// Act
25+
final googlePlayServiceAvailability =
26+
await GoogleApiAvailabilityAndroid()
27+
.checkGooglePlayServicesAvailability();
28+
29+
// Assert
30+
expect(googlePlayServiceAvailability, availability);
31+
},
32+
);
3633

37-
MethodChannelMock(
38-
channelName:
39-
'flutter.baseflow.com/google_api_availability_android/methods',
40-
method: 'checkPlayServicesAvailability',
41-
result: availability,
42-
);
43-
44-
// Act
45-
final googlePlayServiceAvailability = await GoogleApiAvailabilityAndroid()
46-
.checkGooglePlayServicesAvailability();
47-
48-
// Assert
49-
expect(googlePlayServiceAvailability,
50-
GooglePlayServicesAvailability.unknown);
51-
});
34+
test(
35+
'Should receive GooglePlayServiceAvailability.unknown when availability is null',
36+
() async {
37+
// Arrange
38+
const availability = null;
39+
40+
MethodChannelMock(
41+
channelName:
42+
'flutter.baseflow.com/google_api_availability_android/methods',
43+
method: 'checkPlayServicesAvailability',
44+
result: availability,
45+
);
46+
47+
// Act
48+
final googlePlayServiceAvailability =
49+
await GoogleApiAvailabilityAndroid()
50+
.checkGooglePlayServicesAvailability();
51+
52+
// Assert
53+
expect(
54+
googlePlayServiceAvailability,
55+
GooglePlayServicesAvailability.unknown,
56+
);
57+
},
58+
);
5259
});
5360

5461
group('getErrorString', () {
55-
test('Should receive "ErrorString is null" when availability is null',
56-
() async {
57-
// Arrange
58-
const errorString = null;
59-
60-
MethodChannelMock(
61-
channelName:
62-
'flutter.baseflow.com/google_api_availability_android/methods',
63-
method: 'getErrorString',
64-
result: errorString,
65-
);
66-
67-
// Act
68-
final errorStringResult =
69-
await GoogleApiAvailabilityAndroid().getErrorString();
70-
71-
//Assert
72-
expect(errorStringResult, "ErrorString is null");
73-
});
74-
7562
test(
76-
'Should receive ${GooglePlayServicesAvailability.success} when connection status is success',
77-
() async {
78-
// Arrange
79-
MethodChannelMock(
80-
channelName:
81-
'flutter.baseflow.com/google_api_availability_android/methods',
82-
method: 'getErrorString',
83-
result: "SUCCESS",
84-
);
63+
'Should receive "ErrorString is null" when availability is null',
64+
() async {
65+
// Arrange
66+
const errorString = null;
67+
68+
MethodChannelMock(
69+
channelName:
70+
'flutter.baseflow.com/google_api_availability_android/methods',
71+
method: 'getErrorString',
72+
result: errorString,
73+
);
74+
75+
// Act
76+
final errorStringResult =
77+
await GoogleApiAvailabilityAndroid().getErrorString();
78+
79+
//Assert
80+
expect(errorStringResult, "ErrorString is null");
81+
},
82+
);
8583

86-
// Act
87-
final errorString = await GoogleApiAvailabilityAndroid().getErrorString();
88-
89-
// Assert
90-
expect(errorString, "SUCCESS");
91-
});
84+
test(
85+
'Should receive ${GooglePlayServicesAvailability.success} when connection status is success',
86+
() async {
87+
// Arrange
88+
MethodChannelMock(
89+
channelName:
90+
'flutter.baseflow.com/google_api_availability_android/methods',
91+
method: 'getErrorString',
92+
result: "SUCCESS",
93+
);
94+
95+
// Act
96+
final errorString =
97+
await GoogleApiAvailabilityAndroid().getErrorString();
98+
99+
// Assert
100+
expect(errorString, "SUCCESS");
101+
},
102+
);
92103
});
93104

94105
group('isUserResolvable', () {

‎google_api_availability_android/test/method_channel_mock.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,10 @@ class MethodChannelMock {
1919

2020
Future _handler(MethodCall methodCall) async {
2121
if (methodCall.method != method) {
22-
throw MissingPluginException('No implementation found for method '
23-
'$method on channel ${methodChannel.name}');
22+
throw MissingPluginException(
23+
'No implementation found for method '
24+
'$method on channel ${methodChannel.name}',
25+
);
2426
}
2527

2628
return Future.delayed(delay, () {

0 commit comments

Comments
 (0)
Please sign in to comment.