Skip to content

Commit

Permalink
[google_maps_flutter] Update Android view selection (flutter#6319)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuartmorgan committed Aug 29, 2022
1 parent 5f54809 commit 630a200
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'dart:ui' as ui;

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';
Expand All @@ -22,6 +23,40 @@ void main() {
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>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform {
);
},
onCreatePlatformView: (PlatformViewCreationParams params) {
final SurfaceAndroidViewController controller =
PlatformViewsService.initSurfaceAndroidView(
final AndroidViewController controller =
PlatformViewsService.initExpensiveAndroidView(
id: params.id,
viewType: viewType,
layoutDirection: widgetConfiguration.textDirection,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ name: google_maps_flutter_android
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:
Expand Down

0 comments on commit 630a200

Please sign in to comment.