Repository navigation
[google_maps_flutter_android] Default useAndroidViewSurface to true for Hybrid Composition - #13717
ahmedalam782 wants to merge 3 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
|
This pull request has been moved to a draft state because the |
There was a problem hiding this comment.
Code Review
This pull request changes the default value of useAndroidViewSurface to true in google_maps_flutter_android, switching the default platform view mode to Hybrid Composition. It updates the documentation, updates several package dependencies in pubspec.yaml, and adapts existing tests to reflect this new default. Feedback on the changes suggests adding test coverage to verify that the correct marker type is passed and that the marker type defaults to legacy when useAndroidViewSurface is set to true, as the current tests explicitly set it to false.
|
|
||
| test('Correct marker type is passed to platform view', () async { | ||
| final maps = GoogleMapsFlutterAndroid(); | ||
| maps.useAndroidViewSurface = false; |
There was a problem hiding this comment.
Since useAndroidViewSurface now defaults to true, explicitly setting it to false in this test means there is no test coverage verifying that the correct marker type is passed when using the new default PlatformViewLink implementation. Consider adding a corresponding test case to verify this behavior when useAndroidViewSurface is true.
|
|
||
| test('marker type defaults to legacy if unset', () async { | ||
| final maps = GoogleMapsFlutterAndroid(); | ||
| maps.useAndroidViewSurface = false; |
There was a problem hiding this comment.
Since useAndroidViewSurface now defaults to true, explicitly setting it to false in this test means there is no test coverage verifying that the marker type defaults to legacy when using the new default PlatformViewLink implementation. Consider adding a corresponding test case to verify this behavior when useAndroidViewSurface is true.
|
@google-cla I signed it! |
There was a problem hiding this comment.
Code Review
This pull request switches the default value of useAndroidViewSurface to true in google_maps_flutter_android, making Hybrid Composition the default display mode. It updates the README, CHANGELOG, and dependencies in pubspec.yaml. Additionally, the tests are updated to reflect this default change, and new tests are added to verify the behavior under PlatformViewLink. A review comment suggests using tester.binding.defaultBinaryMessenger for idiomatic widget testing and adding safer type checking for the platform view creation parameters to prevent potential test crashes.
| TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( | ||
| SystemChannels.platform_views, | ||
| (MethodCall methodCall) async { | ||
| if (methodCall.method == 'create') { | ||
| final args = Map<String, dynamic>.from(methodCall.arguments as Map<dynamic, dynamic>); | ||
| if (args.containsKey('params')) { | ||
| final paramsUint8List = args['params'] as Uint8List; | ||
| final byteData = ByteData.sublistView(paramsUint8List); | ||
| final creationParams = | ||
| MapsApi.pigeonChannelCodec.decodeMessage(byteData) | ||
| as PlatformMapViewCreationParams?; | ||
| if (creationParams != null && !completer.isCompleted) { | ||
| completer.complete(creationParams); | ||
| } | ||
| } | ||
| } | ||
| return 0; | ||
| }, | ||
| ); | ||
| addTearDown(() { | ||
| TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger.setMockMethodCallHandler( | ||
| SystemChannels.platform_views, | ||
| null, | ||
| ); | ||
| }); |
There was a problem hiding this comment.
Using tester.binding.defaultBinaryMessenger is more idiomatic in widget tests than accessing TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger directly.
Additionally, casting args['params'] directly to Uint8List using as Uint8List can throw a TypeError if the parameters are null or of a different type. It is safer to use type checking (is Uint8List) to prevent potential test crashes.
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform_views,
(MethodCall methodCall) async {
if (methodCall.method == 'create') {
final Map<String, dynamic> args = Map<String, dynamic>.from(methodCall.arguments as Map<dynamic, dynamic>);
final Object? params = args['params'];
if (params is Uint8List) {
final ByteData byteData = ByteData.sublistView(params);
final PlatformMapViewCreationParams? creationParams =
MapsApi.pigeonChannelCodec.decodeMessage(byteData)
as PlatformMapViewCreationParams?;
if (creationParams != null && !completer.isCompleted) {
completer.complete(creationParams);
}
}
}
return 0;
},
);
addTearDown(() {
tester.binding.defaultBinaryMessenger.setMockMethodCallHandler(
SystemChannels.platform_views,
null,
);
});
Description
Switches the default value of
useAndroidViewSurfaceingoogle_maps_flutter_androidfromfalsetotrueso Android uses Hybrid Composition (PlatformViewLink+AndroidViewSurface) by default instead of Texture Layer Hybrid Composition (TextureView).On some Android devices (notably Huawei EMUI devices such as Huawei Nova 5T), TLHC
TextureViewrenders a blank beige surface instead of the map unless Hybrid Composition is enabled.Changes
useAndroidViewSurface = trueby default inGoogleMapsFlutterAndroid.README.mdDisplay Mode documentation.test/google_maps_flutter_android_test.dart.google_maps_flutter_androidto2.21.2and updatedCHANGELOG.mdandpubspec.yaml.