[google_maps_flutter] Update Android view selection (#6319)
diff --git a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md
index 52fb263..38dff3d 100644
--- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md
+++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md
@@ -1,5 +1,8 @@
-## NEXT
+## 2.2.0
+* Updates `useAndroidViewSurface` to require Hybrid Composition, making the
+ selection work again in Flutter 3.0+. Earlier versions of Flutter are
+ no longer supported.
* Fixes violations of new analysis option use_named_constants.
* Fixes avoid_redundant_argument_values lint warnings and minor typos.
diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_test.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_test.dart
index ccda42f..8fc1ede 100644
--- a/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_test.dart
+++ b/packages/google_maps_flutter/google_maps_flutter_android/example/integration_test/google_maps_test.dart
@@ -9,6 +9,7 @@
import 'package:flutter/material.dart';
import 'package:flutter_test/flutter_test.dart';
+import 'package:google_maps_flutter_android/google_maps_flutter_android.dart';
import 'package:google_maps_flutter_example/example_google_map.dart';
import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart';
import 'package:integration_test/integration_test.dart';
@@ -22,6 +23,40 @@
IntegrationTestWidgetsFlutterBinding.ensureInitialized();
GoogleMapsFlutterPlatform.instance.enableDebugInspection();
+ testWidgets('uses surface view', (WidgetTester tester) async {
+ final GoogleMapsFlutterAndroid instance =
+ GoogleMapsFlutterPlatform.instance as GoogleMapsFlutterAndroid;
+ final bool previousUseAndroidViewSurfaceValue =
+ instance.useAndroidViewSurface;
+ instance.useAndroidViewSurface = true;
+
+ final Key key = GlobalKey();
+ final Completer<int> mapIdCompleter = Completer<int>();
+ await tester.pumpWidget(Directionality(
+ textDirection: TextDirection.ltr,
+ child: ExampleGoogleMap(
+ key: key,
+ initialCameraPosition: _kInitialCameraPosition,
+ compassEnabled: false,
+ onMapCreated: (ExampleGoogleMapController controller) {
+ mapIdCompleter.complete(controller.mapId);
+ },
+ ),
+ ));
+
+ await mapIdCompleter.future;
+
+ // Wait for the placeholder to be replaced by the actual view.
+ while (!tester.any(find.byType(AndroidViewSurface)) &&
+ !tester.any(find.byType(AndroidView))) {
+ await tester.pump();
+ }
+
+ instance.useAndroidViewSurface = previousUseAndroidViewSurfaceValue;
+
+ expect(tester.any(find.byType(AndroidViewSurface)), true);
+ });
+
testWidgets('testCompassToggle', (WidgetTester tester) async {
final Key key = GlobalKey();
final Completer<int> mapIdCompleter = Completer<int>();
diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart
index 2c11053..95dea4c 100644
--- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart
+++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_maps_flutter_android.dart
@@ -518,8 +518,8 @@
);
},
onCreatePlatformView: (PlatformViewCreationParams params) {
- final SurfaceAndroidViewController controller =
- PlatformViewsService.initSurfaceAndroidView(
+ final AndroidViewController controller =
+ PlatformViewsService.initExpensiveAndroidView(
id: params.id,
viewType: viewType,
layoutDirection: widgetConfiguration.textDirection,
diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml
index a0417d5..2ee7c82 100644
--- a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml
+++ b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml
@@ -2,11 +2,11 @@
description: Android implementation of the google_maps_flutter plugin.
repository: https://github.com/flutter/plugins/tree/main/packages/google_maps_flutter/google_maps_flutter_android
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
-version: 2.1.10
+version: 2.2.0
environment:
sdk: ">=2.14.0 <3.0.0"
- flutter: ">=2.8.0"
+ flutter: ">=3.0.0"
flutter:
plugin: