Skip to content

Commit 18e206e

Browse files
[camera_android] Removes usage of _ambiguate method in tests (#4948)
Since the minimum Flutter version for this package is +3.0, we can remove the `_ambiguate` method. Because this PR only affects tests, we don't need to publish a new version. Part of flutter/flutter#111841
1 parent 0c546eb commit 18e206e

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

packages/camera/camera_android/test/android_camera_test.dart

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,14 @@ 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 =
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) {});
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) {});
4443
expect(response, null);
4544
});
4645

@@ -422,8 +421,7 @@ void main() {
422421
const DeviceOrientationChangedEvent event =
423422
DeviceOrientationChangedEvent(DeviceOrientation.portraitUp);
424423
for (int i = 0; i < 3; i++) {
425-
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)!
426-
.defaultBinaryMessenger
424+
await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
427425
.handlePlatformMessage(
428426
AndroidCamera.deviceEventChannelName,
429427
const StandardMethodCodec().encodeMethodCall(
@@ -1146,9 +1144,3 @@ void main() {
11461144
});
11471145
});
11481146
}
1149-
1150-
/// This allows a value of type T or T? to be treated as a value of type T?.
1151-
///
1152-
/// We use this so that APIs that have become non-nullable can still be used
1153-
/// with `!` and `?` on the stable branch.
1154-
T? _ambiguate<T>(T? value) => value;

packages/camera/camera_android/test/method_channel_mock.dart

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class MethodChannelMock {
1111
this.delay,
1212
required this.methods,
1313
}) : methodChannel = MethodChannel(channelName) {
14-
_ambiguate(TestDefaultBinaryMessengerBinding.instance)!
15-
.defaultBinaryMessenger
14+
TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger
1615
.setMockMethodCallHandler(methodChannel, _handler);
1716
}
1817

@@ -39,9 +38,3 @@ class MethodChannelMock {
3938
});
4039
}
4140
}
42-
43-
/// This allows a value of type T or T? to be treated as a value of type T?.
44-
///
45-
/// We use this so that APIs that have become non-nullable can still be used
46-
/// with `!` and `?` on the stable branch.
47-
T? _ambiguate<T>(T? value) => value;

0 commit comments

Comments
 (0)