Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 82876ba

Browse files
committed
prepare for TestDefaultBinaryMessengerBinding.instance becoming non-nullable
1 parent 3a093e4 commit 82876ba

File tree

6 files changed

+72
-22
lines changed

6 files changed

+72
-22
lines changed

packages/camera/camera_android/test/android_camera_test.dart

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ void main() {
3232
// registerWith is called very early in initialization the bindings won't
3333
// have been initialized. While registerWith could intialize them, that
3434
// could slow down startup, so instead the handler should be set up lazily.
35-
final ByteData? response = await TestDefaultBinaryMessengerBinding
36-
.instance!.defaultBinaryMessenger
37-
.handlePlatformMessage(
38-
AndroidCamera.deviceEventChannelName,
39-
const StandardMethodCodec().encodeMethodCall(const MethodCall(
40-
'orientation_changed',
41-
<String, Object>{'orientation': 'portraitDown'})),
42-
(ByteData? data) {});
35+
final ByteData? response =
36+
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)
37+
.defaultBinaryMessenger
38+
.handlePlatformMessage(
39+
AndroidCamera.deviceEventChannelName,
40+
const StandardMethodCodec().encodeMethodCall(const MethodCall(
41+
'orientation_changed',
42+
<String, Object>{'orientation': 'portraitDown'})),
43+
(ByteData? data) {});
4344
expect(response, null);
4445
});
4546

@@ -421,7 +422,8 @@ void main() {
421422
const DeviceOrientationChangedEvent event =
422423
DeviceOrientationChangedEvent(DeviceOrientation.portraitUp);
423424
for (int i = 0; i < 3; i++) {
424-
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
425+
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)
426+
.defaultBinaryMessenger
425427
.handlePlatformMessage(
426428
AndroidCamera.deviceEventChannelName,
427429
const StandardMethodCodec().encodeMethodCall(
@@ -1119,3 +1121,10 @@ void main() {
11191121
});
11201122
});
11211123
}
1124+
1125+
// Temporary hack to work around changes in https://github.com/flutter/flutter/pull/116937
1126+
// This should be removed once the relevant changes makes it to stable.
1127+
// TODO(ianh): look into this in Q2 2023.
1128+
T _ambiguate<T extends Object>(T? value) {
1129+
return value!;
1130+
}

packages/camera/camera_avfoundation/test/avfoundation_camera_test.dart

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,15 @@ void main() {
3232
// registerWith is called very early in initialization the bindings won't
3333
// have been initialized. While registerWith could intialize them, that
3434
// could slow down startup, so instead the handler should be set up lazily.
35-
final ByteData? response = await TestDefaultBinaryMessengerBinding
36-
.instance!.defaultBinaryMessenger
37-
.handlePlatformMessage(
38-
AVFoundationCamera.deviceEventChannelName,
39-
const StandardMethodCodec().encodeMethodCall(const MethodCall(
40-
'orientation_changed',
41-
<String, Object>{'orientation': 'portraitDown'})),
42-
(ByteData? data) {});
35+
final ByteData? response =
36+
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)
37+
.defaultBinaryMessenger
38+
.handlePlatformMessage(
39+
AVFoundationCamera.deviceEventChannelName,
40+
const StandardMethodCodec().encodeMethodCall(const MethodCall(
41+
'orientation_changed',
42+
<String, Object>{'orientation': 'portraitDown'})),
43+
(ByteData? data) {});
4344
expect(response, null);
4445
});
4546

@@ -421,7 +422,8 @@ void main() {
421422
const DeviceOrientationChangedEvent event =
422423
DeviceOrientationChangedEvent(DeviceOrientation.portraitUp);
423424
for (int i = 0; i < 3; i++) {
424-
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
425+
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)
426+
.defaultBinaryMessenger
425427
.handlePlatformMessage(
426428
AVFoundationCamera.deviceEventChannelName,
427429
const StandardMethodCodec().encodeMethodCall(
@@ -1117,3 +1119,10 @@ void main() {
11171119
});
11181120
});
11191121
}
1122+
1123+
// Temporary hack to work around changes in https://github.com/flutter/flutter/pull/116937
1124+
// This should be removed once the relevant changes makes it to stable.
1125+
// TODO(ianh): look into this in Q2 2023.
1126+
T _ambiguate<T extends Object>(T? value) {
1127+
return value!;
1128+
}

packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ void main() {
3737
int mapId, String method, Map<dynamic, dynamic> data) async {
3838
final ByteData byteData =
3939
const StandardMethodCodec().encodeMethodCall(MethodCall(method, data));
40-
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
40+
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)
41+
.defaultBinaryMessenger
4142
.handlePlatformMessage('plugins.flutter.dev/google_maps_android_$mapId',
4243
byteData, (ByteData? data) {});
4344
}
@@ -164,3 +165,10 @@ void main() {
164165
expect(widget, isA<PlatformViewLink>());
165166
});
166167
}
168+
169+
// Temporary hack to work around changes in https://github.com/flutter/flutter/pull/116937
170+
// This should be removed once the relevant changes makes it to stable.
171+
// TODO(ianh): look into this in Q2 2023.
172+
T _ambiguate<T extends Object>(T? value) {
173+
return value!;
174+
}

packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ void main() {
3636
int mapId, String method, Map<dynamic, dynamic> data) async {
3737
final ByteData byteData =
3838
const StandardMethodCodec().encodeMethodCall(MethodCall(method, data));
39-
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
39+
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)
40+
.defaultBinaryMessenger
4041
.handlePlatformMessage('plugins.flutter.dev/google_maps_ios_$mapId',
4142
byteData, (ByteData? data) {});
4243
}
@@ -122,3 +123,10 @@ void main() {
122123
equals('drag-end-marker'));
123124
});
124125
}
126+
127+
// Temporary hack to work around changes in https://github.com/flutter/flutter/pull/116937
128+
// This should be removed once the relevant changes makes it to stable.
129+
// TODO(ianh): look into this in Q2 2023.
130+
T _ambiguate<T extends Object>(T? value) {
131+
return value!;
132+
}

packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel/method_channel_google_maps_flutter_test.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ void main() {
3636
int mapId, String method, Map<dynamic, dynamic> data) async {
3737
final ByteData byteData = const StandardMethodCodec()
3838
.encodeMethodCall(MethodCall(method, data));
39-
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
39+
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)
40+
.defaultBinaryMessenger
4041
.handlePlatformMessage('plugins.flutter.io/google_maps_$mapId',
4142
byteData, (ByteData? data) {});
4243
}
@@ -120,3 +121,10 @@ void main() {
120121
});
121122
});
122123
}
124+
125+
// Temporary hack to work around changes in https://github.com/flutter/flutter/pull/116937
126+
// This should be removed once the relevant changes makes it to stable.
127+
// TODO(ianh): look into this in Q2 2023.
128+
T _ambiguate<T extends Object>(T? value) {
129+
return value!;
130+
}

packages/path_provider/path_provider_macos/test/path_provider_macos_test.dart

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ void main() {
4040
downloadsPath = p.join(basePath, 'downloads', 'path');
4141

4242
log = <MethodCall>[];
43-
TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
43+
_ambiguate(TestDefaultBinaryMessengerBinding.instance)
44+
.defaultBinaryMessenger
4445
.setMockMethodCallHandler(pathProvider.methodChannel,
4546
(MethodCall methodCall) async {
4647
log.add(methodCall);
@@ -135,3 +136,10 @@ void main() {
135136
});
136137
});
137138
}
139+
140+
// Temporary hack to work around changes in https://github.com/flutter/flutter/pull/116937
141+
// This should be removed once the relevant changes makes it to stable.
142+
// TODO(ianh): look into this in Q2 2023.
143+
T _ambiguate<T extends Object>(T? value) {
144+
return value!;
145+
}

0 commit comments

Comments
 (0)