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

[camera][google_maps_flutter][path_provider] prepare for TestDefaultBinaryMessengerBinding.instance becoming non-nullable #6847

Merged
merged 1 commit into from
Feb 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/camera/camera_android/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1091,5 +1091,4 @@ Future<void> main() async {
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
// TODO(ianh): Remove this once we roll stable in late 2021.
T? _ambiguate<T>(T? value) => value;
26 changes: 17 additions & 9 deletions packages/camera/camera_android/test/android_camera_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ void main() {
// registerWith is called very early in initialization the bindings won't
// have been initialized. While registerWith could intialize them, that
// could slow down startup, so instead the handler should be set up lazily.
final ByteData? response = await TestDefaultBinaryMessengerBinding
.instance!.defaultBinaryMessenger
.handlePlatformMessage(
AndroidCamera.deviceEventChannelName,
const StandardMethodCodec().encodeMethodCall(const MethodCall(
'orientation_changed',
<String, Object>{'orientation': 'portraitDown'})),
(ByteData? data) {});
final ByteData? response =
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)!
.defaultBinaryMessenger
.handlePlatformMessage(
AndroidCamera.deviceEventChannelName,
const StandardMethodCodec().encodeMethodCall(const MethodCall(
'orientation_changed',
<String, Object>{'orientation': 'portraitDown'})),
(ByteData? data) {});
expect(response, null);
});

Expand Down Expand Up @@ -421,7 +422,8 @@ void main() {
const DeviceOrientationChangedEvent event =
DeviceOrientationChangedEvent(DeviceOrientation.portraitUp);
for (int i = 0; i < 3; i++) {
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)!
.defaultBinaryMessenger
.handlePlatformMessage(
AndroidCamera.deviceEventChannelName,
const StandardMethodCodec().encodeMethodCall(
Expand Down Expand Up @@ -1121,3 +1123,9 @@ void main() {
});
});
}

/// This allows a value of type T or T? to be treated as a value of type T?.
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
T? _ambiguate<T>(T? value) => value;
Original file line number Diff line number Diff line change
Expand Up @@ -1091,5 +1091,4 @@ Future<void> main() async {
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
// TODO(ianh): Remove this once we roll stable in late 2021.
T? _ambiguate<T>(T? value) => value;
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ void main() {
// registerWith is called very early in initialization the bindings won't
// have been initialized. While registerWith could intialize them, that
// could slow down startup, so instead the handler should be set up lazily.
final ByteData? response = await TestDefaultBinaryMessengerBinding
.instance!.defaultBinaryMessenger
.handlePlatformMessage(
AVFoundationCamera.deviceEventChannelName,
const StandardMethodCodec().encodeMethodCall(const MethodCall(
'orientation_changed',
<String, Object>{'orientation': 'portraitDown'})),
(ByteData? data) {});
final ByteData? response =
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)!
.defaultBinaryMessenger
.handlePlatformMessage(
AVFoundationCamera.deviceEventChannelName,
const StandardMethodCodec().encodeMethodCall(const MethodCall(
'orientation_changed',
<String, Object>{'orientation': 'portraitDown'})),
(ByteData? data) {});
expect(response, null);
});

Expand Down Expand Up @@ -421,7 +422,8 @@ void main() {
const DeviceOrientationChangedEvent event =
DeviceOrientationChangedEvent(DeviceOrientation.portraitUp);
for (int i = 0; i < 3; i++) {
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)!
.defaultBinaryMessenger
.handlePlatformMessage(
AVFoundationCamera.deviceEventChannelName,
const StandardMethodCodec().encodeMethodCall(
Expand Down Expand Up @@ -1122,3 +1124,9 @@ void main() {
});
});
}

/// This allows a value of type T or T? to be treated as a value of type T?.
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
T? _ambiguate<T>(T? value) => value;
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ void main() {
int mapId, String method, Map<dynamic, dynamic> data) async {
final ByteData byteData =
const StandardMethodCodec().encodeMethodCall(MethodCall(method, data));
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)!
.defaultBinaryMessenger
.handlePlatformMessage('plugins.flutter.dev/google_maps_android_$mapId',
byteData, (ByteData? data) {});
}
Expand Down Expand Up @@ -164,3 +165,9 @@ void main() {
expect(widget, isA<PlatformViewLink>());
});
}

/// This allows a value of type T or T? to be treated as a value of type T?.
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
T? _ambiguate<T>(T? value) => value;
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ void main() {
int mapId, String method, Map<dynamic, dynamic> data) async {
final ByteData byteData =
const StandardMethodCodec().encodeMethodCall(MethodCall(method, data));
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)!
.defaultBinaryMessenger
.handlePlatformMessage('plugins.flutter.dev/google_maps_ios_$mapId',
byteData, (ByteData? data) {});
}
Expand Down Expand Up @@ -122,3 +123,9 @@ void main() {
equals('drag-end-marker'));
});
}

/// This allows a value of type T or T? to be treated as a value of type T?.
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
T? _ambiguate<T>(T? value) => value;
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ void main() {
int mapId, String method, Map<dynamic, dynamic> data) async {
final ByteData byteData = const StandardMethodCodec()
.encodeMethodCall(MethodCall(method, data));
await TestDefaultBinaryMessengerBinding.instance!.defaultBinaryMessenger
await _ambiguate(TestDefaultBinaryMessengerBinding.instance)!
.defaultBinaryMessenger
.handlePlatformMessage('plugins.flutter.io/google_maps_$mapId',
byteData, (ByteData? data) {});
}
Expand Down Expand Up @@ -120,3 +121,9 @@ void main() {
});
});
}

/// This allows a value of type T or T? to be treated as a value of type T?.
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
T? _ambiguate<T>(T? value) => value;
1 change: 0 additions & 1 deletion packages/url_launcher/url_launcher/lib/src/legacy_api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,4 @@ Future<void> closeWebView() async {
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
// TODO(ianh): Remove this once we roll stable in late 2021.
T? _ambiguate<T>(T? value) => value;
Original file line number Diff line number Diff line change
Expand Up @@ -321,8 +321,6 @@ void main() {

/// This removes the type information from a value so that it can be cast
/// to another type even if that cast is redundant.
///
/// We use this so that APIs whose type have become more descriptive can still
/// be used on the stable branch where they require a cast.
// TODO(ianh): Remove this once we roll stable in late 2021.
Object? _anonymize<T>(T? value) => value;
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,4 @@ Future<ByteData> pushRouteNameToFramework(Object? _, String routeName) {
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
// TODO(ianh): Remove this once we roll stable in late 2021.
T? _ambiguate<T>(T? value) => value;
1 change: 0 additions & 1 deletion packages/video_player/video_player/lib/video_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1100,5 +1100,4 @@ class ClosedCaption extends StatelessWidget {
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
// TODO(ianh): Remove this once we roll stable in late 2021.
T? _ambiguate<T>(T? value) => value;
Original file line number Diff line number Diff line change
Expand Up @@ -360,5 +360,4 @@ void main() {
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
// TODO(ianh): Remove this once we roll stable in late 2021.
T? _ambiguate<T>(T? value) => value;
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,4 @@ void main() {
///
/// We use this so that APIs that have become non-nullable can still be used
/// with `!` and `?` on the stable branch.
// TODO(ianh): Remove this once we roll stable in late 2021.
T? _ambiguate<T>(T? value) => value;