diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index d2bfc03a705..383400892a3 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. + ## 2.12.3 * Updates the example app to use the zIndexInt param instead of the deprecated zIndex. diff --git a/packages/google_maps_flutter/google_maps_flutter/README.md b/packages/google_maps_flutter/google_maps_flutter/README.md index 53b2cceeb2d..bd32b8f7e52 100644 --- a/packages/google_maps_flutter/google_maps_flutter/README.md +++ b/packages/google_maps_flutter/google_maps_flutter/README.md @@ -137,10 +137,11 @@ class MapSampleState extends State { ); static const CameraPosition _kLake = CameraPosition( - bearing: 192.8334901395799, - target: LatLng(37.43296265331129, -122.08832357078792), - tilt: 59.440717697143555, - zoom: 19.151926040649414); + bearing: 192.8334901395799, + target: LatLng(37.43296265331129, -122.08832357078792), + tilt: 59.440717697143555, + zoom: 19.151926040649414, + ); @override Widget build(BuildContext context) { @@ -165,6 +166,7 @@ class MapSampleState extends State { await controller.animateCamera(CameraUpdate.newCameraPosition(_kLake)); } } + ``` See the `example` directory for a complete sample app. diff --git a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart index d44aa4d341e..2a225695bae 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_controller.dart @@ -61,92 +61,108 @@ void runTests() { expect(coordinate.y, (rect.center.dy - rect.topLeft.dy).round()); } else { expect( - coordinate.x, - ((rect.center.dx - rect.topLeft.dx) * tester.view.devicePixelRatio) - .round()); + coordinate.x, + ((rect.center.dx - rect.topLeft.dx) * tester.view.devicePixelRatio) + .round(), + ); expect( - coordinate.y, - ((rect.center.dy - rect.topLeft.dy) * tester.view.devicePixelRatio) - .round()); + coordinate.y, + ((rect.center.dy - rect.topLeft.dy) * tester.view.devicePixelRatio) + .round(), + ); } await tester.binding.setSurfaceSize(null); }, // Android doesn't like the layout required for the web, so we skip web in this test. // The equivalent web test already exists here: // https://github.com/flutter/packages/blob/c43cc13498a1a1c4f3d1b8af2add9ce7c15bd6d0/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/projection_test.dart#L78 - skip: isWeb || + skip: + isWeb || // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 isIOS || // TODO(tarrinneal): Re-enable; see https://github.com/flutter/flutter/issues/160115 isAndroid, ); - testWidgets('testGetVisibleRegion', (WidgetTester tester) async { - final Key key = GlobalKey(); - final LatLngBounds zeroLatLngBounds = LatLngBounds( - southwest: const LatLng(0, 0), northeast: const LatLng(0, 0)); + testWidgets( + 'testGetVisibleRegion', + (WidgetTester tester) async { + final Key key = GlobalKey(); + final LatLngBounds zeroLatLngBounds = LatLngBounds( + southwest: const LatLng(0, 0), + northeast: const LatLng(0, 0), + ); - final Completer mapControllerCompleter = - Completer(); + final Completer mapControllerCompleter = + Completer(); - await pumpMap( - tester, - GoogleMap( - key: key, - initialCameraPosition: kInitialCameraPosition, - onMapCreated: (GoogleMapController controller) { - mapControllerCompleter.complete(controller); - }, - ), - ); - await tester.pumpAndSettle(); - final GoogleMapController mapController = - await mapControllerCompleter.future; - - // Wait for the visible region to be non-zero. - final LatLngBounds firstVisibleRegion = - await waitForValueMatchingPredicate( - tester, - () => mapController.getVisibleRegion(), - (LatLngBounds bounds) => bounds != zeroLatLngBounds) ?? - zeroLatLngBounds; - expect(firstVisibleRegion, isNot(zeroLatLngBounds)); - expect(firstVisibleRegion.contains(kInitialMapCenter), isTrue); - - // Making a new `LatLngBounds` about (10, 10) distance south west to the `firstVisibleRegion`. - // The size of the `LatLngBounds` is 10 by 10. - final LatLng southWest = LatLng(firstVisibleRegion.southwest.latitude - 20, - firstVisibleRegion.southwest.longitude - 20); - final LatLng northEast = LatLng(firstVisibleRegion.southwest.latitude - 10, - firstVisibleRegion.southwest.longitude - 10); - final LatLng newCenter = LatLng( - (northEast.latitude + southWest.latitude) / 2, - (northEast.longitude + southWest.longitude) / 2, - ); + await pumpMap( + tester, + GoogleMap( + key: key, + initialCameraPosition: kInitialCameraPosition, + onMapCreated: (GoogleMapController controller) { + mapControllerCompleter.complete(controller); + }, + ), + ); + await tester.pumpAndSettle(); + final GoogleMapController mapController = + await mapControllerCompleter.future; + + // Wait for the visible region to be non-zero. + final LatLngBounds firstVisibleRegion = + await waitForValueMatchingPredicate( + tester, + () => mapController.getVisibleRegion(), + (LatLngBounds bounds) => bounds != zeroLatLngBounds, + ) ?? + zeroLatLngBounds; + expect(firstVisibleRegion, isNot(zeroLatLngBounds)); + expect(firstVisibleRegion.contains(kInitialMapCenter), isTrue); + + // Making a new `LatLngBounds` about (10, 10) distance south west to the `firstVisibleRegion`. + // The size of the `LatLngBounds` is 10 by 10. + final LatLng southWest = LatLng( + firstVisibleRegion.southwest.latitude - 20, + firstVisibleRegion.southwest.longitude - 20, + ); + final LatLng northEast = LatLng( + firstVisibleRegion.southwest.latitude - 10, + firstVisibleRegion.southwest.longitude - 10, + ); + final LatLng newCenter = LatLng( + (northEast.latitude + southWest.latitude) / 2, + (northEast.longitude + southWest.longitude) / 2, + ); - expect(firstVisibleRegion.contains(northEast), isFalse); - expect(firstVisibleRegion.contains(southWest), isFalse); + expect(firstVisibleRegion.contains(northEast), isFalse); + expect(firstVisibleRegion.contains(southWest), isFalse); - final LatLngBounds latLngBounds = - LatLngBounds(southwest: southWest, northeast: northEast); + final LatLngBounds latLngBounds = LatLngBounds( + southwest: southWest, + northeast: northEast, + ); - // TODO(iskakaushik): non-zero padding is needed for some device configurations - // https://github.com/flutter/flutter/issues/30575 - const double padding = 0; - await mapController - .moveCamera(CameraUpdate.newLatLngBounds(latLngBounds, padding)); - await tester.pumpAndSettle(const Duration(seconds: 3)); + // TODO(iskakaushik): non-zero padding is needed for some device configurations + // https://github.com/flutter/flutter/issues/30575 + const double padding = 0; + await mapController.moveCamera( + CameraUpdate.newLatLngBounds(latLngBounds, padding), + ); + await tester.pumpAndSettle(const Duration(seconds: 3)); - final LatLngBounds secondVisibleRegion = - await mapController.getVisibleRegion(); + final LatLngBounds secondVisibleRegion = + await mapController.getVisibleRegion(); - expect(secondVisibleRegion, isNot(zeroLatLngBounds)); + expect(secondVisibleRegion, isNot(zeroLatLngBounds)); - expect(firstVisibleRegion, isNot(secondVisibleRegion)); - expect(secondVisibleRegion.contains(newCenter), isTrue); - }, - // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 - skip: isIOS); + expect(firstVisibleRegion, isNot(secondVisibleRegion)); + expect(secondVisibleRegion.contains(newCenter), isTrue); + }, + // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 + skip: isIOS, + ); testWidgets('testSetMapStyle valid Json String', (WidgetTester tester) async { final Key key = GlobalKey(); @@ -172,8 +188,9 @@ void runTests() { await controller.setMapStyle(mapStyle); }); - testWidgets('testSetMapStyle invalid Json String', - (WidgetTester tester) async { + testWidgets('testSetMapStyle invalid Json String', ( + WidgetTester tester, + ) async { final Key key = GlobalKey(); final Completer controllerCompleter = Completer(); @@ -246,8 +263,9 @@ void runTests() { await Future.delayed(const Duration(seconds: 1)); final LatLngBounds visibleRegion = await controller.getVisibleRegion(); - final LatLng topLeft = - await controller.getLatLng(const ScreenCoordinate(x: 0, y: 0)); + final LatLng topLeft = await controller.getLatLng( + const ScreenCoordinate(x: 0, y: 0), + ); final LatLng northWest = LatLng( visibleRegion.northeast.latitude, visibleRegion.southwest.longitude, @@ -256,74 +274,81 @@ void runTests() { expect(topLeft, northWest); }); - testWidgets('testGetZoomLevel', (WidgetTester tester) async { - final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + testWidgets( + 'testGetZoomLevel', + (WidgetTester tester) async { + final Key key = GlobalKey(); + final Completer controllerCompleter = + Completer(); - await pumpMap( - tester, - GoogleMap( - key: key, - initialCameraPosition: kInitialCameraPosition, - onMapCreated: (GoogleMapController controller) { - controllerCompleter.complete(controller); - }, - ), - ); - final GoogleMapController controller = await controllerCompleter.future; + await pumpMap( + tester, + GoogleMap( + key: key, + initialCameraPosition: kInitialCameraPosition, + onMapCreated: (GoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), + ); + final GoogleMapController controller = await controllerCompleter.future; - await tester.pumpAndSettle(); - // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen - // in `mapRendered`. - // https://github.com/flutter/flutter/issues/54758 - await Future.delayed(const Duration(seconds: 1)); + await tester.pumpAndSettle(); + // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen + // in `mapRendered`. + // https://github.com/flutter/flutter/issues/54758 + await Future.delayed(const Duration(seconds: 1)); - double zoom = await controller.getZoomLevel(); - expect(zoom, kInitialZoomLevel); + double zoom = await controller.getZoomLevel(); + expect(zoom, kInitialZoomLevel); - await controller.moveCamera(CameraUpdate.zoomTo(7)); - await tester.pumpAndSettle(); - zoom = await controller.getZoomLevel(); - expect(zoom, equals(7)); - }, - // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 - skip: isIOS); + await controller.moveCamera(CameraUpdate.zoomTo(7)); + await tester.pumpAndSettle(); + zoom = await controller.getZoomLevel(); + expect(zoom, equals(7)); + }, + // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 + skip: isIOS, + ); - testWidgets('testScreenCoordinate', (WidgetTester tester) async { - final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + testWidgets( + 'testScreenCoordinate', + (WidgetTester tester) async { + final Key key = GlobalKey(); + final Completer controllerCompleter = + Completer(); - await pumpMap( - tester, - GoogleMap( - key: key, - initialCameraPosition: kInitialCameraPosition, - onMapCreated: (GoogleMapController controller) { - controllerCompleter.complete(controller); - }, - ), - ); - final GoogleMapController controller = await controllerCompleter.future; + await pumpMap( + tester, + GoogleMap( + key: key, + initialCameraPosition: kInitialCameraPosition, + onMapCreated: (GoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), + ); + final GoogleMapController controller = await controllerCompleter.future; - await tester.pumpAndSettle(); - // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen - // in `mapRendered`. - // https://github.com/flutter/flutter/issues/54758 - await Future.delayed(const Duration(seconds: 1)); + await tester.pumpAndSettle(); + // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen + // in `mapRendered`. + // https://github.com/flutter/flutter/issues/54758 + await Future.delayed(const Duration(seconds: 1)); - final LatLngBounds visibleRegion = await controller.getVisibleRegion(); - final LatLng northWest = LatLng( - visibleRegion.northeast.latitude, - visibleRegion.southwest.longitude, - ); - final ScreenCoordinate topLeft = - await controller.getScreenCoordinate(northWest); - expect(topLeft, const ScreenCoordinate(x: 0, y: 0)); - }, - // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 - skip: isIOS); + final LatLngBounds visibleRegion = await controller.getVisibleRegion(); + final LatLng northWest = LatLng( + visibleRegion.northeast.latitude, + visibleRegion.southwest.longitude, + ); + final ScreenCoordinate topLeft = await controller.getScreenCoordinate( + northWest, + ); + expect(topLeft, const ScreenCoordinate(x: 0, y: 0)); + }, + // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 + skip: isIOS, + ); testWidgets('testResizeWidget', (WidgetTester tester) async { final Completer controllerCompleter = @@ -368,8 +393,9 @@ void runTests() { testWidgets('testToggleInfoWindow', (WidgetTester tester) async { const Marker marker = Marker( - markerId: MarkerId('marker'), - infoWindow: InfoWindow(title: 'InfoWindow')); + markerId: MarkerId('marker'), + infoWindow: InfoWindow(title: 'InfoWindow'), + ); final Set markers = {marker}; final Completer controllerCompleter = @@ -395,17 +421,20 @@ void runTests() { // re-evaluated when that issue is fixed. await Future.delayed(const Duration(seconds: 1)); - bool iwVisibleStatus = - await controller.isMarkerInfoWindowShown(marker.markerId); + bool iwVisibleStatus = await controller.isMarkerInfoWindowShown( + marker.markerId, + ); expect(iwVisibleStatus, false); await controller.showMarkerInfoWindow(marker.markerId); // The Maps SDK doesn't always return true for whether it is shown // immediately after showing it, so wait for it to report as shown. - iwVisibleStatus = await waitForValueMatchingPredicate( - tester, - () => controller.isMarkerInfoWindowShown(marker.markerId), - (bool visible) => visible) ?? + iwVisibleStatus = + await waitForValueMatchingPredicate( + tester, + () => controller.isMarkerInfoWindowShown(marker.markerId), + (bool visible) => visible, + ) ?? false; expect(iwVisibleStatus, true); @@ -417,11 +446,9 @@ void runTests() { testWidgets('markerWithAssetMapBitmap', (WidgetTester tester) async { final Set markers = { Marker( - markerId: const MarkerId('1'), - icon: AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 1.0, - )), + markerId: const MarkerId('1'), + icon: AssetMapBitmap('assets/red_square.png', imagePixelRatio: 1.0), + ), }; await pumpMap( tester, @@ -438,11 +465,12 @@ void runTests() { ); final Set markers = { Marker( - markerId: const MarkerId('1'), - icon: await AssetMapBitmap.create( - imageConfiguration, - 'assets/red_square.png', - )), + markerId: const MarkerId('1'), + icon: await AssetMapBitmap.create( + imageConfiguration, + 'assets/red_square.png', + ), + ), }; await pumpMap( tester, @@ -481,13 +509,14 @@ void runTests() { ); final Set markers = { Marker( - markerId: const MarkerId('1'), - // Intentionally testing the deprecated code path. - // ignore: deprecated_member_use - icon: await BitmapDescriptor.fromAssetImage( - imageConfiguration, - 'assets/red_square.png', - )), + markerId: const MarkerId('1'), + // Intentionally testing the deprecated code path. + // ignore: deprecated_member_use + icon: await BitmapDescriptor.fromAssetImage( + imageConfiguration, + 'assets/red_square.png', + ), + ), }; await pumpMap( tester, @@ -505,13 +534,11 @@ void runTests() { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); final Set markers = { Marker( - markerId: const MarkerId('1'), - // Intentionally testing the deprecated code path. - // ignore: deprecated_member_use - icon: BitmapDescriptor.fromBytes( - bytes, - size: const Size(100, 100), - )), + markerId: const MarkerId('1'), + // Intentionally testing the deprecated code path. + // ignore: deprecated_member_use + icon: BitmapDescriptor.fromBytes(bytes, size: const Size(100, 100)), + ), }; await pumpMap( tester, @@ -524,54 +551,54 @@ void runTests() { await tester.pumpAndSettle(); }); - testWidgets('testTakeSnapshot', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); - - await pumpMap( - tester, - GoogleMap( - initialCameraPosition: kInitialCameraPosition, - onMapCreated: (GoogleMapController controller) { - controllerCompleter.complete(controller); - }, - ), - ); - await tester.pumpAndSettle(const Duration(seconds: 3)); - final GoogleMapController controller = await controllerCompleter.future; - - final Uint8List? bytes = await controller.takeSnapshot(); - expect(bytes?.isNotEmpty, true); - }, - // TODO(cyanglaz): un-skip the test when we can test this on CI with API key enabled. - // https://github.com/flutter/flutter/issues/57057 - // https://github.com/flutter/flutter/issues/139825 - skip: isAndroid || isWeb || isIOS); - testWidgets( - 'testCloudMapId', + 'testTakeSnapshot', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final Key key = GlobalKey(); + final Completer controllerCompleter = + Completer(); await pumpMap( tester, GoogleMap( - key: key, initialCameraPosition: kInitialCameraPosition, onMapCreated: (GoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); + controllerCompleter.complete(controller); }, - cloudMapId: kCloudMapId, ), ); - await tester.pumpAndSettle(); + await tester.pumpAndSettle(const Duration(seconds: 3)); + final GoogleMapController controller = await controllerCompleter.future; - // Await mapIdCompleter to finish to make sure map can be created with cloudMapId - await mapIdCompleter.future; + final Uint8List? bytes = await controller.takeSnapshot(); + expect(bytes?.isNotEmpty, true); }, + // TODO(cyanglaz): un-skip the test when we can test this on CI with API key enabled. + // https://github.com/flutter/flutter/issues/57057 + // https://github.com/flutter/flutter/issues/139825 + skip: isAndroid || isWeb || isIOS, ); + testWidgets('testCloudMapId', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final Key key = GlobalKey(); + + await pumpMap( + tester, + GoogleMap( + key: key, + initialCameraPosition: kInitialCameraPosition, + onMapCreated: (GoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + cloudMapId: kCloudMapId, + ), + ); + await tester.pumpAndSettle(); + + // Await mapIdCompleter to finish to make sure map can be created with cloudMapId + await mapIdCompleter.future; + }); + testWidgets('getStyleError reports last error', (WidgetTester tester) async { final Key key = GlobalKey(); final Completer controllerCompleter = @@ -605,9 +632,12 @@ void runTests() { /// This is useful for cases where the Maps SDK has some internally /// asynchronous operation that we don't have visibility into (e.g., native UI /// animations). -Future waitForValueMatchingPredicate(WidgetTester tester, - Future Function() getValue, bool Function(T) predicate, - {int maxTries = 100}) async { +Future waitForValueMatchingPredicate( + WidgetTester tester, + Future Function() getValue, + bool Function(T) predicate, { + int maxTries = 100, +}) async { for (int i = 0; i < maxTries; i++) { final T value = await getValue(); if (predicate(value)) { diff --git a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_inspector.dart b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_inspector.dart index f714ba244d1..460d05aebbf 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_inspector.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/maps_inspector.dart @@ -23,7 +23,9 @@ const CameraPosition _kTestCameraPosition = CameraPosition( tilt: 1.0, ); final LatLngBounds _testCameraBounds = LatLngBounds( - northeast: const LatLng(50, -65), southwest: const LatLng(28.5, -123)); + northeast: const LatLng(50, -65), + southwest: const LatLng(28.5, -123), +); final ValueVariant _cameraUpdateTypeVariants = ValueVariant(CameraUpdateType.values.toSet()); @@ -141,8 +143,8 @@ void runTests() { final GoogleMapController controller = await controllerCompleter.future; if (isIOS) { - final MinMaxZoomPreference zoomLevel = - await inspector.getMinMaxZoomLevels(mapId: controller.mapId); + final MinMaxZoomPreference zoomLevel = await inspector + .getMinMaxZoomLevels(mapId: controller.mapId); expect(zoomLevel, equals(initialZoomLevel)); } else if (isAndroid) { await controller.moveCamera(CameraUpdate.zoomTo(15)); @@ -169,8 +171,8 @@ void runTests() { ); if (isIOS) { - final MinMaxZoomPreference zoomLevel = - await inspector.getMinMaxZoomLevels(mapId: controller.mapId); + final MinMaxZoomPreference zoomLevel = await inspector + .getMinMaxZoomLevels(mapId: controller.mapId); expect(zoomLevel, equals(finalZoomLevel)); } else { await controller.moveCamera(CameraUpdate.zoomTo(15)); @@ -202,8 +204,9 @@ void runTests() { ); final int mapId = await mapIdCompleter.future; - bool zoomGesturesEnabled = - await inspector.areZoomGesturesEnabled(mapId: mapId); + bool zoomGesturesEnabled = await inspector.areZoomGesturesEnabled( + mapId: mapId, + ); expect(zoomGesturesEnabled, false); await pumpMap( @@ -237,8 +240,9 @@ void runTests() { ); final int mapId = await mapIdCompleter.future; - bool zoomControlsEnabled = - await inspector.areZoomControlsEnabled(mapId: mapId); + bool zoomControlsEnabled = await inspector.areZoomControlsEnabled( + mapId: mapId, + ); expect(zoomControlsEnabled, !isIOS); /// Zoom Controls functionality is not available on iOS at the moment. @@ -255,8 +259,9 @@ void runTests() { ), ); - zoomControlsEnabled = - await inspector.areZoomControlsEnabled(mapId: mapId); + zoomControlsEnabled = await inspector.areZoomControlsEnabled( + mapId: mapId, + ); expect(zoomControlsEnabled, false); } }); @@ -313,8 +318,9 @@ void runTests() { ); final int mapId = await mapIdCompleter.future; - bool rotateGesturesEnabled = - await inspector.areRotateGesturesEnabled(mapId: mapId); + bool rotateGesturesEnabled = await inspector.areRotateGesturesEnabled( + mapId: mapId, + ); expect(rotateGesturesEnabled, false); await pumpMap( @@ -328,8 +334,9 @@ void runTests() { ), ); - rotateGesturesEnabled = - await inspector.areRotateGesturesEnabled(mapId: mapId); + rotateGesturesEnabled = await inspector.areRotateGesturesEnabled( + mapId: mapId, + ); expect(rotateGesturesEnabled, !isWeb); }); @@ -350,8 +357,9 @@ void runTests() { ); final int mapId = await mapIdCompleter.future; - bool tiltGesturesEnabled = - await inspector.areTiltGesturesEnabled(mapId: mapId); + bool tiltGesturesEnabled = await inspector.areTiltGesturesEnabled( + mapId: mapId, + ); expect(tiltGesturesEnabled, false); await pumpMap( @@ -386,8 +394,9 @@ void runTests() { ); final int mapId = await mapIdCompleter.future; - bool scrollGesturesEnabled = - await inspector.areScrollGesturesEnabled(mapId: mapId); + bool scrollGesturesEnabled = await inspector.areScrollGesturesEnabled( + mapId: mapId, + ); expect(scrollGesturesEnabled, false); await pumpMap( @@ -401,8 +410,9 @@ void runTests() { ), ); - scrollGesturesEnabled = - await inspector.areScrollGesturesEnabled(mapId: mapId); + scrollGesturesEnabled = await inspector.areScrollGesturesEnabled( + mapId: mapId, + ); expect(scrollGesturesEnabled, true); }); @@ -457,8 +467,9 @@ void runTests() { ); final int mapId = await mapIdCompleter.future; - final bool isBuildingsEnabled = - await inspector.areBuildingsEnabled(mapId: mapId); + final bool isBuildingsEnabled = await inspector.areBuildingsEnabled( + mapId: mapId, + ); expect(isBuildingsEnabled, !isWeb); }); @@ -481,8 +492,9 @@ void runTests() { ); final int mapId = await mapIdCompleter.future; - bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); + bool myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled( + mapId: mapId, + ); expect(myLocationButtonEnabled, true); await pumpMap( @@ -497,13 +509,15 @@ void runTests() { ), ); - myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); + myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled( + mapId: mapId, + ); expect(myLocationButtonEnabled, false); }); - testWidgets('testMyLocationButton initial value false', - (WidgetTester tester) async { + testWidgets('testMyLocationButton initial value false', ( + WidgetTester tester, + ) async { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); @@ -520,13 +534,14 @@ void runTests() { ); final int mapId = await mapIdCompleter.future; - final bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); + final bool myLocationButtonEnabled = await inspector + .isMyLocationButtonEnabled(mapId: mapId); expect(myLocationButtonEnabled, false); }); - testWidgets('testMyLocationButton initial value true', - (WidgetTester tester) async { + testWidgets('testMyLocationButton initial value true', ( + WidgetTester tester, + ) async { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); @@ -542,8 +557,8 @@ void runTests() { ); final int mapId = await mapIdCompleter.future; - final bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); + final bool myLocationButtonEnabled = await inspector + .isMyLocationButtonEnabled(mapId: mapId); expect(myLocationButtonEnabled, true); }); }, skip: !isIOS); @@ -556,22 +571,28 @@ void runTests() { final Set clusterManagers = {}; for (int i = 0; i < clusterManagersAmount; i++) { - final ClusterManagerId clusterManagerId = - ClusterManagerId('cluster_manager_$i'); - final ClusterManager clusterManager = - ClusterManager(clusterManagerId: clusterManagerId); + final ClusterManagerId clusterManagerId = ClusterManagerId( + 'cluster_manager_$i', + ); + final ClusterManager clusterManager = ClusterManager( + clusterManagerId: clusterManagerId, + ); clusterManagers.add(clusterManager); } for (final ClusterManager cm in clusterManagers) { for (int i = 0; i < markersPerClusterManager; i++) { - final MarkerId markerId = - MarkerId('${cm.clusterManagerId.value}_marker_$i'); + final MarkerId markerId = MarkerId( + '${cm.clusterManagerId.value}_marker_$i', + ); final Marker marker = Marker( - markerId: markerId, - clusterManagerId: cm.clusterManagerId, - position: LatLng( - kInitialMapCenter.latitude + i, kInitialMapCenter.longitude)); + markerId: markerId, + clusterManagerId: cm.clusterManagerId, + position: LatLng( + kInitialMapCenter.latitude + i, + kInitialMapCenter.longitude, + ), + ); markers[markerId] = marker; } } @@ -599,7 +620,9 @@ void runTests() { for (final ClusterManager cm in clusterManagers) { final List clusters = await inspector.getClusters( - mapId: controller.mapId, clusterManagerId: cm.clusterManagerId); + mapId: controller.mapId, + clusterManagerId: cm.clusterManagerId, + ); final int markersAmountForClusterManager = clusters .map((Cluster cluster) => cluster.count) .reduce((int value, int element) => value + element); @@ -614,15 +637,18 @@ void runTests() { await pumpMap( tester, GoogleMap( - key: key, - initialCameraPosition: kInitialCameraPosition, - clusterManagers: clusterManagers, - markers: Set.of(markers.values)), + key: key, + initialCameraPosition: kInitialCameraPosition, + clusterManagers: clusterManagers, + markers: Set.of(markers.values), + ), ); for (final ClusterManager cm in clusterManagers) { final List clusters = await inspector.getClusters( - mapId: controller.mapId, clusterManagerId: cm.clusterManagerId); + mapId: controller.mapId, + clusterManagerId: cm.clusterManagerId, + ); expect(clusters.length, 0); } }); @@ -639,22 +665,24 @@ void runTests() { /// Completer to track when the camera has come to rest. Completer? cameraIdleCompleter; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: GoogleMap( - key: key, - initialCameraPosition: kInitialCameraPosition, - onCameraIdle: () { - if (cameraIdleCompleter != null && - !cameraIdleCompleter.isCompleted) { - cameraIdleCompleter.complete(); - } - }, - onMapCreated: (GoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + key: key, + initialCameraPosition: kInitialCameraPosition, + onCameraIdle: () { + if (cameraIdleCompleter != null && + !cameraIdleCompleter.isCompleted) { + cameraIdleCompleter.complete(); + } + }, + onMapCreated: (GoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final GoogleMapController controller = await controllerCompleter.future; @@ -668,8 +696,9 @@ void runTests() { // Create completer for camera idle event. cameraIdleCompleter = Completer(); - final CameraUpdate cameraUpdate = - _getCameraUpdateForType(_cameraUpdateTypeVariants.currentValue!); + final CameraUpdate cameraUpdate = _getCameraUpdateForType( + _cameraUpdateTypeVariants.currentValue!, + ); await controller.animateCamera(cameraUpdate); // If platform supportes getting camera position, check that the camera @@ -679,15 +708,17 @@ void runTests() { // Immediately after calling animateCamera, check that the camera hasn't // reached its final position. This relies on the assumption that the // camera move is animated and won't complete instantly. - beforeFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + beforeFinishedPosition = await inspector.getCameraPosition( + mapId: controller.mapId, + ); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - beforeFinishedPosition, - null, - controller, - (Matcher matcher) => isNot(matcher)); + _cameraUpdateTypeVariants.currentValue!, + beforeFinishedPosition, + null, + controller, + (Matcher matcher) => isNot(matcher), + ); } // Wait for the animation to complete (onCameraIdle). @@ -698,20 +729,22 @@ void runTests() { // has moved as expected. if (inspector.supportsGettingGameraPosition()) { // After onCameraIdle event, the camera should be at the final position. - final CameraPosition afterFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + final CameraPosition afterFinishedPosition = await inspector + .getCameraPosition(mapId: controller.mapId); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - afterFinishedPosition, - beforeFinishedPosition, - controller, - (Matcher matcher) => matcher); + _cameraUpdateTypeVariants.currentValue!, + afterFinishedPosition, + beforeFinishedPosition, + controller, + (Matcher matcher) => matcher, + ); } }, variant: _cameraUpdateTypeVariants, // TODO(stuartmorgan): Remove skip for Android platform once Maps API key is // available for LUCI, https://github.com/flutter/flutter/issues/131071 - skip: isAndroid || + skip: + isAndroid || // Hanging in CI, https://github.com/flutter/flutter/issues/166139 isIOS, ); @@ -749,23 +782,25 @@ void runTests() { // Stopwatch to measure the time taken for the animation to complete. final Stopwatch stopwatch = Stopwatch(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: GoogleMap( - key: key, - initialCameraPosition: kInitialCameraPosition, - onCameraIdle: () { - if (cameraIdleCompleter != null && - !cameraIdleCompleter.isCompleted) { - stopwatch.stop(); - cameraIdleCompleter.complete(); - } - }, - onMapCreated: (GoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + key: key, + initialCameraPosition: kInitialCameraPosition, + onCameraIdle: () { + if (cameraIdleCompleter != null && + !cameraIdleCompleter.isCompleted) { + stopwatch.stop(); + cameraIdleCompleter.complete(); + } + }, + onMapCreated: (GoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final GoogleMapController controller = await controllerCompleter.future; @@ -785,8 +820,9 @@ void runTests() { stopwatch.start(); // First phase with shorter animation duration. - final CameraUpdate cameraUpdateShort = - _getCameraUpdateForType(_cameraUpdateTypeVariants.currentValue!); + final CameraUpdate cameraUpdateShort = _getCameraUpdateForType( + _cameraUpdateTypeVariants.currentValue!, + ); await controller.animateCamera( cameraUpdateShort, duration: const Duration(milliseconds: shortCameraAnimationDurationMS), @@ -798,12 +834,15 @@ void runTests() { // For short animation duration, check that the animation is completed // faster than the midpoint benchmark. - expect(stopwatch.elapsedMilliseconds, - lessThan(animationDurationMiddlePoint)); + expect( + stopwatch.elapsedMilliseconds, + lessThan(animationDurationMiddlePoint), + ); // Reset camera to initial position before testing long duration. - await controller - .moveCamera(CameraUpdate.newCameraPosition(kInitialCameraPosition)); + await controller.moveCamera( + CameraUpdate.newCameraPosition(kInitialCameraPosition), + ); await tester.pumpAndSettle(); // Create completer for camera idle event. @@ -815,8 +854,9 @@ void runTests() { stopwatch.start(); // Second phase with longer animation duration. - final CameraUpdate cameraUpdateLong = - _getCameraUpdateForType(_cameraUpdateTypeVariants.currentValue!); + final CameraUpdate cameraUpdateLong = _getCameraUpdateForType( + _cameraUpdateTypeVariants.currentValue!, + ); await controller.animateCamera( cameraUpdateLong, duration: const Duration(milliseconds: longCameraAnimationDurationMS), @@ -829,15 +869,17 @@ void runTests() { // Immediately after calling animateCamera, check that the camera hasn't // reached its final position. This relies on the assumption that the // camera move is animated and won't complete instantly. - beforeFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + beforeFinishedPosition = await inspector.getCameraPosition( + mapId: controller.mapId, + ); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - beforeFinishedPosition, - null, - controller, - (Matcher matcher) => isNot(matcher)); + _cameraUpdateTypeVariants.currentValue!, + beforeFinishedPosition, + null, + controller, + (Matcher matcher) => isNot(matcher), + ); } // Wait for the animation to complete (onCameraIdle). @@ -846,27 +888,31 @@ void runTests() { // For longer animation duration, check that the animation is completed // slower than the midpoint benchmark. - expect(stopwatch.elapsedMilliseconds, - greaterThan(animationDurationMiddlePoint)); + expect( + stopwatch.elapsedMilliseconds, + greaterThan(animationDurationMiddlePoint), + ); // If platform supportes getting camera position, check that the camera // has moved as expected. if (inspector.supportsGettingGameraPosition()) { // Camera should be at the final position. - final CameraPosition afterFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + final CameraPosition afterFinishedPosition = await inspector + .getCameraPosition(mapId: controller.mapId); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - afterFinishedPosition, - beforeFinishedPosition, - controller, - (Matcher matcher) => matcher); + _cameraUpdateTypeVariants.currentValue!, + afterFinishedPosition, + beforeFinishedPosition, + controller, + (Matcher matcher) => matcher, + ); } }, variant: _cameraUpdateTypeVariants, // TODO(jokerttu): Remove skip once the web implementation is available, // https://github.com/flutter/flutter/issues/159265 - skip: kIsWeb || + skip: + kIsWeb || // TODO(stuartmorgan): Remove skip for Android platform once Maps API key is // available for LUCI, https://github.com/flutter/flutter/issues/131071 isAndroid || @@ -876,7 +922,9 @@ void runTests() { } Marker _copyMarkerWithClusterManagerId( - Marker marker, ClusterManagerId? clusterManagerId) { + Marker marker, + ClusterManagerId? clusterManagerId, +) { return Marker( markerId: marker.markerId, alpha: marker.alpha, @@ -900,16 +948,23 @@ Marker _copyMarkerWithClusterManagerId( CameraUpdate _getCameraUpdateForType(CameraUpdateType type) { return switch (type) { - CameraUpdateType.newCameraPosition => - CameraUpdate.newCameraPosition(_kTestCameraPosition), + CameraUpdateType.newCameraPosition => CameraUpdate.newCameraPosition( + _kTestCameraPosition, + ), CameraUpdateType.newLatLng => CameraUpdate.newLatLng(_kTestMapCenter), - CameraUpdateType.newLatLngBounds => - CameraUpdate.newLatLngBounds(_testCameraBounds, 0), - CameraUpdateType.newLatLngZoom => - CameraUpdate.newLatLngZoom(_kTestMapCenter, _kTestCameraZoomLevel), + CameraUpdateType.newLatLngBounds => CameraUpdate.newLatLngBounds( + _testCameraBounds, + 0, + ), + CameraUpdateType.newLatLngZoom => CameraUpdate.newLatLngZoom( + _kTestMapCenter, + _kTestCameraZoomLevel, + ), CameraUpdateType.scrollBy => CameraUpdate.scrollBy(10, 10), - CameraUpdateType.zoomBy => - CameraUpdate.zoomBy(_kTestZoomByAmount, const Offset(1, 1)), + CameraUpdateType.zoomBy => CameraUpdate.zoomBy( + _kTestZoomByAmount, + const Offset(1, 1), + ), CameraUpdateType.zoomTo => CameraUpdate.zoomTo(_kTestCameraZoomLevel), CameraUpdateType.zoomIn => CameraUpdate.zoomIn(), CameraUpdateType.zoomOut => CameraUpdate.zoomOut(), @@ -929,52 +984,80 @@ Future _checkCameraUpdateByType( switch (type) { case CameraUpdateType.newCameraPosition: - expect(currentPosition.bearing, - wrapMatcher(equals(_kTestCameraPosition.bearing))); expect( - currentPosition.zoom, wrapMatcher(equals(_kTestCameraPosition.zoom))); + currentPosition.bearing, + wrapMatcher(equals(_kTestCameraPosition.bearing)), + ); expect( - currentPosition.tilt, wrapMatcher(equals(_kTestCameraPosition.tilt))); + currentPosition.zoom, + wrapMatcher(equals(_kTestCameraPosition.zoom)), + ); expect( - currentPosition.target.latitude, - wrapMatcher( - closeTo(_kTestCameraPosition.target.latitude, latLngThreshold))); + currentPosition.tilt, + wrapMatcher(equals(_kTestCameraPosition.tilt)), + ); expect( - currentPosition.target.longitude, - wrapMatcher( - closeTo(_kTestCameraPosition.target.longitude, latLngThreshold))); + currentPosition.target.latitude, + wrapMatcher( + closeTo(_kTestCameraPosition.target.latitude, latLngThreshold), + ), + ); + expect( + currentPosition.target.longitude, + wrapMatcher( + closeTo(_kTestCameraPosition.target.longitude, latLngThreshold), + ), + ); case CameraUpdateType.newLatLng: - expect(currentPosition.target.latitude, - wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold))); - expect(currentPosition.target.longitude, - wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold))); + expect( + currentPosition.target.latitude, + wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold)), + ); + expect( + currentPosition.target.longitude, + wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold)), + ); case CameraUpdateType.newLatLngBounds: final LatLngBounds bounds = await controller.getVisibleRegion(); expect( - bounds.northeast.longitude, - wrapMatcher( - closeTo(_testCameraBounds.northeast.longitude, latLngThreshold))); + bounds.northeast.longitude, + wrapMatcher( + closeTo(_testCameraBounds.northeast.longitude, latLngThreshold), + ), + ); expect( - bounds.southwest.longitude, - wrapMatcher( - closeTo(_testCameraBounds.southwest.longitude, latLngThreshold))); + bounds.southwest.longitude, + wrapMatcher( + closeTo(_testCameraBounds.southwest.longitude, latLngThreshold), + ), + ); case CameraUpdateType.newLatLngZoom: - expect(currentPosition.target.latitude, - wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold))); - expect(currentPosition.target.longitude, - wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold))); + expect( + currentPosition.target.latitude, + wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold)), + ); + expect( + currentPosition.target.longitude, + wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold)), + ); expect(currentPosition.zoom, wrapMatcher(equals(_kTestCameraZoomLevel))); case CameraUpdateType.scrollBy: // For scrollBy, just check that the location has changed. if (oldPosition != null) { - expect(currentPosition.target.latitude, - isNot(equals(oldPosition.target.latitude))); - expect(currentPosition.target.longitude, - isNot(equals(oldPosition.target.longitude))); + expect( + currentPosition.target.latitude, + isNot(equals(oldPosition.target.latitude)), + ); + expect( + currentPosition.target.longitude, + isNot(equals(oldPosition.target.longitude)), + ); } case CameraUpdateType.zoomBy: - expect(currentPosition.zoom, - wrapMatcher(equals(kInitialZoomLevel + _kTestZoomByAmount))); + expect( + currentPosition.zoom, + wrapMatcher(equals(kInitialZoomLevel + _kTestZoomByAmount)), + ); case CameraUpdateType.zoomTo: expect(currentPosition.zoom, wrapMatcher(equals(_kTestCameraZoomLevel))); case CameraUpdateType.zoomIn: diff --git a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/shared.dart b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/shared.dart index 126733f678e..3b91ae8285b 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/shared.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/shared.dart @@ -16,8 +16,10 @@ const LatLng kInitialMapCenter = LatLng(0, 0); const double kInitialZoomLevel = 5; /// Initial camera position -const CameraPosition kInitialCameraPosition = - CameraPosition(target: kInitialMapCenter, zoom: kInitialZoomLevel); +const CameraPosition kInitialCameraPosition = CameraPosition( + target: kInitialMapCenter, + zoom: kInitialZoomLevel, +); // Dummy map ID const String kCloudMapId = '000000000000000'; // Dummy map ID. @@ -33,8 +35,11 @@ final bool isAndroid = const bool isWeb = kIsWeb; /// Pumps a [map] widget in [tester] of a certain [size], then waits until it settles. -Future pumpMap(WidgetTester tester, GoogleMap map, - [Size size = const Size.square(200)]) async { +Future pumpMap( + WidgetTester tester, + GoogleMap map, [ + Size size = const Size.square(200), +]) async { await tester.pumpWidget(wrapMap(map, size)); await tester.pumpAndSettle(); } @@ -45,12 +50,7 @@ Future pumpMap(WidgetTester tester, GoogleMap map, Widget wrapMap(GoogleMap map, [Size size = const Size.square(200)]) { return MaterialApp( home: Scaffold( - body: Center( - child: SizedBox.fromSize( - size: size, - child: map, - ), - ), + body: Center(child: SizedBox.fromSize(size: size, child: map)), ), ); } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/tiles_inspector.dart b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/tiles_inspector.dart index b9b20bf9c0f..0cbd351756b 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/tiles_inspector.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/integration_test/src/tiles_inspector.dart @@ -29,182 +29,192 @@ void runTests() { GoogleMapsInspectorPlatform.instance!; group('Tiles', () { - testWidgets( - 'set tileOverlay correctly', - (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final TileOverlay tileOverlay1 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 2, - transparency: 0.2, - ); + testWidgets('set tileOverlay correctly', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final TileOverlay tileOverlay1 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 2, + transparency: 0.2, + ); - final TileOverlay tileOverlay2 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_2'), - tileProvider: _DebugTileProvider(), - zIndex: 1, - visible: false, - transparency: 0.3, - fadeIn: false, - ); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: GoogleMap( - initialCameraPosition: kInitialCameraPosition, - tileOverlays: {tileOverlay1, tileOverlay2}, - onMapCreated: (GoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), + final TileOverlay tileOverlay2 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_2'), + tileProvider: _DebugTileProvider(), + zIndex: 1, + visible: false, + transparency: 0.3, + fadeIn: false, + ); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + initialCameraPosition: kInitialCameraPosition, + tileOverlays: {tileOverlay1, tileOverlay2}, + onMapCreated: (GoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, ), - ); - await tester.pumpAndSettle(const Duration(seconds: 3)); - - final int mapId = await mapIdCompleter.future; - - final TileOverlay tileOverlayInfo1 = (await inspector - .getTileOverlayInfo(tileOverlay1.mapsId, mapId: mapId))!; - final TileOverlay tileOverlayInfo2 = (await inspector - .getTileOverlayInfo(tileOverlay2.mapsId, mapId: mapId))!; - - expect(tileOverlayInfo1.visible, isTrue); - expect(tileOverlayInfo1.fadeIn, isTrue); - expect(tileOverlayInfo1.transparency, - moreOrLessEquals(0.2, epsilon: 0.001)); - expect(tileOverlayInfo1.zIndex, 2); - - expect(tileOverlayInfo2.visible, isFalse); - expect(tileOverlayInfo2.fadeIn, isFalse); - expect(tileOverlayInfo2.transparency, - moreOrLessEquals(0.3, epsilon: 0.001)); - expect(tileOverlayInfo2.zIndex, 1); - }, - ); + ), + ); + await tester.pumpAndSettle(const Duration(seconds: 3)); - testWidgets( - 'update tileOverlays correctly', - (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 2, - transparency: 0.2, - ); + final int mapId = await mapIdCompleter.future; - final TileOverlay tileOverlay2 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_2'), - tileProvider: _DebugTileProvider(), - zIndex: 3, - transparency: 0.5, - ); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: GoogleMap( - key: key, - initialCameraPosition: kInitialCameraPosition, - tileOverlays: {tileOverlay1, tileOverlay2}, - onMapCreated: (GoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), + final TileOverlay tileOverlayInfo1 = + (await inspector.getTileOverlayInfo( + tileOverlay1.mapsId, + mapId: mapId, + ))!; + final TileOverlay tileOverlayInfo2 = + (await inspector.getTileOverlayInfo( + tileOverlay2.mapsId, + mapId: mapId, + ))!; + + expect(tileOverlayInfo1.visible, isTrue); + expect(tileOverlayInfo1.fadeIn, isTrue); + expect( + tileOverlayInfo1.transparency, + moreOrLessEquals(0.2, epsilon: 0.001), + ); + expect(tileOverlayInfo1.zIndex, 2); + + expect(tileOverlayInfo2.visible, isFalse); + expect(tileOverlayInfo2.fadeIn, isFalse); + expect( + tileOverlayInfo2.transparency, + moreOrLessEquals(0.3, epsilon: 0.001), + ); + expect(tileOverlayInfo2.zIndex, 1); + }); + + testWidgets('update tileOverlays correctly', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final Key key = GlobalKey(); + final TileOverlay tileOverlay1 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 2, + transparency: 0.2, + ); + + final TileOverlay tileOverlay2 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_2'), + tileProvider: _DebugTileProvider(), + zIndex: 3, + transparency: 0.5, + ); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + key: key, + initialCameraPosition: kInitialCameraPosition, + tileOverlays: {tileOverlay1, tileOverlay2}, + onMapCreated: (GoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, ), - ); + ), + ); - final int mapId = await mapIdCompleter.future; + final int mapId = await mapIdCompleter.future; - final TileOverlay tileOverlay1New = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 1, - visible: false, - transparency: 0.3, - fadeIn: false, - ); + final TileOverlay tileOverlay1New = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 1, + visible: false, + transparency: 0.3, + fadeIn: false, + ); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: GoogleMap( - key: key, - initialCameraPosition: kInitialCameraPosition, - tileOverlays: {tileOverlay1New}, - onMapCreated: (GoogleMapController controller) { - fail('update: OnMapCreated should get called only once.'); - }, - ), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + key: key, + initialCameraPosition: kInitialCameraPosition, + tileOverlays: {tileOverlay1New}, + onMapCreated: (GoogleMapController controller) { + fail('update: OnMapCreated should get called only once.'); + }, ), - ); + ), + ); - await tester.pumpAndSettle(const Duration(seconds: 3)); + await tester.pumpAndSettle(const Duration(seconds: 3)); - final TileOverlay tileOverlayInfo1 = (await inspector - .getTileOverlayInfo(tileOverlay1.mapsId, mapId: mapId))!; - final TileOverlay? tileOverlayInfo2 = await inspector - .getTileOverlayInfo(tileOverlay2.mapsId, mapId: mapId); + final TileOverlay tileOverlayInfo1 = + (await inspector.getTileOverlayInfo( + tileOverlay1.mapsId, + mapId: mapId, + ))!; + final TileOverlay? tileOverlayInfo2 = await inspector.getTileOverlayInfo( + tileOverlay2.mapsId, + mapId: mapId, + ); - expect(tileOverlayInfo1.visible, isFalse); - expect(tileOverlayInfo1.fadeIn, isFalse); - expect(tileOverlayInfo1.transparency, - moreOrLessEquals(0.3, epsilon: 0.001)); - expect(tileOverlayInfo1.zIndex, 1); + expect(tileOverlayInfo1.visible, isFalse); + expect(tileOverlayInfo1.fadeIn, isFalse); + expect( + tileOverlayInfo1.transparency, + moreOrLessEquals(0.3, epsilon: 0.001), + ); + expect(tileOverlayInfo1.zIndex, 1); - expect(tileOverlayInfo2, isNull); - }, - ); + expect(tileOverlayInfo2, isNull); + }); - testWidgets( - 'remove tileOverlays correctly', - (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 2, - transparency: 0.2, - ); + testWidgets('remove tileOverlays correctly', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final Key key = GlobalKey(); + final TileOverlay tileOverlay1 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 2, + transparency: 0.2, + ); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: GoogleMap( - key: key, - initialCameraPosition: kInitialCameraPosition, - tileOverlays: {tileOverlay1}, - onMapCreated: (GoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + key: key, + initialCameraPosition: kInitialCameraPosition, + tileOverlays: {tileOverlay1}, + onMapCreated: (GoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, ), - ); + ), + ); - final int mapId = await mapIdCompleter.future; - - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: GoogleMap( - key: key, - initialCameraPosition: kInitialCameraPosition, - onMapCreated: (GoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, - ), + final int mapId = await mapIdCompleter.future; + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + key: key, + initialCameraPosition: kInitialCameraPosition, + onMapCreated: (GoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, ), - ); + ), + ); - await tester.pumpAndSettle(const Duration(seconds: 3)); - final TileOverlay? tileOverlayInfo1 = await inspector - .getTileOverlayInfo(tileOverlay1.mapsId, mapId: mapId); + await tester.pumpAndSettle(const Duration(seconds: 3)); + final TileOverlay? tileOverlayInfo1 = await inspector.getTileOverlayInfo( + tileOverlay1.mapsId, + mapId: mapId, + ); - expect(tileOverlayInfo1, isNull); - }, - ); + expect(tileOverlayInfo1, isNull); + }); }, skip: isWeb /* Tiles not supported on the web */); group('Heatmaps', () { @@ -251,7 +261,9 @@ void runTests() { void expectHeatmapEquals(Heatmap heatmap1, Heatmap heatmap2) { expectHeatmapDataMoreOrLessEquals(heatmap1.data, heatmap2.data); expectHeatmapGradientMoreOrLessEquals( - heatmap1.gradient, heatmap2.gradient); + heatmap1.gradient, + heatmap2.gradient, + ); // Only Android supports `maxIntensity` // so the platform value is undefined on others. @@ -295,33 +307,16 @@ void runTests() { WeightedLatLng(LatLng(37.785, -122.441)), WeightedLatLng(LatLng(37.785, -122.439)), WeightedLatLng(LatLng(37.785, -122.437)), - WeightedLatLng(LatLng(37.785, -122.435), weight: 2) + WeightedLatLng(LatLng(37.785, -122.435), weight: 2), ], dissipating: false, - gradient: HeatmapGradient( - [ - HeatmapGradientColor( - Color.fromARGB(255, 0, 255, 255), - 0.2, - ), - HeatmapGradientColor( - Color.fromARGB(255, 0, 63, 255), - 0.4, - ), - HeatmapGradientColor( - Color.fromARGB(255, 0, 0, 191), - 0.6, - ), - HeatmapGradientColor( - Color.fromARGB(255, 63, 0, 91), - 0.8, - ), - HeatmapGradientColor( - Color.fromARGB(255, 255, 0, 0), - 1, - ), - ], - ), + gradient: HeatmapGradient([ + HeatmapGradientColor(Color.fromARGB(255, 0, 255, 255), 0.2), + HeatmapGradientColor(Color.fromARGB(255, 0, 63, 255), 0.4), + HeatmapGradientColor(Color.fromARGB(255, 0, 0, 191), 0.6), + HeatmapGradientColor(Color.fromARGB(255, 63, 0, 91), 0.8), + HeatmapGradientColor(Color.fromARGB(255, 255, 0, 0), 1), + ]), maxIntensity: 1, opacity: 0.5, radius: HeatmapRadius.fromPixels(40), @@ -469,8 +464,10 @@ void runTests() { await tester.pumpAndSettle(const Duration(seconds: 3)); if (inspector.supportsGettingHeatmapInfo()) { - final Heatmap? heatmapInfo1 = - await inspector.getHeatmapInfo(heatmap1.mapsId, mapId: mapId); + final Heatmap? heatmapInfo1 = await inspector.getHeatmapInfo( + heatmap1.mapsId, + mapId: mapId, + ); expect(heatmapInfo1, isNull); } @@ -514,7 +511,9 @@ void runTests() { ); void expectGroundOverlayEquals( - GroundOverlay source, GroundOverlay response) { + GroundOverlay source, + GroundOverlay response, + ) { expect(response.groundOverlayId, source.groundOverlayId); expect( response.transparency, @@ -602,10 +601,16 @@ void runTests() { GoogleMapsInspectorPlatform.instance!; if (inspector.supportsGettingGroundOverlayInfo()) { - final GroundOverlay groundOverlayBoundsInfo1 = (await inspector - .getGroundOverlayInfo(groundOverlayBounds1.mapsId, mapId: mapId))!; - final GroundOverlay groundOverlayBoundsInfo2 = (await inspector - .getGroundOverlayInfo(groundOverlayBounds2.mapsId, mapId: mapId))!; + final GroundOverlay groundOverlayBoundsInfo1 = + (await inspector.getGroundOverlayInfo( + groundOverlayBounds1.mapsId, + mapId: mapId, + ))!; + final GroundOverlay groundOverlayBoundsInfo2 = + (await inspector.getGroundOverlayInfo( + groundOverlayBounds2.mapsId, + mapId: mapId, + ))!; expectGroundOverlayEquals( groundOverlayBounds1, @@ -618,9 +623,11 @@ void runTests() { // Web does not support position-based ground overlays. if (!isWeb) { - final GroundOverlay groundOverlayPositionInfo1 = (await inspector - .getGroundOverlayInfo(groundOverlayPosition1.mapsId, - mapId: mapId))!; + final GroundOverlay groundOverlayPositionInfo1 = + (await inspector.getGroundOverlayInfo( + groundOverlayPosition1.mapsId, + mapId: mapId, + ))!; expectGroundOverlayEquals( groundOverlayPosition1, groundOverlayPositionInfo1, @@ -629,8 +636,9 @@ void runTests() { } }); - testWidgets('update ground overlays correctly', - (WidgetTester tester) async { + testWidgets('update ground overlays correctly', ( + WidgetTester tester, + ) async { final Completer mapIdCompleter = Completer(); final Key key = GlobalKey(); @@ -643,7 +651,7 @@ void runTests() { groundOverlays: { groundOverlayBounds1, // Web does not support position-based ground overlays. - if (!isWeb) groundOverlayPosition1 + if (!isWeb) groundOverlayPosition1, }, onMapCreated: (GoogleMapController controller) { mapIdCompleter.complete(controller.mapId); @@ -657,23 +665,23 @@ void runTests() { final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - final GroundOverlay groundOverlayBounds1New = - groundOverlayBounds1.copyWith( - bearingParam: 10, - clickableParam: false, - visibleParam: false, - transparencyParam: 0.5, - zIndexParam: 10, - ); + final GroundOverlay groundOverlayBounds1New = groundOverlayBounds1 + .copyWith( + bearingParam: 10, + clickableParam: false, + visibleParam: false, + transparencyParam: 0.5, + zIndexParam: 10, + ); - final GroundOverlay groundOverlayPosition1New = - groundOverlayPosition1.copyWith( - bearingParam: 10, - clickableParam: false, - visibleParam: false, - transparencyParam: 0.5, - zIndexParam: 10, - ); + final GroundOverlay groundOverlayPosition1New = groundOverlayPosition1 + .copyWith( + bearingParam: 10, + clickableParam: false, + visibleParam: false, + transparencyParam: 0.5, + zIndexParam: 10, + ); await tester.pumpWidget( Directionality( @@ -684,7 +692,7 @@ void runTests() { groundOverlays: { groundOverlayBounds1New, // Web does not support position-based ground overlays. - if (!isWeb) groundOverlayPosition1New + if (!isWeb) groundOverlayPosition1New, }, onMapCreated: (GoogleMapController controller) { fail('update: OnMapCreated should get called only once.'); @@ -696,8 +704,11 @@ void runTests() { await tester.pumpAndSettle(const Duration(seconds: 3)); if (inspector.supportsGettingGroundOverlayInfo()) { - final GroundOverlay groundOverlayBounds1Info = (await inspector - .getGroundOverlayInfo(groundOverlayBounds1.mapsId, mapId: mapId))!; + final GroundOverlay groundOverlayBounds1Info = + (await inspector.getGroundOverlayInfo( + groundOverlayBounds1.mapsId, + mapId: mapId, + ))!; expectGroundOverlayEquals( groundOverlayBounds1New, @@ -706,9 +717,11 @@ void runTests() { // Web does not support position-based ground overlays. if (!isWeb) { - final GroundOverlay groundOverlayPosition1Info = (await inspector - .getGroundOverlayInfo(groundOverlayPosition1.mapsId, - mapId: mapId))!; + final GroundOverlay groundOverlayPosition1Info = + (await inspector.getGroundOverlayInfo( + groundOverlayPosition1.mapsId, + mapId: mapId, + ))!; expectGroundOverlayEquals( groundOverlayPosition1New, @@ -718,8 +731,9 @@ void runTests() { } }); - testWidgets('remove ground overlays correctly', - (WidgetTester tester) async { + testWidgets('remove ground overlays correctly', ( + WidgetTester tester, + ) async { final Completer mapIdCompleter = Completer(); final Key key = GlobalKey(); @@ -732,7 +746,7 @@ void runTests() { groundOverlays: { groundOverlayBounds1, // Web does not support position-based ground overlays. - if (!isWeb) groundOverlayPosition1 + if (!isWeb) groundOverlayPosition1, }, onMapCreated: (GoogleMapController controller) { mapIdCompleter.complete(controller.mapId); @@ -769,8 +783,10 @@ void runTests() { // Web does not support position-based ground overlays. if (!isWeb) { final GroundOverlay? groundOverlayPositionInfo = await inspector - .getGroundOverlayInfo(groundOverlayPosition1.mapsId, - mapId: mapId); + .getGroundOverlayInfo( + groundOverlayPosition1.mapsId, + mapId: mapId, + ); expect(groundOverlayPositionInfo, isNull); } } @@ -789,34 +805,29 @@ class _DebugTileProvider implements TileProvider { static const int width = 100; static const int height = 100; static final Paint boxPaint = Paint(); - static const TextStyle textStyle = TextStyle( - color: Colors.red, - fontSize: 20, - ); + static const TextStyle textStyle = TextStyle(color: Colors.red, fontSize: 20); @override Future getTile(int x, int y, int? zoom) async { final ui.PictureRecorder recorder = ui.PictureRecorder(); final Canvas canvas = Canvas(recorder); - final TextSpan textSpan = TextSpan( - text: '$x,$y', - style: textStyle, - ); + final TextSpan textSpan = TextSpan(text: '$x,$y', style: textStyle); final TextPainter textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); - textPainter.layout( - maxWidth: width.toDouble(), - ); + textPainter.layout(maxWidth: width.toDouble()); textPainter.paint(canvas, Offset.zero); canvas.drawRect( - Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), boxPaint); + Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), + boxPaint, + ); final ui.Picture picture = recorder.endRecording(); final Uint8List byteData = await picture .toImage(width, height) - .then((ui.Image image) => - image.toByteData(format: ui.ImageByteFormat.png)) + .then( + (ui.Image image) => image.toByteData(format: ui.ImageByteFormat.png), + ) .then((ByteData? byteData) => byteData!.buffer.asUint8List()); return Tile(width, height, byteData); } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/animate_camera.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/animate_camera.dart index bd67f1b713c..58a5fd38c4c 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/animate_camera.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/animate_camera.dart @@ -12,7 +12,7 @@ import 'page.dart'; class AnimateCameraPage extends GoogleMapExampleAppPage { const AnimateCameraPage({Key? key}) - : super(const Icon(Icons.map), 'Camera control, animated', key: key); + : super(const Icon(Icons.map), 'Camera control, animated', key: key); @override Widget build(BuildContext context) { @@ -40,9 +40,10 @@ class AnimateCameraState extends State { void _toggleAnimationDuration() { setState(() { - _cameraUpdateAnimationDuration = _cameraUpdateAnimationDuration != null - ? null - : const Duration(seconds: _durationSeconds); + _cameraUpdateAnimationDuration = + _cameraUpdateAnimationDuration != null + ? null + : const Duration(seconds: _durationSeconds); }); } @@ -58,8 +59,9 @@ class AnimateCameraState extends State { height: 200.0, child: GoogleMap( onMapCreated: _onMapCreated, - initialCameraPosition: - const CameraPosition(target: LatLng(0.0, 0.0)), + initialCameraPosition: const CameraPosition( + target: LatLng(0.0, 0.0), + ), ), ), ), @@ -138,10 +140,7 @@ class AnimateCameraState extends State { TextButton( onPressed: () { mapController?.animateCamera( - CameraUpdate.zoomBy( - -0.5, - const Offset(30.0, 20.0), - ), + CameraUpdate.zoomBy(-0.5, const Offset(30.0, 20.0)), duration: _cameraUpdateAnimationDuration, ); }, @@ -190,18 +189,16 @@ class AnimateCameraState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text( - 'With 10 second duration', - textAlign: TextAlign.right, - ), + const Text('With 10 second duration', textAlign: TextAlign.right), const SizedBox(width: 5), Switch( value: _cameraUpdateAnimationDuration != null, - onChanged: kIsWeb - ? null - : (bool value) { - _toggleAnimationDuration(); - }, + onChanged: + kIsWeb + ? null + : (bool value) { + _toggleAnimationDuration(); + }, ), ], ), diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/clustering.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/clustering.dart index 5c06a61b2a1..511d0e09e15 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/clustering.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/clustering.dart @@ -13,7 +13,7 @@ import 'page.dart'; class ClusteringPage extends GoogleMapExampleAppPage { /// Default Constructor. const ClusteringPage({Key? key}) - : super(const Icon(Icons.place), 'Manage clustering', key: key); + : super(const Icon(Icons.place), 'Manage clustering', key: key); @override Widget build(BuildContext context) { @@ -95,8 +95,9 @@ class ClusteringBodyState extends State { setState(() { final MarkerId? previousMarkerId = selectedMarker; if (previousMarkerId != null && markers.containsKey(previousMarkerId)) { - final Marker resetOld = markers[previousMarkerId]! - .copyWith(iconParam: BitmapDescriptor.defaultMarker); + final Marker resetOld = markers[previousMarkerId]!.copyWith( + iconParam: BitmapDescriptor.defaultMarker, + ); markers[previousMarkerId] = resetOld; } selectedMarker = markerId; @@ -118,14 +119,16 @@ class ClusteringBodyState extends State { final String clusterManagerIdVal = 'cluster_manager_id_$_clusterManagerIdCounter'; _clusterManagerIdCounter++; - final ClusterManagerId clusterManagerId = - ClusterManagerId(clusterManagerIdVal); + final ClusterManagerId clusterManagerId = ClusterManagerId( + clusterManagerIdVal, + ); final ClusterManager clusterManager = ClusterManager( clusterManagerId: clusterManagerId, - onClusterTap: (Cluster cluster) => setState(() { - lastCluster = cluster; - }), + onClusterTap: + (Cluster cluster) => setState(() { + lastCluster = cluster; + }), ); setState(() { @@ -137,8 +140,10 @@ class ClusteringBodyState extends State { void _removeClusterManager(ClusterManager clusterManager) { setState(() { // Remove markers managed by cluster manager to be removed. - markers.removeWhere((MarkerId key, Marker marker) => - marker.clusterManagerId == clusterManager.clusterManagerId); + markers.removeWhere( + (MarkerId key, Marker marker) => + marker.clusterManagerId == clusterManager.clusterManagerId, + ); // Remove cluster manager. clusterManagers.remove(clusterManager.clusterManagerId); }); @@ -151,8 +156,9 @@ class ClusteringBodyState extends State { _markerIdCounter++; final MarkerId markerId = MarkerId(markerIdVal); - final int clusterManagerIndex = - clusterManagers.values.toList().indexOf(clusterManager); + final int clusterManagerIndex = clusterManagers.values.toList().indexOf( + clusterManager, + ); // Add additional offset to longitude for each cluster manager to space // out markers in different cluster managers. @@ -191,9 +197,10 @@ class ClusteringBodyState extends State { final Marker marker = markers[markerId]!; final double current = marker.alpha; markers[markerId] = marker.copyWith( - alphaParam: current == _fullyVisibleAlpha - ? _halfVisibleAlpha - : _fullyVisibleAlpha, + alphaParam: + current == _fullyVisibleAlpha + ? _halfVisibleAlpha + : _fullyVisibleAlpha, ); } setState(() {}); @@ -217,61 +224,72 @@ class ClusteringBodyState extends State { clusterManagers: Set.of(clusterManagers.values), ), ), - Column(children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - onPressed: clusterManagers.length >= _clusterManagerMaxCount - ? null - : () => _addClusterManager(), - child: const Text('Add cluster manager'), - ), - TextButton( - onPressed: clusterManagers.isEmpty - ? null - : () => _removeClusterManager(clusterManagers.values.last), - child: const Text('Remove cluster manager'), - ), - ], - ), - Wrap( - alignment: WrapAlignment.spaceEvenly, - children: [ - for (final MapEntry clusterEntry - in clusterManagers.entries) + Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ TextButton( - onPressed: () => _addMarkersToCluster(clusterEntry.value), - child: Text('Add markers to ${clusterEntry.key.value}'), + onPressed: + clusterManagers.length >= _clusterManagerMaxCount + ? null + : () => _addClusterManager(), + child: const Text('Add cluster manager'), ), - ], - ), - Wrap( - alignment: WrapAlignment.spaceEvenly, - children: [ - TextButton( - onPressed: selectedId == null - ? null - : () { - _remove(selectedId); - setState(() { - selectedMarker = null; - }); - }, - child: const Text('Remove selected marker'), - ), - TextButton( - onPressed: markers.isEmpty ? null : () => _changeMarkersAlpha(), - child: const Text('Change all markers alpha'), - ), - ], - ), - if (lastCluster != null) - Padding( + TextButton( + onPressed: + clusterManagers.isEmpty + ? null + : () => _removeClusterManager( + clusterManagers.values.last, + ), + child: const Text('Remove cluster manager'), + ), + ], + ), + Wrap( + alignment: WrapAlignment.spaceEvenly, + children: [ + for (final MapEntry + clusterEntry + in clusterManagers.entries) + TextButton( + onPressed: () => _addMarkersToCluster(clusterEntry.value), + child: Text('Add markers to ${clusterEntry.key.value}'), + ), + ], + ), + Wrap( + alignment: WrapAlignment.spaceEvenly, + children: [ + TextButton( + onPressed: + selectedId == null + ? null + : () { + _remove(selectedId); + setState(() { + selectedMarker = null; + }); + }, + child: const Text('Remove selected marker'), + ), + TextButton( + onPressed: + markers.isEmpty ? null : () => _changeMarkersAlpha(), + child: const Text('Change all markers alpha'), + ), + ], + ), + if (lastCluster != null) + Padding( padding: const EdgeInsets.all(10), child: Text( - 'Cluster with ${lastCluster!.count} markers clicked at ${lastCluster!.position}')), - ]), + 'Cluster with ${lastCluster!.count} markers clicked at ${lastCluster!.position}', + ), + ), + ], + ), ], ); } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/custom_marker_icon.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/custom_marker_icon.dart index 8940762f02e..02daad7a52e 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/custom_marker_icon.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/custom_marker_icon.dart @@ -15,12 +15,14 @@ Future createCustomMarkerIconImage({required Size size}) async { painter.paint(canvas, size); - final ui.Image image = await recorder - .endRecording() - .toImage(size.width.floor(), size.height.floor()); - - final ByteData? bytes = - await image.toByteData(format: ui.ImageByteFormat.png); + final ui.Image image = await recorder.endRecording().toImage( + size.width.floor(), + size.height.floor(), + ); + + final ByteData? bytes = await image.toByteData( + format: ui.ImageByteFormat.png, + ); return bytes!; } @@ -34,10 +36,7 @@ class _MarkerPainter extends CustomPainter { ); // Draw radial gradient - canvas.drawRect( - rect, - Paint()..shader = gradient.createShader(rect), - ); + canvas.drawRect(rect, Paint()..shader = gradient.createShader(rect)); // Draw diagonal black line canvas.drawLine( diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/ground_overlay.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/ground_overlay.dart index 748eb04590c..0a0c2a6d3a3 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/ground_overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/ground_overlay.dart @@ -14,7 +14,7 @@ enum _GroundOverlayPlacing { position, bounds } class GroundOverlayPage extends GoogleMapExampleAppPage { const GroundOverlayPage({Key? key}) - : super(const Icon(Icons.map), 'Ground overlay', key: key); + : super(const Icon(Icons.map), 'Ground overlay', key: key); @override Widget build(BuildContext context) { @@ -48,11 +48,13 @@ class GroundOverlayBodyState extends State { // Bounds for demonstranting placing ground overlays with bounds, and // changing bounds. final LatLngBounds _groundOverlayBounds1 = LatLngBounds( - southwest: const LatLng(37.42, -122.09), - northeast: const LatLng(37.423, -122.084)); + southwest: const LatLng(37.42, -122.09), + northeast: const LatLng(37.423, -122.084), + ); final LatLngBounds _groundOverlayBounds2 = LatLngBounds( - southwest: const LatLng(37.421, -122.091), - northeast: const LatLng(37.424, -122.08)); + southwest: const LatLng(37.421, -122.091), + northeast: const LatLng(37.424, -122.08), + ); late LatLngBounds _currentGroundOverlayBounds; Offset _anchor = const Offset(0.5, 0.5); @@ -93,31 +95,32 @@ class GroundOverlayBodyState extends State { _groundOverlayIndex += 1; - final GroundOverlayId id = - GroundOverlayId('ground_overlay_$_groundOverlayIndex'); + final GroundOverlayId id = GroundOverlayId( + 'ground_overlay_$_groundOverlayIndex', + ); final GroundOverlay groundOverlay = switch (_placingType) { _GroundOverlayPlacing.position => GroundOverlay.fromPosition( - groundOverlayId: id, - image: assetMapBitmap, - position: _currentGroundOverlayPos, - width: _dimensions.dx, // Android only - height: _dimensions.dy, // Android only - zoomLevel: 14.0, // iOS only - anchor: _anchor, - onTap: () { - _onGroundOverlayTapped(); - }, - ), + groundOverlayId: id, + image: assetMapBitmap, + position: _currentGroundOverlayPos, + width: _dimensions.dx, // Android only + height: _dimensions.dy, // Android only + zoomLevel: 14.0, // iOS only + anchor: _anchor, + onTap: () { + _onGroundOverlayTapped(); + }, + ), _GroundOverlayPlacing.bounds => GroundOverlay.fromBounds( - groundOverlayId: id, - image: assetMapBitmap, - bounds: _currentGroundOverlayBounds, - anchor: _anchor, - onTap: () { - _onGroundOverlayTapped(); - }, - ), + groundOverlayId: id, + image: assetMapBitmap, + bounds: _currentGroundOverlayBounds, + anchor: _anchor, + onTap: () { + _onGroundOverlayTapped(); + }, + ), }; setState(() { @@ -133,9 +136,9 @@ class GroundOverlayBodyState extends State { assert(_groundOverlay != null); setState(() { _groundOverlay = _groundOverlay!.copyWith( - bearingParam: _groundOverlay!.bearing >= 350 - ? 0 - : _groundOverlay!.bearing + 10); + bearingParam: + _groundOverlay!.bearing >= 350 ? 0 : _groundOverlay!.bearing + 10, + ); }); } @@ -144,8 +147,9 @@ class GroundOverlayBodyState extends State { setState(() { final double transparency = _groundOverlay!.transparency == 0.0 ? 0.5 : 0.0; - _groundOverlay = - _groundOverlay!.copyWith(transparencyParam: transparency); + _groundOverlay = _groundOverlay!.copyWith( + transparencyParam: transparency, + ); }); } @@ -153,9 +157,10 @@ class GroundOverlayBodyState extends State { assert(_groundOverlay != null); assert(_placingType == _GroundOverlayPlacing.position); setState(() { - _dimensions = _dimensions == const Offset(1000, 1000) - ? const Offset(1500, 500) - : const Offset(1000, 1000); + _dimensions = + _dimensions == const Offset(1000, 1000) + ? const Offset(1500, 500) + : const Offset(1000, 1000); }); // Re-add the ground overlay to apply the new position, as the position @@ -167,9 +172,10 @@ class GroundOverlayBodyState extends State { assert(_groundOverlay != null); assert(_placingType == _GroundOverlayPlacing.position); setState(() { - _currentGroundOverlayPos = _currentGroundOverlayPos == _groundOverlayPos1 - ? _groundOverlayPos2 - : _groundOverlayPos1; + _currentGroundOverlayPos = + _currentGroundOverlayPos == _groundOverlayPos1 + ? _groundOverlayPos2 + : _groundOverlayPos1; }); // Re-add the ground overlay to apply the new position, as the position @@ -195,8 +201,9 @@ class GroundOverlayBodyState extends State { void _toggleVisible() { assert(_groundOverlay != null); setState(() { - _groundOverlay = - _groundOverlay!.copyWith(visibleParam: !_groundOverlay!.visible); + _groundOverlay = _groundOverlay!.copyWith( + visibleParam: !_groundOverlay!.visible, + ); }); } @@ -211,9 +218,10 @@ class GroundOverlayBodyState extends State { Future _changeType() async { setState(() { - _placingType = _placingType == _GroundOverlayPlacing.position - ? _GroundOverlayPlacing.bounds - : _GroundOverlayPlacing.position; + _placingType = + _placingType == _GroundOverlayPlacing.position + ? _GroundOverlayPlacing.bounds + : _GroundOverlayPlacing.position; }); // Re-add the ground overlay to change the positioning type. @@ -223,9 +231,10 @@ class GroundOverlayBodyState extends State { Future _changeAnchor() async { assert(_groundOverlay != null); setState(() { - _anchor = _groundOverlay!.anchor == const Offset(0.5, 0.5) - ? const Offset(1.0, 1.0) - : const Offset(0.5, 0.5); + _anchor = + _groundOverlay!.anchor == const Offset(0.5, 0.5) + ? const Offset(1.0, 1.0) + : const Offset(0.5, 0.5); }); // Re-add the ground overlay to apply the new anchor as the anchor cannot be @@ -298,31 +307,36 @@ class GroundOverlayBodyState extends State { if (!kIsWeb) TextButton( onPressed: _groundOverlay == null ? null : () => _changeType(), - child: Text(_placingType == _GroundOverlayPlacing.position - ? 'use bounds' - : 'use position'), + child: Text( + _placingType == _GroundOverlayPlacing.position + ? 'use bounds' + : 'use position', + ), ), if (!kIsWeb) TextButton( - onPressed: _placingType != _GroundOverlayPlacing.position || - _groundOverlay == null - ? null - : () => _changePosition(), + onPressed: + _placingType != _GroundOverlayPlacing.position || + _groundOverlay == null + ? null + : () => _changePosition(), child: const Text('change position'), ), if (defaultTargetPlatform == TargetPlatform.android) TextButton( - onPressed: _placingType != _GroundOverlayPlacing.position || - _groundOverlay == null - ? null - : () => _changeDimensions(), + onPressed: + _placingType != _GroundOverlayPlacing.position || + _groundOverlay == null + ? null + : () => _changeDimensions(), child: const Text('change dimensions'), ), TextButton( - onPressed: _placingType != _GroundOverlayPlacing.bounds || - _groundOverlay == null - ? null - : () => _changeBounds(), + onPressed: + _placingType != _GroundOverlayPlacing.bounds || + _groundOverlay == null + ? null + : () => _changeBounds(), child: const Text('change bounds'), ), ], diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/heatmap.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/heatmap.dart index 956a0a49e1b..af9f21b5fca 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/heatmap.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/heatmap.dart @@ -11,7 +11,7 @@ import 'page.dart'; class HeatmapPage extends GoogleMapExampleAppPage { const HeatmapPage({Key? key}) - : super(const Icon(Icons.map), 'Heatmaps', key: key); + : super(const Icon(Icons.map), 'Heatmaps', key: key); @override Widget build(BuildContext context) { @@ -43,7 +43,7 @@ class HeatmapBodyState extends State { const WeightedLatLng(LatLng(37.785, -122.441)), const WeightedLatLng(LatLng(37.785, -122.439)), const WeightedLatLng(LatLng(37.785, -122.437)), - const WeightedLatLng(LatLng(37.785, -122.435)) + const WeightedLatLng(LatLng(37.785, -122.435)), ]; List disabledPoints = []; @@ -95,42 +95,26 @@ class HeatmapBodyState extends State { width: 350.0, height: 300.0, child: GoogleMap( - initialCameraPosition: const CameraPosition( - target: sanFrancisco, - zoom: 13, + initialCameraPosition: const CameraPosition( + target: sanFrancisco, + zoom: 13, + ), + heatmaps: { + Heatmap( + heatmapId: const HeatmapId('test'), + data: enabledPoints, + gradient: const HeatmapGradient([ + HeatmapGradientColor(Color.fromARGB(255, 0, 255, 255), 0.2), + HeatmapGradientColor(Color.fromARGB(255, 0, 63, 255), 0.4), + HeatmapGradientColor(Color.fromARGB(255, 0, 0, 191), 0.6), + HeatmapGradientColor(Color.fromARGB(255, 63, 0, 91), 0.8), + HeatmapGradientColor(Color.fromARGB(255, 255, 0, 0), 1), + ]), + maxIntensity: 1, + radius: HeatmapRadius.fromPixels(radius), ), - heatmaps: { - Heatmap( - heatmapId: const HeatmapId('test'), - data: enabledPoints, - gradient: const HeatmapGradient( - [ - HeatmapGradientColor( - Color.fromARGB(255, 0, 255, 255), - 0.2, - ), - HeatmapGradientColor( - Color.fromARGB(255, 0, 63, 255), - 0.4, - ), - HeatmapGradientColor( - Color.fromARGB(255, 0, 0, 191), - 0.6, - ), - HeatmapGradientColor( - Color.fromARGB(255, 63, 0, 91), - 0.8, - ), - HeatmapGradientColor( - Color.fromARGB(255, 255, 0, 0), - 1, - ), - ], - ), - maxIntensity: 1, - radius: HeatmapRadius.fromPixels(radius), - ) - }), + }, + ), ), ), Expanded( @@ -153,9 +137,9 @@ class HeatmapBodyState extends State { child: const Text('Remove point'), ), ], - ) + ), ], - ) + ), ], ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/lite_mode.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/lite_mode.dart index fd95cf864a7..96c1c8434dd 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/lite_mode.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/lite_mode.dart @@ -8,12 +8,14 @@ import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class LiteModePage extends GoogleMapExampleAppPage { const LiteModePage({Key? key}) - : super(const Icon(Icons.map), 'Lite mode', key: key); + : super(const Icon(Icons.map), 'Lite mode', key: key); @override Widget build(BuildContext context) { diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart index db7f38f9f8a..1ffd90754d7 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/main.dart @@ -57,11 +57,13 @@ class MapsDemo extends StatelessWidget { const MapsDemo({super.key}); void _pushPage(BuildContext context, GoogleMapExampleAppPage page) { - Navigator.of(context).push(MaterialPageRoute( - builder: (_) => Scaffold( - appBar: AppBar(title: Text(page.title)), - body: page, - ))); + Navigator.of(context).push( + MaterialPageRoute( + builder: + (_) => + Scaffold(appBar: AppBar(title: Text(page.title)), body: page), + ), + ); } @override @@ -70,11 +72,12 @@ class MapsDemo extends StatelessWidget { appBar: AppBar(title: const Text('GoogleMaps examples')), body: ListView.builder( itemCount: _allPages.length, - itemBuilder: (_, int index) => ListTile( - leading: _allPages[index].leading, - title: Text(_allPages[index].title), - onTap: () => _pushPage(context, _allPages[index]), - ), + itemBuilder: + (_, int index) => ListTile( + leading: _allPages[index].leading, + title: Text(_allPages[index].title), + onTap: () => _pushPage(context, _allPages[index]), + ), ), ); } @@ -109,10 +112,14 @@ Future initializeMapRenderer() async { final GoogleMapsFlutterPlatform mapsImplementation = GoogleMapsFlutterPlatform.instance; if (mapsImplementation is GoogleMapsFlutterAndroid) { - unawaited(mapsImplementation - .initializeWithRenderer(AndroidMapRenderer.latest) - .then((AndroidMapRenderer initializedRenderer) => - completer.complete(initializedRenderer))); + unawaited( + mapsImplementation + .initializeWithRenderer(AndroidMapRenderer.latest) + .then( + (AndroidMapRenderer initializedRenderer) => + completer.complete(initializedRenderer), + ), + ); } else { completer.complete(null); } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_click.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_click.dart index ed25d475ebd..f48ca5414f5 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_click.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_click.dart @@ -8,12 +8,14 @@ import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class MapClickPage extends GoogleMapExampleAppPage { const MapClickPage({Key? key}) - : super(const Icon(Icons.mouse), 'Map click', key: key); + : super(const Icon(Icons.mouse), 'Map click', key: key); @override Widget build(BuildContext context) { @@ -56,11 +58,7 @@ class _MapClickBodyState extends State<_MapClickBody> { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), ]; @@ -68,26 +66,28 @@ class _MapClickBodyState extends State<_MapClickBody> { if (mapController != null) { final String lastTap = 'Tap:\n${_lastTap ?? ""}\n'; final String lastLongPress = 'Long press:\n${_lastLongPress ?? ""}'; - columnChildren.add(Center( - child: Text( - lastTap, - textAlign: TextAlign.center, - ))); - columnChildren.add(Center( + columnChildren.add( + Center(child: Text(lastTap, textAlign: TextAlign.center)), + ); + columnChildren.add( + Center( child: Text( - _lastTap != null ? 'Tapped' : '', - textAlign: TextAlign.center, - ))); - columnChildren.add(Center( - child: Text( - lastLongPress, - textAlign: TextAlign.center, - ))); - columnChildren.add(Center( + _lastTap != null ? 'Tapped' : '', + textAlign: TextAlign.center, + ), + ), + ); + columnChildren.add( + Center(child: Text(lastLongPress, textAlign: TextAlign.center)), + ); + columnChildren.add( + Center( child: Text( - _lastLongPress != null ? 'Long pressed' : '', - textAlign: TextAlign.center, - ))); + _lastLongPress != null ? 'Long pressed' : '', + textAlign: TextAlign.center, + ), + ), + ); } return Column( crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_coordinates.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_coordinates.dart index efb4a105fd0..ab8bb7703ed 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_coordinates.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_coordinates.dart @@ -8,12 +8,14 @@ import 'package:flutter/material.dart'; import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class MapCoordinatesPage extends GoogleMapExampleAppPage { const MapCoordinatesPage({Key? key}) - : super(const Icon(Icons.map), 'Map coordinates', key: key); + : super(const Icon(Icons.map), 'Map coordinates', key: key); @override Widget build(BuildContext context) { @@ -56,26 +58,21 @@ class _MapCoordinatesBodyState extends State<_MapCoordinatesBody> { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), if (mapController != null) Center( - child: Text('VisibleRegion:' - '\nnortheast: ${_visibleRegion.northeast},' - '\nsouthwest: ${_visibleRegion.southwest}'), + child: Text( + 'VisibleRegion:' + '\nnortheast: ${_visibleRegion.northeast},' + '\nsouthwest: ${_visibleRegion.southwest}', + ), ), // Add a block at the bottom of this list to allow validation that the visible region of the map // does not change when scrolled under the safe view on iOS. // https://github.com/flutter/flutter/issues/107913 - const SizedBox( - width: 300, - height: 1000, - ), + const SizedBox(width: 300, height: 1000), ], ), ); diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart index 6b90d777da0..acd1c1f15f5 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart @@ -15,7 +15,7 @@ import 'page.dart'; class MapIdPage extends GoogleMapExampleAppPage { const MapIdPage({Key? key}) - : super(const Icon(Icons.map), 'Cloud-based maps styling', key: key); + : super(const Icon(Icons.map), 'Cloud-based maps styling', key: key); @override Widget build(BuildContext context) { @@ -42,10 +42,11 @@ class MapIdBodyState extends State { @override void initState() { - initializeMapRenderer() - .then((AndroidMapRenderer? initializedRenderer) => setState(() { - _initializedRenderer = initializedRenderer; - })); + initializeMapRenderer().then( + (AndroidMapRenderer? initializedRenderer) => setState(() { + _initializedRenderer = initializedRenderer; + }), + ); super.initState(); } @@ -74,49 +75,45 @@ class MapIdBodyState extends State { @override Widget build(BuildContext context) { final GoogleMap googleMap = GoogleMap( - onMapCreated: _onMapCreated, - initialCameraPosition: const CameraPosition( - target: _kMapCenter, - zoom: 7.0, - ), - key: _key, - cloudMapId: _mapId); + onMapCreated: _onMapCreated, + initialCameraPosition: const CameraPosition( + target: _kMapCenter, + zoom: 7.0, + ), + key: _key, + cloudMapId: _mapId, + ); final List columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), Padding( - padding: const EdgeInsets.all(10.0), - child: TextField( - controller: _mapIdController, - decoration: const InputDecoration( - hintText: 'Map Id', - ), - )), + padding: const EdgeInsets.all(10.0), + child: TextField( + controller: _mapIdController, + decoration: const InputDecoration(hintText: 'Map Id'), + ), + ), Padding( - padding: const EdgeInsets.all(10.0), - child: ElevatedButton( - onPressed: () => _setMapId(), - child: const Text( - 'Press to use specified map Id', - ), - )), + padding: const EdgeInsets.all(10.0), + child: ElevatedButton( + onPressed: () => _setMapId(), + child: const Text('Press to use specified map Id'), + ), + ), if (!kIsWeb && Platform.isAndroid && _initializedRenderer != AndroidMapRenderer.latest) Padding( padding: const EdgeInsets.all(10.0), child: Text( - 'On Android, Cloud-based maps styling only works with "latest" renderer.\n\n' - 'Current initialized renderer is "${_getInitializedsRendererType()}".'), + 'On Android, Cloud-based maps styling only works with "latest" renderer.\n\n' + 'Current initialized renderer is "${_getInitializedsRendererType()}".', + ), ), ]; diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_ui.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_ui.dart index 26c0b2ab720..a740ff2bcff 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/map_ui.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/map_ui.dart @@ -18,7 +18,7 @@ final LatLngBounds sydneyBounds = LatLngBounds( class MapUiPage extends GoogleMapExampleAppPage { const MapUiPage({Key? key}) - : super(const Icon(Icons.map), 'User interface', key: key); + : super(const Icon(Icons.map), 'User interface', key: key); @override Widget build(BuildContext context) { @@ -103,9 +103,10 @@ class MapUiBodyState extends State { ), onPressed: () { setState(() { - _cameraTargetBounds = _cameraTargetBounds.bounds == null - ? CameraTargetBounds(sydneyBounds) - : CameraTargetBounds.unbounded; + _cameraTargetBounds = + _cameraTargetBounds.bounds == null + ? CameraTargetBounds(sydneyBounds) + : CameraTargetBounds.unbounded; }); }, ); @@ -113,14 +114,15 @@ class MapUiBodyState extends State { Widget _zoomBoundsToggler() { return TextButton( - child: Text(_minMaxZoomPreference.minZoom == null - ? 'bound zoom' - : 'release zoom'), + child: Text( + _minMaxZoomPreference.minZoom == null ? 'bound zoom' : 'release zoom', + ), onPressed: () { setState(() { - _minMaxZoomPreference = _minMaxZoomPreference.minZoom == null - ? const MinMaxZoomPreference(12.0, 16.0) - : MinMaxZoomPreference.unbounded; + _minMaxZoomPreference = + _minMaxZoomPreference.minZoom == null + ? const MinMaxZoomPreference(12.0, 16.0) + : MinMaxZoomPreference.unbounded; }); }, ); @@ -185,8 +187,9 @@ class MapUiBodyState extends State { Widget _zoomControlsToggler() { return TextButton( - child: - Text('${_zoomControlsEnabled ? 'disable' : 'enable'} zoom controls'), + child: Text( + '${_zoomControlsEnabled ? 'disable' : 'enable'} zoom controls', + ), onPressed: () { setState(() { _zoomControlsEnabled = !_zoomControlsEnabled; @@ -209,7 +212,8 @@ class MapUiBodyState extends State { Widget _myLocationToggler() { return TextButton( child: Text( - '${_myLocationEnabled ? 'disable' : 'enable'} my location marker'), + '${_myLocationEnabled ? 'disable' : 'enable'} my location marker', + ), onPressed: () { setState(() { _myLocationEnabled = !_myLocationEnabled; @@ -221,7 +225,8 @@ class MapUiBodyState extends State { Widget _myLocationButtonToggler() { return TextButton( child: Text( - '${_myLocationButtonEnabled ? 'disable' : 'enable'} my location button'), + '${_myLocationButtonEnabled ? 'disable' : 'enable'} my location button', + ), onPressed: () { setState(() { _myLocationButtonEnabled = !_myLocationButtonEnabled; @@ -288,11 +293,7 @@ class MapUiBodyState extends State { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), ]; @@ -304,8 +305,9 @@ class MapUiBodyState extends State { children: [ Text('camera bearing: ${_position.bearing}'), Text( - 'camera target: ${_position.target.latitude.toStringAsFixed(4)},' - '${_position.target.longitude.toStringAsFixed(4)}'), + 'camera target: ${_position.target.latitude.toStringAsFixed(4)},' + '${_position.target.longitude.toStringAsFixed(4)}', + ), Text('camera zoom: ${_position.zoom}'), Text('camera tilt: ${_position.tilt}'), Text(_isMoving ? '(Camera moving)' : '(Camera idle)'), diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/marker_icons.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/marker_icons.dart index d2010b65b13..8de81b04cdc 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/marker_icons.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/marker_icons.dart @@ -16,7 +16,7 @@ import 'page.dart'; class MarkerIconsPage extends GoogleMapExampleAppPage { const MarkerIconsPage({Key? key}) - : super(const Icon(Icons.image), 'Marker icons', key: key); + : super(const Icon(Icons.image), 'Marker icons', key: key); @override Widget build(BuildContext context) { @@ -33,13 +33,7 @@ class MarkerIconsBody extends StatefulWidget { const LatLng _kMapCenter = LatLng(52.4478, -3.5402); -enum _MarkerSizeOption { - original, - width30, - height40, - size30x60, - size120x60, -} +enum _MarkerSizeOption { original, width30, height40, size30x60, size120x60 } class MarkerIconsBodyState extends State { final Size _markerAssetImageSize = const Size(48, 48); @@ -62,75 +56,82 @@ class MarkerIconsBodyState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Column(children: [ - Center( - child: SizedBox( - width: 350.0, - height: 300.0, - child: GoogleMap( - initialCameraPosition: const CameraPosition( - target: _kMapCenter, - zoom: 7.0, + Column( + children: [ + Center( + child: SizedBox( + width: 350.0, + height: 300.0, + child: GoogleMap( + initialCameraPosition: const CameraPosition( + target: _kMapCenter, + zoom: 7.0, + ), + markers: _markers, + onMapCreated: _onMapCreated, ), - markers: _markers, - onMapCreated: _onMapCreated, ), ), - ), - TextButton( - onPressed: () => _toggleScaling(context), - child: Text(_scalingEnabled - ? 'Disable auto scaling' - : 'Enable auto scaling'), - ), - if (_scalingEnabled) ...[ - Container( - width: referenceSize.width, - height: referenceSize.height, - decoration: BoxDecoration( - border: Border.all(), + TextButton( + onPressed: () => _toggleScaling(context), + child: Text( + _scalingEnabled + ? 'Disable auto scaling' + : 'Enable auto scaling', ), ), - Text( - 'Reference box with size of ${referenceSize.width} x ${referenceSize.height} in logical pixels.'), - const SizedBox(height: 10), - Image.asset( - 'assets/red_square.png', - scale: _mipMapsEnabled ? null : 1.0, - ), - const Text('Asset image rendered with flutter'), - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text('Marker size:'), - const SizedBox(width: 10), - DropdownButton<_MarkerSizeOption>( - value: _currentSizeOption, - onChanged: (_MarkerSizeOption? newValue) { - if (newValue != null) { - setState(() { - _currentSizeOption = newValue; - _updateMarkerImages(context); - }); - } - }, - items: - _MarkerSizeOption.values.map((_MarkerSizeOption option) { - return DropdownMenuItem<_MarkerSizeOption>( - value: option, - child: Text(_getMarkerSizeOptionName(option)), - ); - }).toList(), - ) - ], + if (_scalingEnabled) ...[ + Container( + width: referenceSize.width, + height: referenceSize.height, + decoration: BoxDecoration(border: Border.all()), + ), + Text( + 'Reference box with size of ${referenceSize.width} x ${referenceSize.height} in logical pixels.', + ), + const SizedBox(height: 10), + Image.asset( + 'assets/red_square.png', + scale: _mipMapsEnabled ? null : 1.0, + ), + const Text('Asset image rendered with flutter'), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Marker size:'), + const SizedBox(width: 10), + DropdownButton<_MarkerSizeOption>( + value: _currentSizeOption, + onChanged: (_MarkerSizeOption? newValue) { + if (newValue != null) { + setState(() { + _currentSizeOption = newValue; + _updateMarkerImages(context); + }); + } + }, + items: + _MarkerSizeOption.values.map(( + _MarkerSizeOption option, + ) { + return DropdownMenuItem<_MarkerSizeOption>( + value: option, + child: Text(_getMarkerSizeOptionName(option)), + ); + }).toList(), + ), + ], + ), + ], + TextButton( + onPressed: () => _toggleMipMaps(context), + child: Text( + _mipMapsEnabled ? 'Disable mipmaps' : 'Enable mipmaps', + ), ), ], - TextButton( - onPressed: () => _toggleMipMaps(context), - child: Text(_mipMapsEnabled ? 'Disable mipmaps' : 'Enable mipmaps'), - ), - ]) + ), ], ); } @@ -178,12 +179,15 @@ class MarkerIconsBodyState extends State { if (width != null && height != null) { return Size(width, height); } else if (width != null) { - return Size(width, - width * _markerAssetImageSize.height / _markerAssetImageSize.width); + return Size( + width, + width * _markerAssetImageSize.height / _markerAssetImageSize.width, + ); } else if (height != null) { return Size( - height * _markerAssetImageSize.width / _markerAssetImageSize.height, - height); + height * _markerAssetImageSize.width / _markerAssetImageSize.height, + height, + ); } else { return _markerAssetImageSize; } @@ -206,8 +210,10 @@ class MarkerIconsBodyState extends State { } Marker _createAssetMarker(int index) { - final LatLng position = - LatLng(_kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude - 1); + final LatLng position = LatLng( + _kMapCenter.latitude - (index * 0.5), + _kMapCenter.longitude - 1, + ); return Marker( markerId: MarkerId('marker_asset_$index'), @@ -217,8 +223,10 @@ class MarkerIconsBodyState extends State { } Marker _createBytesMarker(int index) { - final LatLng position = - LatLng(_kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude + 1); + final LatLng position = LatLng( + _kMapCenter.latitude - (index * 0.5), + _kMapCenter.longitude + 1, + ); return Marker( markerId: MarkerId('marker_bytes_$index'), @@ -252,9 +260,7 @@ class MarkerIconsBodyState extends State { AssetMapBitmap assetMapBitmap; if (_mipMapsEnabled) { final ImageConfiguration imageConfiguration = - createLocalImageConfiguration( - context, - ); + createLocalImageConfiguration(context); assetMapBitmap = await AssetMapBitmap.create( imageConfiguration, @@ -281,16 +287,18 @@ class MarkerIconsBodyState extends State { } Future _updateMarkerBytesImage(BuildContext context) async { - final double? devicePixelRatio = - MediaQuery.maybeDevicePixelRatioOf(context); + final double? devicePixelRatio = MediaQuery.maybeDevicePixelRatioOf( + context, + ); final Size bitmapLogicalSize = _getMarkerReferenceSize(); final double? imagePixelRatio = _scalingEnabled ? devicePixelRatio : null; // Create canvasSize with physical marker size final Size canvasSize = Size( - bitmapLogicalSize.width * (imagePixelRatio ?? 1.0), - bitmapLogicalSize.height * (imagePixelRatio ?? 1.0)); + bitmapLogicalSize.width * (imagePixelRatio ?? 1.0), + bitmapLogicalSize.height * (imagePixelRatio ?? 1.0), + ); final ByteData bytes = await createCustomMarkerIconImage(size: canvasSize); @@ -300,12 +308,14 @@ class MarkerIconsBodyState extends State { ? _getCurrentMarkerSize() : (null, null); - final BytesMapBitmap bitmap = BytesMapBitmap(bytes.buffer.asUint8List(), - imagePixelRatio: imagePixelRatio, - width: width, - height: height, - bitmapScaling: - _scalingEnabled ? MapBitmapScaling.auto : MapBitmapScaling.none); + final BytesMapBitmap bitmap = BytesMapBitmap( + bytes.buffer.asUint8List(), + imagePixelRatio: imagePixelRatio, + width: width, + height: height, + bitmapScaling: + _scalingEnabled ? MapBitmapScaling.auto : MapBitmapScaling.none, + ); _updateBytesBitmap(bitmap); } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/move_camera.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/move_camera.dart index 4314522f647..460dc00ee6b 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/move_camera.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/move_camera.dart @@ -11,7 +11,7 @@ import 'page.dart'; class MoveCameraPage extends GoogleMapExampleAppPage { const MoveCameraPage({Key? key}) - : super(const Icon(Icons.map), 'Camera control', key: key); + : super(const Icon(Icons.map), 'Camera control', key: key); @override Widget build(BuildContext context) { @@ -45,8 +45,9 @@ class MoveCameraState extends State { height: 200.0, child: GoogleMap( onMapCreated: _onMapCreated, - initialCameraPosition: - const CameraPosition(target: LatLng(0.0, 0.0)), + initialCameraPosition: const CameraPosition( + target: LatLng(0.0, 0.0), + ), ), ), ), @@ -120,50 +121,39 @@ class MoveCameraState extends State { TextButton( onPressed: () { mapController?.moveCamera( - CameraUpdate.zoomBy( - -0.5, - const Offset(30.0, 20.0), - ), + CameraUpdate.zoomBy(-0.5, const Offset(30.0, 20.0)), ); }, child: const Text('zoomBy with focus'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomBy(-0.5), - ); + mapController?.moveCamera(CameraUpdate.zoomBy(-0.5)); }, child: const Text('zoomBy'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomIn(), - ); + mapController?.moveCamera(CameraUpdate.zoomIn()); }, child: const Text('zoomIn'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomOut(), - ); + mapController?.moveCamera(CameraUpdate.zoomOut()); }, child: const Text('zoomOut'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomTo(16.0), - ); + mapController?.moveCamera(CameraUpdate.zoomTo(16.0)); }, child: const Text('zoomTo'), ), ], ), ], - ) + ), ], ); } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/padding.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/padding.dart index a3103c5ee91..0ae39ec2453 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/padding.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/padding.dart @@ -10,7 +10,7 @@ import 'page.dart'; class PaddingPage extends GoogleMapExampleAppPage { const PaddingPage({Key? key}) - : super(const Icon(Icons.map), 'Add padding to the map', key: key); + : super(const Icon(Icons.map), 'Add padding to the map', key: key); @override Widget build(BuildContext context) { @@ -47,11 +47,7 @@ class MarkerIconsBodyState extends State { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), const Padding( @@ -95,9 +91,7 @@ class MarkerIconsBodyState extends State { controller: _topController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Top', - ), + decoration: const InputDecoration(hintText: 'Top'), ), ), const Spacer(), @@ -107,9 +101,7 @@ class MarkerIconsBodyState extends State { controller: _bottomController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Bottom', - ), + decoration: const InputDecoration(hintText: 'Bottom'), ), ), const Spacer(), @@ -119,9 +111,7 @@ class MarkerIconsBodyState extends State { controller: _leftController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Left', - ), + decoration: const InputDecoration(hintText: 'Left'), ), ), const Spacer(), @@ -131,9 +121,7 @@ class MarkerIconsBodyState extends State { controller: _rightController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Right', - ), + decoration: const InputDecoration(hintText: 'Right'), ), ), ], @@ -152,10 +140,11 @@ class MarkerIconsBodyState extends State { onPressed: () { setState(() { _padding = EdgeInsets.fromLTRB( - double.tryParse(_leftController.value.text) ?? 0, - double.tryParse(_topController.value.text) ?? 0, - double.tryParse(_rightController.value.text) ?? 0, - double.tryParse(_bottomController.value.text) ?? 0); + double.tryParse(_leftController.value.text) ?? 0, + double.tryParse(_topController.value.text) ?? 0, + double.tryParse(_rightController.value.text) ?? 0, + double.tryParse(_bottomController.value.text) ?? 0, + ); }); }, ), @@ -170,7 +159,7 @@ class MarkerIconsBodyState extends State { _padding = EdgeInsets.zero; }); }, - ) + ), ], ), ); diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_circle.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_circle.dart index 7e3c1177166..314df03f661 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_circle.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_circle.dart @@ -11,7 +11,7 @@ import 'page.dart'; class PlaceCirclePage extends GoogleMapExampleAppPage { const PlaceCirclePage({Key? key}) - : super(const Icon(Icons.linear_scale), 'Place circle', key: key); + : super(const Icon(Icons.linear_scale), 'Place circle', key: key); @override Widget build(BuildContext context) { @@ -107,9 +107,7 @@ class PlaceCircleBodyState extends State { void _toggleVisible(CircleId circleId) { final Circle circle = circles[circleId]!; setState(() { - circles[circleId] = circle.copyWith( - visibleParam: !circle.visible, - ); + circles[circleId] = circle.copyWith(visibleParam: !circle.visible); }); } @@ -170,20 +168,19 @@ class PlaceCircleBodyState extends State { children: [ Column( children: [ + TextButton(onPressed: _add, child: const Text('add')), TextButton( - onPressed: _add, - child: const Text('add'), - ), - TextButton( - onPressed: (selectedId == null) - ? null - : () => _remove(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _remove(selectedId), child: const Text('remove'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleVisible(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleVisible(selectedId), child: const Text('toggle visible'), ), ], @@ -191,27 +188,30 @@ class PlaceCircleBodyState extends State { Column( children: [ TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeStrokeWidth(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeStrokeWidth(selectedId), child: const Text('change stroke width'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeStrokeColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeStrokeColor(selectedId), child: const Text('change stroke color'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeFillColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeFillColor(selectedId), child: const Text('change fill color'), ), ], - ) + ), ], - ) + ), ], ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_marker.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_marker.dart index 4871c742b27..0fc30c98c19 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_marker.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_marker.dart @@ -16,7 +16,7 @@ import 'page.dart'; class PlaceMarkerPage extends GoogleMapExampleAppPage { const PlaceMarkerPage({Key? key}) - : super(const Icon(Icons.place), 'Place marker', key: key); + : super(const Icon(Icons.place), 'Place marker', key: key); @override Widget build(BuildContext context) { @@ -59,8 +59,9 @@ class PlaceMarkerBodyState extends State { setState(() { final MarkerId? previousMarkerId = selectedMarker; if (previousMarkerId != null && markers.containsKey(previousMarkerId)) { - final Marker resetOld = markers[previousMarkerId]! - .copyWith(iconParam: BitmapDescriptor.defaultMarker); + final Marker resetOld = markers[previousMarkerId]!.copyWith( + iconParam: BitmapDescriptor.defaultMarker, + ); markers[previousMarkerId] = resetOld; } selectedMarker = markerId; @@ -89,25 +90,28 @@ class PlaceMarkerBodyState extends State { markerPosition = null; }); await showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - actions: [ - TextButton( - child: const Text('OK'), - onPressed: () => Navigator.of(context).pop(), - ) + context: context, + builder: (BuildContext context) { + return AlertDialog( + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () => Navigator.of(context).pop(), + ), + ], + content: Padding( + padding: const EdgeInsets.symmetric(vertical: 66), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text('Old position: ${tappedMarker.position}'), + Text('New position: $newPosition'), ], - content: Padding( - padding: const EdgeInsets.symmetric(vertical: 66), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text('Old position: ${tappedMarker.position}'), - Text('New position: $newPosition'), - ], - ))); - }); + ), + ), + ); + }, + ); } } @@ -169,9 +173,7 @@ class PlaceMarkerBodyState extends State { final Offset currentAnchor = marker.anchor; final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { - markers[markerId] = marker.copyWith( - anchorParam: newAnchor, - ); + markers[markerId] = marker.copyWith(anchorParam: newAnchor); }); } @@ -181,9 +183,7 @@ class PlaceMarkerBodyState extends State { final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { markers[markerId] = marker.copyWith( - infoWindowParam: marker.infoWindow.copyWith( - anchorParam: newAnchor, - ), + infoWindowParam: marker.infoWindow.copyWith(anchorParam: newAnchor), ); }); } @@ -191,18 +191,14 @@ class PlaceMarkerBodyState extends State { Future _toggleDraggable(MarkerId markerId) async { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - draggableParam: !marker.draggable, - ); + markers[markerId] = marker.copyWith(draggableParam: !marker.draggable); }); } Future _toggleFlat(MarkerId markerId) async { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - flatParam: !marker.flat, - ); + markers[markerId] = marker.copyWith(flatParam: !marker.flat); }); } @@ -211,9 +207,7 @@ class PlaceMarkerBodyState extends State { final String newSnippet = '${marker.infoWindow.snippet!}*'; setState(() { markers[markerId] = marker.copyWith( - infoWindowParam: marker.infoWindow.copyWith( - snippetParam: newSnippet, - ), + infoWindowParam: marker.infoWindow.copyWith(snippetParam: newSnippet), ); }); } @@ -241,9 +235,7 @@ class PlaceMarkerBodyState extends State { Future _toggleVisible(MarkerId markerId) async { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - visibleParam: !marker.visible, - ); + markers[markerId] = marker.copyWith(visibleParam: !marker.visible); }); } @@ -260,9 +252,7 @@ class PlaceMarkerBodyState extends State { void _setMarkerIcon(MarkerId markerId, BitmapDescriptor assetIcon) { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - iconParam: assetIcon, - ); + markers[markerId] = marker.copyWith(iconParam: assetIcon); }); } @@ -275,130 +265,141 @@ class PlaceMarkerBodyState extends State { @override Widget build(BuildContext context) { final MarkerId? selectedId = selectedMarker; - return Stack(children: [ - Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - child: GoogleMap( - onMapCreated: _onMapCreated, - initialCameraPosition: const CameraPosition( - target: LatLng(-33.852, 151.211), - zoom: 11.0, + return Stack( + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: GoogleMap( + onMapCreated: _onMapCreated, + initialCameraPosition: const CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, + ), + markers: Set.of(markers.values), ), - markers: Set.of(markers.values), ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - onPressed: _add, - child: const Text('Add'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _remove(selectedId), - child: const Text('Remove'), - ), - ], - ), - Wrap( - alignment: WrapAlignment.spaceEvenly, - children: [ - TextButton( - onPressed: - selectedId == null ? null : () => _changeInfo(selectedId), - child: const Text('change info'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _changeInfoAnchor(selectedId), - child: const Text('change info anchor'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _changeAlpha(selectedId), - child: const Text('change alpha'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _changeAnchor(selectedId), - child: const Text('change anchor'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _toggleDraggable(selectedId), - child: const Text('toggle draggable'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _toggleFlat(selectedId), - child: const Text('toggle flat'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _changePosition(selectedId), - child: const Text('change position'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _changeRotation(selectedId), - child: const Text('change rotation'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _toggleVisible(selectedId), - child: const Text('toggle visible'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _changeZIndex(selectedId), - child: const Text('change zIndex'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () { - _getMarkerIcon(context).then( - (BitmapDescriptor icon) { - _setMarkerIcon(selectedId, icon); + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + TextButton(onPressed: _add, child: const Text('Add')), + TextButton( + onPressed: + selectedId == null ? null : () => _remove(selectedId), + child: const Text('Remove'), + ), + ], + ), + Wrap( + alignment: WrapAlignment.spaceEvenly, + children: [ + TextButton( + onPressed: + selectedId == null ? null : () => _changeInfo(selectedId), + child: const Text('change info'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeInfoAnchor(selectedId), + child: const Text('change info anchor'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeAlpha(selectedId), + child: const Text('change alpha'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeAnchor(selectedId), + child: const Text('change anchor'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _toggleDraggable(selectedId), + child: const Text('toggle draggable'), + ), + TextButton( + onPressed: + selectedId == null ? null : () => _toggleFlat(selectedId), + child: const Text('toggle flat'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changePosition(selectedId), + child: const Text('change position'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeRotation(selectedId), + child: const Text('change rotation'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _toggleVisible(selectedId), + child: const Text('toggle visible'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeZIndex(selectedId), + child: const Text('change zIndex'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () { + _getMarkerIcon(context).then(( + BitmapDescriptor icon, + ) { + _setMarkerIcon(selectedId, icon); + }); }, - ); - }, - child: const Text('set marker icon'), - ), - ], - ), - ], - ), - Visibility( - visible: markerPosition != null, - child: Container( - color: Colors.white70, - height: 30, - padding: const EdgeInsets.only(left: 12, right: 12), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - if (markerPosition == null) - Container() - else - Expanded(child: Text('lat: ${markerPosition!.latitude}')), - if (markerPosition == null) - Container() - else - Expanded(child: Text('lng: ${markerPosition!.longitude}')), - ], + child: const Text('set marker icon'), + ), + ], + ), + ], + ), + Visibility( + visible: markerPosition != null, + child: Container( + color: Colors.white70, + height: 30, + padding: const EdgeInsets.only(left: 12, right: 12), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + if (markerPosition == null) + Container() + else + Expanded(child: Text('lat: ${markerPosition!.latitude}')), + if (markerPosition == null) + Container() + else + Expanded(child: Text('lng: ${markerPosition!.longitude}')), + ], + ), ), ), - ), - ]); + ], + ); } } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polygon.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polygon.dart index 11b3ed6e0bb..61d25b27f09 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polygon.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polygon.dart @@ -11,7 +11,7 @@ import 'page.dart'; class PlacePolygonPage extends GoogleMapExampleAppPage { const PlacePolygonPage({Key? key}) - : super(const Icon(Icons.linear_scale), 'Place polygon', key: key); + : super(const Icon(Icons.linear_scale), 'Place polygon', key: key); @override Widget build(BuildContext context) { @@ -107,18 +107,14 @@ class PlacePolygonBodyState extends State { void _toggleGeodesic(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = polygon.copyWith( - geodesicParam: !polygon.geodesic, - ); + polygons[polygonId] = polygon.copyWith(geodesicParam: !polygon.geodesic); }); } void _toggleVisible(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = polygon.copyWith( - visibleParam: !polygon.visible, - ); + polygons[polygonId] = polygon.copyWith(visibleParam: !polygon.visible); }); } @@ -152,17 +148,16 @@ class PlacePolygonBodyState extends State { void _addHoles(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = - polygon.copyWith(holesParam: _createHoles(polygonId)); + polygons[polygonId] = polygon.copyWith( + holesParam: _createHoles(polygonId), + ); }); } void _removeHoles(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = polygon.copyWith( - holesParam: >[], - ); + polygons[polygonId] = polygon.copyWith(holesParam: >[]); }); } @@ -196,26 +191,26 @@ class PlacePolygonBodyState extends State { children: [ Column( children: [ + TextButton(onPressed: _add, child: const Text('add')), TextButton( - onPressed: _add, - child: const Text('add'), - ), - TextButton( - onPressed: (selectedId == null) - ? null - : () => _remove(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _remove(selectedId), child: const Text('remove'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleVisible(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleVisible(selectedId), child: const Text('toggle visible'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleGeodesic(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleGeodesic(selectedId), child: const Text('toggle geodesic'), ), ], @@ -223,43 +218,48 @@ class PlacePolygonBodyState extends State { Column( children: [ TextButton( - onPressed: (selectedId == null) - ? null - : (polygons[selectedId]!.holes.isNotEmpty + onPressed: + (selectedId == null) ? null - : () => _addHoles(selectedId)), + : (polygons[selectedId]!.holes.isNotEmpty + ? null + : () => _addHoles(selectedId)), child: const Text('add holes'), ), TextButton( - onPressed: (selectedId == null) - ? null - : (polygons[selectedId]!.holes.isEmpty + onPressed: + (selectedId == null) ? null - : () => _removeHoles(selectedId)), + : (polygons[selectedId]!.holes.isEmpty + ? null + : () => _removeHoles(selectedId)), child: const Text('remove holes'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeWidth(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeWidth(selectedId), child: const Text('change stroke width'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeStrokeColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeStrokeColor(selectedId), child: const Text('change stroke color'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeFillColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeFillColor(selectedId), child: const Text('change fill color'), ), ], - ) + ), ], - ) + ), ], ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart index 7cb07ae37db..a7e2b335383 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/place_polyline.dart @@ -12,7 +12,7 @@ import 'page.dart'; class PlacePolylinePage extends GoogleMapExampleAppPage { const PlacePolylinePage({Key? key}) - : super(const Icon(Icons.linear_scale), 'Place polyline', key: key); + : super(const Icon(Icons.linear_scale), 'Place polyline', key: key); @override Widget build(BuildContext context) { @@ -52,7 +52,7 @@ class PlacePolylineBodyState extends State { List jointTypes = [ JointType.mitered, JointType.bevel, - JointType.round + JointType.round, ]; // Values when toggling polyline end cap type @@ -71,7 +71,7 @@ class PlacePolylineBodyState extends State { PatternItem.dash(30.0), PatternItem.gap(20.0), PatternItem.dot, - PatternItem.gap(20.0) + PatternItem.gap(20.0), ], [PatternItem.dash(30.0), PatternItem.gap(20.0)], [PatternItem.dot, PatternItem.gap(10.0)], @@ -234,26 +234,26 @@ class PlacePolylineBodyState extends State { children: [ Column( children: [ + TextButton(onPressed: _add, child: const Text('add')), TextButton( - onPressed: _add, - child: const Text('add'), - ), - TextButton( - onPressed: (selectedId == null) - ? null - : () => _remove(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _remove(selectedId), child: const Text('remove'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleVisible(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleVisible(selectedId), child: const Text('toggle visible'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleGeodesic(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleGeodesic(selectedId), child: const Text('toggle geodesic'), ), ], @@ -261,45 +261,51 @@ class PlacePolylineBodyState extends State { Column( children: [ TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeWidth(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeWidth(selectedId), child: const Text('change width'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeColor(selectedId), child: const Text('change color'), ), TextButton( - onPressed: isIOS || (selectedId == null) - ? null - : () => _changeStartCap(selectedId), + onPressed: + isIOS || (selectedId == null) + ? null + : () => _changeStartCap(selectedId), child: const Text('change start cap [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) - ? null - : () => _changeEndCap(selectedId), + onPressed: + isIOS || (selectedId == null) + ? null + : () => _changeEndCap(selectedId), child: const Text('change end cap [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) - ? null - : () => _changeJointType(selectedId), + onPressed: + isIOS || (selectedId == null) + ? null + : () => _changeJointType(selectedId), child: const Text('change joint type [Android only]'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changePattern(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changePattern(selectedId), child: const Text('change pattern'), ), ], - ) + ), ], - ) + ), ], ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart index 672a3718776..dd77919147c 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/readme_sample.dart @@ -41,10 +41,11 @@ class MapSampleState extends State { ); static const CameraPosition _kLake = CameraPosition( - bearing: 192.8334901395799, - target: LatLng(37.43296265331129, -122.08832357078792), - tilt: 59.440717697143555, - zoom: 19.151926040649414); + bearing: 192.8334901395799, + target: LatLng(37.43296265331129, -122.08832357078792), + tilt: 59.440717697143555, + zoom: 19.151926040649414, + ); @override Widget build(BuildContext context) { @@ -69,4 +70,5 @@ class MapSampleState extends State { await controller.animateCamera(CameraUpdate.newCameraPosition(_kLake)); } } + // #enddocregion MapSample diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/scrolling_map.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/scrolling_map.dart index 9ec6a02f425..456f960abed 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/scrolling_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/scrolling_map.dart @@ -15,7 +15,7 @@ const LatLng _center = LatLng(32.080664, 34.9563837); class ScrollingMapPage extends GoogleMapExampleAppPage { const ScrollingMapPage({Key? key}) - : super(const Icon(Icons.map), 'Scrolling map', key: key); + : super(const Icon(Icons.map), 'Scrolling map', key: key); @override Widget build(BuildContext context) { @@ -69,8 +69,9 @@ class ScrollingMapBody extends StatelessWidget { const Text("This map doesn't consume the vertical drags."), const Padding( padding: EdgeInsets.only(bottom: 12.0), - child: - Text('It still gets other gestures (e.g scale or tap).'), + child: Text( + 'It still gets other gestures (e.g scale or tap).', + ), ), Center( child: SizedBox( @@ -84,22 +85,19 @@ class ScrollingMapBody extends StatelessWidget { markers: { Marker( markerId: const MarkerId('test_marker_id'), - position: LatLng( - _center.latitude, - _center.longitude, - ), + position: LatLng(_center.latitude, _center.longitude), infoWindow: const InfoWindow( title: 'An interesting location', snippet: '*', ), ), }, - gestureRecognizers: >{ - Factory( - () => ScaleGestureRecognizer(), - ), - }, + gestureRecognizers: + >{ + Factory( + () => ScaleGestureRecognizer(), + ), + }, ), ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/snapshot.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/snapshot.dart index fbc7ae2a3e2..2281ccaf2dc 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/snapshot.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/snapshot.dart @@ -11,13 +11,18 @@ import 'package:google_maps_flutter/google_maps_flutter.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class SnapshotPage extends GoogleMapExampleAppPage { const SnapshotPage({Key? key}) - : super(const Icon(Icons.camera_alt), 'Take a snapshot of the map', - key: key); + : super( + const Icon(Icons.camera_alt), + 'Take a snapshot of the map', + key: key, + ); @override Widget build(BuildContext context) { diff --git a/packages/google_maps_flutter/google_maps_flutter/example/lib/tile_overlay.dart b/packages/google_maps_flutter/google_maps_flutter/example/lib/tile_overlay.dart index 21ae075d357..c3ce4e4e0ef 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/lib/tile_overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter/example/lib/tile_overlay.dart @@ -14,7 +14,7 @@ import 'page.dart'; class TileOverlayPage extends GoogleMapExampleAppPage { const TileOverlayPage({Key? key}) - : super(const Icon(Icons.map), 'Tile overlay', key: key); + : super(const Icon(Icons.map), 'Tile overlay', key: key); @override Widget build(BuildContext context) { @@ -119,34 +119,29 @@ class _DebugTileProvider implements TileProvider { static const int width = 100; static const int height = 100; static final Paint boxPaint = Paint(); - static const TextStyle textStyle = TextStyle( - color: Colors.red, - fontSize: 20, - ); + static const TextStyle textStyle = TextStyle(color: Colors.red, fontSize: 20); @override Future getTile(int x, int y, int? zoom) async { final ui.PictureRecorder recorder = ui.PictureRecorder(); final Canvas canvas = Canvas(recorder); - final TextSpan textSpan = TextSpan( - text: '$x,$y', - style: textStyle, - ); + final TextSpan textSpan = TextSpan(text: '$x,$y', style: textStyle); final TextPainter textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); - textPainter.layout( - maxWidth: width.toDouble(), - ); + textPainter.layout(maxWidth: width.toDouble()); textPainter.paint(canvas, Offset.zero); canvas.drawRect( - Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), boxPaint); + Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), + boxPaint, + ); final ui.Picture picture = recorder.endRecording(); final Uint8List byteData = await picture .toImage(width, height) - .then((ui.Image image) => - image.toByteData(format: ui.ImageByteFormat.png)) + .then( + (ui.Image image) => image.toByteData(format: ui.ImageByteFormat.png), + ) .then((ByteData? byteData) => byteData!.buffer.asUint8List()); return Tile(width, height, byteData); } diff --git a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml index 7e16cbbc00f..7a6c28c7258 100644 --- a/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the google_maps_flutter plugin. publish_to: none environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" dependencies: cupertino_icons: ^1.0.5 diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/controller.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/controller.dart index 50b0641f68a..1248e5d5b9e 100644 --- a/packages/google_maps_flutter/google_maps_flutter/lib/src/controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/controller.dart @@ -8,10 +8,7 @@ part of '../google_maps_flutter.dart'; /// Controller for a single GoogleMap instance running on the host platform. class GoogleMapController { - GoogleMapController._( - this._googleMapState, { - required this.mapId, - }) { + GoogleMapController._(this._googleMapState, {required this.mapId}) { _connectStreams(mapId); } @@ -36,10 +33,7 @@ class GoogleMapController { _GoogleMapState googleMapState, ) async { await GoogleMapsFlutterPlatform.instance.init(id); - return GoogleMapController._( - googleMapState, - mapId: id, - ); + return GoogleMapController._(googleMapState, mapId: id); } final _GoogleMapState _googleMapState; @@ -54,7 +48,9 @@ class GoogleMapController { } if (_googleMapState.widget.onCameraMove != null) { _streamSubscriptions.add( - GoogleMapsFlutterPlatform.instance.onCameraMove(mapId: mapId).listen( + GoogleMapsFlutterPlatform.instance + .onCameraMove(mapId: mapId) + .listen( (CameraMoveEvent e) => _googleMapState.widget.onCameraMove!(e.value), ), @@ -73,37 +69,47 @@ class GoogleMapController { .listen((MarkerTapEvent e) => _googleMapState.onMarkerTap(e.value)), ); _streamSubscriptions.add( - GoogleMapsFlutterPlatform.instance.onMarkerDragStart(mapId: mapId).listen( + GoogleMapsFlutterPlatform.instance + .onMarkerDragStart(mapId: mapId) + .listen( (MarkerDragStartEvent e) => _googleMapState.onMarkerDragStart(e.value, e.position), ), ); _streamSubscriptions.add( - GoogleMapsFlutterPlatform.instance.onMarkerDrag(mapId: mapId).listen( + GoogleMapsFlutterPlatform.instance + .onMarkerDrag(mapId: mapId) + .listen( (MarkerDragEvent e) => _googleMapState.onMarkerDrag(e.value, e.position), ), ); _streamSubscriptions.add( - GoogleMapsFlutterPlatform.instance.onMarkerDragEnd(mapId: mapId).listen( + GoogleMapsFlutterPlatform.instance + .onMarkerDragEnd(mapId: mapId) + .listen( (MarkerDragEndEvent e) => _googleMapState.onMarkerDragEnd(e.value, e.position), ), ); _streamSubscriptions.add( - GoogleMapsFlutterPlatform.instance.onInfoWindowTap(mapId: mapId).listen( + GoogleMapsFlutterPlatform.instance + .onInfoWindowTap(mapId: mapId) + .listen( (InfoWindowTapEvent e) => _googleMapState.onInfoWindowTap(e.value), ), ); _streamSubscriptions.add( - GoogleMapsFlutterPlatform.instance.onPolylineTap(mapId: mapId).listen( + GoogleMapsFlutterPlatform.instance + .onPolylineTap(mapId: mapId) + .listen( (PolylineTapEvent e) => _googleMapState.onPolylineTap(e.value), ), ); _streamSubscriptions.add( - GoogleMapsFlutterPlatform.instance.onPolygonTap(mapId: mapId).listen( - (PolygonTapEvent e) => _googleMapState.onPolygonTap(e.value), - ), + GoogleMapsFlutterPlatform.instance + .onPolygonTap(mapId: mapId) + .listen((PolygonTapEvent e) => _googleMapState.onPolygonTap(e.value)), ); _streamSubscriptions.add( GoogleMapsFlutterPlatform.instance @@ -116,14 +122,16 @@ class GoogleMapController { .listen((MapTapEvent e) => _googleMapState.onTap(e.position)), ); _streamSubscriptions.add( - GoogleMapsFlutterPlatform.instance.onLongPress(mapId: mapId).listen( + GoogleMapsFlutterPlatform.instance + .onLongPress(mapId: mapId) + .listen( (MapLongPressEvent e) => _googleMapState.onLongPress(e.position), ), ); _streamSubscriptions.add( - GoogleMapsFlutterPlatform.instance.onClusterTap(mapId: mapId).listen( - (ClusterTapEvent e) => _googleMapState.onClusterTap(e.value), - ), + GoogleMapsFlutterPlatform.instance + .onClusterTap(mapId: mapId) + .listen((ClusterTapEvent e) => _googleMapState.onClusterTap(e.value)), ); } @@ -134,8 +142,10 @@ class GoogleMapController { /// /// The returned [Future] completes after listeners have been notified. Future _updateMapConfiguration(MapConfiguration update) { - return GoogleMapsFlutterPlatform.instance - .updateMapConfiguration(update, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateMapConfiguration( + update, + mapId: mapId, + ); } /// Updates marker configuration. @@ -145,8 +155,10 @@ class GoogleMapController { /// /// The returned [Future] completes after listeners have been notified. Future _updateMarkers(MarkerUpdates markerUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateMarkers(markerUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateMarkers( + markerUpdates, + mapId: mapId, + ); } /// Updates cluster manager configuration. @@ -156,9 +168,12 @@ class GoogleMapController { /// /// The returned [Future] completes after listeners have been notified. Future _updateClusterManagers( - ClusterManagerUpdates clusterManagerUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateClusterManagers(clusterManagerUpdates, mapId: mapId); + ClusterManagerUpdates clusterManagerUpdates, + ) { + return GoogleMapsFlutterPlatform.instance.updateClusterManagers( + clusterManagerUpdates, + mapId: mapId, + ); } /// Updates ground overlay configuration. @@ -168,9 +183,12 @@ class GoogleMapController { /// /// The returned [Future] completes after listeners have been notified. Future _updateGroundOverlays( - GroundOverlayUpdates groundOverlayUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateGroundOverlays(groundOverlayUpdates, mapId: mapId); + GroundOverlayUpdates groundOverlayUpdates, + ) { + return GoogleMapsFlutterPlatform.instance.updateGroundOverlays( + groundOverlayUpdates, + mapId: mapId, + ); } /// Updates polygon configuration. @@ -180,8 +198,10 @@ class GoogleMapController { /// /// The returned [Future] completes after listeners have been notified. Future _updatePolygons(PolygonUpdates polygonUpdates) { - return GoogleMapsFlutterPlatform.instance - .updatePolygons(polygonUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updatePolygons( + polygonUpdates, + mapId: mapId, + ); } /// Updates polyline configuration. @@ -191,8 +211,10 @@ class GoogleMapController { /// /// The returned [Future] completes after listeners have been notified. Future _updatePolylines(PolylineUpdates polylineUpdates) { - return GoogleMapsFlutterPlatform.instance - .updatePolylines(polylineUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updatePolylines( + polylineUpdates, + mapId: mapId, + ); } /// Updates circle configuration. @@ -202,8 +224,10 @@ class GoogleMapController { /// /// The returned [Future] completes after listeners have been notified. Future _updateCircles(CircleUpdates circleUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateCircles(circleUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateCircles( + circleUpdates, + mapId: mapId, + ); } /// Updates heatmap configuration. @@ -213,8 +237,10 @@ class GoogleMapController { /// /// The returned [Future] completes after listeners have been notified. Future _updateHeatmaps(HeatmapUpdates heatmapUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateHeatmaps(heatmapUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateHeatmaps( + heatmapUpdates, + mapId: mapId, + ); } /// Updates tile overlays configuration. @@ -224,8 +250,10 @@ class GoogleMapController { /// /// The returned [Future] completes after listeners have been notified. Future _updateTileOverlays(Set newTileOverlays) { - return GoogleMapsFlutterPlatform.instance - .updateTileOverlays(newTileOverlays: newTileOverlays, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateTileOverlays( + newTileOverlays: newTileOverlays, + mapId: mapId, + ); } /// Clears the tile cache so that all tiles will be requested again from the @@ -236,8 +264,10 @@ class GoogleMapController { /// in-memory cache of tiles. If you want to cache tiles for longer, you /// should implement an on-disk cache. Future clearTileCache(TileOverlayId tileOverlayId) async { - return GoogleMapsFlutterPlatform.instance - .clearTileCache(tileOverlayId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.clearTileCache( + tileOverlayId, + mapId: mapId, + ); } /// Starts an animated change of the map camera position. @@ -249,8 +279,10 @@ class GoogleMapController { /// platform side. Future animateCamera(CameraUpdate cameraUpdate, {Duration? duration}) { return GoogleMapsFlutterPlatform.instance.animateCameraWithConfiguration( - cameraUpdate, CameraUpdateAnimationConfiguration(duration: duration), - mapId: mapId); + cameraUpdate, + CameraUpdateAnimationConfiguration(duration: duration), + mapId: mapId, + ); } /// Changes the map camera position. @@ -258,8 +290,10 @@ class GoogleMapController { /// The returned [Future] completes after the change has been made on the /// platform side. Future moveCamera(CameraUpdate cameraUpdate) { - return GoogleMapsFlutterPlatform.instance - .moveCamera(cameraUpdate, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.moveCamera( + cameraUpdate, + mapId: mapId, + ); } /// Sets the styling of the base map. @@ -277,8 +311,10 @@ class GoogleMapController { /// style reference for more information regarding the supported styles. @Deprecated('Use GoogleMap.style instead.') Future setMapStyle(String? mapStyle) { - return GoogleMapsFlutterPlatform.instance - .setMapStyle(mapStyle, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.setMapStyle( + mapStyle, + mapId: mapId, + ); } /// Returns the last style error, if any. @@ -297,8 +333,10 @@ class GoogleMapController { /// Screen location is in screen pixels (not display pixels) with respect to the top left corner /// of the map, not necessarily of the whole screen. Future getScreenCoordinate(LatLng latLng) { - return GoogleMapsFlutterPlatform.instance - .getScreenCoordinate(latLng, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.getScreenCoordinate( + latLng, + mapId: mapId, + ); } /// Returns [LatLng] corresponding to the [ScreenCoordinate] in the current map view. @@ -306,8 +344,10 @@ class GoogleMapController { /// Returned [LatLng] corresponds to a screen location. The screen location is specified in screen /// pixels (not display pixels) relative to the top left of the map, not top left of the whole screen. Future getLatLng(ScreenCoordinate screenCoordinate) { - return GoogleMapsFlutterPlatform.instance - .getLatLng(screenCoordinate, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.getLatLng( + screenCoordinate, + mapId: mapId, + ); } /// Programmatically show the Info Window for a [Marker]. @@ -319,8 +359,10 @@ class GoogleMapController { /// * [hideMarkerInfoWindow] to hide the Info Window. /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. Future showMarkerInfoWindow(MarkerId markerId) { - return GoogleMapsFlutterPlatform.instance - .showMarkerInfoWindow(markerId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.showMarkerInfoWindow( + markerId, + mapId: mapId, + ); } /// Programmatically hide the Info Window for a [Marker]. @@ -332,8 +374,10 @@ class GoogleMapController { /// * [showMarkerInfoWindow] to show the Info Window. /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. Future hideMarkerInfoWindow(MarkerId markerId) { - return GoogleMapsFlutterPlatform.instance - .hideMarkerInfoWindow(markerId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.hideMarkerInfoWindow( + markerId, + mapId: mapId, + ); } /// Returns `true` when the [InfoWindow] is showing, `false` otherwise. @@ -345,8 +389,10 @@ class GoogleMapController { /// * [showMarkerInfoWindow] to show the Info Window. /// * [hideMarkerInfoWindow] to hide the Info Window. Future isMarkerInfoWindowShown(MarkerId markerId) { - return GoogleMapsFlutterPlatform.instance - .isMarkerInfoWindowShown(markerId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.isMarkerInfoWindowShown( + markerId, + mapId: mapId, + ); } /// Returns the current zoom level of the map diff --git a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart index 76bcad6e26c..97822cc89f7 100644 --- a/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart @@ -41,10 +41,12 @@ class UnknownMapObjectIdError extends Error { /// Android specific settings for [GoogleMap]. @Deprecated( - 'See https://pub.dev/packages/google_maps_flutter_android#display-mode') + 'See https://pub.dev/packages/google_maps_flutter_android#display-mode', +) class AndroidGoogleMapsFlutter { @Deprecated( - 'See https://pub.dev/packages/google_maps_flutter_android#display-mode') + 'See https://pub.dev/packages/google_maps_flutter_android#display-mode', + ) AndroidGoogleMapsFlutter._(); /// Whether to render [GoogleMap] with a [AndroidViewSurface] to build the Google Maps widget. @@ -55,7 +57,8 @@ class AndroidGoogleMapsFlutter { /// https://docs.flutter.dev/platform-integration/android/platform-views#performance for more /// information. @Deprecated( - 'See https://pub.dev/packages/google_maps_flutter_android#display-mode') + 'See https://pub.dev/packages/google_maps_flutter_android#display-mode', + ) static bool get useAndroidViewSurface { final GoogleMapsFlutterPlatform platform = GoogleMapsFlutterPlatform.instance; @@ -73,7 +76,8 @@ class AndroidGoogleMapsFlutter { /// https://docs.flutter.dev/platform-integration/android/platform-views#performance for more /// information. @Deprecated( - 'See https://pub.dev/packages/google_maps_flutter_android#display-mode') + 'See https://pub.dev/packages/google_maps_flutter_android#display-mode', + ) static set useAndroidViewSurface(bool useAndroidViewSurface) { final GoogleMapsFlutterPlatform platform = GoogleMapsFlutterPlatform.instance; @@ -383,7 +387,8 @@ class _GoogleMapState extends State { _mapId, onPlatformViewCreated, widgetConfiguration: MapWidgetConfiguration( - textDirection: widget.layoutDirection ?? + textDirection: + widget.layoutDirection ?? Directionality.maybeOf(context) ?? TextDirection.ltr, initialCameraPosition: widget.initialCameraPosition, @@ -453,43 +458,67 @@ class _GoogleMapState extends State { Future _updateMarkers() async { final GoogleMapController controller = await _controller.future; - unawaited(controller._updateMarkers( - MarkerUpdates.from(_markers.values.toSet(), widget.markers))); + unawaited( + controller._updateMarkers( + MarkerUpdates.from(_markers.values.toSet(), widget.markers), + ), + ); _markers = keyByMarkerId(widget.markers); } Future _updateClusterManagers() async { final GoogleMapController controller = await _controller.future; - unawaited(controller._updateClusterManagers(ClusterManagerUpdates.from( - _clusterManagers.values.toSet(), widget.clusterManagers))); + unawaited( + controller._updateClusterManagers( + ClusterManagerUpdates.from( + _clusterManagers.values.toSet(), + widget.clusterManagers, + ), + ), + ); _clusterManagers = keyByClusterManagerId(widget.clusterManagers); } Future _updateGroundOverlays() async { final GoogleMapController controller = await _controller.future; - unawaited(controller._updateGroundOverlays(GroundOverlayUpdates.from( - _groundOverlays.values.toSet(), widget.groundOverlays))); + unawaited( + controller._updateGroundOverlays( + GroundOverlayUpdates.from( + _groundOverlays.values.toSet(), + widget.groundOverlays, + ), + ), + ); _groundOverlays = keyByGroundOverlayId(widget.groundOverlays); } Future _updatePolygons() async { final GoogleMapController controller = await _controller.future; - unawaited(controller._updatePolygons( - PolygonUpdates.from(_polygons.values.toSet(), widget.polygons))); + unawaited( + controller._updatePolygons( + PolygonUpdates.from(_polygons.values.toSet(), widget.polygons), + ), + ); _polygons = keyByPolygonId(widget.polygons); } Future _updatePolylines() async { final GoogleMapController controller = await _controller.future; - unawaited(controller._updatePolylines( - PolylineUpdates.from(_polylines.values.toSet(), widget.polylines))); + unawaited( + controller._updatePolylines( + PolylineUpdates.from(_polylines.values.toSet(), widget.polylines), + ), + ); _polylines = keyByPolylineId(widget.polylines); } Future _updateCircles() async { final GoogleMapController controller = await _controller.future; - unawaited(controller._updateCircles( - CircleUpdates.from(_circles.values.toSet(), widget.circles))); + unawaited( + controller._updateCircles( + CircleUpdates.from(_circles.values.toSet(), widget.circles), + ), + ); _circles = keyByCircleId(widget.circles); } @@ -640,7 +669,10 @@ class _GoogleMapState extends State { _clusterManagers[cluster.clusterManagerId]; if (clusterManager == null) { throw UnknownMapObjectIdError( - 'clusterManager', cluster.clusterManagerId, 'onClusterTap'); + 'clusterManager', + cluster.clusterManagerId, + 'onClusterTap', + ); } final ArgumentCallback? onClusterTap = clusterManager.onClusterTap; if (onClusterTap != null) { diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 550bb8996e6..f6bc801ea5c 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -5,8 +5,8 @@ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+ version: 2.12.3 environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" flutter: plugin: diff --git a/packages/google_maps_flutter/google_maps_flutter/test/camera_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/camera_test.dart index d4725709236..170dcd4e18f 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/camera_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/camera_test.dart @@ -22,38 +22,40 @@ void main() { testWidgets('Can animate camera with duration', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: GoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - onMapCreated: (GoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: GoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + onMapCreated: (GoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final GoogleMapController controller = await controllerCompleter.future; final PlatformMapStateRecorder map = platform.lastCreatedMap; expect(map.animateCameraConfiguration, isNull); - final CameraUpdate newCameraUpdate = - CameraUpdate.newLatLng(const LatLng(20.0, 25.0)); + final CameraUpdate newCameraUpdate = CameraUpdate.newLatLng( + const LatLng(20.0, 25.0), + ); const Duration updateDuration = Duration(seconds: 10); - await controller.animateCamera( - newCameraUpdate, - duration: updateDuration, - ); + await controller.animateCamera(newCameraUpdate, duration: updateDuration); expect(map.animateCameraConfiguration, isNotNull); expect(map.animateCameraConfiguration!.cameraUpdate, newCameraUpdate); - expect(map.animateCameraConfiguration!.configuration?.duration, - updateDuration); + expect( + map.animateCameraConfiguration!.configuration?.duration, + updateDuration, + ); /// Tests that the camera update respects the default behavior when the /// duration is null. - await controller.animateCamera( - newCameraUpdate, - ); + await controller.animateCamera(newCameraUpdate); expect(map.animateCameraConfiguration!.configuration?.duration, isNull); }); } diff --git a/packages/google_maps_flutter/google_maps_flutter/test/clustermanager_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/clustermanager_updates_test.dart index fee29e1fb67..282ed24db04 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/clustermanager_updates_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/clustermanager_updates_test.dart @@ -40,9 +40,13 @@ void main() { map.clusterManagerUpdates.last.clusterManagersToAdd.first; expect(initializedHeatmap, equals(cm1)); expect( - map.clusterManagerUpdates.last.clusterManagerIdsToRemove.isEmpty, true); + map.clusterManagerUpdates.last.clusterManagerIdsToRemove.isEmpty, + true, + ); expect( - map.clusterManagerUpdates.last.clusterManagersToChange.isEmpty, true); + map.clusterManagerUpdates.last.clusterManagersToChange.isEmpty, + true, + ); }); testWidgets('Adding a cluster manager', (WidgetTester tester) async { @@ -54,8 +58,9 @@ void main() { ); await tester.pumpWidget(_mapWithClusterManagers({cm1})); - await tester - .pumpWidget(_mapWithClusterManagers({cm1, cm2})); + await tester.pumpWidget( + _mapWithClusterManagers({cm1, cm2}), + ); final PlatformMapStateRecorder map = platform.lastCreatedMap; expect(map.clusterManagerUpdates.last.clusterManagersToAdd.length, 1); @@ -65,10 +70,14 @@ void main() { expect(addedClusterManager, equals(cm2)); expect( - map.clusterManagerUpdates.last.clusterManagerIdsToRemove.isEmpty, true); + map.clusterManagerUpdates.last.clusterManagerIdsToRemove.isEmpty, + true, + ); expect( - map.clusterManagerUpdates.last.clusterManagersToChange.isEmpty, true); + map.clusterManagerUpdates.last.clusterManagersToChange.isEmpty, + true, + ); }); testWidgets('Removing a cluster manager', (WidgetTester tester) async { @@ -81,11 +90,15 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; expect(map.clusterManagerUpdates.last.clusterManagerIdsToRemove.length, 1); - expect(map.clusterManagerUpdates.last.clusterManagerIdsToRemove.first, - equals(cm1.clusterManagerId)); + expect( + map.clusterManagerUpdates.last.clusterManagerIdsToRemove.first, + equals(cm1.clusterManagerId), + ); expect( - map.clusterManagerUpdates.last.clusterManagersToChange.isEmpty, true); + map.clusterManagerUpdates.last.clusterManagersToChange.isEmpty, + true, + ); expect(map.clusterManagerUpdates.last.clusterManagersToAdd.isEmpty, true); }); @@ -94,8 +107,9 @@ void main() { // properties to change, it should not trigger any updates. If new properties // are added to [ClusterManager] in the future, this test will need to be // updated accordingly to check that changes are triggered. - testWidgets('Updating a cluster manager with same data', - (WidgetTester tester) async { + testWidgets('Updating a cluster manager with same data', ( + WidgetTester tester, + ) async { const ClusterManager cm1 = ClusterManager( clusterManagerId: ClusterManagerId('cm_1'), ); @@ -111,9 +125,13 @@ void main() { // As cluster manager does not have any properties to change, // it should not populate the clusterManagersToChange set. expect( - map.clusterManagerUpdates.last.clusterManagersToChange.isEmpty, true); + map.clusterManagerUpdates.last.clusterManagersToChange.isEmpty, + true, + ); expect( - map.clusterManagerUpdates.last.clusterManagerIdsToRemove.isEmpty, true); + map.clusterManagerUpdates.last.clusterManagerIdsToRemove.isEmpty, + true, + ); expect(map.clusterManagerUpdates.last.clusterManagersToAdd.isEmpty, true); }); @@ -130,12 +148,8 @@ void main() { clusterManagerId: ClusterManagerId('cm_2'), ); final Set prev = {cm1, cm2}; - cm1 = const ClusterManager( - clusterManagerId: ClusterManagerId('cm_1'), - ); - cm2 = const ClusterManager( - clusterManagerId: ClusterManagerId('cm_2'), - ); + cm1 = const ClusterManager(clusterManagerId: ClusterManagerId('cm_1')); + cm2 = const ClusterManager(clusterManagerId: ClusterManagerId('cm_2')); final Set cur = {cm1, cm2}; await tester.pumpWidget(_mapWithClusterManagers(prev)); @@ -147,7 +161,9 @@ void main() { // it should not populate the clusterManagersToChange set. expect(map.clusterManagerUpdates.last.clusterManagersToAdd.isEmpty, true); expect( - map.clusterManagerUpdates.last.clusterManagerIdsToRemove.isEmpty, true); + map.clusterManagerUpdates.last.clusterManagerIdsToRemove.isEmpty, + true, + ); expect(map.clusterManagerUpdates.last.clusterManagersToAdd.isEmpty, true); }); @@ -167,9 +183,7 @@ void main() { clusterManagerId: ClusterManagerId('heatmap_3'), ); final Set prev = {cm1, cm2, cm3}; - cm3 = const ClusterManager( - clusterManagerId: ClusterManagerId('heatmap_3'), - ); + cm3 = const ClusterManager(clusterManagerId: ClusterManagerId('heatmap_3')); final Set cur = {cm1, cm2, cm3}; await tester.pumpWidget(_mapWithClusterManagers(prev)); @@ -180,9 +194,13 @@ void main() { // As cluster manager does not have any properties to change, // it should not populate the clusterManagersToChange set. expect( - map.clusterManagerUpdates.last.clusterManagersToChange.isEmpty, true); + map.clusterManagerUpdates.last.clusterManagersToChange.isEmpty, + true, + ); expect( - map.clusterManagerUpdates.last.clusterManagerIdsToRemove.isEmpty, true); + map.clusterManagerUpdates.last.clusterManagerIdsToRemove.isEmpty, + true, + ); expect(map.clusterManagerUpdates.last.clusterManagersToAdd.isEmpty, true); }); } diff --git a/packages/google_maps_flutter/google_maps_flutter/test/controller_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/controller_test.dart index a279848a84b..e7821ef87be 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/controller_test.dart @@ -14,8 +14,9 @@ import 'fake_google_maps_flutter_platform.dart'; void main() { TestWidgetsFlutterBinding.ensureInitialized(); - testWidgets('Subscriptions are canceled on dispose', - (WidgetTester tester) async { + testWidgets('Subscriptions are canceled on dispose', ( + WidgetTester tester, + ) async { final FakeGoogleMapsFlutterPlatform platform = FakeGoogleMapsFlutterPlatform(); @@ -28,15 +29,12 @@ void main() { onMapCreated: (GoogleMapController controller) { controllerCompleter.complete(controller); }, - initialCameraPosition: const CameraPosition( - target: LatLng(0, 0), - ), + initialCameraPosition: const CameraPosition(target: LatLng(0, 0)), ); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: googleMap, - )); + await tester.pumpWidget( + Directionality(textDirection: TextDirection.ltr, child: googleMap), + ); await tester.pump(); @@ -49,10 +47,9 @@ void main() { expect(platform.mapEventStreamController.hasListener, true); // Remove the map from the widget tree. - await tester.pumpWidget(const Directionality( - textDirection: TextDirection.ltr, - child: SizedBox(), - )); + await tester.pumpWidget( + const Directionality(textDirection: TextDirection.ltr, child: SizedBox()), + ); await tester.binding.runAsync(() async { await tester.pump(); diff --git a/packages/google_maps_flutter/google_maps_flutter/test/fake_google_maps_flutter_platform.dart b/packages/google_maps_flutter/google_maps_flutter/test/fake_google_maps_flutter_platform.dart index 3910fb5f9f3..093ef96b6d5 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/fake_google_maps_flutter_platform.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/fake_google_maps_flutter_platform.dart @@ -132,8 +132,8 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { CameraUpdate cameraUpdate, { required int mapId, }) async { - mapInstances[mapId]?.animateCameraConfiguration = - CameraUpdateWithConfiguration( + mapInstances[mapId] + ?.animateCameraConfiguration = CameraUpdateWithConfiguration( cameraUpdate: cameraUpdate, configuration: null, ); @@ -146,8 +146,8 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { CameraUpdateAnimationConfiguration configuration, { required int mapId, }) async { - mapInstances[mapId]?.animateCameraConfiguration = - CameraUpdateWithConfiguration( + mapInstances[mapId] + ?.animateCameraConfiguration = CameraUpdateWithConfiguration( cameraUpdate: cameraUpdate, configuration: configuration, ); @@ -161,17 +161,14 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { }) async {} @override - Future setMapStyle( - String? mapStyle, { - required int mapId, - }) async {} + Future setMapStyle(String? mapStyle, {required int mapId}) async {} @override - Future getVisibleRegion({ - required int mapId, - }) async { + Future getVisibleRegion({required int mapId}) async { return LatLngBounds( - southwest: const LatLng(0, 0), northeast: const LatLng(0, 0)); + southwest: const LatLng(0, 0), + northeast: const LatLng(0, 0), + ); } @override @@ -211,16 +208,12 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { } @override - Future getZoomLevel({ - required int mapId, - }) async { + Future getZoomLevel({required int mapId}) async { return 0.0; } @override - Future takeSnapshot({ - required int mapId, - }) async { + Future takeSnapshot({required int mapId}) async { return null; } @@ -316,9 +309,10 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { if (instance == null) { createdIds.add(creationId); mapInstances[creationId] = PlatformMapStateRecorder( - widgetConfiguration: widgetConfiguration, - mapConfiguration: mapConfiguration, - mapObjects: mapObjects); + widgetConfiguration: widgetConfiguration, + mapConfiguration: mapConfiguration, + mapObjects: mapObjects, + ); onPlatformViewCreated(creationId); } return Container(); @@ -340,18 +334,29 @@ class PlatformMapStateRecorder { this.mapObjects = const MapObjects(), this.mapConfiguration = const MapConfiguration(), }) { - clusterManagerUpdates.add(ClusterManagerUpdates.from( - const {}, mapObjects.clusterManagers)); - groundOverlayUpdates.add(GroundOverlayUpdates.from( - const {}, mapObjects.groundOverlays)); + clusterManagerUpdates.add( + ClusterManagerUpdates.from( + const {}, + mapObjects.clusterManagers, + ), + ); + groundOverlayUpdates.add( + GroundOverlayUpdates.from( + const {}, + mapObjects.groundOverlays, + ), + ); markerUpdates.add(MarkerUpdates.from(const {}, mapObjects.markers)); - polygonUpdates - .add(PolygonUpdates.from(const {}, mapObjects.polygons)); - polylineUpdates - .add(PolylineUpdates.from(const {}, mapObjects.polylines)); + polygonUpdates.add( + PolygonUpdates.from(const {}, mapObjects.polygons), + ); + polylineUpdates.add( + PolylineUpdates.from(const {}, mapObjects.polylines), + ); circleUpdates.add(CircleUpdates.from(const {}, mapObjects.circles)); - heatmapUpdates - .add(HeatmapUpdates.from(const {}, mapObjects.heatmaps)); + heatmapUpdates.add( + HeatmapUpdates.from(const {}, mapObjects.heatmaps), + ); tileOverlaySets.add(mapObjects.tileOverlays); } diff --git a/packages/google_maps_flutter/google_maps_flutter/test/google_map_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/google_map_test.dart index 9276a7dbda3..5b17360128f 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/google_map_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/google_map_test.dart @@ -29,12 +29,15 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; - expect(map.widgetConfiguration.initialCameraPosition, - const CameraPosition(target: LatLng(10.0, 15.0))); + expect( + map.widgetConfiguration.initialCameraPosition, + const CameraPosition(target: LatLng(10.0, 15.0)), + ); }); - testWidgets('Initial camera position change is a no-op', - (WidgetTester tester) async { + testWidgets('Initial camera position change is a no-op', ( + WidgetTester tester, + ) async { await tester.pumpWidget( const Directionality( textDirection: TextDirection.ltr, @@ -55,8 +58,10 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; - expect(map.widgetConfiguration.initialCameraPosition, - const CameraPosition(target: LatLng(10.0, 15.0))); + expect( + map.widgetConfiguration.initialCameraPosition, + const CameraPosition(target: LatLng(10.0, 15.0)), + ); }); testWidgets('Can update compassEnabled', (WidgetTester tester) async { @@ -118,8 +123,9 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: GoogleMap( - initialCameraPosition: - const CameraPosition(target: LatLng(10.0, 15.0)), + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), cameraTargetBounds: CameraTargetBounds( LatLngBounds( southwest: const LatLng(10.0, 20.0), @@ -133,20 +139,22 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; expect( - map.mapConfiguration.cameraTargetBounds, - CameraTargetBounds( - LatLngBounds( - southwest: const LatLng(10.0, 20.0), - northeast: const LatLng(30.0, 40.0), - ), - )); + map.mapConfiguration.cameraTargetBounds, + CameraTargetBounds( + LatLngBounds( + southwest: const LatLng(10.0, 20.0), + northeast: const LatLng(30.0, 40.0), + ), + ), + ); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, child: GoogleMap( - initialCameraPosition: - const CameraPosition(target: LatLng(10.0, 15.0)), + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), cameraTargetBounds: CameraTargetBounds( LatLngBounds( southwest: const LatLng(16.0, 20.0), @@ -158,13 +166,14 @@ void main() { ); expect( - map.mapConfiguration.cameraTargetBounds, - CameraTargetBounds( - LatLngBounds( - southwest: const LatLng(16.0, 20.0), - northeast: const LatLng(30.0, 40.0), - ), - )); + map.mapConfiguration.cameraTargetBounds, + CameraTargetBounds( + LatLngBounds( + southwest: const LatLng(16.0, 20.0), + northeast: const LatLng(30.0, 40.0), + ), + ), + ); }); testWidgets('Can update mapType', (WidgetTester tester) async { @@ -208,8 +217,10 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; - expect(map.mapConfiguration.minMaxZoomPreference, - const MinMaxZoomPreference(1.0, 3.0)); + expect( + map.mapConfiguration.minMaxZoomPreference, + const MinMaxZoomPreference(1.0, 3.0), + ); await tester.pumpWidget( const Directionality( @@ -220,8 +231,10 @@ void main() { ), ); - expect(map.mapConfiguration.minMaxZoomPreference, - MinMaxZoomPreference.unbounded); + expect( + map.mapConfiguration.minMaxZoomPreference, + MinMaxZoomPreference.unbounded, + ); }); testWidgets('Can update rotateGesturesEnabled', (WidgetTester tester) async { @@ -323,8 +336,9 @@ void main() { Directionality( textDirection: TextDirection.ltr, child: GoogleMap( - initialCameraPosition: - const CameraPosition(target: LatLng(10.0, 15.0)), + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), onCameraMove: (CameraPosition position) {}, ), ), @@ -414,8 +428,9 @@ void main() { expect(map.mapConfiguration.myLocationEnabled, true); }); - testWidgets('Can update myLocationButtonEnabled', - (WidgetTester tester) async { + testWidgets('Can update myLocationButtonEnabled', ( + WidgetTester tester, + ) async { await tester.pumpWidget( const Directionality( textDirection: TextDirection.ltr, @@ -481,8 +496,10 @@ void main() { ), ); - expect(map.mapConfiguration.padding, - const EdgeInsets.fromLTRB(10, 20, 30, 40)); + expect( + map.mapConfiguration.padding, + const EdgeInsets.fromLTRB(10, 20, 30, 40), + ); await tester.pumpWidget( const Directionality( @@ -494,8 +511,10 @@ void main() { ), ); - expect(map.mapConfiguration.padding, - const EdgeInsets.fromLTRB(50, 60, 70, 80)); + expect( + map.mapConfiguration.padding, + const EdgeInsets.fromLTRB(50, 60, 70, 80), + ); }); testWidgets('Can update traffic', (WidgetTester tester) async { diff --git a/packages/google_maps_flutter/google_maps_flutter/test/groundoverlay_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/groundoverlay_updates_test.dart index 79b55102108..72d91c580fd 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/groundoverlay_updates_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/groundoverlay_updates_test.dart @@ -74,7 +74,9 @@ void main() { expect(initializedGroundOverlays.first, equals(go1)); expect(initializedGroundOverlays.last, equals(go2)); expect( - map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, true); + map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, + true, + ); expect(map.groundOverlayUpdates.last.groundOverlaysToChange.isEmpty, true); }); @@ -120,7 +122,9 @@ void main() { expect(addedMarker, equals(go2)); expect( - map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, true); + map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, + true, + ); expect(map.groundOverlayUpdates.last.groundOverlaysToChange.isEmpty, true); }); @@ -144,8 +148,10 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; expect(map.groundOverlayUpdates.last.groundOverlayIdsToRemove.length, 1); - expect(map.groundOverlayUpdates.last.groundOverlayIdsToRemove.first, - equals(go1.groundOverlayId)); + expect( + map.groundOverlayUpdates.last.groundOverlayIdsToRemove.first, + equals(go1.groundOverlayId), + ); expect(map.groundOverlayUpdates.last.groundOverlaysToChange.isEmpty, true); expect(map.groundOverlayUpdates.last.groundOverlaysToAdd.isEmpty, true); @@ -172,11 +178,15 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; expect(map.groundOverlayUpdates.last.groundOverlaysToChange.length, 1); - expect(map.groundOverlayUpdates.last.groundOverlaysToChange.first, - equals(go2)); + expect( + map.groundOverlayUpdates.last.groundOverlaysToChange.first, + equals(go2), + ); expect( - map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, true); + map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, + true, + ); expect(map.groundOverlayUpdates.last.groundOverlaysToAdd.isEmpty, true); }); @@ -223,7 +233,9 @@ void main() { expect(map.groundOverlayUpdates.last.groundOverlaysToChange, cur); expect( - map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, true); + map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, + true, + ); expect(map.groundOverlayUpdates.last.groundOverlaysToAdd.isEmpty, true); }); @@ -290,12 +302,18 @@ void main() { expect(map.groundOverlayUpdates.last.groundOverlaysToAdd.length, 1); expect(map.groundOverlayUpdates.last.groundOverlayIdsToRemove.length, 1); - expect(map.groundOverlayUpdates.last.groundOverlaysToChange.first, - equals(go2)); expect( - map.groundOverlayUpdates.last.groundOverlaysToAdd.first, equals(go1)); - expect(map.groundOverlayUpdates.last.groundOverlayIdsToRemove.first, - equals(go3.groundOverlayId)); + map.groundOverlayUpdates.last.groundOverlaysToChange.first, + equals(go2), + ); + expect( + map.groundOverlayUpdates.last.groundOverlaysToAdd.first, + equals(go1), + ); + expect( + map.groundOverlayUpdates.last.groundOverlayIdsToRemove.first, + equals(go3.groundOverlayId), + ); }); testWidgets('Partial Update', (WidgetTester tester) async { @@ -354,10 +372,14 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; - expect(map.groundOverlayUpdates.last.groundOverlaysToChange, - {go3}); expect( - map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, true); + map.groundOverlayUpdates.last.groundOverlaysToChange, + {go3}, + ); + expect( + map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, + true, + ); expect(map.groundOverlayUpdates.last.groundOverlaysToAdd.isEmpty, true); }); @@ -375,9 +397,7 @@ void main() { zIndex: 10, ); final Set prev = {go1}; - go1 = go1.copyWith( - onTapParam: () {}, - ); + go1 = go1.copyWith(onTapParam: () {}); final Set cur = {go1}; await tester.pumpWidget(_mapWithMarkers(prev)); @@ -387,7 +407,9 @@ void main() { expect(map.groundOverlayUpdates.last.groundOverlaysToChange.isEmpty, true); expect( - map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, true); + map.groundOverlayUpdates.last.groundOverlayIdsToRemove.isEmpty, + true, + ); expect(map.groundOverlayUpdates.last.groundOverlaysToAdd.isEmpty, true); }); @@ -453,18 +475,24 @@ void main() { expect(map.groundOverlayUpdates.length, 3); expect(map.groundOverlayUpdates[0].groundOverlaysToChange.isEmpty, true); - expect(map.groundOverlayUpdates[0].groundOverlaysToAdd, - {go1, go2}); + expect(map.groundOverlayUpdates[0].groundOverlaysToAdd, { + go1, + go2, + }); expect(map.groundOverlayUpdates[0].groundOverlayIdsToRemove.isEmpty, true); expect(map.groundOverlayUpdates[1].groundOverlaysToChange.isEmpty, true); + expect(map.groundOverlayUpdates[1].groundOverlaysToAdd, { + go3, + }); expect( - map.groundOverlayUpdates[1].groundOverlaysToAdd, {go3}); - expect(map.groundOverlayUpdates[1].groundOverlayIdsToRemove, - {go2.groundOverlayId}); + map.groundOverlayUpdates[1].groundOverlayIdsToRemove, + {go2.groundOverlayId}, + ); - expect(map.groundOverlayUpdates[2].groundOverlaysToChange, - {go3updated}); + expect(map.groundOverlayUpdates[2].groundOverlaysToChange, { + go3updated, + }); expect(map.groundOverlayUpdates[2].groundOverlaysToAdd.isEmpty, true); expect(map.groundOverlayUpdates[2].groundOverlayIdsToRemove.isEmpty, true); diff --git a/packages/google_maps_flutter/google_maps_flutter/test/heatmap_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/heatmap_updates_test.dart index b9cb250c856..70c582b38de 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/heatmap_updates_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/heatmap_updates_test.dart @@ -33,7 +33,7 @@ const List _heatmapPoints = [ WeightedLatLng(LatLng(37.785, -122.441)), WeightedLatLng(LatLng(37.785, -122.439)), WeightedLatLng(LatLng(37.785, -122.437)), - WeightedLatLng(LatLng(37.785, -122.435)) + WeightedLatLng(LatLng(37.785, -122.435)), ]; void main() { @@ -101,7 +101,9 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; expect(map.heatmapUpdates.last.heatmapIdsToRemove.length, 1); expect( - map.heatmapUpdates.last.heatmapIdsToRemove.first, equals(h1.heatmapId)); + map.heatmapUpdates.last.heatmapIdsToRemove.first, + equals(h1.heatmapId), + ); expect(map.heatmapUpdates.last.heatmapsToChange.isEmpty, true); expect(map.heatmapUpdates.last.heatmapsToAdd.isEmpty, true); @@ -226,7 +228,9 @@ void main() { expect(map.heatmapUpdates.last.heatmapsToChange.first, equals(h2)); expect(map.heatmapUpdates.last.heatmapsToAdd.first, equals(h1)); expect( - map.heatmapUpdates.last.heatmapIdsToRemove.first, equals(h3.heatmapId)); + map.heatmapUpdates.last.heatmapIdsToRemove.first, + equals(h3.heatmapId), + ); }); testWidgets('Partial Update', (WidgetTester tester) async { diff --git a/packages/google_maps_flutter/google_maps_flutter/test/map_creation_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/map_creation_test.dart index eb7e038c043..ea2e679fc8c 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/map_creation_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/map_creation_test.dart @@ -52,11 +52,11 @@ void main() { testWidgets('Calls platform.dispose when GoogleMap is disposed of', ( WidgetTester tester, ) async { - await tester.pumpWidget(const GoogleMap( - initialCameraPosition: CameraPosition( - target: LatLng(43.3608, -5.8702), + await tester.pumpWidget( + const GoogleMap( + initialCameraPosition: CameraPosition(target: LatLng(43.3608, -5.8702)), ), - )); + ); // Now dispose of the map... await tester.pumpWidget(Container()); diff --git a/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart index 9f65f5d3bf5..1feb3503332 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/marker_updates_test.dart @@ -169,9 +169,10 @@ void main() { Marker m1 = const Marker(markerId: MarkerId('marker_1')); final Set prev = {m1}; m1 = Marker( - markerId: const MarkerId('marker_1'), - onTap: () {}, - onDragEnd: (LatLng latLng) {}); + markerId: const MarkerId('marker_1'), + onTap: () {}, + onDragEnd: (LatLng latLng) {}, + ); final Set cur = {m1}; await tester.pumpWidget(_mapWithMarkers(prev)); @@ -190,8 +191,10 @@ void main() { const Marker m1 = Marker(markerId: MarkerId('marker_1')); const Marker m2 = Marker(markerId: MarkerId('marker_2')); const Marker m3 = Marker(markerId: MarkerId('marker_3')); - const Marker m3updated = - Marker(markerId: MarkerId('marker_3'), draggable: true); + const Marker m3updated = Marker( + markerId: MarkerId('marker_3'), + draggable: true, + ); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithMarkers({m1, m2})); diff --git a/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart index 08910fa5ccb..8bb9a8db031 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/polygon_updates_test.dart @@ -91,7 +91,9 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; expect(map.polygonUpdates.last.polygonIdsToRemove.length, 1); expect( - map.polygonUpdates.last.polygonIdsToRemove.first, equals(p1.polygonId)); + map.polygonUpdates.last.polygonIdsToRemove.first, + equals(p1.polygonId), + ); expect(map.polygonUpdates.last.polygonsToChange.isEmpty, true); expect(map.polygonUpdates.last.polygonsToAdd.isEmpty, true); @@ -99,8 +101,10 @@ void main() { testWidgets('Updating a polygon', (WidgetTester tester) async { const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); - const Polygon p2 = - Polygon(polygonId: PolygonId('polygon_1'), geodesic: true); + const Polygon p2 = Polygon( + polygonId: PolygonId('polygon_1'), + geodesic: true, + ); await tester.pumpWidget(_mapWithPolygons({p1})); await tester.pumpWidget(_mapWithPolygons({p2})); @@ -172,7 +176,9 @@ void main() { expect(map.polygonUpdates.last.polygonsToChange.first, equals(p2)); expect(map.polygonUpdates.last.polygonsToAdd.first, equals(p1)); expect( - map.polygonUpdates.last.polygonIdsToRemove.first, equals(p3.polygonId)); + map.polygonUpdates.last.polygonIdsToRemove.first, + equals(p3.polygonId), + ); }); testWidgets('Partial Update', (WidgetTester tester) async { @@ -209,8 +215,9 @@ void main() { expect(map.polygonUpdates.last.polygonsToAdd.isEmpty, true); }); - testWidgets('Initializing a polygon with points and hole', - (WidgetTester tester) async { + testWidgets('Initializing a polygon with points and hole', ( + WidgetTester tester, + ) async { final Polygon p1 = _polygonWithPointsAndHole(const PolygonId('polygon_1')); await tester.pumpWidget(_mapWithPolygons({p1})); @@ -224,8 +231,9 @@ void main() { expect(map.polygonUpdates.last.polygonsToChange.isEmpty, true); }); - testWidgets('Adding a polygon with points and hole', - (WidgetTester tester) async { + testWidgets('Adding a polygon with points and hole', ( + WidgetTester tester, + ) async { const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); final Polygon p2 = _polygonWithPointsAndHole(const PolygonId('polygon_2')); @@ -243,8 +251,9 @@ void main() { expect(map.polygonUpdates.last.polygonsToChange.isEmpty, true); }); - testWidgets('Removing a polygon with points and hole', - (WidgetTester tester) async { + testWidgets('Removing a polygon with points and hole', ( + WidgetTester tester, + ) async { final Polygon p1 = _polygonWithPointsAndHole(const PolygonId('polygon_1')); await tester.pumpWidget(_mapWithPolygons({p1})); @@ -253,14 +262,17 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; expect(map.polygonUpdates.last.polygonIdsToRemove.length, 1); expect( - map.polygonUpdates.last.polygonIdsToRemove.first, equals(p1.polygonId)); + map.polygonUpdates.last.polygonIdsToRemove.first, + equals(p1.polygonId), + ); expect(map.polygonUpdates.last.polygonsToChange.isEmpty, true); expect(map.polygonUpdates.last.polygonsToAdd.isEmpty, true); }); - testWidgets('Updating a polygon by adding points and hole', - (WidgetTester tester) async { + testWidgets('Updating a polygon by adding points and hole', ( + WidgetTester tester, + ) async { const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); final Polygon p2 = _polygonWithPointsAndHole(const PolygonId('polygon_1')); @@ -275,8 +287,9 @@ void main() { expect(map.polygonUpdates.last.polygonsToAdd.isEmpty, true); }); - testWidgets('Mutate a polygon with points and holes', - (WidgetTester tester) async { + testWidgets('Mutate a polygon with points and holes', ( + WidgetTester tester, + ) async { final Polygon p1 = Polygon( polygonId: const PolygonId('polygon_1'), points: _rectPoints(size: 1), @@ -300,8 +313,9 @@ void main() { expect(map.polygonUpdates.last.polygonsToAdd.isEmpty, true); }); - testWidgets('Multi Update polygons with points and hole', - (WidgetTester tester) async { + testWidgets('Multi Update polygons with points and hole', ( + WidgetTester tester, + ) async { Polygon p1 = const Polygon(polygonId: PolygonId('polygon_1')); Polygon p2 = Polygon( polygonId: const PolygonId('polygon_2'), @@ -326,8 +340,9 @@ void main() { expect(map.polygonUpdates.last.polygonsToAdd.isEmpty, true); }); - testWidgets('Multi Update polygons with points and hole', - (WidgetTester tester) async { + testWidgets('Multi Update polygons with points and hole', ( + WidgetTester tester, + ) async { Polygon p2 = Polygon( polygonId: const PolygonId('polygon_2'), points: _rectPoints(size: 2), @@ -356,11 +371,14 @@ void main() { expect(map.polygonUpdates.last.polygonsToChange.first, equals(p2)); expect(map.polygonUpdates.last.polygonsToAdd.first, equals(p1)); expect( - map.polygonUpdates.last.polygonIdsToRemove.first, equals(p3.polygonId)); + map.polygonUpdates.last.polygonIdsToRemove.first, + equals(p3.polygonId), + ); }); - testWidgets('Partial Update polygons with points and hole', - (WidgetTester tester) async { + testWidgets('Partial Update polygons with points and hole', ( + WidgetTester tester, + ) async { final Polygon p1 = _polygonWithPointsAndHole(const PolygonId('polygon_1')); const Polygon p2 = Polygon(polygonId: PolygonId('polygon_2')); Polygon p3 = Polygon( @@ -390,10 +408,14 @@ void main() { const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); const Polygon p2 = Polygon(polygonId: PolygonId('polygon_2')); - const Polygon p3 = - Polygon(polygonId: PolygonId('polygon_3'), strokeWidth: 1); - const Polygon p3updated = - Polygon(polygonId: PolygonId('polygon_3'), strokeWidth: 2); + const Polygon p3 = Polygon( + polygonId: PolygonId('polygon_3'), + strokeWidth: 1, + ); + const Polygon p3updated = Polygon( + polygonId: PolygonId('polygon_3'), + strokeWidth: 2, + ); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithPolygons({p1, p2})); diff --git a/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart index cac311f7f2e..6f1fc6f7d0a 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/polyline_updates_test.dart @@ -68,8 +68,10 @@ void main() { final PlatformMapStateRecorder map = platform.lastCreatedMap; expect(map.polylineUpdates.last.polylineIdsToRemove.length, 1); - expect(map.polylineUpdates.last.polylineIdsToRemove.first, - equals(p1.polylineId)); + expect( + map.polylineUpdates.last.polylineIdsToRemove.first, + equals(p1.polylineId), + ); expect(map.polylineUpdates.last.polylinesToChange.isEmpty, true); expect(map.polylineUpdates.last.polylinesToAdd.isEmpty, true); @@ -77,8 +79,10 @@ void main() { testWidgets('Updating a polyline', (WidgetTester tester) async { const Polyline p1 = Polyline(polylineId: PolylineId('polyline_1')); - const Polyline p2 = - Polyline(polylineId: PolylineId('polyline_1'), geodesic: true); + const Polyline p2 = Polyline( + polylineId: PolylineId('polyline_1'), + geodesic: true, + ); await tester.pumpWidget(_mapWithPolylines({p1})); await tester.pumpWidget(_mapWithPolylines({p2})); @@ -93,8 +97,10 @@ void main() { testWidgets('Updating a polyline', (WidgetTester tester) async { const Polyline p1 = Polyline(polylineId: PolylineId('polyline_1')); - const Polyline p2 = - Polyline(polylineId: PolylineId('polyline_1'), geodesic: true); + const Polyline p2 = Polyline( + polylineId: PolylineId('polyline_1'), + geodesic: true, + ); await tester.pumpWidget(_mapWithPolylines({p1})); await tester.pumpWidget(_mapWithPolylines({p2})); @@ -165,8 +171,10 @@ void main() { expect(map.polylineUpdates.last.polylinesToChange.first, equals(p2)); expect(map.polylineUpdates.last.polylinesToAdd.first, equals(p1)); - expect(map.polylineUpdates.last.polylineIdsToRemove.first, - equals(p3.polylineId)); + expect( + map.polylineUpdates.last.polylineIdsToRemove.first, + equals(p3.polylineId), + ); }); testWidgets('Partial Update', (WidgetTester tester) async { @@ -208,10 +216,14 @@ void main() { const Polyline p1 = Polyline(polylineId: PolylineId('polyline_1')); const Polyline p2 = Polyline(polylineId: PolylineId('polyline_2')); - const Polyline p3 = - Polyline(polylineId: PolylineId('polyline_3'), width: 1); - const Polyline p3updated = - Polyline(polylineId: PolylineId('polyline_3'), width: 2); + const Polyline p3 = Polyline( + polylineId: PolylineId('polyline_3'), + width: 1, + ); + const Polyline p3updated = Polyline( + polylineId: PolylineId('polyline_3'), + width: 2, + ); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithPolylines({p1, p2})); @@ -228,8 +240,9 @@ void main() { expect(map.polylineUpdates[1].polylinesToChange.isEmpty, true); expect(map.polylineUpdates[1].polylinesToAdd, {p3}); - expect(map.polylineUpdates[1].polylineIdsToRemove, - {p2.polylineId}); + expect(map.polylineUpdates[1].polylineIdsToRemove, { + p2.polylineId, + }); expect(map.polylineUpdates[2].polylinesToChange, {p3updated}); expect(map.polylineUpdates[2].polylinesToAdd.isEmpty, true); diff --git a/packages/google_maps_flutter/google_maps_flutter/test/tile_overlay_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/tile_overlay_updates_test.dart index c2faca593bc..128b4378b1f 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/tile_overlay_updates_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/tile_overlay_updates_test.dart @@ -28,8 +28,9 @@ void main() { }); testWidgets('Initializing a tile overlay', (WidgetTester tester) async { - const TileOverlay t1 = - TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_1')); + const TileOverlay t1 = TileOverlay( + tileOverlayId: TileOverlayId('tile_overlay_1'), + ); await tester.pumpWidget(_mapWithTileOverlays({t1})); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -37,10 +38,12 @@ void main() { }); testWidgets('Adding a tile overlay', (WidgetTester tester) async { - const TileOverlay t1 = - TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_1')); - const TileOverlay t2 = - TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_2')); + const TileOverlay t1 = TileOverlay( + tileOverlayId: TileOverlayId('tile_overlay_1'), + ); + const TileOverlay t2 = TileOverlay( + tileOverlayId: TileOverlayId('tile_overlay_2'), + ); await tester.pumpWidget(_mapWithTileOverlays({t1})); await tester.pumpWidget(_mapWithTileOverlays({t1, t2})); @@ -50,8 +53,9 @@ void main() { }); testWidgets('Removing a tile overlay', (WidgetTester tester) async { - const TileOverlay t1 = - TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_1')); + const TileOverlay t1 = TileOverlay( + tileOverlayId: TileOverlayId('tile_overlay_1'), + ); await tester.pumpWidget(_mapWithTileOverlays({t1})); await tester.pumpWidget(_mapWithTileOverlays({})); @@ -61,10 +65,13 @@ void main() { }); testWidgets('Updating a tile overlay', (WidgetTester tester) async { - const TileOverlay t1 = - TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_1')); - const TileOverlay t2 = - TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_1'), zIndex: 10); + const TileOverlay t1 = TileOverlay( + tileOverlayId: TileOverlayId('tile_overlay_1'), + ); + const TileOverlay t2 = TileOverlay( + tileOverlayId: TileOverlayId('tile_overlay_1'), + zIndex: 10, + ); await tester.pumpWidget(_mapWithTileOverlays({t1})); await tester.pumpWidget(_mapWithTileOverlays({t2})); 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 5c7a093320e..7465697bca3 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. + ## 2.18.1 * Updates kotlin version to 2.2.0 to enable gradle 8.11 support. 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 66e8af30562..c48aeb114d3 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 @@ -39,7 +39,9 @@ const CameraPosition _kTestCameraPosition = CameraPosition( tilt: 1.0, ); final LatLngBounds _testCameraBounds = LatLngBounds( - northeast: const LatLng(50, -65), southwest: const LatLng(28.5, -123)); + northeast: const LatLng(50, -65), + southwest: const LatLng(28.5, -123), +); final ValueVariant _cameraUpdateTypeVariants = ValueVariant(CameraUpdateType.values.toSet()); @@ -51,8 +53,9 @@ void main() { setUpAll(() async { final GoogleMapsFlutterAndroid instance = GoogleMapsFlutterPlatform.instance as GoogleMapsFlutterAndroid; - initializedRenderer = - await instance.initializeWithRenderer(AndroidMapRenderer.latest); + initializedRenderer = await instance.initializeWithRenderer( + AndroidMapRenderer.latest, + ); }); testWidgets('initialized with latest renderer', (WidgetTester _) async { @@ -61,19 +64,27 @@ void main() { // Instead, just test that the request succeeded and returned a valid // value. expect( - initializedRenderer == AndroidMapRenderer.latest || - initializedRenderer == AndroidMapRenderer.legacy, - true); + initializedRenderer == AndroidMapRenderer.latest || + initializedRenderer == AndroidMapRenderer.legacy, + true, + ); }); - testWidgets('throws PlatformException on multiple renderer initializations', - (WidgetTester _) async { + testWidgets('throws PlatformException on multiple renderer initializations', ( + WidgetTester _, + ) async { final GoogleMapsFlutterAndroid instance = GoogleMapsFlutterPlatform.instance as GoogleMapsFlutterAndroid; expect( - () async => instance.initializeWithRenderer(AndroidMapRenderer.latest), - throwsA(isA().having((PlatformException e) => e.code, - 'code', 'Renderer already initialized'))); + () async => instance.initializeWithRenderer(AndroidMapRenderer.latest), + throwsA( + isA().having( + (PlatformException e) => e.code, + 'code', + 'Renderer already initialized', + ), + ), + ); }); // Repeatedly checks an asynchronous value against a test condition, waiting @@ -85,9 +96,12 @@ void main() { // This is useful for cases where the Maps SDK has some internally // asynchronous operation that we don't have visibility into (e.g., native UI // animations). - Future waitForValueMatchingPredicate(WidgetTester tester, - Future Function() getValue, bool Function(T) predicate, - {int maxTries = 100}) async { + Future waitForValueMatchingPredicate( + WidgetTester tester, + Future Function() getValue, + bool Function(T) predicate, { + int maxTries = 100, + }) async { for (int i = 0; i < maxTries; i++) { final T value = await getValue(); if (predicate(value)) { @@ -107,17 +121,19 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - compassEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + 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; @@ -135,17 +151,19 @@ void main() { testWidgets('testCompassToggle', (WidgetTester tester) async { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - compassEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + compassEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = @@ -153,16 +171,18 @@ void main() { bool compassEnabled = await inspector.isCompassEnabled(mapId: mapId); expect(compassEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); compassEnabled = await inspector.isCompassEnabled(mapId: mapId); expect(compassEnabled, true); @@ -172,17 +192,19 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - mapToolbarEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + mapToolbarEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = @@ -190,16 +212,18 @@ void main() { bool mapToolbarEnabled = await inspector.isMapToolbarEnabled(mapId: mapId); expect(mapToolbarEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); mapToolbarEnabled = await inspector.isMapToolbarEnabled(mapId: mapId); expect(mapToolbarEnabled, true); @@ -213,17 +237,19 @@ void main() { const MinMaxZoomPreference initialZoomLevel = MinMaxZoomPreference(4, 8); const MinMaxZoomPreference finalZoomLevel = MinMaxZoomPreference(6, 10); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - minMaxZoomPreference: initialZoomLevel, - onMapCreated: (ExampleGoogleMapController c) async { - controllerCompleter.complete(c); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + minMaxZoomPreference: initialZoomLevel, + onMapCreated: (ExampleGoogleMapController c) async { + controllerCompleter.complete(c); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -239,17 +265,19 @@ void main() { zoomLevel = await controller.getZoomLevel(); expect(zoomLevel, equals(initialZoomLevel.minZoom)); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - minMaxZoomPreference: finalZoomLevel, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + minMaxZoomPreference: finalZoomLevel, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); await controller.moveCamera(CameraUpdate.zoomTo(15)); await tester.pumpAndSettle(); @@ -266,35 +294,40 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - zoomGesturesEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + zoomGesturesEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - bool zoomGesturesEnabled = - await inspector.areZoomGesturesEnabled(mapId: mapId); + bool zoomGesturesEnabled = await inspector.areZoomGesturesEnabled( + mapId: mapId, + ); expect(zoomGesturesEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); zoomGesturesEnabled = await inspector.areZoomGesturesEnabled(mapId: mapId); expect(zoomGesturesEnabled, true); @@ -304,35 +337,40 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - bool zoomControlsEnabled = - await inspector.areZoomControlsEnabled(mapId: mapId); + bool zoomControlsEnabled = await inspector.areZoomControlsEnabled( + mapId: mapId, + ); expect(zoomControlsEnabled, true); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - zoomControlsEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + zoomControlsEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); zoomControlsEnabled = await inspector.areZoomControlsEnabled(mapId: mapId); expect(zoomControlsEnabled, false); @@ -342,16 +380,18 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = @@ -359,17 +399,19 @@ void main() { bool liteModeEnabled = await inspector.isLiteModeEnabled(mapId: mapId); expect(liteModeEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - liteModeEnabled: true, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + liteModeEnabled: true, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); liteModeEnabled = await inspector.isLiteModeEnabled(mapId: mapId); expect(liteModeEnabled, true); @@ -379,38 +421,44 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - rotateGesturesEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + rotateGesturesEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - bool rotateGesturesEnabled = - await inspector.areRotateGesturesEnabled(mapId: mapId); + bool rotateGesturesEnabled = await inspector.areRotateGesturesEnabled( + mapId: mapId, + ); expect(rotateGesturesEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); - rotateGesturesEnabled = - await inspector.areRotateGesturesEnabled(mapId: mapId); + rotateGesturesEnabled = await inspector.areRotateGesturesEnabled( + mapId: mapId, + ); expect(rotateGesturesEnabled, true); }); @@ -418,35 +466,40 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - tiltGesturesEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + tiltGesturesEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - bool tiltGesturesEnabled = - await inspector.areTiltGesturesEnabled(mapId: mapId); + bool tiltGesturesEnabled = await inspector.areTiltGesturesEnabled( + mapId: mapId, + ); expect(tiltGesturesEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); tiltGesturesEnabled = await inspector.areTiltGesturesEnabled(mapId: mapId); expect(tiltGesturesEnabled, true); @@ -456,38 +509,44 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - scrollGesturesEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + scrollGesturesEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - bool scrollGesturesEnabled = - await inspector.areScrollGesturesEnabled(mapId: mapId); + bool scrollGesturesEnabled = await inspector.areScrollGesturesEnabled( + mapId: mapId, + ); expect(scrollGesturesEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); - scrollGesturesEnabled = - await inspector.areScrollGesturesEnabled(mapId: mapId); + scrollGesturesEnabled = await inspector.areScrollGesturesEnabled( + mapId: mapId, + ); expect(scrollGesturesEnabled, true); }); @@ -520,38 +579,45 @@ void main() { // https://github.com/flutter/flutter/issues/54758 await Future.delayed(const Duration(seconds: 1)); - final ScreenCoordinate coordinate = - await mapController.getScreenCoordinate(_kInitialCameraPosition.target); + final ScreenCoordinate coordinate = await mapController.getScreenCoordinate( + _kInitialCameraPosition.target, + ); final Rect rect = tester.getRect(find.byKey(key)); expect( - coordinate.x, - ((rect.center.dx - rect.topLeft.dx) * tester.view.devicePixelRatio) - .round()); + coordinate.x, + ((rect.center.dx - rect.topLeft.dx) * tester.view.devicePixelRatio) + .round(), + ); expect( - coordinate.y, - ((rect.center.dy - rect.topLeft.dy) * tester.view.devicePixelRatio) - .round()); + coordinate.y, + ((rect.center.dy - rect.topLeft.dy) * tester.view.devicePixelRatio) + .round(), + ); await tester.binding.setSurfaceSize(null); }); testWidgets('testGetVisibleRegion', (WidgetTester tester) async { final Key key = GlobalKey(); final LatLngBounds zeroLatLngBounds = LatLngBounds( - southwest: const LatLng(0, 0), northeast: const LatLng(0, 0)); + southwest: const LatLng(0, 0), + northeast: const LatLng(0, 0), + ); final Completer mapControllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapControllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapControllerCompleter.complete(controller); + }, + ), ), - )); + ); await tester.pumpAndSettle(); final ExampleGoogleMapController mapController = @@ -560,21 +626,26 @@ void main() { // Wait for the visible region to be non-zero. final LatLngBounds firstVisibleRegion = await waitForValueMatchingPredicate( - tester, - () => mapController.getVisibleRegion(), - (LatLngBounds bounds) => - bounds != zeroLatLngBounds && - bounds.northeast != bounds.southwest) ?? - zeroLatLngBounds; + tester, + () => mapController.getVisibleRegion(), + (LatLngBounds bounds) => + bounds != zeroLatLngBounds && + bounds.northeast != bounds.southwest, + ) ?? + zeroLatLngBounds; expect(firstVisibleRegion, isNot(zeroLatLngBounds)); expect(firstVisibleRegion.contains(_kInitialMapCenter), isTrue); // Making a new `LatLngBounds` about (10, 10) distance south west to the `firstVisibleRegion`. // The size of the `LatLngBounds` is 10 by 10. - final LatLng southWest = LatLng(firstVisibleRegion.southwest.latitude - 20, - firstVisibleRegion.southwest.longitude - 20); - final LatLng northEast = LatLng(firstVisibleRegion.southwest.latitude - 10, - firstVisibleRegion.southwest.longitude - 10); + final LatLng southWest = LatLng( + firstVisibleRegion.southwest.latitude - 20, + firstVisibleRegion.southwest.longitude - 20, + ); + final LatLng northEast = LatLng( + firstVisibleRegion.southwest.latitude - 10, + firstVisibleRegion.southwest.longitude - 10, + ); final LatLng newCenter = LatLng( (northEast.latitude + southWest.latitude) / 2, (northEast.longitude + southWest.longitude) / 2, @@ -583,14 +654,17 @@ void main() { expect(firstVisibleRegion.contains(northEast), isFalse); expect(firstVisibleRegion.contains(southWest), isFalse); - final LatLngBounds latLngBounds = - LatLngBounds(southwest: southWest, northeast: northEast); + final LatLngBounds latLngBounds = LatLngBounds( + southwest: southWest, + northeast: northEast, + ); // TODO(iskakaushik): non-zero padding is needed for some device configurations // https://github.com/flutter/flutter/issues/30575 const double padding = 0; - await mapController - .moveCamera(CameraUpdate.newLatLngBounds(latLngBounds, padding)); + await mapController.moveCamera( + CameraUpdate.newLatLngBounds(latLngBounds, padding), + ); await tester.pumpAndSettle(const Duration(seconds: 3)); final LatLngBounds secondVisibleRegion = @@ -606,17 +680,19 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - trafficEnabled: true, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + trafficEnabled: true, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = @@ -624,18 +700,20 @@ void main() { bool isTrafficEnabled = await inspector.isTrafficEnabled(mapId: mapId); expect(isTrafficEnabled, true); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, - ), - )); - - isTrafficEnabled = await inspector.isTrafficEnabled(mapId: mapId); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), + ), + ); + + isTrafficEnabled = await inspector.isTrafficEnabled(mapId: mapId); expect(isTrafficEnabled, false); }); @@ -643,166 +721,195 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - final bool isBuildingsEnabled = - await inspector.areBuildingsEnabled(mapId: mapId); + final bool isBuildingsEnabled = await inspector.areBuildingsEnabled( + mapId: mapId, + ); expect(isBuildingsEnabled, true); }); - testWidgets('testMyLocationButtonToggle', (WidgetTester tester) async { - final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + testWidgets( + 'testMyLocationButtonToggle', + (WidgetTester tester) async { + final Key key = GlobalKey(); + final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), - )); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), + ), + ); - final int mapId = await mapIdCompleter.future; - final GoogleMapsInspectorPlatform inspector = - GoogleMapsInspectorPlatform.instance!; - bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); - expect(myLocationButtonEnabled, true); + final int mapId = await mapIdCompleter.future; + final GoogleMapsInspectorPlatform inspector = + GoogleMapsInspectorPlatform.instance!; + bool myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled( + mapId: mapId, + ); + expect(myLocationButtonEnabled, true); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - myLocationButtonEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, - ), - )); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + myLocationButtonEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), + ), + ); - myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); - expect(myLocationButtonEnabled, false); - }, - // Location button tests are skipped in Android because we don't have location permission to test. - skip: true); + myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled( + mapId: mapId, + ); + expect(myLocationButtonEnabled, false); + }, + // Location button tests are skipped in Android because we don't have location permission to test. + skip: true, + ); - testWidgets('testMyLocationButton initial value false', - (WidgetTester tester) async { - final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + testWidgets( + 'testMyLocationButton initial value false', + (WidgetTester tester) async { + final Key key = GlobalKey(); + final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - myLocationButtonEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), - )); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + myLocationButtonEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), + ), + ); - final int mapId = await mapIdCompleter.future; - final GoogleMapsInspectorPlatform inspector = - GoogleMapsInspectorPlatform.instance!; - final bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); - expect(myLocationButtonEnabled, false); - }, - // Location button tests are skipped in Android because we don't have location permission to test. - skip: true); - - testWidgets('testMyLocationButton initial value true', - (WidgetTester tester) async { - final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final int mapId = await mapIdCompleter.future; + final GoogleMapsInspectorPlatform inspector = + GoogleMapsInspectorPlatform.instance!; + final bool myLocationButtonEnabled = await inspector + .isMyLocationButtonEnabled(mapId: mapId); + expect(myLocationButtonEnabled, false); + }, + // Location button tests are skipped in Android because we don't have location permission to test. + skip: true, + ); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), - )); + testWidgets( + 'testMyLocationButton initial value true', + (WidgetTester tester) async { + final Key key = GlobalKey(); + final Completer mapIdCompleter = Completer(); - final int mapId = await mapIdCompleter.future; - final GoogleMapsInspectorPlatform inspector = - GoogleMapsInspectorPlatform.instance!; - final bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); - expect(myLocationButtonEnabled, true); - }, - // Location button tests are skipped in Android because we don't have location permission to test. - skip: true); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), + ), + ); + + final int mapId = await mapIdCompleter.future; + final GoogleMapsInspectorPlatform inspector = + GoogleMapsInspectorPlatform.instance!; + final bool myLocationButtonEnabled = await inspector + .isMyLocationButtonEnabled(mapId: mapId); + expect(myLocationButtonEnabled, true); + }, + // Location button tests are skipped in Android because we don't have location permission to test. + skip: true, + ); testWidgets('testSetMapStyle valid Json String', (WidgetTester tester) async { final Key key = GlobalKey(); final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; const String mapStyle = '[{"elementType":"geometry","stylers":[{"color":"#242f3e"}]}]'; - await GoogleMapsFlutterPlatform.instance - .setMapStyle(mapStyle, mapId: controller.mapId); + await GoogleMapsFlutterPlatform.instance.setMapStyle( + mapStyle, + mapId: controller.mapId, + ); }); - testWidgets('testSetMapStyle invalid Json String', - (WidgetTester tester) async { + testWidgets('testSetMapStyle invalid Json String', ( + WidgetTester tester, + ) async { final Key key = GlobalKey(); final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; try { - await GoogleMapsFlutterPlatform.instance - .setMapStyle('invalid_value', mapId: controller.mapId); + await GoogleMapsFlutterPlatform.instance.setMapStyle( + 'invalid_value', + mapId: controller.mapId, + ); fail('expected MapStyleException'); } on MapStyleException catch (e) { expect(e.cause, isNotNull); @@ -815,21 +922,25 @@ void main() { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; - await GoogleMapsFlutterPlatform.instance - .setMapStyle(null, mapId: controller.mapId); + await GoogleMapsFlutterPlatform.instance.setMapStyle( + null, + mapId: controller.mapId, + ); }); testWidgets('testGetLatLng', (WidgetTester tester) async { @@ -837,16 +948,18 @@ void main() { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -858,8 +971,9 @@ void main() { await Future.delayed(const Duration(seconds: 1)); final LatLngBounds visibleRegion = await controller.getVisibleRegion(); - final LatLng topLeft = - await controller.getLatLng(const ScreenCoordinate(x: 0, y: 0)); + final LatLng topLeft = await controller.getLatLng( + const ScreenCoordinate(x: 0, y: 0), + ); final LatLng northWest = LatLng( visibleRegion.northeast.latitude, visibleRegion.southwest.longitude, @@ -873,16 +987,18 @@ void main() { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -907,16 +1023,18 @@ void main() { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -931,8 +1049,9 @@ void main() { visibleRegion.northeast.latitude, visibleRegion.southwest.longitude, ); - final ScreenCoordinate topLeft = - await controller.getScreenCoordinate(northWest); + final ScreenCoordinate topLeft = await controller.getScreenCoordinate( + northWest, + ); expect(topLeft, const ScreenCoordinate(x: 0, y: 0)); }); @@ -945,19 +1064,25 @@ void main() { controllerCompleter.complete(controller); }, ); - await tester.pumpWidget(Directionality( + await tester.pumpWidget( + Directionality( textDirection: TextDirection.ltr, child: MaterialApp( - home: Scaffold( - body: SizedBox(height: 100, width: 100, child: map))))); + home: Scaffold(body: SizedBox(height: 100, width: 100, child: map)), + ), + ), + ); final ExampleGoogleMapController controller = await controllerCompleter.future; - await tester.pumpWidget(Directionality( + await tester.pumpWidget( + Directionality( textDirection: TextDirection.ltr, child: MaterialApp( - home: Scaffold( - body: SizedBox(height: 400, width: 400, child: map))))); + home: Scaffold(body: SizedBox(height: 400, width: 400, child: map)), + ), + ), + ); await tester.pumpAndSettle(); // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen @@ -973,23 +1098,28 @@ void main() { testWidgets('testToggleInfoWindow', (WidgetTester tester) async { const Marker marker = Marker( - markerId: MarkerId('marker'), - infoWindow: InfoWindow(title: 'InfoWindow')); + markerId: MarkerId('marker'), + infoWindow: InfoWindow(title: 'InfoWindow'), + ); final Set markers = {marker}; final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, - onMapCreated: (ExampleGoogleMapController googleMapController) { - controllerCompleter.complete(googleMapController); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + onMapCreated: (ExampleGoogleMapController googleMapController) { + controllerCompleter.complete(googleMapController); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -1002,17 +1132,20 @@ void main() { // re-evaluated when that issue is fixed. await Future.delayed(const Duration(seconds: 1)); - bool iwVisibleStatus = - await controller.isMarkerInfoWindowShown(marker.markerId); + bool iwVisibleStatus = await controller.isMarkerInfoWindowShown( + marker.markerId, + ); expect(iwVisibleStatus, false); await controller.showMarkerInfoWindow(marker.markerId); // The Maps SDK doesn't always return true for whether it is shown // immediately after showing it, so wait for it to report as shown. - iwVisibleStatus = await waitForValueMatchingPredicate( - tester, - () => controller.isMarkerInfoWindowShown(marker.markerId), - (bool visible) => visible) ?? + iwVisibleStatus = + await waitForValueMatchingPredicate( + tester, + () => controller.isMarkerInfoWindowShown(marker.markerId), + (bool visible) => visible, + ) ?? false; expect(iwVisibleStatus, true); @@ -1021,215 +1154,228 @@ void main() { expect(iwVisibleStatus, false); }); - testWidgets('testTakeSnapshot', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); - - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, - ), - ), - ); - - await tester.pumpAndSettle(const Duration(seconds: 3)); - - final ExampleGoogleMapController controller = - await controllerCompleter.future; - final Uint8List? bytes = await controller.takeSnapshot(); - expect(bytes?.isNotEmpty, true); - }, - // TODO(cyanglaz): un-skip the test when we can test this on CI with API key enabled. - // https://github.com/flutter/flutter/issues/57057 - skip: true); - testWidgets( - 'set tileOverlay correctly', + 'testTakeSnapshot', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final TileOverlay tileOverlay1 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 2, - transparency: 0.2, - ); + final Completer controllerCompleter = + Completer(); - final TileOverlay tileOverlay2 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_2'), - tileProvider: _DebugTileProvider(), - zIndex: 1, - visible: false, - transparency: 0.3, - fadeIn: false, - ); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, child: ExampleGoogleMap( initialCameraPosition: _kInitialCameraPosition, - tileOverlays: {tileOverlay1, tileOverlay2}, onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); + controllerCompleter.complete(controller); }, ), ), ); + await tester.pumpAndSettle(const Duration(seconds: 3)); - final int mapId = await mapIdCompleter.future; - final GoogleMapsInspectorPlatform inspector = - GoogleMapsInspectorPlatform.instance!; + final ExampleGoogleMapController controller = + await controllerCompleter.future; + final Uint8List? bytes = await controller.takeSnapshot(); + expect(bytes?.isNotEmpty, true); + }, + // TODO(cyanglaz): un-skip the test when we can test this on CI with API key enabled. + // https://github.com/flutter/flutter/issues/57057 + skip: true, + ); - final TileOverlay tileOverlayInfo1 = (await inspector - .getTileOverlayInfo(tileOverlay1.mapsId, mapId: mapId))!; - final TileOverlay tileOverlayInfo2 = (await inspector - .getTileOverlayInfo(tileOverlay2.mapsId, mapId: mapId))!; + testWidgets('set tileOverlay correctly', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final TileOverlay tileOverlay1 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 2, + transparency: 0.2, + ); - expect(tileOverlayInfo1.visible, isTrue); - expect(tileOverlayInfo1.fadeIn, isTrue); - expect( - tileOverlayInfo1.transparency, moreOrLessEquals(0.2, epsilon: 0.001)); - expect(tileOverlayInfo1.zIndex, 2); + final TileOverlay tileOverlay2 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_2'), + tileProvider: _DebugTileProvider(), + zIndex: 1, + visible: false, + transparency: 0.3, + fadeIn: false, + ); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: _kInitialCameraPosition, + tileOverlays: {tileOverlay1, tileOverlay2}, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), + ), + ); + await tester.pumpAndSettle(const Duration(seconds: 3)); - expect(tileOverlayInfo2.visible, isFalse); - expect(tileOverlayInfo2.fadeIn, isFalse); - expect( - tileOverlayInfo2.transparency, moreOrLessEquals(0.3, epsilon: 0.001)); - expect(tileOverlayInfo2.zIndex, 1); - }, - ); + final int mapId = await mapIdCompleter.future; + final GoogleMapsInspectorPlatform inspector = + GoogleMapsInspectorPlatform.instance!; - testWidgets( - 'update tileOverlays correctly', - (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 2, - transparency: 0.2, - ); + final TileOverlay tileOverlayInfo1 = + (await inspector.getTileOverlayInfo( + tileOverlay1.mapsId, + mapId: mapId, + ))!; + final TileOverlay tileOverlayInfo2 = + (await inspector.getTileOverlayInfo( + tileOverlay2.mapsId, + mapId: mapId, + ))!; + + expect(tileOverlayInfo1.visible, isTrue); + expect(tileOverlayInfo1.fadeIn, isTrue); + expect( + tileOverlayInfo1.transparency, + moreOrLessEquals(0.2, epsilon: 0.001), + ); + expect(tileOverlayInfo1.zIndex, 2); - final TileOverlay tileOverlay2 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_2'), - tileProvider: _DebugTileProvider(), - zIndex: 3, - transparency: 0.5, - ); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - tileOverlays: {tileOverlay1, tileOverlay2}, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), + expect(tileOverlayInfo2.visible, isFalse); + expect(tileOverlayInfo2.fadeIn, isFalse); + expect( + tileOverlayInfo2.transparency, + moreOrLessEquals(0.3, epsilon: 0.001), + ); + expect(tileOverlayInfo2.zIndex, 1); + }); + + testWidgets('update tileOverlays correctly', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final Key key = GlobalKey(); + final TileOverlay tileOverlay1 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 2, + transparency: 0.2, + ); + + final TileOverlay tileOverlay2 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_2'), + tileProvider: _DebugTileProvider(), + zIndex: 3, + transparency: 0.5, + ); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + tileOverlays: {tileOverlay1, tileOverlay2}, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, ), - ); + ), + ); - final int mapId = await mapIdCompleter.future; - final GoogleMapsInspectorPlatform inspector = - GoogleMapsInspectorPlatform.instance!; + final int mapId = await mapIdCompleter.future; + final GoogleMapsInspectorPlatform inspector = + GoogleMapsInspectorPlatform.instance!; - final TileOverlay tileOverlay1New = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 1, - visible: false, - transparency: 0.3, - fadeIn: false, - ); + final TileOverlay tileOverlay1New = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 1, + visible: false, + transparency: 0.3, + fadeIn: false, + ); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - tileOverlays: {tileOverlay1New}, - onMapCreated: (ExampleGoogleMapController controller) { - fail('update: OnMapCreated should get called only once.'); - }, - ), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + tileOverlays: {tileOverlay1New}, + onMapCreated: (ExampleGoogleMapController controller) { + fail('update: OnMapCreated should get called only once.'); + }, ), - ); + ), + ); - await tester.pumpAndSettle(const Duration(seconds: 3)); + await tester.pumpAndSettle(const Duration(seconds: 3)); - final TileOverlay tileOverlayInfo1 = (await inspector - .getTileOverlayInfo(tileOverlay1.mapsId, mapId: mapId))!; - final TileOverlay? tileOverlayInfo2 = - await inspector.getTileOverlayInfo(tileOverlay2.mapsId, mapId: mapId); + final TileOverlay tileOverlayInfo1 = + (await inspector.getTileOverlayInfo( + tileOverlay1.mapsId, + mapId: mapId, + ))!; + final TileOverlay? tileOverlayInfo2 = await inspector.getTileOverlayInfo( + tileOverlay2.mapsId, + mapId: mapId, + ); - expect(tileOverlayInfo1.visible, isFalse); - expect(tileOverlayInfo1.fadeIn, isFalse); - expect( - tileOverlayInfo1.transparency, moreOrLessEquals(0.3, epsilon: 0.001)); - expect(tileOverlayInfo1.zIndex, 1); + expect(tileOverlayInfo1.visible, isFalse); + expect(tileOverlayInfo1.fadeIn, isFalse); + expect( + tileOverlayInfo1.transparency, + moreOrLessEquals(0.3, epsilon: 0.001), + ); + expect(tileOverlayInfo1.zIndex, 1); - expect(tileOverlayInfo2, isNull); - }, - ); + expect(tileOverlayInfo2, isNull); + }); - testWidgets( - 'remove tileOverlays correctly', - (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 2, - transparency: 0.2, - ); + testWidgets('remove tileOverlays correctly', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final Key key = GlobalKey(); + final TileOverlay tileOverlay1 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 2, + transparency: 0.2, + ); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - tileOverlays: {tileOverlay1}, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + tileOverlays: {tileOverlay1}, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, ), - ); + ), + ); - final int mapId = await mapIdCompleter.future; - final GoogleMapsInspectorPlatform inspector = - GoogleMapsInspectorPlatform.instance!; + final int mapId = await mapIdCompleter.future; + final GoogleMapsInspectorPlatform inspector = + GoogleMapsInspectorPlatform.instance!; - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, - ), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, ), - ); + ), + ); - await tester.pumpAndSettle(const Duration(seconds: 3)); - final TileOverlay? tileOverlayInfo1 = - await inspector.getTileOverlayInfo(tileOverlay1.mapsId, mapId: mapId); + await tester.pumpAndSettle(const Duration(seconds: 3)); + final TileOverlay? tileOverlayInfo1 = await inspector.getTileOverlayInfo( + tileOverlay1.mapsId, + mapId: mapId, + ); - expect(tileOverlayInfo1, isNull); - }, - ); + expect(tileOverlayInfo1, isNull); + }); testWidgets('marker clustering', (WidgetTester tester) async { final Key key = GlobalKey(); @@ -1239,22 +1385,28 @@ void main() { final Set clusterManagers = {}; for (int i = 0; i < clusterManagersAmount; i++) { - final ClusterManagerId clusterManagerId = - ClusterManagerId('cluster_manager_$i'); - final ClusterManager clusterManager = - ClusterManager(clusterManagerId: clusterManagerId); + final ClusterManagerId clusterManagerId = ClusterManagerId( + 'cluster_manager_$i', + ); + final ClusterManager clusterManager = ClusterManager( + clusterManagerId: clusterManagerId, + ); clusterManagers.add(clusterManager); } for (final ClusterManager cm in clusterManagers) { for (int i = 0; i < markersPerClusterManager; i++) { - final MarkerId markerId = - MarkerId('${cm.clusterManagerId.value}_marker_$i'); + final MarkerId markerId = MarkerId( + '${cm.clusterManagerId.value}_marker_$i', + ); final Marker marker = Marker( - markerId: markerId, - clusterManagerId: cm.clusterManagerId, - position: LatLng( - _kInitialMapCenter.latitude + i, _kInitialMapCenter.longitude)); + markerId: markerId, + clusterManagerId: cm.clusterManagerId, + position: LatLng( + _kInitialMapCenter.latitude + i, + _kInitialMapCenter.longitude, + ), + ); markers[markerId] = marker; } } @@ -1262,18 +1414,20 @@ void main() { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - clusterManagers: clusterManagers, - markers: Set.of(markers.values), - onMapCreated: (ExampleGoogleMapController googleMapController) { - controllerCompleter.complete(googleMapController); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + clusterManagers: clusterManagers, + markers: Set.of(markers.values), + onMapCreated: (ExampleGoogleMapController googleMapController) { + controllerCompleter.complete(googleMapController); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -1283,7 +1437,9 @@ void main() { for (final ClusterManager cm in clusterManagers) { final List clusters = await inspector.getClusters( - mapId: controller.mapId, clusterManagerId: cm.clusterManagerId); + mapId: controller.mapId, + clusterManagerId: cm.clusterManagerId, + ); final int markersAmountForClusterManager = clusters .map((Cluster cluster) => cluster.count) .reduce((int value, int element) => value + element); @@ -1294,64 +1450,68 @@ void main() { for (final MapEntry entry in markers.entries) { markers[entry.key] = _copyMarkerWithClusterManagerId(entry.value, null); } - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( key: key, initialCameraPosition: _kInitialCameraPosition, clusterManagers: clusterManagers, - markers: Set.of(markers.values)), - )); + markers: Set.of(markers.values), + ), + ), + ); for (final ClusterManager cm in clusterManagers) { final List clusters = await inspector.getClusters( - mapId: controller.mapId, clusterManagerId: cm.clusterManagerId); + mapId: controller.mapId, + clusterManagerId: cm.clusterManagerId, + ); expect(clusters.length, 0); } }); - testWidgets( - 'testCloudMapId', - (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final Key key = GlobalKey(); + testWidgets('testCloudMapId', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final Key key = GlobalKey(); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - cloudMapId: _kCloudMapId, - ), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + cloudMapId: _kCloudMapId, ), - ); + ), + ); - // Await mapIdCompleter to finish to make sure map can be created with styledMapId - // Styled map - await mapIdCompleter.future; - }, - ); + // Await mapIdCompleter to finish to make sure map can be created with styledMapId + // Styled map + await mapIdCompleter.future; + }); testWidgets('getStyleError reports last error', (WidgetTester tester) async { final Key key = GlobalKey(); final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - style: '[[[this is an invalid style', - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + style: '[[[this is an invalid style', + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -1363,24 +1523,27 @@ void main() { expect(error, isNotNull); }); - testWidgets('getStyleError returns null for a valid style', - (WidgetTester tester) async { + testWidgets('getStyleError returns null for a valid style', ( + WidgetTester tester, + ) async { final Key key = GlobalKey(); final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - // An empty array is the simplest valid style. - style: '[]', - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + // An empty array is the simplest valid style. + style: '[]', + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -1391,19 +1554,21 @@ void main() { testWidgets('markerWithAssetMapBitmap', (WidgetTester tester) async { final Set markers = { Marker( - markerId: const MarkerId('1'), - icon: AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 1.0, - )), + markerId: const MarkerId('1'), + icon: AssetMapBitmap('assets/red_square.png', imagePixelRatio: 1.0), + ), }; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + ), ), - )); + ); }); testWidgets('markerWithAssetMapBitmapCreate', (WidgetTester tester) async { @@ -1412,19 +1577,24 @@ void main() { ); final Set markers = { Marker( - markerId: const MarkerId('1'), - icon: await AssetMapBitmap.create( - imageConfiguration, - 'assets/red_square.png', - )), + markerId: const MarkerId('1'), + icon: await AssetMapBitmap.create( + imageConfiguration, + 'assets/red_square.png', + ), + ), }; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + ), ), - )); + ); }); testWidgets('markerWithBytesMapBitmap', (WidgetTester tester) async { @@ -1438,13 +1608,17 @@ void main() { ), ), }; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + ), ), - )); + ); }); testWidgets('markerWithLegacyAsset', (WidgetTester tester) async { @@ -1455,21 +1629,26 @@ void main() { ); final Set markers = { Marker( - markerId: const MarkerId('1'), - // Intentionally testing the deprecated code path. - // ignore: deprecated_member_use - icon: await BitmapDescriptor.fromAssetImage( - imageConfiguration, - 'assets/red_square.png', - )), + markerId: const MarkerId('1'), + // Intentionally testing the deprecated code path. + // ignore: deprecated_member_use + icon: await BitmapDescriptor.fromAssetImage( + imageConfiguration, + 'assets/red_square.png', + ), + ), }; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + ), ), - )); + ); await tester.pumpAndSettle(); }); @@ -1479,21 +1658,23 @@ void main() { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); final Set markers = { Marker( - markerId: const MarkerId('1'), - // Intentionally testing the deprecated code path. - // ignore: deprecated_member_use - icon: BitmapDescriptor.fromBytes( - bytes, - size: const Size(100, 100), - )), + markerId: const MarkerId('1'), + // Intentionally testing the deprecated code path. + // ignore: deprecated_member_use + icon: BitmapDescriptor.fromBytes(bytes, size: const Size(100, 100)), + ), }; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + ), ), - )); + ); await tester.pumpAndSettle(); }); @@ -1515,19 +1696,22 @@ void main() { ); final GroundOverlay groundOverlayPosition1 = GroundOverlay.fromPosition( - groundOverlayId: const GroundOverlayId('position_1'), - position: kGroundOverlayBounds.northeast, - width: 100, - height: 100, - anchor: const Offset(0.1, 0.2), - image: AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 1.0, - bitmapScaling: MapBitmapScaling.none, - )); + groundOverlayId: const GroundOverlayId('position_1'), + position: kGroundOverlayBounds.northeast, + width: 100, + height: 100, + anchor: const Offset(0.1, 0.2), + image: AssetMapBitmap( + 'assets/red_square.png', + imagePixelRatio: 1.0, + bitmapScaling: MapBitmapScaling.none, + ), + ); void expectGroundOverlayEquals( - GroundOverlay source, GroundOverlay response) { + GroundOverlay source, + GroundOverlay response, + ) { expect(response.groundOverlayId, source.groundOverlayId); expect( response.transparency, @@ -1596,13 +1780,21 @@ void main() { GoogleMapsInspectorPlatform.instance!; if (inspector.supportsGettingGroundOverlayInfo()) { - final GroundOverlay groundOverlayBoundsInfo1 = (await inspector - .getGroundOverlayInfo(groundOverlayBounds1.mapsId, mapId: mapId))!; - final GroundOverlay groundOverlayBoundsInfo2 = (await inspector - .getGroundOverlayInfo(groundOverlayBounds2.mapsId, mapId: mapId))!; + final GroundOverlay groundOverlayBoundsInfo1 = + (await inspector.getGroundOverlayInfo( + groundOverlayBounds1.mapsId, + mapId: mapId, + ))!; + final GroundOverlay groundOverlayBoundsInfo2 = + (await inspector.getGroundOverlayInfo( + groundOverlayBounds2.mapsId, + mapId: mapId, + ))!; final GroundOverlay groundOverlayPositionInfo1 = - (await inspector.getGroundOverlayInfo(groundOverlayPosition1.mapsId, - mapId: mapId))!; + (await inspector.getGroundOverlayInfo( + groundOverlayPosition1.mapsId, + mapId: mapId, + ))!; expectGroundOverlayEquals( groundOverlayBounds1, @@ -1619,8 +1811,9 @@ void main() { } }); - testWidgets('update ground overlays correctly', - (WidgetTester tester) async { + testWidgets('update ground overlays correctly', ( + WidgetTester tester, + ) async { final Completer mapIdCompleter = Completer(); final Key key = GlobalKey(); @@ -1632,7 +1825,7 @@ void main() { initialCameraPosition: _kInitialCameraPosition, groundOverlays: { groundOverlayBounds1, - groundOverlayPosition1 + groundOverlayPosition1, }, onMapCreated: (ExampleGoogleMapController controller) { mapIdCompleter.complete(controller.mapId); @@ -1645,23 +1838,23 @@ void main() { final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - final GroundOverlay groundOverlayBounds1New = - groundOverlayBounds1.copyWith( - bearingParam: 10, - clickableParam: false, - transparencyParam: 0.5, - visibleParam: false, - zIndexParam: 10, - ); - - final GroundOverlay groundOverlayPosition1New = - groundOverlayPosition1.copyWith( - bearingParam: 10, - clickableParam: false, - transparencyParam: 0.5, - visibleParam: false, - zIndexParam: 10, - ); + final GroundOverlay groundOverlayBounds1New = groundOverlayBounds1 + .copyWith( + bearingParam: 10, + clickableParam: false, + transparencyParam: 0.5, + visibleParam: false, + zIndexParam: 10, + ); + + final GroundOverlay groundOverlayPosition1New = groundOverlayPosition1 + .copyWith( + bearingParam: 10, + clickableParam: false, + transparencyParam: 0.5, + visibleParam: false, + zIndexParam: 10, + ); await tester.pumpWidget( Directionality( @@ -1671,7 +1864,7 @@ void main() { initialCameraPosition: _kInitialCameraPosition, groundOverlays: { groundOverlayBounds1New, - groundOverlayPosition1New + groundOverlayPosition1New, }, onMapCreated: (ExampleGoogleMapController controller) { fail('update: OnMapCreated should get called only once.'); @@ -1683,11 +1876,16 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 3)); if (inspector.supportsGettingGroundOverlayInfo()) { - final GroundOverlay groundOverlayBounds1Info = (await inspector - .getGroundOverlayInfo(groundOverlayBounds1.mapsId, mapId: mapId))!; + final GroundOverlay groundOverlayBounds1Info = + (await inspector.getGroundOverlayInfo( + groundOverlayBounds1.mapsId, + mapId: mapId, + ))!; final GroundOverlay groundOverlayPosition1Info = - (await inspector.getGroundOverlayInfo(groundOverlayPosition1.mapsId, - mapId: mapId))!; + (await inspector.getGroundOverlayInfo( + groundOverlayPosition1.mapsId, + mapId: mapId, + ))!; expectGroundOverlayEquals( groundOverlayBounds1New, @@ -1700,8 +1898,9 @@ void main() { } }); - testWidgets('remove ground overlays correctly', - (WidgetTester tester) async { + testWidgets('remove ground overlays correctly', ( + WidgetTester tester, + ) async { final Completer mapIdCompleter = Completer(); final Key key = GlobalKey(); @@ -1713,7 +1912,7 @@ void main() { initialCameraPosition: _kInitialCameraPosition, groundOverlays: { groundOverlayBounds1, - groundOverlayPosition1 + groundOverlayPosition1, }, onMapCreated: (ExampleGoogleMapController controller) { mapIdCompleter.complete(controller.mapId); @@ -1765,22 +1964,24 @@ void main() { /// Completer to track when the camera has come to rest. Completer? cameraIdleCompleter; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onCameraIdle: () { - if (cameraIdleCompleter != null && - !cameraIdleCompleter.isCompleted) { - cameraIdleCompleter.complete(); - } - }, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onCameraIdle: () { + if (cameraIdleCompleter != null && + !cameraIdleCompleter.isCompleted) { + cameraIdleCompleter.complete(); + } + }, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -1795,36 +1996,39 @@ void main() { // Create completer for camera idle event. cameraIdleCompleter = Completer(); - final CameraUpdate cameraUpdate = - _getCameraUpdateForType(_cameraUpdateTypeVariants.currentValue!); + final CameraUpdate cameraUpdate = _getCameraUpdateForType( + _cameraUpdateTypeVariants.currentValue!, + ); await controller.animateCamera(cameraUpdate); // Immediately after calling animateCamera, check that the camera hasn't // reached its final position. This relies on the assumption that the // camera move is animated and won't complete instantly. - final CameraPosition beforeFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + final CameraPosition beforeFinishedPosition = await inspector + .getCameraPosition(mapId: controller.mapId); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - beforeFinishedPosition, - null, - controller, - (Matcher matcher) => isNot(matcher)); + _cameraUpdateTypeVariants.currentValue!, + beforeFinishedPosition, + null, + controller, + (Matcher matcher) => isNot(matcher), + ); // Wait for the animation to complete (onCameraIdle). expect(cameraIdleCompleter.isCompleted, isFalse); await cameraIdleCompleter.future; // After onCameraIdle event, the camera should be at the final position. - final CameraPosition afterFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + final CameraPosition afterFinishedPosition = await inspector + .getCameraPosition(mapId: controller.mapId); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - afterFinishedPosition, - beforeFinishedPosition, - controller, - (Matcher matcher) => matcher); + _cameraUpdateTypeVariants.currentValue!, + afterFinishedPosition, + beforeFinishedPosition, + controller, + (Matcher matcher) => matcher, + ); await tester.pumpAndSettle(); }, @@ -1867,23 +2071,25 @@ void main() { // Stopwatch to measure the time taken for the animation to complete. final Stopwatch stopwatch = Stopwatch(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onCameraIdle: () { - if (cameraIdleCompleter != null && - !cameraIdleCompleter.isCompleted) { - stopwatch.stop(); - cameraIdleCompleter.complete(); - } - }, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onCameraIdle: () { + if (cameraIdleCompleter != null && + !cameraIdleCompleter.isCompleted) { + stopwatch.stop(); + cameraIdleCompleter.complete(); + } + }, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -1904,8 +2110,9 @@ void main() { stopwatch.start(); // First phase with shorter animation duration. - final CameraUpdate cameraUpdateShort = - _getCameraUpdateForType(_cameraUpdateTypeVariants.currentValue!); + final CameraUpdate cameraUpdateShort = _getCameraUpdateForType( + _cameraUpdateTypeVariants.currentValue!, + ); await controller.animateCamera( cameraUpdateShort, duration: const Duration(milliseconds: shortCameraAnimationDurationMS), @@ -1917,12 +2124,15 @@ void main() { // For short animation duration, check that the animation is completed // faster than the midpoint benchmark. - expect(stopwatch.elapsedMilliseconds, - lessThan(animationDurationMiddlePoint)); + expect( + stopwatch.elapsedMilliseconds, + lessThan(animationDurationMiddlePoint), + ); // Reset camera to initial position before testing long duration. - await controller - .moveCamera(CameraUpdate.newCameraPosition(_kInitialCameraPosition)); + await controller.moveCamera( + CameraUpdate.newCameraPosition(_kInitialCameraPosition), + ); await tester.pumpAndSettle(); // Create completer for camera idle event. @@ -1934,8 +2144,9 @@ void main() { stopwatch.start(); // Second phase with longer animation duration. - final CameraUpdate cameraUpdateLong = - _getCameraUpdateForType(_cameraUpdateTypeVariants.currentValue!); + final CameraUpdate cameraUpdateLong = _getCameraUpdateForType( + _cameraUpdateTypeVariants.currentValue!, + ); await controller.animateCamera( cameraUpdateLong, duration: const Duration(milliseconds: longCameraAnimationDurationMS), @@ -1944,15 +2155,16 @@ void main() { // Immediately after calling animateCamera, check that the camera hasn't // reached its final position. This relies on the assumption that the // camera move is animated and won't complete instantly. - final CameraPosition beforeFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + final CameraPosition beforeFinishedPosition = await inspector + .getCameraPosition(mapId: controller.mapId); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - beforeFinishedPosition, - null, - controller, - (Matcher matcher) => isNot(matcher)); + _cameraUpdateTypeVariants.currentValue!, + beforeFinishedPosition, + null, + controller, + (Matcher matcher) => isNot(matcher), + ); // Wait for the animation to complete (onCameraIdle). expect(cameraIdleCompleter.isCompleted, isFalse); @@ -1960,18 +2172,21 @@ void main() { // For longer animation duration, check that the animation is completed // slower than the midpoint benchmark. - expect(stopwatch.elapsedMilliseconds, - greaterThan(animationDurationMiddlePoint)); + expect( + stopwatch.elapsedMilliseconds, + greaterThan(animationDurationMiddlePoint), + ); // Camera should be at the final position. - final CameraPosition afterFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + final CameraPosition afterFinishedPosition = await inspector + .getCameraPosition(mapId: controller.mapId); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - afterFinishedPosition, - beforeFinishedPosition, - controller, - (Matcher matcher) => matcher); + _cameraUpdateTypeVariants.currentValue!, + afterFinishedPosition, + beforeFinishedPosition, + controller, + (Matcher matcher) => matcher, + ); await tester.pumpAndSettle(); }, @@ -1993,41 +2208,38 @@ class _DebugTileProvider implements TileProvider { static const int width = 100; static const int height = 100; static final Paint boxPaint = Paint(); - static const TextStyle textStyle = TextStyle( - color: Colors.red, - fontSize: 20, - ); + static const TextStyle textStyle = TextStyle(color: Colors.red, fontSize: 20); @override Future getTile(int x, int y, int? zoom) async { final ui.PictureRecorder recorder = ui.PictureRecorder(); final Canvas canvas = Canvas(recorder); - final TextSpan textSpan = TextSpan( - text: '$x,$y', - style: textStyle, - ); + final TextSpan textSpan = TextSpan(text: '$x,$y', style: textStyle); final TextPainter textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); - textPainter.layout( - maxWidth: width.toDouble(), - ); + textPainter.layout(maxWidth: width.toDouble()); textPainter.paint(canvas, Offset.zero); canvas.drawRect( - Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), boxPaint); + Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), + boxPaint, + ); final ui.Picture picture = recorder.endRecording(); final Uint8List byteData = await picture .toImage(width, height) - .then((ui.Image image) => - image.toByteData(format: ui.ImageByteFormat.png)) + .then( + (ui.Image image) => image.toByteData(format: ui.ImageByteFormat.png), + ) .then((ByteData? byteData) => byteData!.buffer.asUint8List()); return Tile(width, height, byteData); } } Marker _copyMarkerWithClusterManagerId( - Marker marker, ClusterManagerId? clusterManagerId) { + Marker marker, + ClusterManagerId? clusterManagerId, +) { return Marker( markerId: marker.markerId, alpha: marker.alpha, @@ -2053,16 +2265,23 @@ Marker _copyMarkerWithClusterManagerId( CameraUpdate _getCameraUpdateForType(CameraUpdateType type) { return switch (type) { - CameraUpdateType.newCameraPosition => - CameraUpdate.newCameraPosition(_kTestCameraPosition), + CameraUpdateType.newCameraPosition => CameraUpdate.newCameraPosition( + _kTestCameraPosition, + ), CameraUpdateType.newLatLng => CameraUpdate.newLatLng(_kTestMapCenter), - CameraUpdateType.newLatLngBounds => - CameraUpdate.newLatLngBounds(_testCameraBounds, 0), - CameraUpdateType.newLatLngZoom => - CameraUpdate.newLatLngZoom(_kTestMapCenter, _kTestCameraZoomLevel), + CameraUpdateType.newLatLngBounds => CameraUpdate.newLatLngBounds( + _testCameraBounds, + 0, + ), + CameraUpdateType.newLatLngZoom => CameraUpdate.newLatLngZoom( + _kTestMapCenter, + _kTestCameraZoomLevel, + ), CameraUpdateType.scrollBy => CameraUpdate.scrollBy(10, 10), - CameraUpdateType.zoomBy => - CameraUpdate.zoomBy(_kTestZoomByAmount, const Offset(1, 1)), + CameraUpdateType.zoomBy => CameraUpdate.zoomBy( + _kTestZoomByAmount, + const Offset(1, 1), + ), CameraUpdateType.zoomTo => CameraUpdate.zoomTo(_kTestCameraZoomLevel), CameraUpdateType.zoomIn => CameraUpdate.zoomIn(), CameraUpdateType.zoomOut => CameraUpdate.zoomOut(), @@ -2082,52 +2301,80 @@ Future _checkCameraUpdateByType( switch (type) { case CameraUpdateType.newCameraPosition: - expect(currentPosition.bearing, - wrapMatcher(equals(_kTestCameraPosition.bearing))); expect( - currentPosition.zoom, wrapMatcher(equals(_kTestCameraPosition.zoom))); + currentPosition.bearing, + wrapMatcher(equals(_kTestCameraPosition.bearing)), + ); expect( - currentPosition.tilt, wrapMatcher(equals(_kTestCameraPosition.tilt))); + currentPosition.zoom, + wrapMatcher(equals(_kTestCameraPosition.zoom)), + ); expect( - currentPosition.target.latitude, - wrapMatcher( - closeTo(_kTestCameraPosition.target.latitude, latLngThreshold))); + currentPosition.tilt, + wrapMatcher(equals(_kTestCameraPosition.tilt)), + ); expect( - currentPosition.target.longitude, - wrapMatcher( - closeTo(_kTestCameraPosition.target.longitude, latLngThreshold))); + currentPosition.target.latitude, + wrapMatcher( + closeTo(_kTestCameraPosition.target.latitude, latLngThreshold), + ), + ); + expect( + currentPosition.target.longitude, + wrapMatcher( + closeTo(_kTestCameraPosition.target.longitude, latLngThreshold), + ), + ); case CameraUpdateType.newLatLng: - expect(currentPosition.target.latitude, - wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold))); - expect(currentPosition.target.longitude, - wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold))); + expect( + currentPosition.target.latitude, + wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold)), + ); + expect( + currentPosition.target.longitude, + wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold)), + ); case CameraUpdateType.newLatLngBounds: final LatLngBounds bounds = await controller.getVisibleRegion(); expect( - bounds.northeast.longitude, - wrapMatcher( - closeTo(_testCameraBounds.northeast.longitude, latLngThreshold))); + bounds.northeast.longitude, + wrapMatcher( + closeTo(_testCameraBounds.northeast.longitude, latLngThreshold), + ), + ); expect( - bounds.southwest.longitude, - wrapMatcher( - closeTo(_testCameraBounds.southwest.longitude, latLngThreshold))); + bounds.southwest.longitude, + wrapMatcher( + closeTo(_testCameraBounds.southwest.longitude, latLngThreshold), + ), + ); case CameraUpdateType.newLatLngZoom: - expect(currentPosition.target.latitude, - wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold))); - expect(currentPosition.target.longitude, - wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold))); + expect( + currentPosition.target.latitude, + wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold)), + ); + expect( + currentPosition.target.longitude, + wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold)), + ); expect(currentPosition.zoom, wrapMatcher(equals(_kTestCameraZoomLevel))); case CameraUpdateType.scrollBy: // For scrollBy, just check that the location has changed. if (oldPosition != null) { - expect(currentPosition.target.latitude, - isNot(equals(oldPosition.target.latitude))); - expect(currentPosition.target.longitude, - isNot(equals(oldPosition.target.longitude))); + expect( + currentPosition.target.latitude, + isNot(equals(oldPosition.target.latitude)), + ); + expect( + currentPosition.target.longitude, + isNot(equals(oldPosition.target.longitude)), + ); } case CameraUpdateType.zoomBy: - expect(currentPosition.zoom, - wrapMatcher(equals(_kInitialZoomLevel + _kTestZoomByAmount))); + expect( + currentPosition.zoom, + wrapMatcher(equals(_kInitialZoomLevel + _kTestZoomByAmount)), + ); case CameraUpdateType.zoomTo: expect(currentPosition.zoom, wrapMatcher(equals(_kTestCameraZoomLevel))); case CameraUpdateType.zoomIn: diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/animate_camera.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/animate_camera.dart index ed4c744c48b..a5a83a95059 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/animate_camera.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/animate_camera.dart @@ -12,7 +12,7 @@ import 'page.dart'; class AnimateCameraPage extends GoogleMapExampleAppPage { const AnimateCameraPage({Key? key}) - : super(const Icon(Icons.map), 'Camera control, animated', key: key); + : super(const Icon(Icons.map), 'Camera control, animated', key: key); @override Widget build(BuildContext context) { @@ -40,9 +40,10 @@ class AnimateCameraState extends State { void _toggleAnimationDuration() { setState(() { - _cameraUpdateAnimationDuration = _cameraUpdateAnimationDuration != null - ? null - : const Duration(seconds: _durationSeconds); + _cameraUpdateAnimationDuration = + _cameraUpdateAnimationDuration != null + ? null + : const Duration(seconds: _durationSeconds); }); } @@ -58,8 +59,9 @@ class AnimateCameraState extends State { height: 200.0, child: ExampleGoogleMap( onMapCreated: _onMapCreated, - initialCameraPosition: - const CameraPosition(target: LatLng(0.0, 0.0)), + initialCameraPosition: const CameraPosition( + target: LatLng(0.0, 0.0), + ), ), ), ), @@ -138,10 +140,7 @@ class AnimateCameraState extends State { TextButton( onPressed: () { mapController?.animateCamera( - CameraUpdate.zoomBy( - -0.5, - const Offset(30.0, 20.0), - ), + CameraUpdate.zoomBy(-0.5, const Offset(30.0, 20.0)), duration: _cameraUpdateAnimationDuration, ); }, @@ -190,10 +189,7 @@ class AnimateCameraState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text( - 'With 10 second duration', - textAlign: TextAlign.right, - ), + const Text('With 10 second duration', textAlign: TextAlign.right), const SizedBox(width: 5), Switch( value: _cameraUpdateAnimationDuration != null, diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/clustering.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/clustering.dart index 1cd95118eb1..4a04ec52b53 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/clustering.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/clustering.dart @@ -14,7 +14,7 @@ import 'page.dart'; class ClusteringPage extends GoogleMapExampleAppPage { /// Default Constructor. const ClusteringPage({Key? key}) - : super(const Icon(Icons.place), 'Manage clustering', key: key); + : super(const Icon(Icons.place), 'Manage clustering', key: key); @override Widget build(BuildContext context) { @@ -101,8 +101,9 @@ class ClusteringBodyState extends State { setState(() { final MarkerId? previousMarkerId = selectedMarker; if (previousMarkerId != null && markers.containsKey(previousMarkerId)) { - final Marker resetOld = markers[previousMarkerId]! - .copyWith(iconParam: BitmapDescriptor.defaultMarker); + final Marker resetOld = markers[previousMarkerId]!.copyWith( + iconParam: BitmapDescriptor.defaultMarker, + ); markers[previousMarkerId] = resetOld; } selectedMarker = markerId; @@ -124,14 +125,16 @@ class ClusteringBodyState extends State { final String clusterManagerIdVal = 'cluster_manager_id_$_clusterManagerIdCounter'; _clusterManagerIdCounter++; - final ClusterManagerId clusterManagerId = - ClusterManagerId(clusterManagerIdVal); + final ClusterManagerId clusterManagerId = ClusterManagerId( + clusterManagerIdVal, + ); final ClusterManager clusterManager = ClusterManager( clusterManagerId: clusterManagerId, - onClusterTap: (Cluster cluster) => setState(() { - lastCluster = cluster; - }), + onClusterTap: + (Cluster cluster) => setState(() { + lastCluster = cluster; + }), ); setState(() { @@ -143,8 +146,10 @@ class ClusteringBodyState extends State { void _removeClusterManager(ClusterManager clusterManager) { setState(() { // Remove markers managed by cluster manager to be removed. - markers.removeWhere((MarkerId key, Marker marker) => - marker.clusterManagerId == clusterManager.clusterManagerId); + markers.removeWhere( + (MarkerId key, Marker marker) => + marker.clusterManagerId == clusterManager.clusterManagerId, + ); // Remove cluster manager. clusterManagers.remove(clusterManager.clusterManagerId); }); @@ -157,8 +162,9 @@ class ClusteringBodyState extends State { _markerIdCounter++; final MarkerId markerId = MarkerId(markerIdVal); - final int clusterManagerIndex = - clusterManagers.values.toList().indexOf(clusterManager); + final int clusterManagerIndex = clusterManagers.values.toList().indexOf( + clusterManager, + ); // Add additional offset to longitude for each cluster manager to space // out markers in different cluster managers. @@ -197,9 +203,10 @@ class ClusteringBodyState extends State { final Marker marker = markers[markerId]!; final double current = marker.alpha; markers[markerId] = marker.copyWith( - alphaParam: current == _fullyVisibleAlpha - ? _halfVisibleAlpha - : _fullyVisibleAlpha, + alphaParam: + current == _fullyVisibleAlpha + ? _halfVisibleAlpha + : _fullyVisibleAlpha, ); } setState(() {}); @@ -224,15 +231,18 @@ class ClusteringBodyState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ TextButton( - onPressed: clusterManagers.length >= _clusterManagerMaxCount - ? null - : () => _addClusterManager(), + onPressed: + clusterManagers.length >= _clusterManagerMaxCount + ? null + : () => _addClusterManager(), child: const Text('Add cluster manager'), ), TextButton( - onPressed: clusterManagers.isEmpty - ? null - : () => _removeClusterManager(clusterManagers.values.last), + onPressed: + clusterManagers.isEmpty + ? null + : () => + _removeClusterManager(clusterManagers.values.last), child: const Text('Remove cluster manager'), ), ], @@ -252,14 +262,15 @@ class ClusteringBodyState extends State { alignment: WrapAlignment.spaceEvenly, children: [ TextButton( - onPressed: selectedId == null - ? null - : () { - _remove(selectedId); - setState(() { - selectedMarker = null; - }); - }, + onPressed: + selectedId == null + ? null + : () { + _remove(selectedId); + setState(() { + selectedMarker = null; + }); + }, child: const Text('Remove selected marker'), ), TextButton( @@ -270,9 +281,11 @@ class ClusteringBodyState extends State { ), if (lastCluster != null) Padding( - padding: const EdgeInsets.all(10), - child: Text( - 'Cluster with ${lastCluster!.count} markers clicked at ${lastCluster!.position}')), + padding: const EdgeInsets.all(10), + child: Text( + 'Cluster with ${lastCluster!.count} markers clicked at ${lastCluster!.position}', + ), + ), ], ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/custom_marker_icon.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/custom_marker_icon.dart index 8940762f02e..02daad7a52e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/custom_marker_icon.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/custom_marker_icon.dart @@ -15,12 +15,14 @@ Future createCustomMarkerIconImage({required Size size}) async { painter.paint(canvas, size); - final ui.Image image = await recorder - .endRecording() - .toImage(size.width.floor(), size.height.floor()); - - final ByteData? bytes = - await image.toByteData(format: ui.ImageByteFormat.png); + final ui.Image image = await recorder.endRecording().toImage( + size.width.floor(), + size.height.floor(), + ); + + final ByteData? bytes = await image.toByteData( + format: ui.ImageByteFormat.png, + ); return bytes!; } @@ -34,10 +36,7 @@ class _MarkerPainter extends CustomPainter { ); // Draw radial gradient - canvas.drawRect( - rect, - Paint()..shader = gradient.createShader(rect), - ); + canvas.drawRect(rect, Paint()..shader = gradient.createShader(rect)); // Draw diagonal black line canvas.drawLine( diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart index e712208421c..5bed583ceac 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/example_google_map.dart @@ -16,10 +16,7 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf /// Controller for a single ExampleGoogleMap instance running on the host platform. class ExampleGoogleMapController { - ExampleGoogleMapController._( - this._googleMapState, { - required this.mapId, - }) { + ExampleGoogleMapController._(this._googleMapState, {required this.mapId}) { _connectStreams(mapId); } @@ -36,10 +33,7 @@ class ExampleGoogleMapController { _ExampleGoogleMapState googleMapState, ) async { await GoogleMapsFlutterPlatform.instance.init(id); - return ExampleGoogleMapController._( - googleMapState, - mapId: id, - ); + return ExampleGoogleMapController._(googleMapState, mapId: id); } final _ExampleGoogleMapState _googleMapState; @@ -51,8 +45,12 @@ class ExampleGoogleMapController { .listen((_) => _googleMapState.widget.onCameraMoveStarted!()); } if (_googleMapState.widget.onCameraMove != null) { - GoogleMapsFlutterPlatform.instance.onCameraMove(mapId: mapId).listen( - (CameraMoveEvent e) => _googleMapState.widget.onCameraMove!(e.value)); + GoogleMapsFlutterPlatform.instance + .onCameraMove(mapId: mapId) + .listen( + (CameraMoveEvent e) => + _googleMapState.widget.onCameraMove!(e.value), + ); } if (_googleMapState.widget.onCameraIdle != null) { GoogleMapsFlutterPlatform.instance @@ -62,17 +60,29 @@ class ExampleGoogleMapController { GoogleMapsFlutterPlatform.instance .onMarkerTap(mapId: mapId) .listen((MarkerTapEvent e) => _googleMapState.onMarkerTap(e.value)); - GoogleMapsFlutterPlatform.instance.onMarkerDragStart(mapId: mapId).listen( - (MarkerDragStartEvent e) => - _googleMapState.onMarkerDragStart(e.value, e.position)); - GoogleMapsFlutterPlatform.instance.onMarkerDrag(mapId: mapId).listen( - (MarkerDragEvent e) => - _googleMapState.onMarkerDrag(e.value, e.position)); - GoogleMapsFlutterPlatform.instance.onMarkerDragEnd(mapId: mapId).listen( - (MarkerDragEndEvent e) => - _googleMapState.onMarkerDragEnd(e.value, e.position)); - GoogleMapsFlutterPlatform.instance.onInfoWindowTap(mapId: mapId).listen( - (InfoWindowTapEvent e) => _googleMapState.onInfoWindowTap(e.value)); + GoogleMapsFlutterPlatform.instance + .onMarkerDragStart(mapId: mapId) + .listen( + (MarkerDragStartEvent e) => + _googleMapState.onMarkerDragStart(e.value, e.position), + ); + GoogleMapsFlutterPlatform.instance + .onMarkerDrag(mapId: mapId) + .listen( + (MarkerDragEvent e) => + _googleMapState.onMarkerDrag(e.value, e.position), + ); + GoogleMapsFlutterPlatform.instance + .onMarkerDragEnd(mapId: mapId) + .listen( + (MarkerDragEndEvent e) => + _googleMapState.onMarkerDragEnd(e.value, e.position), + ); + GoogleMapsFlutterPlatform.instance + .onInfoWindowTap(mapId: mapId) + .listen( + (InfoWindowTapEvent e) => _googleMapState.onInfoWindowTap(e.value), + ); GoogleMapsFlutterPlatform.instance .onPolylineTap(mapId: mapId) .listen((PolylineTapEvent e) => _googleMapState.onPolylineTap(e.value)); @@ -82,14 +92,20 @@ class ExampleGoogleMapController { GoogleMapsFlutterPlatform.instance .onCircleTap(mapId: mapId) .listen((CircleTapEvent e) => _googleMapState.onCircleTap(e.value)); - GoogleMapsFlutterPlatform.instance.onGroundOverlayTap(mapId: mapId).listen( - (GroundOverlayTapEvent e) => - _googleMapState.onGroundOverlayTap(e.value)); + GoogleMapsFlutterPlatform.instance + .onGroundOverlayTap(mapId: mapId) + .listen( + (GroundOverlayTapEvent e) => + _googleMapState.onGroundOverlayTap(e.value), + ); GoogleMapsFlutterPlatform.instance .onTap(mapId: mapId) .listen((MapTapEvent e) => _googleMapState.onTap(e.position)); - GoogleMapsFlutterPlatform.instance.onLongPress(mapId: mapId).listen( - (MapLongPressEvent e) => _googleMapState.onLongPress(e.position)); + GoogleMapsFlutterPlatform.instance + .onLongPress(mapId: mapId) + .listen( + (MapLongPressEvent e) => _googleMapState.onLongPress(e.position), + ); GoogleMapsFlutterPlatform.instance .onClusterTap(mapId: mapId) .listen((ClusterTapEvent e) => _googleMapState.onClusterTap(e.value)); @@ -97,72 +113,96 @@ class ExampleGoogleMapController { /// Updates configuration options of the map user interface. Future _updateMapConfiguration(MapConfiguration update) { - return GoogleMapsFlutterPlatform.instance - .updateMapConfiguration(update, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateMapConfiguration( + update, + mapId: mapId, + ); } /// Updates marker configuration. Future _updateMarkers(MarkerUpdates markerUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateMarkers(markerUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateMarkers( + markerUpdates, + mapId: mapId, + ); } /// Updates cluster manager configuration. Future _updateClusterManagers( - ClusterManagerUpdates clusterManagerUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateClusterManagers(clusterManagerUpdates, mapId: mapId); + ClusterManagerUpdates clusterManagerUpdates, + ) { + return GoogleMapsFlutterPlatform.instance.updateClusterManagers( + clusterManagerUpdates, + mapId: mapId, + ); } /// Updates ground overlay configuration. Future _updateGroundOverlays( - GroundOverlayUpdates groundOverlayUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateGroundOverlays(groundOverlayUpdates, mapId: mapId); + GroundOverlayUpdates groundOverlayUpdates, + ) { + return GoogleMapsFlutterPlatform.instance.updateGroundOverlays( + groundOverlayUpdates, + mapId: mapId, + ); } /// Updates polygon configuration. Future _updatePolygons(PolygonUpdates polygonUpdates) { - return GoogleMapsFlutterPlatform.instance - .updatePolygons(polygonUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updatePolygons( + polygonUpdates, + mapId: mapId, + ); } /// Updates polyline configuration. Future _updatePolylines(PolylineUpdates polylineUpdates) { - return GoogleMapsFlutterPlatform.instance - .updatePolylines(polylineUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updatePolylines( + polylineUpdates, + mapId: mapId, + ); } /// Updates circle configuration. Future _updateCircles(CircleUpdates circleUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateCircles(circleUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateCircles( + circleUpdates, + mapId: mapId, + ); } /// Updates tile overlays configuration. Future _updateTileOverlays(Set newTileOverlays) { - return GoogleMapsFlutterPlatform.instance - .updateTileOverlays(newTileOverlays: newTileOverlays, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateTileOverlays( + newTileOverlays: newTileOverlays, + mapId: mapId, + ); } /// Clears the tile cache so that all tiles will be requested again from the /// [TileProvider]. Future clearTileCache(TileOverlayId tileOverlayId) async { - return GoogleMapsFlutterPlatform.instance - .clearTileCache(tileOverlayId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.clearTileCache( + tileOverlayId, + mapId: mapId, + ); } /// Starts an animated change of the map camera position. Future animateCamera(CameraUpdate cameraUpdate, {Duration? duration}) { return GoogleMapsFlutterPlatform.instance.animateCameraWithConfiguration( - cameraUpdate, CameraUpdateAnimationConfiguration(duration: duration), - mapId: mapId); + cameraUpdate, + CameraUpdateAnimationConfiguration(duration: duration), + mapId: mapId, + ); } /// Changes the map camera position. Future moveCamera(CameraUpdate cameraUpdate) { - return GoogleMapsFlutterPlatform.instance - .moveCamera(cameraUpdate, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.moveCamera( + cameraUpdate, + mapId: mapId, + ); } /// Return [LatLngBounds] defining the region that is visible in a map. @@ -172,32 +212,42 @@ class ExampleGoogleMapController { /// Return [ScreenCoordinate] of the [LatLng] in the current map view. Future getScreenCoordinate(LatLng latLng) { - return GoogleMapsFlutterPlatform.instance - .getScreenCoordinate(latLng, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.getScreenCoordinate( + latLng, + mapId: mapId, + ); } /// Returns [LatLng] corresponding to the [ScreenCoordinate] in the current map view. Future getLatLng(ScreenCoordinate screenCoordinate) { - return GoogleMapsFlutterPlatform.instance - .getLatLng(screenCoordinate, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.getLatLng( + screenCoordinate, + mapId: mapId, + ); } /// Programmatically show the Info Window for a [Marker]. Future showMarkerInfoWindow(MarkerId markerId) { - return GoogleMapsFlutterPlatform.instance - .showMarkerInfoWindow(markerId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.showMarkerInfoWindow( + markerId, + mapId: mapId, + ); } /// Programmatically hide the Info Window for a [Marker]. Future hideMarkerInfoWindow(MarkerId markerId) { - return GoogleMapsFlutterPlatform.instance - .hideMarkerInfoWindow(markerId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.hideMarkerInfoWindow( + markerId, + mapId: mapId, + ); } /// Returns `true` when the [InfoWindow] is showing, `false` otherwise. Future isMarkerInfoWindowShown(MarkerId markerId) { - return GoogleMapsFlutterPlatform.instance - .isMarkerInfoWindowShown(markerId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.isMarkerInfoWindowShown( + markerId, + mapId: mapId, + ); } /// Returns the current zoom level of the map @@ -412,7 +462,8 @@ class _ExampleGoogleMapState extends State { _mapId, onPlatformViewCreated, widgetConfiguration: MapWidgetConfiguration( - textDirection: widget.layoutDirection ?? + textDirection: + widget.layoutDirection ?? Directionality.maybeOf(context) ?? TextDirection.ltr, initialCameraPosition: widget.initialCameraPosition, @@ -444,8 +495,9 @@ class _ExampleGoogleMapState extends State { @override void dispose() { - _controller.future - .then((ExampleGoogleMapController controller) => controller.dispose()); + _controller.future.then( + (ExampleGoogleMapController controller) => controller.dispose(), + ); super.dispose(); } @@ -475,43 +527,67 @@ class _ExampleGoogleMapState extends State { Future _updateMarkers() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updateMarkers( - MarkerUpdates.from(_markers.values.toSet(), widget.markers))); + unawaited( + controller._updateMarkers( + MarkerUpdates.from(_markers.values.toSet(), widget.markers), + ), + ); _markers = keyByMarkerId(widget.markers); } Future _updateClusterManagers() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updateClusterManagers(ClusterManagerUpdates.from( - _clusterManagers.values.toSet(), widget.clusterManagers))); + unawaited( + controller._updateClusterManagers( + ClusterManagerUpdates.from( + _clusterManagers.values.toSet(), + widget.clusterManagers, + ), + ), + ); _clusterManagers = keyByClusterManagerId(widget.clusterManagers); } Future _updateGroundOverlays() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updateGroundOverlays(GroundOverlayUpdates.from( - _groundOverlays.values.toSet(), widget.groundOverlays))); + unawaited( + controller._updateGroundOverlays( + GroundOverlayUpdates.from( + _groundOverlays.values.toSet(), + widget.groundOverlays, + ), + ), + ); _groundOverlays = keyByGroundOverlayId(widget.groundOverlays); } Future _updatePolygons() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updatePolygons( - PolygonUpdates.from(_polygons.values.toSet(), widget.polygons))); + unawaited( + controller._updatePolygons( + PolygonUpdates.from(_polygons.values.toSet(), widget.polygons), + ), + ); _polygons = keyByPolygonId(widget.polygons); } Future _updatePolylines() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updatePolylines( - PolylineUpdates.from(_polylines.values.toSet(), widget.polylines))); + unawaited( + controller._updatePolylines( + PolylineUpdates.from(_polylines.values.toSet(), widget.polylines), + ), + ); _polylines = keyByPolylineId(widget.polylines); } Future _updateCircles() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updateCircles( - CircleUpdates.from(_circles.values.toSet(), widget.circles))); + unawaited( + controller._updateCircles( + CircleUpdates.from(_circles.values.toSet(), widget.circles), + ), + ); _circles = keyByCircleId(widget.circles); } @@ -523,10 +599,10 @@ class _ExampleGoogleMapState extends State { Future onPlatformViewCreated(int id) async { final ExampleGoogleMapController controller = await ExampleGoogleMapController._init( - id, - widget.initialCameraPosition, - this, - ); + id, + widget.initialCameraPosition, + this, + ); _controller.complete(controller); unawaited(_updateTileOverlays()); widget.onMapCreated?.call(controller); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/ground_overlay.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/ground_overlay.dart index a7029b643f5..d4da5c4ba2b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/ground_overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/ground_overlay.dart @@ -14,7 +14,7 @@ enum _GroundOverlayPlacing { position, bounds } class GroundOverlayPage extends GoogleMapExampleAppPage { const GroundOverlayPage({Key? key}) - : super(const Icon(Icons.map), 'Ground overlay', key: key); + : super(const Icon(Icons.map), 'Ground overlay', key: key); @override Widget build(BuildContext context) { @@ -48,11 +48,13 @@ class GroundOverlayBodyState extends State { // Bounds for demonstranting placing ground overlays with bounds, and // changing bounds. final LatLngBounds _groundOverlayBounds1 = LatLngBounds( - southwest: const LatLng(37.42, -122.09), - northeast: const LatLng(37.423, -122.084)); + southwest: const LatLng(37.42, -122.09), + northeast: const LatLng(37.423, -122.084), + ); final LatLngBounds _groundOverlayBounds2 = LatLngBounds( - southwest: const LatLng(37.421, -122.091), - northeast: const LatLng(37.424, -122.08)); + southwest: const LatLng(37.421, -122.091), + northeast: const LatLng(37.424, -122.08), + ); late LatLngBounds _currentGroundOverlayBounds; Offset _anchor = const Offset(0.5, 0.5); @@ -93,30 +95,31 @@ class GroundOverlayBodyState extends State { _groundOverlayIndex += 1; - final GroundOverlayId id = - GroundOverlayId('ground_overlay_$_groundOverlayIndex'); + final GroundOverlayId id = GroundOverlayId( + 'ground_overlay_$_groundOverlayIndex', + ); final GroundOverlay groundOverlay = switch (_placingType) { _GroundOverlayPlacing.position => GroundOverlay.fromPosition( - groundOverlayId: id, - image: assetMapBitmap, - position: _currentGroundOverlayPos, - width: _dimensions.dx, - height: _dimensions.dy, - anchor: _anchor, - onTap: () { - _onGroundOverlayTapped(); - }, - ), + groundOverlayId: id, + image: assetMapBitmap, + position: _currentGroundOverlayPos, + width: _dimensions.dx, + height: _dimensions.dy, + anchor: _anchor, + onTap: () { + _onGroundOverlayTapped(); + }, + ), _GroundOverlayPlacing.bounds => GroundOverlay.fromBounds( - groundOverlayId: id, - image: assetMapBitmap, - bounds: _currentGroundOverlayBounds, - anchor: _anchor, - onTap: () { - _onGroundOverlayTapped(); - }, - ), + groundOverlayId: id, + image: assetMapBitmap, + bounds: _currentGroundOverlayBounds, + anchor: _anchor, + onTap: () { + _onGroundOverlayTapped(); + }, + ), }; setState(() { @@ -134,9 +137,9 @@ class GroundOverlayBodyState extends State { // Adjusts the bearing by 10 degrees, wrapping around at 360 degrees. // 10 is the increment, 350 degrees of the full circle -10. _groundOverlay = _groundOverlay!.copyWith( - bearingParam: _groundOverlay!.bearing >= 350 - ? 0 - : _groundOverlay!.bearing + 10); + bearingParam: + _groundOverlay!.bearing >= 350 ? 0 : _groundOverlay!.bearing + 10, + ); }); } @@ -145,8 +148,9 @@ class GroundOverlayBodyState extends State { setState(() { final double transparency = _groundOverlay!.transparency == 0.0 ? 0.5 : 0.0; - _groundOverlay = - _groundOverlay!.copyWith(transparencyParam: transparency); + _groundOverlay = _groundOverlay!.copyWith( + transparencyParam: transparency, + ); }); } @@ -154,9 +158,10 @@ class GroundOverlayBodyState extends State { assert(_groundOverlay != null); assert(_placingType == _GroundOverlayPlacing.position); setState(() { - _dimensions = _dimensions == const Offset(1000, 1000) - ? const Offset(1500, 500) - : const Offset(1000, 1000); + _dimensions = + _dimensions == const Offset(1000, 1000) + ? const Offset(1500, 500) + : const Offset(1000, 1000); }); // Re-add the ground overlay to apply the new position, as the position @@ -168,9 +173,10 @@ class GroundOverlayBodyState extends State { assert(_groundOverlay != null); assert(_placingType == _GroundOverlayPlacing.position); setState(() { - _currentGroundOverlayPos = _currentGroundOverlayPos == _groundOverlayPos1 - ? _groundOverlayPos2 - : _groundOverlayPos1; + _currentGroundOverlayPos = + _currentGroundOverlayPos == _groundOverlayPos1 + ? _groundOverlayPos2 + : _groundOverlayPos1; }); // Re-add the ground overlay to apply the new position, as the position @@ -196,8 +202,9 @@ class GroundOverlayBodyState extends State { void _toggleVisible() { assert(_groundOverlay != null); setState(() { - _groundOverlay = - _groundOverlay!.copyWith(visibleParam: !_groundOverlay!.visible); + _groundOverlay = _groundOverlay!.copyWith( + visibleParam: !_groundOverlay!.visible, + ); }); } @@ -212,9 +219,10 @@ class GroundOverlayBodyState extends State { Future _changeType() async { setState(() { - _placingType = _placingType == _GroundOverlayPlacing.position - ? _GroundOverlayPlacing.bounds - : _GroundOverlayPlacing.position; + _placingType = + _placingType == _GroundOverlayPlacing.position + ? _GroundOverlayPlacing.bounds + : _GroundOverlayPlacing.position; }); // Re-add the ground overlay to apply the new position, as the position @@ -225,9 +233,10 @@ class GroundOverlayBodyState extends State { Future _changeAnchor() async { assert(_groundOverlay != null); setState(() { - _anchor = _groundOverlay!.anchor == const Offset(0.5, 0.5) - ? const Offset(1.0, 1.0) - : const Offset(0.5, 0.5); + _anchor = + _groundOverlay!.anchor == const Offset(0.5, 0.5) + ? const Offset(1.0, 1.0) + : const Offset(0.5, 0.5); }); // Re-add the ground overlay to apply the new anchor, as anchor cannot be @@ -294,29 +303,34 @@ class GroundOverlayBodyState extends State { ), TextButton( onPressed: _groundOverlay == null ? null : () => _changeType(), - child: Text(_placingType == _GroundOverlayPlacing.position - ? 'use bounds' - : 'use position'), + child: Text( + _placingType == _GroundOverlayPlacing.position + ? 'use bounds' + : 'use position', + ), ), TextButton( - onPressed: _placingType != _GroundOverlayPlacing.position || - _groundOverlay == null - ? null - : () => _changePosition(), + onPressed: + _placingType != _GroundOverlayPlacing.position || + _groundOverlay == null + ? null + : () => _changePosition(), child: const Text('change position'), ), TextButton( - onPressed: _placingType != _GroundOverlayPlacing.position || - _groundOverlay == null - ? null - : () => _changeDimensions(), + onPressed: + _placingType != _GroundOverlayPlacing.position || + _groundOverlay == null + ? null + : () => _changeDimensions(), child: const Text('change dimensions'), ), TextButton( - onPressed: _placingType != _GroundOverlayPlacing.bounds || - _groundOverlay == null - ? null - : () => _changeBounds(), + onPressed: + _placingType != _GroundOverlayPlacing.bounds || + _groundOverlay == null + ? null + : () => _changeBounds(), child: const Text('change bounds'), ), ], diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/lite_mode.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/lite_mode.dart index f7bead951f5..df92a926018 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/lite_mode.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/lite_mode.dart @@ -10,12 +10,14 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf import 'example_google_map.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class LiteModePage extends GoogleMapExampleAppPage { const LiteModePage({Key? key}) - : super(const Icon(Icons.map), 'Lite mode', key: key); + : super(const Icon(Icons.map), 'Lite mode', key: key); @override Widget build(BuildContext context) { diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart index 06fb6565a80..f07defd05b2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/main.dart @@ -55,11 +55,13 @@ class MapsDemo extends StatelessWidget { const MapsDemo({super.key}); void _pushPage(BuildContext context, GoogleMapExampleAppPage page) { - Navigator.of(context).push(MaterialPageRoute( - builder: (_) => Scaffold( - appBar: AppBar(title: Text(page.title)), - body: page, - ))); + Navigator.of(context).push( + MaterialPageRoute( + builder: + (_) => + Scaffold(appBar: AppBar(title: Text(page.title)), body: page), + ), + ); } @override @@ -68,11 +70,12 @@ class MapsDemo extends StatelessWidget { appBar: AppBar(title: const Text('GoogleMaps examples')), body: ListView.builder( itemCount: _allPages.length, - itemBuilder: (_, int index) => ListTile( - leading: _allPages[index].leading, - title: Text(_allPages[index].title), - onTap: () => _pushPage(context, _allPages[index]), - ), + itemBuilder: + (_, int index) => ListTile( + leading: _allPages[index].leading, + title: Text(_allPages[index].title), + onTap: () => _pushPage(context, _allPages[index]), + ), ), ); } @@ -103,11 +106,15 @@ Future initializeMapRenderer() async { final GoogleMapsFlutterAndroid platform = GoogleMapsFlutterPlatform.instance as GoogleMapsFlutterAndroid; - unawaited(platform - .initializeWithRenderer(AndroidMapRenderer.latest) - .then((AndroidMapRenderer initializedRenderer) => - completer.complete(initializedRenderer)) - .then((_) => platform.warmup())); + unawaited( + platform + .initializeWithRenderer(AndroidMapRenderer.latest) + .then( + (AndroidMapRenderer initializedRenderer) => + completer.complete(initializedRenderer), + ) + .then((_) => platform.warmup()), + ); return completer.future; } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_click.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_click.dart index 4017a9fccce..098f3f1a5a5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_click.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_click.dart @@ -10,12 +10,14 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf import 'example_google_map.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class MapClickPage extends GoogleMapExampleAppPage { const MapClickPage({Key? key}) - : super(const Icon(Icons.mouse), 'Map click', key: key); + : super(const Icon(Icons.mouse), 'Map click', key: key); @override Widget build(BuildContext context) { @@ -58,11 +60,7 @@ class _MapClickBodyState extends State<_MapClickBody> { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), ]; @@ -70,26 +68,28 @@ class _MapClickBodyState extends State<_MapClickBody> { if (mapController != null) { final String lastTap = 'Tap:\n${_lastTap ?? ""}\n'; final String lastLongPress = 'Long press:\n${_lastLongPress ?? ""}'; - columnChildren.add(Center( - child: Text( - lastTap, - textAlign: TextAlign.center, - ))); - columnChildren.add(Center( + columnChildren.add( + Center(child: Text(lastTap, textAlign: TextAlign.center)), + ); + columnChildren.add( + Center( child: Text( - _lastTap != null ? 'Tapped' : '', - textAlign: TextAlign.center, - ))); - columnChildren.add(Center( - child: Text( - lastLongPress, - textAlign: TextAlign.center, - ))); - columnChildren.add(Center( + _lastTap != null ? 'Tapped' : '', + textAlign: TextAlign.center, + ), + ), + ); + columnChildren.add( + Center(child: Text(lastLongPress, textAlign: TextAlign.center)), + ); + columnChildren.add( + Center( child: Text( - _lastLongPress != null ? 'Long pressed' : '', - textAlign: TextAlign.center, - ))); + _lastLongPress != null ? 'Long pressed' : '', + textAlign: TextAlign.center, + ), + ), + ); } return Column( crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_coordinates.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_coordinates.dart index 22f383bd125..361e7a0fa30 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_coordinates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_coordinates.dart @@ -10,12 +10,14 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf import 'example_google_map.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class MapCoordinatesPage extends GoogleMapExampleAppPage { const MapCoordinatesPage({Key? key}) - : super(const Icon(Icons.map), 'Map coordinates', key: key); + : super(const Icon(Icons.map), 'Map coordinates', key: key); @override Widget build(BuildContext context) { @@ -58,26 +60,21 @@ class _MapCoordinatesBodyState extends State<_MapCoordinatesBody> { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), if (mapController != null) Center( - child: Text('VisibleRegion:' - '\nnortheast: ${_visibleRegion.northeast},' - '\nsouthwest: ${_visibleRegion.southwest}'), + child: Text( + 'VisibleRegion:' + '\nnortheast: ${_visibleRegion.northeast},' + '\nsouthwest: ${_visibleRegion.southwest}', + ), ), // Add a block at the bottom of this list to allow validation that the visible region of the map // does not change when scrolled under the safe view on iOS. // https://github.com/flutter/flutter/issues/107913 - const SizedBox( - width: 300, - height: 1000, - ), + const SizedBox(width: 300, height: 1000), ], ), ); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart index 984e32a8ea5..20352c1c054 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_map_id.dart @@ -14,7 +14,7 @@ import 'page.dart'; class MapIdPage extends GoogleMapExampleAppPage { const MapIdPage({Key? key}) - : super(const Icon(Icons.map), 'Cloud-based maps styling', key: key); + : super(const Icon(Icons.map), 'Cloud-based maps styling', key: key); @override Widget build(BuildContext context) { @@ -41,10 +41,11 @@ class MapIdBodyState extends State { @override void initState() { - initializeMapRenderer() - .then((AndroidMapRenderer? initializedRenderer) => setState(() { - _initializedRenderer = initializedRenderer; - })); + initializeMapRenderer().then( + (AndroidMapRenderer? initializedRenderer) => setState(() { + _initializedRenderer = initializedRenderer; + }), + ); super.initState(); } @@ -86,35 +87,30 @@ class MapIdBodyState extends State { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), Padding( - padding: const EdgeInsets.all(10.0), - child: TextField( - controller: _mapIdController, - decoration: const InputDecoration( - hintText: 'Map Id', - ), - )), + padding: const EdgeInsets.all(10.0), + child: TextField( + controller: _mapIdController, + decoration: const InputDecoration(hintText: 'Map Id'), + ), + ), Padding( - padding: const EdgeInsets.all(10.0), - child: ElevatedButton( - onPressed: () => _setMapId(), - child: const Text( - 'Press to use specified map Id', - ), - )), + padding: const EdgeInsets.all(10.0), + child: ElevatedButton( + onPressed: () => _setMapId(), + child: const Text('Press to use specified map Id'), + ), + ), if (_initializedRenderer != AndroidMapRenderer.latest) Padding( padding: const EdgeInsets.all(10.0), child: Text( - 'On Android, Cloud-based maps styling only works with "latest" renderer.\n\n' - 'Current initialized renderer is "${_getInitializedsRendererType()}".'), + 'On Android, Cloud-based maps styling only works with "latest" renderer.\n\n' + 'Current initialized renderer is "${_getInitializedsRendererType()}".', + ), ), ]; diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_ui.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_ui.dart index 105676da9ed..6541143d22d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_ui.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/map_ui.dart @@ -18,7 +18,7 @@ final LatLngBounds sydneyBounds = LatLngBounds( class MapUiPage extends GoogleMapExampleAppPage { const MapUiPage({Key? key}) - : super(const Icon(Icons.map), 'User interface', key: key); + : super(const Icon(Icons.map), 'User interface', key: key); @override Widget build(BuildContext context) { @@ -103,9 +103,10 @@ class MapUiBodyState extends State { ), onPressed: () { setState(() { - _cameraTargetBounds = _cameraTargetBounds.bounds == null - ? CameraTargetBounds(sydneyBounds) - : CameraTargetBounds.unbounded; + _cameraTargetBounds = + _cameraTargetBounds.bounds == null + ? CameraTargetBounds(sydneyBounds) + : CameraTargetBounds.unbounded; }); }, ); @@ -113,14 +114,15 @@ class MapUiBodyState extends State { Widget _zoomBoundsToggler() { return TextButton( - child: Text(_minMaxZoomPreference.minZoom == null - ? 'bound zoom' - : 'release zoom'), + child: Text( + _minMaxZoomPreference.minZoom == null ? 'bound zoom' : 'release zoom', + ), onPressed: () { setState(() { - _minMaxZoomPreference = _minMaxZoomPreference.minZoom == null - ? const MinMaxZoomPreference(12.0, 16.0) - : MinMaxZoomPreference.unbounded; + _minMaxZoomPreference = + _minMaxZoomPreference.minZoom == null + ? const MinMaxZoomPreference(12.0, 16.0) + : MinMaxZoomPreference.unbounded; }); }, ); @@ -185,8 +187,9 @@ class MapUiBodyState extends State { Widget _zoomControlsToggler() { return TextButton( - child: - Text('${_zoomControlsEnabled ? 'disable' : 'enable'} zoom controls'), + child: Text( + '${_zoomControlsEnabled ? 'disable' : 'enable'} zoom controls', + ), onPressed: () { setState(() { _zoomControlsEnabled = !_zoomControlsEnabled; @@ -209,7 +212,8 @@ class MapUiBodyState extends State { Widget _myLocationToggler() { return TextButton( child: Text( - '${_myLocationEnabled ? 'disable' : 'enable'} my location marker'), + '${_myLocationEnabled ? 'disable' : 'enable'} my location marker', + ), onPressed: () { setState(() { _myLocationEnabled = !_myLocationEnabled; @@ -221,7 +225,8 @@ class MapUiBodyState extends State { Widget _myLocationButtonToggler() { return TextButton( child: Text( - '${_myLocationButtonEnabled ? 'disable' : 'enable'} my location button'), + '${_myLocationButtonEnabled ? 'disable' : 'enable'} my location button', + ), onPressed: () { setState(() { _myLocationButtonEnabled = !_myLocationButtonEnabled; @@ -286,11 +291,7 @@ class MapUiBodyState extends State { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), ]; @@ -302,8 +303,9 @@ class MapUiBodyState extends State { children: [ Text('camera bearing: ${_position.bearing}'), Text( - 'camera target: ${_position.target.latitude.toStringAsFixed(4)},' - '${_position.target.longitude.toStringAsFixed(4)}'), + 'camera target: ${_position.target.latitude.toStringAsFixed(4)},' + '${_position.target.longitude.toStringAsFixed(4)}', + ), Text('camera zoom: ${_position.zoom}'), Text('camera tilt: ${_position.tilt}'), Text(_isMoving ? '(Camera moving)' : '(Camera idle)'), diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/marker_icons.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/marker_icons.dart index df4f79205e8..2b18c56c60e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/marker_icons.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/marker_icons.dart @@ -17,7 +17,7 @@ import 'page.dart'; class MarkerIconsPage extends GoogleMapExampleAppPage { const MarkerIconsPage({Key? key}) - : super(const Icon(Icons.image), 'Marker icons', key: key); + : super(const Icon(Icons.image), 'Marker icons', key: key); @override Widget build(BuildContext context) { @@ -34,13 +34,7 @@ class MarkerIconsBody extends StatefulWidget { const LatLng _kMapCenter = LatLng(52.4478, -3.5402); -enum _MarkerSizeOption { - original, - width30, - height40, - size30x60, - size120x60, -} +enum _MarkerSizeOption { original, width30, height40, size30x60, size120x60 } class MarkerIconsBodyState extends State { final Size _markerAssetImageSize = const Size(48, 48); @@ -63,75 +57,82 @@ class MarkerIconsBodyState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Column(children: [ - Center( - child: SizedBox( - width: 350.0, - height: 300.0, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition( - target: _kMapCenter, - zoom: 7.0, + Column( + children: [ + Center( + child: SizedBox( + width: 350.0, + height: 300.0, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: _kMapCenter, + zoom: 7.0, + ), + markers: _markers, + onMapCreated: _onMapCreated, ), - markers: _markers, - onMapCreated: _onMapCreated, ), ), - ), - TextButton( - onPressed: () => _toggleScaling(context), - child: Text(_scalingEnabled - ? 'Disable auto scaling' - : 'Enable auto scaling'), - ), - if (_scalingEnabled) ...[ - Container( - width: referenceSize.width, - height: referenceSize.height, - decoration: BoxDecoration( - border: Border.all(), + TextButton( + onPressed: () => _toggleScaling(context), + child: Text( + _scalingEnabled + ? 'Disable auto scaling' + : 'Enable auto scaling', ), ), - Text( - 'Reference box with size of ${referenceSize.width} x ${referenceSize.height} in logical pixels.'), - const SizedBox(height: 10), - Image.asset( - 'assets/red_square.png', - scale: _mipMapsEnabled ? null : 1.0, - ), - const Text('Asset image rendered with flutter'), - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text('Marker size:'), - const SizedBox(width: 10), - DropdownButton<_MarkerSizeOption>( - value: _currentSizeOption, - onChanged: (_MarkerSizeOption? newValue) { - if (newValue != null) { - setState(() { - _currentSizeOption = newValue; - _updateMarkerImages(context); - }); - } - }, - items: - _MarkerSizeOption.values.map((_MarkerSizeOption option) { - return DropdownMenuItem<_MarkerSizeOption>( - value: option, - child: Text(_getMarkerSizeOptionName(option)), - ); - }).toList(), - ) - ], + if (_scalingEnabled) ...[ + Container( + width: referenceSize.width, + height: referenceSize.height, + decoration: BoxDecoration(border: Border.all()), + ), + Text( + 'Reference box with size of ${referenceSize.width} x ${referenceSize.height} in logical pixels.', + ), + const SizedBox(height: 10), + Image.asset( + 'assets/red_square.png', + scale: _mipMapsEnabled ? null : 1.0, + ), + const Text('Asset image rendered with flutter'), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Marker size:'), + const SizedBox(width: 10), + DropdownButton<_MarkerSizeOption>( + value: _currentSizeOption, + onChanged: (_MarkerSizeOption? newValue) { + if (newValue != null) { + setState(() { + _currentSizeOption = newValue; + _updateMarkerImages(context); + }); + } + }, + items: + _MarkerSizeOption.values.map(( + _MarkerSizeOption option, + ) { + return DropdownMenuItem<_MarkerSizeOption>( + value: option, + child: Text(_getMarkerSizeOptionName(option)), + ); + }).toList(), + ), + ], + ), + ], + TextButton( + onPressed: () => _toggleMipMaps(context), + child: Text( + _mipMapsEnabled ? 'Disable mipmaps' : 'Enable mipmaps', + ), ), ], - TextButton( - onPressed: () => _toggleMipMaps(context), - child: Text(_mipMapsEnabled ? 'Disable mipmaps' : 'Enable mipmaps'), - ), - ]) + ), ], ); } @@ -179,12 +180,15 @@ class MarkerIconsBodyState extends State { if (width != null && height != null) { return Size(width, height); } else if (width != null) { - return Size(width, - width * _markerAssetImageSize.height / _markerAssetImageSize.width); + return Size( + width, + width * _markerAssetImageSize.height / _markerAssetImageSize.width, + ); } else if (height != null) { return Size( - height * _markerAssetImageSize.width / _markerAssetImageSize.height, - height); + height * _markerAssetImageSize.width / _markerAssetImageSize.height, + height, + ); } else { return _markerAssetImageSize; } @@ -207,8 +211,10 @@ class MarkerIconsBodyState extends State { } Marker _createAssetMarker(int index) { - final LatLng position = - LatLng(_kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude - 1); + final LatLng position = LatLng( + _kMapCenter.latitude - (index * 0.5), + _kMapCenter.longitude - 1, + ); return Marker( markerId: MarkerId('marker_asset_$index'), @@ -218,8 +224,10 @@ class MarkerIconsBodyState extends State { } Marker _createBytesMarker(int index) { - final LatLng position = - LatLng(_kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude + 1); + final LatLng position = LatLng( + _kMapCenter.latitude - (index * 0.5), + _kMapCenter.longitude + 1, + ); return Marker( markerId: MarkerId('marker_bytes_$index'), @@ -253,9 +261,7 @@ class MarkerIconsBodyState extends State { AssetMapBitmap assetMapBitmap; if (_mipMapsEnabled) { final ImageConfiguration imageConfiguration = - createLocalImageConfiguration( - context, - ); + createLocalImageConfiguration(context); assetMapBitmap = await AssetMapBitmap.create( imageConfiguration, @@ -282,16 +288,18 @@ class MarkerIconsBodyState extends State { } Future _updateMarkerBytesImage(BuildContext context) async { - final double? devicePixelRatio = - MediaQuery.maybeDevicePixelRatioOf(context); + final double? devicePixelRatio = MediaQuery.maybeDevicePixelRatioOf( + context, + ); final Size bitmapLogicalSize = _getMarkerReferenceSize(); final double? imagePixelRatio = _scalingEnabled ? devicePixelRatio : null; // Create canvasSize with physical marker size final Size canvasSize = Size( - bitmapLogicalSize.width * (imagePixelRatio ?? 1.0), - bitmapLogicalSize.height * (imagePixelRatio ?? 1.0)); + bitmapLogicalSize.width * (imagePixelRatio ?? 1.0), + bitmapLogicalSize.height * (imagePixelRatio ?? 1.0), + ); final ByteData bytes = await createCustomMarkerIconImage(size: canvasSize); @@ -301,12 +309,14 @@ class MarkerIconsBodyState extends State { ? _getCurrentMarkerSize() : (null, null); - final BytesMapBitmap bitmap = BytesMapBitmap(bytes.buffer.asUint8List(), - imagePixelRatio: imagePixelRatio, - width: width, - height: height, - bitmapScaling: - _scalingEnabled ? MapBitmapScaling.auto : MapBitmapScaling.none); + final BytesMapBitmap bitmap = BytesMapBitmap( + bytes.buffer.asUint8List(), + imagePixelRatio: imagePixelRatio, + width: width, + height: height, + bitmapScaling: + _scalingEnabled ? MapBitmapScaling.auto : MapBitmapScaling.none, + ); _updateBytesBitmap(bitmap); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/move_camera.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/move_camera.dart index b1fb55cad54..b41d3d65fae 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/move_camera.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/move_camera.dart @@ -12,7 +12,7 @@ import 'page.dart'; class MoveCameraPage extends GoogleMapExampleAppPage { const MoveCameraPage({Key? key}) - : super(const Icon(Icons.map), 'Camera control', key: key); + : super(const Icon(Icons.map), 'Camera control', key: key); @override Widget build(BuildContext context) { @@ -46,8 +46,9 @@ class MoveCameraState extends State { height: 200.0, child: ExampleGoogleMap( onMapCreated: _onMapCreated, - initialCameraPosition: - const CameraPosition(target: LatLng(0.0, 0.0)), + initialCameraPosition: const CameraPosition( + target: LatLng(0.0, 0.0), + ), ), ), ), @@ -121,50 +122,39 @@ class MoveCameraState extends State { TextButton( onPressed: () { mapController?.moveCamera( - CameraUpdate.zoomBy( - -0.5, - const Offset(30.0, 20.0), - ), + CameraUpdate.zoomBy(-0.5, const Offset(30.0, 20.0)), ); }, child: const Text('zoomBy with focus'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomBy(-0.5), - ); + mapController?.moveCamera(CameraUpdate.zoomBy(-0.5)); }, child: const Text('zoomBy'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomIn(), - ); + mapController?.moveCamera(CameraUpdate.zoomIn()); }, child: const Text('zoomIn'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomOut(), - ); + mapController?.moveCamera(CameraUpdate.zoomOut()); }, child: const Text('zoomOut'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomTo(16.0), - ); + mapController?.moveCamera(CameraUpdate.zoomTo(16.0)); }, child: const Text('zoomTo'), ), ], ), ], - ) + ), ], ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/padding.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/padding.dart index bfddb167d43..aadac26f96b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/padding.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/padding.dart @@ -12,7 +12,7 @@ import 'page.dart'; class PaddingPage extends GoogleMapExampleAppPage { const PaddingPage({Key? key}) - : super(const Icon(Icons.map), 'Add padding to the map', key: key); + : super(const Icon(Icons.map), 'Add padding to the map', key: key); @override Widget build(BuildContext context) { @@ -49,11 +49,7 @@ class MarkerIconsBodyState extends State { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), const Padding( @@ -97,9 +93,7 @@ class MarkerIconsBodyState extends State { controller: _topController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Top', - ), + decoration: const InputDecoration(hintText: 'Top'), ), ), const Spacer(), @@ -109,9 +103,7 @@ class MarkerIconsBodyState extends State { controller: _bottomController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Bottom', - ), + decoration: const InputDecoration(hintText: 'Bottom'), ), ), const Spacer(), @@ -121,9 +113,7 @@ class MarkerIconsBodyState extends State { controller: _leftController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Left', - ), + decoration: const InputDecoration(hintText: 'Left'), ), ), const Spacer(), @@ -133,9 +123,7 @@ class MarkerIconsBodyState extends State { controller: _rightController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Right', - ), + decoration: const InputDecoration(hintText: 'Right'), ), ), ], @@ -154,10 +142,11 @@ class MarkerIconsBodyState extends State { onPressed: () { setState(() { _padding = EdgeInsets.fromLTRB( - double.tryParse(_leftController.value.text) ?? 0, - double.tryParse(_topController.value.text) ?? 0, - double.tryParse(_rightController.value.text) ?? 0, - double.tryParse(_bottomController.value.text) ?? 0); + double.tryParse(_leftController.value.text) ?? 0, + double.tryParse(_topController.value.text) ?? 0, + double.tryParse(_rightController.value.text) ?? 0, + double.tryParse(_bottomController.value.text) ?? 0, + ); }); }, ), @@ -172,7 +161,7 @@ class MarkerIconsBodyState extends State { _padding = EdgeInsets.zero; }); }, - ) + ), ], ), ); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_circle.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_circle.dart index 29be7442965..00092afab7a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_circle.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_circle.dart @@ -12,7 +12,7 @@ import 'page.dart'; class PlaceCirclePage extends GoogleMapExampleAppPage { const PlaceCirclePage({Key? key}) - : super(const Icon(Icons.linear_scale), 'Place circle', key: key); + : super(const Icon(Icons.linear_scale), 'Place circle', key: key); @override Widget build(BuildContext context) { @@ -108,9 +108,7 @@ class PlaceCircleBodyState extends State { void _toggleVisible(CircleId circleId) { final Circle circle = circles[circleId]!; setState(() { - circles[circleId] = circle.copyWith( - visibleParam: !circle.visible, - ); + circles[circleId] = circle.copyWith(visibleParam: !circle.visible); }); } @@ -171,20 +169,19 @@ class PlaceCircleBodyState extends State { children: [ Column( children: [ + TextButton(onPressed: _add, child: const Text('add')), TextButton( - onPressed: _add, - child: const Text('add'), - ), - TextButton( - onPressed: (selectedId == null) - ? null - : () => _remove(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _remove(selectedId), child: const Text('remove'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleVisible(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleVisible(selectedId), child: const Text('toggle visible'), ), ], @@ -192,27 +189,30 @@ class PlaceCircleBodyState extends State { Column( children: [ TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeStrokeWidth(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeStrokeWidth(selectedId), child: const Text('change stroke width'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeStrokeColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeStrokeColor(selectedId), child: const Text('change stroke color'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeFillColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeFillColor(selectedId), child: const Text('change fill color'), ), ], - ) + ), ], - ) + ), ], ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_marker.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_marker.dart index 946b3df33cb..9581871fde8 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_marker.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_marker.dart @@ -17,7 +17,7 @@ import 'page.dart'; class PlaceMarkerPage extends GoogleMapExampleAppPage { const PlaceMarkerPage({Key? key}) - : super(const Icon(Icons.place), 'Place marker', key: key); + : super(const Icon(Icons.place), 'Place marker', key: key); @override Widget build(BuildContext context) { @@ -60,8 +60,9 @@ class PlaceMarkerBodyState extends State { setState(() { final MarkerId? previousMarkerId = selectedMarker; if (previousMarkerId != null && markers.containsKey(previousMarkerId)) { - final Marker resetOld = markers[previousMarkerId]! - .copyWith(iconParam: BitmapDescriptor.defaultMarker); + final Marker resetOld = markers[previousMarkerId]!.copyWith( + iconParam: BitmapDescriptor.defaultMarker, + ); markers[previousMarkerId] = resetOld; } selectedMarker = markerId; @@ -90,25 +91,28 @@ class PlaceMarkerBodyState extends State { markerPosition = null; }); await showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - actions: [ - TextButton( - child: const Text('OK'), - onPressed: () => Navigator.of(context).pop(), - ) + context: context, + builder: (BuildContext context) { + return AlertDialog( + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () => Navigator.of(context).pop(), + ), + ], + content: Padding( + padding: const EdgeInsets.symmetric(vertical: 66), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text('Old position: ${tappedMarker.position}'), + Text('New position: $newPosition'), ], - content: Padding( - padding: const EdgeInsets.symmetric(vertical: 66), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text('Old position: ${tappedMarker.position}'), - Text('New position: $newPosition'), - ], - ))); - }); + ), + ), + ); + }, + ); } } @@ -170,9 +174,7 @@ class PlaceMarkerBodyState extends State { final Offset currentAnchor = marker.anchor; final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { - markers[markerId] = marker.copyWith( - anchorParam: newAnchor, - ); + markers[markerId] = marker.copyWith(anchorParam: newAnchor); }); } @@ -182,9 +184,7 @@ class PlaceMarkerBodyState extends State { final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { markers[markerId] = marker.copyWith( - infoWindowParam: marker.infoWindow.copyWith( - anchorParam: newAnchor, - ), + infoWindowParam: marker.infoWindow.copyWith(anchorParam: newAnchor), ); }); } @@ -192,18 +192,14 @@ class PlaceMarkerBodyState extends State { Future _toggleDraggable(MarkerId markerId) async { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - draggableParam: !marker.draggable, - ); + markers[markerId] = marker.copyWith(draggableParam: !marker.draggable); }); } Future _toggleFlat(MarkerId markerId) async { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - flatParam: !marker.flat, - ); + markers[markerId] = marker.copyWith(flatParam: !marker.flat); }); } @@ -212,9 +208,7 @@ class PlaceMarkerBodyState extends State { final String newSnippet = '${marker.infoWindow.snippet!}*'; setState(() { markers[markerId] = marker.copyWith( - infoWindowParam: marker.infoWindow.copyWith( - snippetParam: newSnippet, - ), + infoWindowParam: marker.infoWindow.copyWith(snippetParam: newSnippet), ); }); } @@ -242,9 +236,7 @@ class PlaceMarkerBodyState extends State { Future _toggleVisible(MarkerId markerId) async { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - visibleParam: !marker.visible, - ); + markers[markerId] = marker.copyWith(visibleParam: !marker.visible); }); } @@ -261,9 +253,7 @@ class PlaceMarkerBodyState extends State { void _setMarkerIcon(MarkerId markerId, BitmapDescriptor assetIcon) { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - iconParam: assetIcon, - ); + markers[markerId] = marker.copyWith(iconParam: assetIcon); }); } @@ -276,130 +266,141 @@ class PlaceMarkerBodyState extends State { @override Widget build(BuildContext context) { final MarkerId? selectedId = selectedMarker; - return Stack(children: [ - Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - child: ExampleGoogleMap( - onMapCreated: _onMapCreated, - initialCameraPosition: const CameraPosition( - target: LatLng(-33.852, 151.211), - zoom: 11.0, + return Stack( + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: ExampleGoogleMap( + onMapCreated: _onMapCreated, + initialCameraPosition: const CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, + ), + markers: Set.of(markers.values), ), - markers: Set.of(markers.values), ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - onPressed: _add, - child: const Text('Add'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _remove(selectedId), - child: const Text('Remove'), - ), - ], - ), - Wrap( - alignment: WrapAlignment.spaceEvenly, - children: [ - TextButton( - onPressed: - selectedId == null ? null : () => _changeInfo(selectedId), - child: const Text('change info'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _changeInfoAnchor(selectedId), - child: const Text('change info anchor'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _changeAlpha(selectedId), - child: const Text('change alpha'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _changeAnchor(selectedId), - child: const Text('change anchor'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _toggleDraggable(selectedId), - child: const Text('toggle draggable'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _toggleFlat(selectedId), - child: const Text('toggle flat'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _changePosition(selectedId), - child: const Text('change position'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _changeRotation(selectedId), - child: const Text('change rotation'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _toggleVisible(selectedId), - child: const Text('toggle visible'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _changeZIndex(selectedId), - child: const Text('change zIndex'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () { - _getMarkerIcon(context).then( - (BitmapDescriptor icon) { - _setMarkerIcon(selectedId, icon); + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + TextButton(onPressed: _add, child: const Text('Add')), + TextButton( + onPressed: + selectedId == null ? null : () => _remove(selectedId), + child: const Text('Remove'), + ), + ], + ), + Wrap( + alignment: WrapAlignment.spaceEvenly, + children: [ + TextButton( + onPressed: + selectedId == null ? null : () => _changeInfo(selectedId), + child: const Text('change info'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeInfoAnchor(selectedId), + child: const Text('change info anchor'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeAlpha(selectedId), + child: const Text('change alpha'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeAnchor(selectedId), + child: const Text('change anchor'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _toggleDraggable(selectedId), + child: const Text('toggle draggable'), + ), + TextButton( + onPressed: + selectedId == null ? null : () => _toggleFlat(selectedId), + child: const Text('toggle flat'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changePosition(selectedId), + child: const Text('change position'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeRotation(selectedId), + child: const Text('change rotation'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _toggleVisible(selectedId), + child: const Text('toggle visible'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeZIndex(selectedId), + child: const Text('change zIndex'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () { + _getMarkerIcon(context).then(( + BitmapDescriptor icon, + ) { + _setMarkerIcon(selectedId, icon); + }); }, - ); - }, - child: const Text('set marker icon'), - ), - ], - ), - ], - ), - Visibility( - visible: markerPosition != null, - child: Container( - color: Colors.white70, - height: 30, - padding: const EdgeInsets.only(left: 12, right: 12), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - if (markerPosition == null) - Container() - else - Expanded(child: Text('lat: ${markerPosition!.latitude}')), - if (markerPosition == null) - Container() - else - Expanded(child: Text('lng: ${markerPosition!.longitude}')), - ], + child: const Text('set marker icon'), + ), + ], + ), + ], + ), + Visibility( + visible: markerPosition != null, + child: Container( + color: Colors.white70, + height: 30, + padding: const EdgeInsets.only(left: 12, right: 12), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + if (markerPosition == null) + Container() + else + Expanded(child: Text('lat: ${markerPosition!.latitude}')), + if (markerPosition == null) + Container() + else + Expanded(child: Text('lng: ${markerPosition!.longitude}')), + ], + ), ), ), - ), - ]); + ], + ); } } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polygon.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polygon.dart index a1fdafd7a31..b40e83cec7a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polygon.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polygon.dart @@ -12,7 +12,7 @@ import 'page.dart'; class PlacePolygonPage extends GoogleMapExampleAppPage { const PlacePolygonPage({Key? key}) - : super(const Icon(Icons.linear_scale), 'Place polygon', key: key); + : super(const Icon(Icons.linear_scale), 'Place polygon', key: key); @override Widget build(BuildContext context) { @@ -108,18 +108,14 @@ class PlacePolygonBodyState extends State { void _toggleGeodesic(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = polygon.copyWith( - geodesicParam: !polygon.geodesic, - ); + polygons[polygonId] = polygon.copyWith(geodesicParam: !polygon.geodesic); }); } void _toggleVisible(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = polygon.copyWith( - visibleParam: !polygon.visible, - ); + polygons[polygonId] = polygon.copyWith(visibleParam: !polygon.visible); }); } @@ -153,17 +149,16 @@ class PlacePolygonBodyState extends State { void _addHoles(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = - polygon.copyWith(holesParam: _createHoles(polygonId)); + polygons[polygonId] = polygon.copyWith( + holesParam: _createHoles(polygonId), + ); }); } void _removeHoles(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = polygon.copyWith( - holesParam: >[], - ); + polygons[polygonId] = polygon.copyWith(holesParam: >[]); }); } @@ -197,26 +192,26 @@ class PlacePolygonBodyState extends State { children: [ Column( children: [ + TextButton(onPressed: _add, child: const Text('add')), TextButton( - onPressed: _add, - child: const Text('add'), - ), - TextButton( - onPressed: (selectedId == null) - ? null - : () => _remove(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _remove(selectedId), child: const Text('remove'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleVisible(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleVisible(selectedId), child: const Text('toggle visible'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleGeodesic(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleGeodesic(selectedId), child: const Text('toggle geodesic'), ), ], @@ -224,43 +219,48 @@ class PlacePolygonBodyState extends State { Column( children: [ TextButton( - onPressed: (selectedId == null) - ? null - : (polygons[selectedId]!.holes.isNotEmpty + onPressed: + (selectedId == null) ? null - : () => _addHoles(selectedId)), + : (polygons[selectedId]!.holes.isNotEmpty + ? null + : () => _addHoles(selectedId)), child: const Text('add holes'), ), TextButton( - onPressed: (selectedId == null) - ? null - : (polygons[selectedId]!.holes.isEmpty + onPressed: + (selectedId == null) ? null - : () => _removeHoles(selectedId)), + : (polygons[selectedId]!.holes.isEmpty + ? null + : () => _removeHoles(selectedId)), child: const Text('remove holes'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeWidth(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeWidth(selectedId), child: const Text('change stroke width'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeStrokeColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeStrokeColor(selectedId), child: const Text('change stroke color'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeFillColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeFillColor(selectedId), child: const Text('change fill color'), ), ], - ) + ), ], - ) + ), ], ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart index d008b7d3b97..e0510cd67d4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/place_polyline.dart @@ -13,7 +13,7 @@ import 'page.dart'; class PlacePolylinePage extends GoogleMapExampleAppPage { const PlacePolylinePage({Key? key}) - : super(const Icon(Icons.linear_scale), 'Place polyline', key: key); + : super(const Icon(Icons.linear_scale), 'Place polyline', key: key); @override Widget build(BuildContext context) { @@ -53,7 +53,7 @@ class PlacePolylineBodyState extends State { List jointTypes = [ JointType.mitered, JointType.bevel, - JointType.round + JointType.round, ]; // Values when toggling polyline end cap type @@ -72,7 +72,7 @@ class PlacePolylineBodyState extends State { PatternItem.dash(30.0), PatternItem.gap(20.0), PatternItem.dot, - PatternItem.gap(20.0) + PatternItem.gap(20.0), ], [PatternItem.dash(30.0), PatternItem.gap(20.0)], [PatternItem.dot, PatternItem.gap(10.0)], @@ -235,26 +235,26 @@ class PlacePolylineBodyState extends State { children: [ Column( children: [ + TextButton(onPressed: _add, child: const Text('add')), TextButton( - onPressed: _add, - child: const Text('add'), - ), - TextButton( - onPressed: (selectedId == null) - ? null - : () => _remove(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _remove(selectedId), child: const Text('remove'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleVisible(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleVisible(selectedId), child: const Text('toggle visible'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleGeodesic(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleGeodesic(selectedId), child: const Text('toggle geodesic'), ), ], @@ -262,45 +262,51 @@ class PlacePolylineBodyState extends State { Column( children: [ TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeWidth(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeWidth(selectedId), child: const Text('change width'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeColor(selectedId), child: const Text('change color'), ), TextButton( - onPressed: isIOS || (selectedId == null) - ? null - : () => _changeStartCap(selectedId), + onPressed: + isIOS || (selectedId == null) + ? null + : () => _changeStartCap(selectedId), child: const Text('change start cap [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) - ? null - : () => _changeEndCap(selectedId), + onPressed: + isIOS || (selectedId == null) + ? null + : () => _changeEndCap(selectedId), child: const Text('change end cap [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) - ? null - : () => _changeJointType(selectedId), + onPressed: + isIOS || (selectedId == null) + ? null + : () => _changeJointType(selectedId), child: const Text('change joint type [Android only]'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changePattern(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changePattern(selectedId), child: const Text('change pattern'), ), ], - ) + ), ], - ) + ), ], ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/readme_excerpts.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/readme_excerpts.dart index 97544420da1..68f6f72a9ed 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/readme_excerpts.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/readme_excerpts.dart @@ -39,9 +39,7 @@ class _MyAppState extends State { Widget build(BuildContext context) { return MaterialApp( home: Scaffold( - appBar: AppBar( - title: const Text('README snippet app'), - ), + appBar: AppBar(title: const Text('README snippet app')), body: const Text('See example in main.dart'), ), ); @@ -53,8 +51,9 @@ class _MyAppState extends State { GoogleMapsFlutterPlatform.instance; if (mapsImplementation is GoogleMapsFlutterAndroid) { WidgetsFlutterBinding.ensureInitialized(); - mapRenderer = await mapsImplementation - .initializeWithRenderer(AndroidMapRenderer.latest); + mapRenderer = await mapsImplementation.initializeWithRenderer( + AndroidMapRenderer.latest, + ); } // #enddocregion MapRenderer } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart index a4901f2ce5f..e203fee7a45 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/scrolling_map.dart @@ -16,7 +16,7 @@ const LatLng _center = LatLng(32.080664, 34.9563837); class ScrollingMapPage extends GoogleMapExampleAppPage { const ScrollingMapPage({Key? key}) - : super(const Icon(Icons.map), 'Scrolling map', key: key); + : super(const Icon(Icons.map), 'Scrolling map', key: key); @override Widget build(BuildContext context) { @@ -70,8 +70,9 @@ class ScrollingMapBody extends StatelessWidget { const Text("This map doesn't consume the vertical drags."), const Padding( padding: EdgeInsets.only(bottom: 12.0), - child: - Text('It still gets other gestures (e.g scale or tap).'), + child: Text( + 'It still gets other gestures (e.g scale or tap).', + ), ), Center( child: SizedBox( @@ -85,22 +86,19 @@ class ScrollingMapBody extends StatelessWidget { markers: { Marker( markerId: const MarkerId('test_marker_id'), - position: LatLng( - _center.latitude, - _center.longitude, - ), + position: LatLng(_center.latitude, _center.longitude), infoWindow: const InfoWindow( title: 'An interesting location', snippet: '*', ), ), }, - gestureRecognizers: >{ - Factory( - () => ScaleGestureRecognizer(), - ), - }, + gestureRecognizers: + >{ + Factory( + () => ScaleGestureRecognizer(), + ), + }, ), ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/snapshot.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/snapshot.dart index 56a90a8e49f..1eaef239947 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/snapshot.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/snapshot.dart @@ -12,13 +12,18 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf import 'example_google_map.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class SnapshotPage extends GoogleMapExampleAppPage { const SnapshotPage({Key? key}) - : super(const Icon(Icons.camera_alt), 'Take a snapshot of the map', - key: key); + : super( + const Icon(Icons.camera_alt), + 'Take a snapshot of the map', + key: key, + ); @override Widget build(BuildContext context) { diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/tile_overlay.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/tile_overlay.dart index 9122fda76ce..26bdde9bd69 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/lib/tile_overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/lib/tile_overlay.dart @@ -15,7 +15,7 @@ import 'page.dart'; class TileOverlayPage extends GoogleMapExampleAppPage { const TileOverlayPage({Key? key}) - : super(const Icon(Icons.map), 'Tile overlay', key: key); + : super(const Icon(Icons.map), 'Tile overlay', key: key); @override Widget build(BuildContext context) { @@ -120,34 +120,29 @@ class _DebugTileProvider implements TileProvider { static const int width = 100; static const int height = 100; static final Paint boxPaint = Paint(); - static const TextStyle textStyle = TextStyle( - color: Colors.red, - fontSize: 20, - ); + static const TextStyle textStyle = TextStyle(color: Colors.red, fontSize: 20); @override Future getTile(int x, int y, int? zoom) async { final ui.PictureRecorder recorder = ui.PictureRecorder(); final Canvas canvas = Canvas(recorder); - final TextSpan textSpan = TextSpan( - text: '$x,$y', - style: textStyle, - ); + final TextSpan textSpan = TextSpan(text: '$x,$y', style: textStyle); final TextPainter textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); - textPainter.layout( - maxWidth: width.toDouble(), - ); + textPainter.layout(maxWidth: width.toDouble()); textPainter.paint(canvas, Offset.zero); canvas.drawRect( - Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), boxPaint); + Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), + boxPaint, + ); final ui.Picture picture = recorder.endRecording(); final Uint8List byteData = await picture .toImage(width, height) - .then((ui.Image image) => - image.toByteData(format: ui.ImageByteFormat.png)) + .then( + (ui.Image image) => image.toByteData(format: ui.ImageByteFormat.png), + ) .then((ByteData? byteData) => byteData!.buffer.asUint8List()); return Tile(width, height, byteData); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml index 46b41e3f9f4..11f5f9cf7fe 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the google_maps_flutter plugin. publish_to: none environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" dependencies: cupertino_icons: ^1.0.5 diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/test/example_google_map_test.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/test/example_google_map_test.dart index 57b6d1e2a67..649f1070c28 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/test/example_google_map_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/test/example_google_map_test.dart @@ -75,8 +75,10 @@ void main() { const Marker m1 = Marker(markerId: MarkerId('marker_1')); const Marker m2 = Marker(markerId: MarkerId('marker_2')); const Marker m3 = Marker(markerId: MarkerId('marker_3')); - const Marker m3updated = - Marker(markerId: MarkerId('marker_3'), draggable: true); + const Marker m3updated = Marker( + markerId: MarkerId('marker_3'), + draggable: true, + ); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithObjects(markers: {m1, m2})); @@ -107,16 +109,21 @@ void main() { const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); const Polygon p2 = Polygon(polygonId: PolygonId('polygon_2')); - const Polygon p3 = - Polygon(polygonId: PolygonId('polygon_3'), strokeWidth: 1); - const Polygon p3updated = - Polygon(polygonId: PolygonId('polygon_3'), strokeWidth: 2); + const Polygon p3 = Polygon( + polygonId: PolygonId('polygon_3'), + strokeWidth: 1, + ); + const Polygon p3updated = Polygon( + polygonId: PolygonId('polygon_3'), + strokeWidth: 2, + ); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithObjects(polygons: {p1, p2})); await tester.pumpWidget(_mapWithObjects(polygons: {p1, p3})); - await tester - .pumpWidget(_mapWithObjects(polygons: {p1, p3updated})); + await tester.pumpWidget( + _mapWithObjects(polygons: {p1, p3updated}), + ); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -142,16 +149,21 @@ void main() { const Polyline p1 = Polyline(polylineId: PolylineId('polyline_1')); const Polyline p2 = Polyline(polylineId: PolylineId('polyline_2')); - const Polyline p3 = - Polyline(polylineId: PolylineId('polyline_3'), width: 1); - const Polyline p3updated = - Polyline(polylineId: PolylineId('polyline_3'), width: 2); + const Polyline p3 = Polyline( + polylineId: PolylineId('polyline_3'), + width: 1, + ); + const Polyline p3updated = Polyline( + polylineId: PolylineId('polyline_3'), + width: 2, + ); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithObjects(polylines: {p1, p2})); await tester.pumpWidget(_mapWithObjects(polylines: {p1, p3})); - await tester - .pumpWidget(_mapWithObjects(polylines: {p1, p3updated})); + await tester.pumpWidget( + _mapWithObjects(polylines: {p1, p3updated}), + ); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -163,8 +175,9 @@ void main() { expect(map.polylineUpdates[1].polylinesToChange.isEmpty, true); expect(map.polylineUpdates[1].polylinesToAdd, {p3}); - expect(map.polylineUpdates[1].polylineIdsToRemove, - {p2.polylineId}); + expect(map.polylineUpdates[1].polylineIdsToRemove, { + p2.polylineId, + }); expect(map.polylineUpdates[2].polylinesToChange, {p3updated}); expect(map.polylineUpdates[2].polylinesToAdd.isEmpty, true); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/example/test/fake_google_maps_flutter_platform.dart b/packages/google_maps_flutter/google_maps_flutter_android/example/test/fake_google_maps_flutter_platform.dart index 8568329a6cf..45313164546 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/example/test/fake_google_maps_flutter_platform.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/example/test/fake_google_maps_flutter_platform.dart @@ -138,17 +138,14 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { }) async {} @override - Future setMapStyle( - String? mapStyle, { - required int mapId, - }) async {} + Future setMapStyle(String? mapStyle, {required int mapId}) async {} @override - Future getVisibleRegion({ - required int mapId, - }) async { + Future getVisibleRegion({required int mapId}) async { return LatLngBounds( - southwest: const LatLng(0, 0), northeast: const LatLng(0, 0)); + southwest: const LatLng(0, 0), + northeast: const LatLng(0, 0), + ); } @override @@ -188,16 +185,12 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { } @override - Future getZoomLevel({ - required int mapId, - }) async { + Future getZoomLevel({required int mapId}) async { return 0.0; } @override - Future takeSnapshot({ - required int mapId, - }) async { + Future takeSnapshot({required int mapId}) async { return null; } @@ -293,9 +286,10 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { if (instance == null) { createdIds.add(creationId); mapInstances[creationId] = PlatformMapStateRecorder( - widgetConfiguration: widgetConfiguration, - mapConfiguration: mapConfiguration, - mapObjects: mapObjects); + widgetConfiguration: widgetConfiguration, + mapConfiguration: mapConfiguration, + mapObjects: mapObjects, + ); onPlatformViewCreated(creationId); } return Container(); @@ -317,15 +311,25 @@ class PlatformMapStateRecorder { this.mapObjects = const MapObjects(), this.mapConfiguration = const MapConfiguration(), }) { - clusterManagerUpdates.add(ClusterManagerUpdates.from( - const {}, mapObjects.clusterManagers)); - groundOverlayUpdates.add(GroundOverlayUpdates.from( - const {}, mapObjects.groundOverlays)); + clusterManagerUpdates.add( + ClusterManagerUpdates.from( + const {}, + mapObjects.clusterManagers, + ), + ); + groundOverlayUpdates.add( + GroundOverlayUpdates.from( + const {}, + mapObjects.groundOverlays, + ), + ); markerUpdates.add(MarkerUpdates.from(const {}, mapObjects.markers)); - polygonUpdates - .add(PolygonUpdates.from(const {}, mapObjects.polygons)); - polylineUpdates - .add(PolylineUpdates.from(const {}, mapObjects.polylines)); + polygonUpdates.add( + PolygonUpdates.from(const {}, mapObjects.polygons), + ); + polylineUpdates.add( + PolylineUpdates.from(const {}, mapObjects.polylines), + ); circleUpdates.add(CircleUpdates.from(const {}, mapObjects.circles)); tileOverlaySets.add(mapObjects.tileOverlays); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_map_inspector_android.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_map_inspector_android.dart index 63dd910ce72..35e6affa235 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_map_inspector_android.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/google_map_inspector_android.dart @@ -16,8 +16,8 @@ class GoogleMapsInspectorAndroid extends GoogleMapsInspectorPlatform { /// Creates an inspector API instance for a given map ID from /// [inspectorProvider]. GoogleMapsInspectorAndroid( - MapsInspectorApi? Function(int mapId) inspectorProvider) - : _inspectorProvider = inspectorProvider; + MapsInspectorApi? Function(int mapId) inspectorProvider, + ) : _inspectorProvider = inspectorProvider; final MapsInspectorApi? Function(int mapId) _inspectorProvider; @@ -59,10 +59,13 @@ class GoogleMapsInspectorAndroid extends GoogleMapsInspectorPlatform { } @override - Future getTileOverlayInfo(TileOverlayId tileOverlayId, - {required int mapId}) async { - final PlatformTileLayer? tileInfo = await _inspectorProvider(mapId)! - .getTileOverlayInfo(tileOverlayId.value); + Future getTileOverlayInfo( + TileOverlayId tileOverlayId, { + required int mapId, + }) async { + final PlatformTileLayer? tileInfo = await _inspectorProvider( + mapId, + )!.getTileOverlayInfo(tileOverlayId.value); if (tileInfo == null) { return null; } @@ -84,11 +87,13 @@ class GoogleMapsInspectorAndroid extends GoogleMapsInspectorPlatform { bool supportsGettingGroundOverlayInfo() => true; @override - Future getGroundOverlayInfo(GroundOverlayId groundOverlayId, - {required int mapId}) async { - final PlatformGroundOverlay? groundOverlayInfo = - await _inspectorProvider(mapId)! - .getGroundOverlayInfo(groundOverlayId.value); + Future getGroundOverlayInfo( + GroundOverlayId groundOverlayId, { + required int mapId, + }) async { + final PlatformGroundOverlay? groundOverlayInfo = await _inspectorProvider( + mapId, + )!.getGroundOverlayInfo(groundOverlayId.value); if (groundOverlayInfo == null) { return null; @@ -115,17 +120,24 @@ class GoogleMapsInspectorAndroid extends GoogleMapsInspectorPlatform { transparency: groundOverlayInfo.transparency, visible: groundOverlayInfo.visible, clickable: groundOverlayInfo.clickable, - anchor: - Offset(groundOverlayInfo.anchor!.x, groundOverlayInfo.anchor!.y), + anchor: Offset( + groundOverlayInfo.anchor!.x, + groundOverlayInfo.anchor!.y, + ), ); } else if (bounds != null) { return GroundOverlay.fromBounds( groundOverlayId: groundOverlayId, bounds: LatLngBounds( - southwest: - LatLng(bounds.southwest.latitude, bounds.southwest.longitude), - northeast: - LatLng(bounds.northeast.latitude, bounds.northeast.longitude)), + southwest: LatLng( + bounds.southwest.latitude, + bounds.southwest.longitude, + ), + northeast: LatLng( + bounds.northeast.latitude, + bounds.northeast.longitude, + ), + ), image: dummyImage, zIndex: groundOverlayInfo.zIndex, bearing: groundOverlayInfo.bearing, @@ -168,11 +180,14 @@ class GoogleMapsInspectorAndroid extends GoogleMapsInspectorPlatform { required int mapId, required ClusterManagerId clusterManagerId, }) async { - return (await _inspectorProvider(mapId)! - .getClusters(clusterManagerId.value)) + return (await _inspectorProvider( + mapId, + )!.getClusters(clusterManagerId.value)) // See comment in messages.dart for why the force unwrap is okay. - .map((PlatformCluster? cluster) => - GoogleMapsFlutterAndroid.clusterFromPlatformCluster(cluster!)) + .map( + (PlatformCluster? cluster) => + GoogleMapsFlutterAndroid.clusterFromPlatformCluster(cluster!), + ) .toList(); } 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 e06deb40c93..b00c19dfc0f 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 @@ -52,8 +52,10 @@ enum AndroidMapRenderer { latest, /// Legacy renderer type. - @Deprecated('The legacy renderer is no longer supported by the Google Maps, ' - 'SDK, so requesting it will have no effect.') + @Deprecated( + 'The legacy renderer is no longer supported by the Google Maps, ' + 'SDK, so requesting it will have no effect.', + ) legacy, /// Requests the default map renderer type. @@ -66,8 +68,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { GoogleMapsFlutterAndroid({ @visibleForTesting MapsApi Function(int mapId)? apiProvider, @visibleForTesting MapsInitializerApi? initializerApi, - }) : _apiProvider = apiProvider ?? _productionApiProvider, - _initializerApi = initializerApi ?? MapsInitializerApi(); + }) : _apiProvider = apiProvider ?? _productionApiProvider, + _initializerApi = initializerApi ?? MapsInitializerApi(); /// Registers the Android implementation of GoogleMapsFlutterPlatform. static void registerWith() { @@ -151,9 +153,9 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { StreamController>.broadcast(); // Returns a filtered view of the events in the _controller, by mapId. - Stream> _events(int mapId) => - _mapEventStreamController.stream - .where((MapEvent event) => event.mapId == mapId); + Stream> _events(int mapId) => _mapEventStreamController + .stream + .where((MapEvent event) => event.mapId == mapId); @override Stream onCameraMoveStarted({required int mapId}) { @@ -236,7 +238,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { required int mapId, }) { return _hostApi(mapId).updateMapConfiguration( - _platformMapConfigurationFromMapConfiguration(configuration)); + _platformMapConfigurationFromMapConfiguration(configuration), + ); } @override @@ -245,7 +248,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { required int mapId, }) { return _hostApi(mapId).updateMapConfiguration( - _platformMapConfigurationFromOptionsJson(optionsUpdate)); + _platformMapConfigurationFromOptionsJson(optionsUpdate), + ); } @override @@ -325,11 +329,14 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { }) { final Map? currentTileOverlays = _tileOverlays[mapId]; - final Set previousSet = currentTileOverlays != null - ? currentTileOverlays.values.toSet() - : {}; - final _TileOverlayUpdates updates = - _TileOverlayUpdates.from(previousSet, newTileOverlays); + final Set previousSet = + currentTileOverlays != null + ? currentTileOverlays.values.toSet() + : {}; + final _TileOverlayUpdates updates = _TileOverlayUpdates.from( + previousSet, + newTileOverlays, + ); _tileOverlays[mapId] = keyTileOverlayId(newTileOverlays); return _hostApi(mapId).updateTileOverlays( updates.tileOverlaysToAdd @@ -365,10 +372,12 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { required int mapId, }) { assert( - groundOverlayUpdates.groundOverlaysToAdd.every( - (GroundOverlay groundOverlay) => - groundOverlay.position == null || groundOverlay.width != null), - 'On Android width must be set when position is set for ground overlays.'); + groundOverlayUpdates.groundOverlaysToAdd.every( + (GroundOverlay groundOverlay) => + groundOverlay.position == null || groundOverlay.width != null, + ), + 'On Android width must be set when position is set for ground overlays.', + ); return _hostApi(mapId).updateGroundOverlays( groundOverlayUpdates.groundOverlaysToAdd @@ -392,13 +401,12 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { } @override - Future animateCamera( - CameraUpdate cameraUpdate, { - required int mapId, - }) { + Future animateCamera(CameraUpdate cameraUpdate, {required int mapId}) { return animateCameraWithConfiguration( - cameraUpdate, const CameraUpdateAnimationConfiguration(), - mapId: mapId); + cameraUpdate, + const CameraUpdateAnimationConfiguration(), + mapId: mapId, + ); } @override @@ -408,24 +416,20 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { required int mapId, }) { return _hostApi(mapId).animateCamera( - _platformCameraUpdateFromCameraUpdate(cameraUpdate), - configuration.duration?.inMilliseconds); + _platformCameraUpdateFromCameraUpdate(cameraUpdate), + configuration.duration?.inMilliseconds, + ); } @override - Future moveCamera( - CameraUpdate cameraUpdate, { - required int mapId, - }) { - return _hostApi(mapId) - .moveCamera(_platformCameraUpdateFromCameraUpdate(cameraUpdate)); + Future moveCamera(CameraUpdate cameraUpdate, {required int mapId}) { + return _hostApi( + mapId, + ).moveCamera(_platformCameraUpdateFromCameraUpdate(cameraUpdate)); } @override - Future setMapStyle( - String? mapStyle, { - required int mapId, - }) async { + Future setMapStyle(String? mapStyle, {required int mapId}) async { final bool success = await _hostApi(mapId).setStyle(mapStyle ?? ''); if (!success) { throw const MapStyleException(_setStyleFailureMessage); @@ -433,11 +437,10 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { } @override - Future getVisibleRegion({ - required int mapId, - }) async { + Future getVisibleRegion({required int mapId}) async { return _latLngBoundsFromPlatformLatLngBounds( - await _hostApi(mapId).getVisibleRegion()); + await _hostApi(mapId).getVisibleRegion(), + ); } @override @@ -445,8 +448,11 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { LatLng latLng, { required int mapId, }) async { - return _screenCoordinateFromPlatformPoint(await _hostApi(mapId) - .getScreenCoordinate(_platformLatLngFromLatLng(latLng))); + return _screenCoordinateFromPlatformPoint( + await _hostApi( + mapId, + ).getScreenCoordinate(_platformLatLngFromLatLng(latLng)), + ); } @override @@ -454,23 +460,20 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { ScreenCoordinate screenCoordinate, { required int mapId, }) async { - return _latLngFromPlatformLatLng(await _hostApi(mapId) - .getLatLng(_platformPointFromScreenCoordinate(screenCoordinate))); + return _latLngFromPlatformLatLng( + await _hostApi( + mapId, + ).getLatLng(_platformPointFromScreenCoordinate(screenCoordinate)), + ); } @override - Future showMarkerInfoWindow( - MarkerId markerId, { - required int mapId, - }) { + Future showMarkerInfoWindow(MarkerId markerId, {required int mapId}) { return _hostApi(mapId).showInfoWindow(markerId.value); } @override - Future hideMarkerInfoWindow( - MarkerId markerId, { - required int mapId, - }) { + Future hideMarkerInfoWindow(MarkerId markerId, {required int mapId}) { return _hostApi(mapId).hideInfoWindow(markerId.value); } @@ -483,16 +486,12 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { } @override - Future getZoomLevel({ - required int mapId, - }) { + Future getZoomLevel({required int mapId}) { return _hostApi(mapId).getZoomLevel(); } @override - Future takeSnapshot({ - required int mapId, - }) { + Future takeSnapshot({required int mapId}) { return _hostApi(mapId).takeSnapshot(); } @@ -524,7 +523,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { /// The returned [Future] completes after renderer has been initialized. /// Initialized [AndroidMapRenderer] type is returned. Future initializeWithRenderer( - AndroidMapRenderer? rendererType) async { + AndroidMapRenderer? rendererType, + ) async { PlatformRendererType? preferredRenderer; switch (rendererType) { case AndroidMapRenderer.latest: @@ -559,35 +559,42 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { MapObjects mapObjects = const MapObjects(), }) { assert( - mapObjects.groundOverlays.every((GroundOverlay groundOverlay) => - groundOverlay.position == null || groundOverlay.width != null), - 'On Android width must be set when position is set for ground overlays.'); + mapObjects.groundOverlays.every( + (GroundOverlay groundOverlay) => + groundOverlay.position == null || groundOverlay.width != null, + ), + 'On Android width must be set when position is set for ground overlays.', + ); final PlatformMapViewCreationParams creationParams = PlatformMapViewCreationParams( - initialCameraPosition: _platformCameraPositionFromCameraPosition( - widgetConfiguration.initialCameraPosition), - mapConfiguration: mapConfiguration, - initialMarkers: - mapObjects.markers.map(_platformMarkerFromMarker).toList(), - initialPolygons: - mapObjects.polygons.map(_platformPolygonFromPolygon).toList(), - initialPolylines: - mapObjects.polylines.map(_platformPolylineFromPolyline).toList(), - initialCircles: - mapObjects.circles.map(_platformCircleFromCircle).toList(), - initialHeatmaps: - mapObjects.heatmaps.map(_platformHeatmapFromHeatmap).toList(), - initialTileOverlays: mapObjects.tileOverlays - .map(_platformTileOverlayFromTileOverlay) - .toList(), - initialClusterManagers: mapObjects.clusterManagers - .map(_platformClusterManagerFromClusterManager) - .toList(), - initialGroundOverlays: mapObjects.groundOverlays - .map(_platformGroundOverlayFromGroundOverlay) - .toList(), - ); + initialCameraPosition: _platformCameraPositionFromCameraPosition( + widgetConfiguration.initialCameraPosition, + ), + mapConfiguration: mapConfiguration, + initialMarkers: + mapObjects.markers.map(_platformMarkerFromMarker).toList(), + initialPolygons: + mapObjects.polygons.map(_platformPolygonFromPolygon).toList(), + initialPolylines: + mapObjects.polylines.map(_platformPolylineFromPolyline).toList(), + initialCircles: + mapObjects.circles.map(_platformCircleFromCircle).toList(), + initialHeatmaps: + mapObjects.heatmaps.map(_platformHeatmapFromHeatmap).toList(), + initialTileOverlays: + mapObjects.tileOverlays + .map(_platformTileOverlayFromTileOverlay) + .toList(), + initialClusterManagers: + mapObjects.clusterManagers + .map(_platformClusterManagerFromClusterManager) + .toList(), + initialGroundOverlays: + mapObjects.groundOverlays + .map(_platformGroundOverlayFromGroundOverlay) + .toList(), + ); const String viewType = 'plugins.flutter.dev/google_maps_android'; if (useAndroidViewSurface) { @@ -606,19 +613,17 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { onCreatePlatformView: (PlatformViewCreationParams params) { final AndroidViewController controller = PlatformViewsService.initExpensiveAndroidView( - id: params.id, - viewType: viewType, - layoutDirection: widgetConfiguration.textDirection, - creationParams: creationParams, - creationParamsCodec: MapsApi.pigeonChannelCodec, - onFocus: () => params.onFocusChanged(true), - ); + id: params.id, + viewType: viewType, + layoutDirection: widgetConfiguration.textDirection, + creationParams: creationParams, + creationParamsCodec: MapsApi.pigeonChannelCodec, + onFocus: () => params.onFocusChanged(true), + ); controller.addOnPlatformViewCreatedListener( params.onPlatformViewCreated, ); - controller.addOnPlatformViewCreatedListener( - onPlatformViewCreated, - ); + controller.addOnPlatformViewCreatedListener(onPlatformViewCreated); controller.create(); return controller; @@ -649,8 +654,9 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { onPlatformViewCreated, widgetConfiguration: widgetConfiguration, mapObjects: mapObjects, - mapConfiguration: - _platformMapConfigurationFromMapConfiguration(mapConfiguration), + mapConfiguration: _platformMapConfigurationFromMapConfiguration( + mapConfiguration, + ), ); } @@ -673,15 +679,17 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { creationId, onPlatformViewCreated, widgetConfiguration: MapWidgetConfiguration( - initialCameraPosition: initialCameraPosition, - textDirection: textDirection), + initialCameraPosition: initialCameraPosition, + textDirection: textDirection, + ), mapObjects: MapObjects( - markers: markers, - polygons: polygons, - polylines: polylines, - circles: circles, - clusterManagers: clusterManagers, - tileOverlays: tileOverlays), + markers: markers, + polygons: polygons, + polylines: polylines, + circles: circles, + clusterManagers: clusterManagers, + tileOverlays: tileOverlays, + ), mapConfiguration: _platformMapConfigurationFromOptionsJson(mapOptions), ); } @@ -720,25 +728,28 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { @visibleForTesting void enableDebugInspection() { GoogleMapsInspectorPlatform.instance = GoogleMapsInspectorAndroid( - (int mapId) => - MapsInspectorApi(messageChannelSuffix: mapId.toString())); + (int mapId) => MapsInspectorApi(messageChannelSuffix: mapId.toString()), + ); } /// Converts a Pigeon [PlatformCluster] to the corresponding [Cluster]. static Cluster clusterFromPlatformCluster(PlatformCluster cluster) { return Cluster( - ClusterManagerId(cluster.clusterManagerId), - cluster.markerIds - // See comment in messages.dart for why the force unwrap is okay. - .map((String? markerId) => MarkerId(markerId!)) - .toList(), - position: _latLngFromPlatformLatLng(cluster.position), - bounds: _latLngBoundsFromPlatformLatLngBounds(cluster.bounds)); + ClusterManagerId(cluster.clusterManagerId), + cluster.markerIds + // See comment in messages.dart for why the force unwrap is okay. + .map((String? markerId) => MarkerId(markerId!)) + .toList(), + position: _latLngFromPlatformLatLng(cluster.position), + bounds: _latLngBoundsFromPlatformLatLngBounds(cluster.bounds), + ); } static PlatformLatLng _platformLatLngFromLatLng(LatLng latLng) { return PlatformLatLng( - latitude: latLng.latitude, longitude: latLng.longitude); + latitude: latLng.latitude, + longitude: latLng.longitude, + ); } static PlatformDoublePair _platformPairFromOffset(Offset offset) { @@ -750,12 +761,14 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { } static ScreenCoordinate _screenCoordinateFromPlatformPoint( - PlatformPoint point) { + PlatformPoint point, + ) { return ScreenCoordinate(x: point.x, y: point.y); } static PlatformPoint _platformPointFromScreenCoordinate( - ScreenCoordinate coordinate) { + ScreenCoordinate coordinate, + ) { return PlatformPoint(x: coordinate.x, y: coordinate.y); } @@ -778,17 +791,21 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { } static PlatformClusterManager _platformClusterManagerFromClusterManager( - ClusterManager clusterManager) { + ClusterManager clusterManager, + ) { return PlatformClusterManager( - identifier: clusterManager.clusterManagerId.value); + identifier: clusterManager.clusterManagerId.value, + ); } static PlatformInfoWindow _platformInfoWindowFromInfoWindow( - InfoWindow window) { + InfoWindow window, + ) { return PlatformInfoWindow( - title: window.title, - snippet: window.snippet, - anchor: _platformPairFromOffset(window.anchor)); + title: window.title, + snippet: window.snippet, + anchor: _platformPairFromOffset(window.anchor), + ); } static PlatformMarker _platformMarkerFromMarker(Marker marker) { @@ -813,16 +830,19 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { } static PlatformGroundOverlay _platformGroundOverlayFromGroundOverlay( - GroundOverlay groundOverlay) { + GroundOverlay groundOverlay, + ) { return PlatformGroundOverlay( groundOverlayId: groundOverlay.groundOverlayId.value, - anchor: groundOverlay.anchor != null - ? _platformPairFromOffset(groundOverlay.anchor!) - : null, + anchor: + groundOverlay.anchor != null + ? _platformPairFromOffset(groundOverlay.anchor!) + : null, image: platformBitmapFromBitmapDescriptor(groundOverlay.image), - position: groundOverlay.position != null - ? _platformLatLngFromLatLng(groundOverlay.position!) - : null, + position: + groundOverlay.position != null + ? _platformLatLngFromLatLng(groundOverlay.position!) + : null, bounds: _platformLatLngBoundsFromLatLngBounds(groundOverlay.bounds), visible: groundOverlay.visible, zIndex: groundOverlay.zIndex, @@ -839,8 +859,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { polygon.points.map(_platformLatLngFromLatLng).toList(); final List> holes = polygon.holes.map((List hole) { - return hole.map(_platformLatLngFromLatLng).toList(); - }).toList(); + return hole.map(_platformLatLngFromLatLng).toList(); + }).toList(); return PlatformPolygon( polygonId: polygon.polygonId.value, fillColor: polygon.fillColor.value, @@ -877,7 +897,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { } static PlatformTileOverlay _platformTileOverlayFromTileOverlay( - TileOverlay tileOverlay) { + TileOverlay tileOverlay, + ) { return PlatformTileOverlay( tileOverlayId: tileOverlay.tileOverlayId.value, fadeIn: tileOverlay.fadeIn, @@ -889,63 +910,83 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { } static PlatformCameraUpdate _platformCameraUpdateFromCameraUpdate( - CameraUpdate update) { + CameraUpdate update, + ) { switch (update.updateType) { case CameraUpdateType.newCameraPosition: update as CameraUpdateNewCameraPosition; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateNewCameraPosition( - cameraPosition: _platformCameraPositionFromCameraPosition( - update.cameraPosition))); + cameraUpdate: PlatformCameraUpdateNewCameraPosition( + cameraPosition: _platformCameraPositionFromCameraPosition( + update.cameraPosition, + ), + ), + ); case CameraUpdateType.newLatLng: update as CameraUpdateNewLatLng; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateNewLatLng( - latLng: _platformLatLngFromLatLng(update.latLng))); + cameraUpdate: PlatformCameraUpdateNewLatLng( + latLng: _platformLatLngFromLatLng(update.latLng), + ), + ); case CameraUpdateType.newLatLngZoom: update as CameraUpdateNewLatLngZoom; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateNewLatLngZoom( - latLng: _platformLatLngFromLatLng(update.latLng), - zoom: update.zoom)); + cameraUpdate: PlatformCameraUpdateNewLatLngZoom( + latLng: _platformLatLngFromLatLng(update.latLng), + zoom: update.zoom, + ), + ); case CameraUpdateType.newLatLngBounds: update as CameraUpdateNewLatLngBounds; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateNewLatLngBounds( - bounds: _platformLatLngBoundsFromLatLngBounds(update.bounds)!, - padding: update.padding)); + cameraUpdate: PlatformCameraUpdateNewLatLngBounds( + bounds: _platformLatLngBoundsFromLatLngBounds(update.bounds)!, + padding: update.padding, + ), + ); case CameraUpdateType.zoomTo: update as CameraUpdateZoomTo; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateZoomTo(zoom: update.zoom)); + cameraUpdate: PlatformCameraUpdateZoomTo(zoom: update.zoom), + ); case CameraUpdateType.zoomBy: update as CameraUpdateZoomBy; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateZoomBy( - amount: update.amount, - focus: update.focus == null + cameraUpdate: PlatformCameraUpdateZoomBy( + amount: update.amount, + focus: + update.focus == null ? null - : _platformPairFromOffset(update.focus!))); + : _platformPairFromOffset(update.focus!), + ), + ); case CameraUpdateType.zoomIn: update as CameraUpdateZoomIn; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateZoom(out: false)); + cameraUpdate: PlatformCameraUpdateZoom(out: false), + ); case CameraUpdateType.zoomOut: update as CameraUpdateZoomOut; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateZoom(out: true)); + cameraUpdate: PlatformCameraUpdateZoom(out: true), + ); case CameraUpdateType.scrollBy: update as CameraUpdateScrollBy; return PlatformCameraUpdate( - cameraUpdate: - PlatformCameraUpdateScrollBy(dx: update.dx, dy: update.dy)); + cameraUpdate: PlatformCameraUpdateScrollBy( + dx: update.dx, + dy: update.dy, + ), + ); } } /// Convert [MapBitmapScaling] from platform interface to [PlatformMapBitmapScaling] Pigeon. @visibleForTesting static PlatformMapBitmapScaling platformMapBitmapScalingFromScaling( - MapBitmapScaling scaling) { + MapBitmapScaling scaling, + ) { switch (scaling) { case MapBitmapScaling.auto: return PlatformMapBitmapScaling.auto; @@ -965,54 +1006,71 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { /// Convert [BitmapDescriptor] from platform interface to [PlatformBitmap] pigeon. @visibleForTesting static PlatformBitmap platformBitmapFromBitmapDescriptor( - BitmapDescriptor bitmap) { + BitmapDescriptor bitmap, + ) { switch (bitmap) { case final DefaultMarker marker: return PlatformBitmap( - bitmap: PlatformBitmapDefaultMarker(hue: marker.hue?.toDouble())); + bitmap: PlatformBitmapDefaultMarker(hue: marker.hue?.toDouble()), + ); // Clients may still use this deprecated format, so it must be supported. // ignore: deprecated_member_use case final BytesBitmap bytes: return PlatformBitmap( - bitmap: PlatformBitmapBytes( - byteData: bytes.byteData, - size: (bytes.size == null) + bitmap: PlatformBitmapBytes( + byteData: bytes.byteData, + size: + (bytes.size == null) ? null - : _platformPairFromSize(bytes.size!))); + : _platformPairFromSize(bytes.size!), + ), + ); case final AssetBitmap asset: return PlatformBitmap( - bitmap: PlatformBitmapAsset(name: asset.name, pkg: asset.package)); + bitmap: PlatformBitmapAsset(name: asset.name, pkg: asset.package), + ); // Clients may still use this deprecated format, so it must be supported. // ignore: deprecated_member_use case final AssetImageBitmap asset: return PlatformBitmap( - bitmap: PlatformBitmapAssetImage( - name: asset.name, - scale: asset.scale, - size: (asset.size == null) + bitmap: PlatformBitmapAssetImage( + name: asset.name, + scale: asset.scale, + size: + (asset.size == null) ? null - : _platformPairFromSize(asset.size!))); + : _platformPairFromSize(asset.size!), + ), + ); case final AssetMapBitmap asset: return PlatformBitmap( - bitmap: PlatformBitmapAssetMap( - assetName: asset.assetName, - bitmapScaling: - platformMapBitmapScalingFromScaling(asset.bitmapScaling), - imagePixelRatio: asset.imagePixelRatio, - width: asset.width, - height: asset.height)); + bitmap: PlatformBitmapAssetMap( + assetName: asset.assetName, + bitmapScaling: platformMapBitmapScalingFromScaling( + asset.bitmapScaling, + ), + imagePixelRatio: asset.imagePixelRatio, + width: asset.width, + height: asset.height, + ), + ); case final BytesMapBitmap bytes: return PlatformBitmap( - bitmap: PlatformBitmapBytesMap( - byteData: bytes.byteData, - bitmapScaling: - platformMapBitmapScalingFromScaling(bytes.bitmapScaling), - imagePixelRatio: bytes.imagePixelRatio, - width: bytes.width, - height: bytes.height)); + bitmap: PlatformBitmapBytesMap( + byteData: bytes.byteData, + bitmapScaling: platformMapBitmapScalingFromScaling( + bytes.bitmapScaling, + ), + imagePixelRatio: bytes.imagePixelRatio, + width: bytes.width, + height: bytes.height, + ), + ); default: throw ArgumentError( - 'Unrecognized type of bitmap ${bitmap.runtimeType}', 'bitmap'); + 'Unrecognized type of bitmap ${bitmap.runtimeType}', + 'bitmap', + ); } } @@ -1029,10 +1087,12 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { case CapType.custom: cap as CustomCap; return PlatformCap( - type: PlatformCapType.customCap, - bitmapDescriptor: - platformBitmapFromBitmapDescriptor(cap.bitmapDescriptor), - refWidth: cap.refWidth); + type: PlatformCapType.customCap, + bitmapDescriptor: platformBitmapFromBitmapDescriptor( + cap.bitmapDescriptor, + ), + refWidth: cap.refWidth, + ); } } } @@ -1071,12 +1131,14 @@ class HostMapMessageHandler implements MapsCallbackApi { PlatformPoint location, int zoom, ) async { - final TileOverlay? tileOverlay = - tileOverlayProvider(TileOverlayId(tileOverlayId)); + final TileOverlay? tileOverlay = tileOverlayProvider( + TileOverlayId(tileOverlayId), + ); final TileProvider? tileProvider = tileOverlay?.tileProvider; - final Tile tile = tileProvider == null - ? TileProvider.noTile - : await tileProvider.getTile(location.x, location.y, zoom); + final Tile tile = + tileProvider == null + ? TileProvider.noTile + : await tileProvider.getTile(location.x, location.y, zoom); return _platformTileFromTile(tile); } @@ -1087,15 +1149,17 @@ class HostMapMessageHandler implements MapsCallbackApi { @override void onCameraMove(PlatformCameraPosition cameraPosition) { - streamController.add(CameraMoveEvent( - mapId, - CameraPosition( - target: _latLngFromPlatformLatLng(cameraPosition.target), - bearing: cameraPosition.bearing, - tilt: cameraPosition.tilt, - zoom: cameraPosition.zoom, + streamController.add( + CameraMoveEvent( + mapId, + CameraPosition( + target: _latLngFromPlatformLatLng(cameraPosition.target), + bearing: cameraPosition.bearing, + tilt: cameraPosition.tilt, + zoom: cameraPosition.zoom, + ), ), - )); + ); } @override @@ -1110,16 +1174,18 @@ class HostMapMessageHandler implements MapsCallbackApi { @override void onClusterTap(PlatformCluster cluster) { - streamController.add(ClusterTapEvent( - mapId, - Cluster( - ClusterManagerId(cluster.clusterManagerId), - // See comment in messages.dart for why this is force-unwrapped. - cluster.markerIds.map((String? id) => MarkerId(id!)).toList(), - position: _latLngFromPlatformLatLng(cluster.position), - bounds: _latLngBoundsFromPlatformLatLngBounds(cluster.bounds), + streamController.add( + ClusterTapEvent( + mapId, + Cluster( + ClusterManagerId(cluster.clusterManagerId), + // See comment in messages.dart for why this is force-unwrapped. + cluster.markerIds.map((String? id) => MarkerId(id!)).toList(), + position: _latLngFromPlatformLatLng(cluster.position), + bounds: _latLngBoundsFromPlatformLatLngBounds(cluster.bounds), + ), ), - )); + ); } @override @@ -1129,26 +1195,42 @@ class HostMapMessageHandler implements MapsCallbackApi { @override void onLongPress(PlatformLatLng position) { - streamController - .add(MapLongPressEvent(mapId, _latLngFromPlatformLatLng(position))); + streamController.add( + MapLongPressEvent(mapId, _latLngFromPlatformLatLng(position)), + ); } @override void onMarkerDrag(String markerId, PlatformLatLng position) { - streamController.add(MarkerDragEvent( - mapId, _latLngFromPlatformLatLng(position), MarkerId(markerId))); + streamController.add( + MarkerDragEvent( + mapId, + _latLngFromPlatformLatLng(position), + MarkerId(markerId), + ), + ); } @override void onMarkerDragStart(String markerId, PlatformLatLng position) { - streamController.add(MarkerDragStartEvent( - mapId, _latLngFromPlatformLatLng(position), MarkerId(markerId))); + streamController.add( + MarkerDragStartEvent( + mapId, + _latLngFromPlatformLatLng(position), + MarkerId(markerId), + ), + ); } @override void onMarkerDragEnd(String markerId, PlatformLatLng position) { - streamController.add(MarkerDragEndEvent( - mapId, _latLngFromPlatformLatLng(position), MarkerId(markerId))); + streamController.add( + MarkerDragEndEvent( + mapId, + _latLngFromPlatformLatLng(position), + MarkerId(markerId), + ), + ); } @override @@ -1168,14 +1250,16 @@ class HostMapMessageHandler implements MapsCallbackApi { @override void onGroundOverlayTap(String groundOverlayId) { - streamController - .add(GroundOverlayTapEvent(mapId, GroundOverlayId(groundOverlayId))); + streamController.add( + GroundOverlayTapEvent(mapId, GroundOverlayId(groundOverlayId)), + ); } @override void onTap(PlatformLatLng position) { - streamController - .add(MapTapEvent(mapId, _latLngFromPlatformLatLng(position))); + streamController.add( + MapTapEvent(mapId, _latLngFromPlatformLatLng(position)), + ); } } @@ -1184,10 +1268,12 @@ LatLng _latLngFromPlatformLatLng(PlatformLatLng latLng) { } LatLngBounds _latLngBoundsFromPlatformLatLngBounds( - PlatformLatLngBounds bounds) { + PlatformLatLngBounds bounds, +) { return LatLngBounds( - southwest: _latLngFromPlatformLatLng(bounds.southwest), - northeast: _latLngFromPlatformLatLng(bounds.northeast)); + southwest: _latLngFromPlatformLatLng(bounds.southwest), + northeast: _latLngFromPlatformLatLng(bounds.northeast), + ); } PlatformTile _platformTileFromTile(Tile tile) { @@ -1199,21 +1285,25 @@ PlatformLatLng _platformLatLngFromLatLng(LatLng latLng) { } PlatformLatLngBounds? _platformLatLngBoundsFromLatLngBounds( - LatLngBounds? bounds) { + LatLngBounds? bounds, +) { if (bounds == null) { return null; } return PlatformLatLngBounds( - northeast: _platformLatLngFromLatLng(bounds.northeast), - southwest: _platformLatLngFromLatLng(bounds.southwest)); + northeast: _platformLatLngFromLatLng(bounds.northeast), + southwest: _platformLatLngFromLatLng(bounds.southwest), + ); } PlatformCameraTargetBounds? _platformCameraTargetBoundsFromCameraTargetBounds( - CameraTargetBounds? bounds) { + CameraTargetBounds? bounds, +) { return bounds == null ? null : PlatformCameraTargetBounds( - bounds: _platformLatLngBoundsFromLatLngBounds(bounds.bounds)); + bounds: _platformLatLngBoundsFromLatLngBounds(bounds.bounds), + ); } PlatformMapType? _platformMapTypeFromMapType(MapType? type) { @@ -1241,7 +1331,8 @@ PlatformMapType? _platformMapTypeFromMapType(MapType? type) { } PlatformZoomRange? _platformZoomRangeFromMinMaxZoomPreference( - MinMaxZoomPreference? zoomPref) { + MinMaxZoomPreference? zoomPref, +) { return zoomPref == null ? null : PlatformZoomRange(min: zoomPref.minZoom, max: zoomPref.maxZoom); @@ -1251,21 +1342,25 @@ PlatformEdgeInsets? _platformEdgeInsetsFromEdgeInsets(EdgeInsets? insets) { return insets == null ? null : PlatformEdgeInsets( - top: insets.top, - bottom: insets.bottom, - left: insets.left, - right: insets.right); + top: insets.top, + bottom: insets.bottom, + left: insets.left, + right: insets.right, + ); } PlatformMapConfiguration _platformMapConfigurationFromMapConfiguration( - MapConfiguration config) { + MapConfiguration config, +) { return PlatformMapConfiguration( compassEnabled: config.compassEnabled, cameraTargetBounds: _platformCameraTargetBoundsFromCameraTargetBounds( - config.cameraTargetBounds), + config.cameraTargetBounds, + ), mapType: _platformMapTypeFromMapType(config.mapType), - minMaxZoomPreference: - _platformZoomRangeFromMinMaxZoomPreference(config.minMaxZoomPreference), + minMaxZoomPreference: _platformZoomRangeFromMinMaxZoomPreference( + config.minMaxZoomPreference, + ), mapToolbarEnabled: config.mapToolbarEnabled, rotateGesturesEnabled: config.rotateGesturesEnabled, scrollGesturesEnabled: config.scrollGesturesEnabled, @@ -1287,7 +1382,8 @@ PlatformMapConfiguration _platformMapConfigurationFromMapConfiguration( // For supporting the deprecated updateMapOptions API. PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( - Map options) { + Map options, +) { // All of these hard-coded values and structures come from // google_maps_flutter_platform_interface/lib/src/types/utils/map_configuration_serialization.dart // to support this legacy API that relied on cross-package magic strings. @@ -1297,10 +1393,12 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( return PlatformMapConfiguration( compassEnabled: options['compassEnabled'] as bool?, cameraTargetBounds: _platformCameraTargetBoundsFromCameraTargetBoundsJson( - options['cameraTargetBounds']), + options['cameraTargetBounds'], + ), mapType: mapType == null ? null : _platformMapTypeFromMapTypeIndex(mapType), minMaxZoomPreference: _platformZoomRangeFromMinMaxZoomPreferenceJson( - options['minMaxZoomPreference']), + options['minMaxZoomPreference'], + ), mapToolbarEnabled: options['mapToolbarEnabled'] as bool?, rotateGesturesEnabled: options['rotateGesturesEnabled'] as bool?, scrollGesturesEnabled: options['scrollGesturesEnabled'] as bool?, @@ -1310,13 +1408,15 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( zoomGesturesEnabled: options['zoomGesturesEnabled'] as bool?, myLocationEnabled: options['myLocationEnabled'] as bool?, myLocationButtonEnabled: options['myLocationButtonEnabled'] as bool?, - padding: padding == null - ? null - : PlatformEdgeInsets( - top: padding[0], - left: padding[1], - bottom: padding[2], - right: padding[3]), + padding: + padding == null + ? null + : PlatformEdgeInsets( + top: padding[0], + left: padding[1], + bottom: padding[2], + right: padding[3], + ), indoorViewEnabled: options['indoorEnabled'] as bool?, trafficEnabled: options['trafficEnabled'] as bool?, buildingsEnabled: options['buildingsEnabled'] as bool?, @@ -1327,12 +1427,14 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( } PlatformCameraPosition _platformCameraPositionFromCameraPosition( - CameraPosition position) { + CameraPosition position, +) { return PlatformCameraPosition( - bearing: position.bearing, - target: _platformLatLngFromLatLng(position.target), - tilt: position.tilt, - zoom: position.zoom); + bearing: position.bearing, + target: _platformLatLngFromLatLng(position.target), + tilt: position.tilt, + zoom: position.zoom, + ); } PlatformMapType _platformMapTypeFromMapTypeIndex(int index) { @@ -1355,30 +1457,35 @@ PlatformLatLng _platformLatLngFromLatLngJson(Object latLngJson) { } PlatformLatLngBounds? _platformLatLngBoundsFromLatLngBoundsJson( - Object? boundsJson) { + Object? boundsJson, +) { if (boundsJson == null) { return null; } // See `LatLngBounds.toJson`. final List boundsList = (boundsJson as List).cast(); return PlatformLatLngBounds( - southwest: _platformLatLngFromLatLngJson(boundsList[0]), - northeast: _platformLatLngFromLatLngJson(boundsList[1])); + southwest: _platformLatLngFromLatLngJson(boundsList[0]), + northeast: _platformLatLngFromLatLngJson(boundsList[1]), + ); } PlatformCameraTargetBounds? - _platformCameraTargetBoundsFromCameraTargetBoundsJson(Object? targetJson) { +_platformCameraTargetBoundsFromCameraTargetBoundsJson(Object? targetJson) { if (targetJson == null) { return null; } // See `CameraTargetBounds.toJson`. return PlatformCameraTargetBounds( - bounds: _platformLatLngBoundsFromLatLngBoundsJson( - (targetJson as List)[0])); + bounds: _platformLatLngBoundsFromLatLngBoundsJson( + (targetJson as List)[0], + ), + ); } PlatformZoomRange? _platformZoomRangeFromMinMaxZoomPreferenceJson( - Object? zoomPrefsJson) { + Object? zoomPrefsJson, +) { if (zoomPrefsJson == null) { return null; } @@ -1418,11 +1525,15 @@ PlatformPatternItem platformPatternItemFromPatternItem(PatternItem item) { case PatternItemType.dash: final double length = (item as VariableLengthPatternItem).length; return PlatformPatternItem( - type: PlatformPatternItemType.dash, length: length); + type: PlatformPatternItemType.dash, + length: length, + ); case PatternItemType.gap: final double length = (item as VariableLengthPatternItem).length; return PlatformPatternItem( - type: PlatformPatternItemType.gap, length: length); + type: PlatformPatternItemType.gap, + length: length, + ); } // The enum comes from a different package, which could get a new value at @@ -1440,7 +1551,7 @@ PlatformPatternItem platformPatternItemFromPatternItem(PatternItem item) { class _TileOverlayUpdates extends MapsObjectUpdates { /// Computes [TileOverlayUpdates] given previous and current [TileOverlay]s. _TileOverlayUpdates.from(super.previous, super.current) - : super.from(objectName: 'tileOverlay'); + : super.from(objectName: 'tileOverlay'); /// Set of TileOverlays to be added in this update. Set get tileOverlaysToAdd => objectsToAdd; diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart index 563ffd32d13..dd108cd3fa6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/messages.g.dart @@ -18,8 +18,11 @@ PlatformException _createConnectionError(String channelName) { ); } -List wrapResponse( - {Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse({ + Object? result, + PlatformException? error, + bool empty = false, +}) { if (empty) { return []; } @@ -30,48 +33,23 @@ List wrapResponse( } /// Pigeon equivalent of MapType -enum PlatformMapType { - none, - normal, - satellite, - terrain, - hybrid, -} +enum PlatformMapType { none, normal, satellite, terrain, hybrid } -enum PlatformRendererType { - legacy, - latest, -} +enum PlatformRendererType { legacy, latest } /// Join types for polyline joints. -enum PlatformJointType { - mitered, - bevel, - round, -} +enum PlatformJointType { mitered, bevel, round } /// Enumeration of possible types of PlatformCap, corresponding to the /// subclasses of Cap in the Google Maps Android SDK. /// See https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/Cap. -enum PlatformCapType { - buttCap, - roundCap, - squareCap, - customCap, -} +enum PlatformCapType { buttCap, roundCap, squareCap, customCap } /// Enumeration of possible types for PatternItem. -enum PlatformPatternItemType { - dot, - dash, - gap, -} +enum PlatformPatternItemType { dot, dash, gap } /// Pigeon equivalent of [MapBitmapScaling]. -enum PlatformMapBitmapScaling { - auto, - none, -} +enum PlatformMapBitmapScaling { auto, none } /// Pigeon representatation of a CameraPosition. class PlatformCameraPosition { @@ -91,12 +69,7 @@ class PlatformCameraPosition { double zoom; Object encode() { - return [ - bearing, - target, - tilt, - zoom, - ]; + return [bearing, target, tilt, zoom]; } static PlatformCameraPosition decode(Object result) { @@ -112,9 +85,7 @@ class PlatformCameraPosition { /// Pigeon representation of a CameraUpdate. class PlatformCameraUpdate { - PlatformCameraUpdate({ - required this.cameraUpdate, - }); + PlatformCameraUpdate({required this.cameraUpdate}); /// This Object shall be any of the below classes prefixed with /// PlatformCameraUpdate. Each such class represents a different type of @@ -125,31 +96,23 @@ class PlatformCameraUpdate { Object cameraUpdate; Object encode() { - return [ - cameraUpdate, - ]; + return [cameraUpdate]; } static PlatformCameraUpdate decode(Object result) { result as List; - return PlatformCameraUpdate( - cameraUpdate: result[0]!, - ); + return PlatformCameraUpdate(cameraUpdate: result[0]!); } } /// Pigeon equivalent of NewCameraPosition class PlatformCameraUpdateNewCameraPosition { - PlatformCameraUpdateNewCameraPosition({ - required this.cameraPosition, - }); + PlatformCameraUpdateNewCameraPosition({required this.cameraPosition}); PlatformCameraPosition cameraPosition; Object encode() { - return [ - cameraPosition, - ]; + return [cameraPosition]; } static PlatformCameraUpdateNewCameraPosition decode(Object result) { @@ -162,23 +125,17 @@ class PlatformCameraUpdateNewCameraPosition { /// Pigeon equivalent of NewLatLng class PlatformCameraUpdateNewLatLng { - PlatformCameraUpdateNewLatLng({ - required this.latLng, - }); + PlatformCameraUpdateNewLatLng({required this.latLng}); PlatformLatLng latLng; Object encode() { - return [ - latLng, - ]; + return [latLng]; } static PlatformCameraUpdateNewLatLng decode(Object result) { result as List; - return PlatformCameraUpdateNewLatLng( - latLng: result[0]! as PlatformLatLng, - ); + return PlatformCameraUpdateNewLatLng(latLng: result[0]! as PlatformLatLng); } } @@ -194,10 +151,7 @@ class PlatformCameraUpdateNewLatLngBounds { double padding; Object encode() { - return [ - bounds, - padding, - ]; + return [bounds, padding]; } static PlatformCameraUpdateNewLatLngBounds decode(Object result) { @@ -211,20 +165,14 @@ class PlatformCameraUpdateNewLatLngBounds { /// Pigeon equivalent of NewLatLngZoom class PlatformCameraUpdateNewLatLngZoom { - PlatformCameraUpdateNewLatLngZoom({ - required this.latLng, - required this.zoom, - }); + PlatformCameraUpdateNewLatLngZoom({required this.latLng, required this.zoom}); PlatformLatLng latLng; double zoom; Object encode() { - return [ - latLng, - zoom, - ]; + return [latLng, zoom]; } static PlatformCameraUpdateNewLatLngZoom decode(Object result) { @@ -238,20 +186,14 @@ class PlatformCameraUpdateNewLatLngZoom { /// Pigeon equivalent of ScrollBy class PlatformCameraUpdateScrollBy { - PlatformCameraUpdateScrollBy({ - required this.dx, - required this.dy, - }); + PlatformCameraUpdateScrollBy({required this.dx, required this.dy}); double dx; double dy; Object encode() { - return [ - dx, - dy, - ]; + return [dx, dy]; } static PlatformCameraUpdateScrollBy decode(Object result) { @@ -265,20 +207,14 @@ class PlatformCameraUpdateScrollBy { /// Pigeon equivalent of ZoomBy class PlatformCameraUpdateZoomBy { - PlatformCameraUpdateZoomBy({ - required this.amount, - this.focus, - }); + PlatformCameraUpdateZoomBy({required this.amount, this.focus}); double amount; PlatformDoublePair? focus; Object encode() { - return [ - amount, - focus, - ]; + return [amount, focus]; } static PlatformCameraUpdateZoomBy decode(Object result) { @@ -292,45 +228,33 @@ class PlatformCameraUpdateZoomBy { /// Pigeon equivalent of ZoomIn/ZoomOut class PlatformCameraUpdateZoom { - PlatformCameraUpdateZoom({ - required this.out, - }); + PlatformCameraUpdateZoom({required this.out}); bool out; Object encode() { - return [ - out, - ]; + return [out]; } static PlatformCameraUpdateZoom decode(Object result) { result as List; - return PlatformCameraUpdateZoom( - out: result[0]! as bool, - ); + return PlatformCameraUpdateZoom(out: result[0]! as bool); } } /// Pigeon equivalent of ZoomTo class PlatformCameraUpdateZoomTo { - PlatformCameraUpdateZoomTo({ - required this.zoom, - }); + PlatformCameraUpdateZoomTo({required this.zoom}); double zoom; Object encode() { - return [ - zoom, - ]; + return [zoom]; } static PlatformCameraUpdateZoomTo decode(Object result) { result as List; - return PlatformCameraUpdateZoomTo( - zoom: result[0]! as double, - ); + return PlatformCameraUpdateZoomTo(zoom: result[0]! as double); } } @@ -398,9 +322,7 @@ class PlatformCircle { /// Pigeon equivalent of the Heatmap class. class PlatformHeatmap { - PlatformHeatmap({ - required this.json, - }); + PlatformHeatmap({required this.json}); /// The heatmap data, as JSON. This should only be set from /// Heatmap.toJson, and the native code must interpret it according to the @@ -408,9 +330,7 @@ class PlatformHeatmap { Map json; Object encode() { - return [ - json, - ]; + return [json]; } static PlatformHeatmap decode(Object result) { @@ -423,60 +343,41 @@ class PlatformHeatmap { /// Pigeon equivalent of the ClusterManager class. class PlatformClusterManager { - PlatformClusterManager({ - required this.identifier, - }); + PlatformClusterManager({required this.identifier}); String identifier; Object encode() { - return [ - identifier, - ]; + return [identifier]; } static PlatformClusterManager decode(Object result) { result as List; - return PlatformClusterManager( - identifier: result[0]! as String, - ); + return PlatformClusterManager(identifier: result[0]! as String); } } /// Pair of double values, such as for an offset or size. class PlatformDoublePair { - PlatformDoublePair({ - required this.x, - required this.y, - }); + PlatformDoublePair({required this.x, required this.y}); double x; double y; Object encode() { - return [ - x, - y, - ]; + return [x, y]; } static PlatformDoublePair decode(Object result) { result as List; - return PlatformDoublePair( - x: result[0]! as double, - y: result[1]! as double, - ); + return PlatformDoublePair(x: result[0]! as double, y: result[1]! as double); } } /// Pigeon equivalent of the InfoWindow class. class PlatformInfoWindow { - PlatformInfoWindow({ - this.title, - this.snippet, - required this.anchor, - }); + PlatformInfoWindow({this.title, this.snippet, required this.anchor}); String? title; @@ -485,11 +386,7 @@ class PlatformInfoWindow { PlatformDoublePair anchor; Object encode() { - return [ - title, - snippet, - anchor, - ]; + return [title, snippet, anchor]; } static PlatformInfoWindow decode(Object result) { @@ -735,11 +632,7 @@ class PlatformPolyline { /// Pigeon equivalent of Cap from the platform interface. /// https://github.com/flutter/packages/blob/main/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart class PlatformCap { - PlatformCap({ - required this.type, - this.bitmapDescriptor, - this.refWidth, - }); + PlatformCap({required this.type, this.bitmapDescriptor, this.refWidth}); PlatformCapType type; @@ -748,11 +641,7 @@ class PlatformCap { double? refWidth; Object encode() { - return [ - type, - bitmapDescriptor, - refWidth, - ]; + return [type, bitmapDescriptor, refWidth]; } static PlatformCap decode(Object result) { @@ -767,20 +656,14 @@ class PlatformCap { /// Pigeon equivalent of the PatternItem class. class PlatformPatternItem { - PlatformPatternItem({ - required this.type, - this.length, - }); + PlatformPatternItem({required this.type, this.length}); PlatformPatternItemType type; double? length; Object encode() { - return [ - type, - length, - ]; + return [type, length]; } static PlatformPatternItem decode(Object result) { @@ -794,11 +677,7 @@ class PlatformPatternItem { /// Pigeon equivalent of the Tile class. class PlatformTile { - PlatformTile({ - required this.width, - required this.height, - this.data, - }); + PlatformTile({required this.width, required this.height, this.data}); int width; @@ -807,11 +686,7 @@ class PlatformTile { Uint8List? data; Object encode() { - return [ - width, - height, - data, - ]; + return [width, height, data]; } static PlatformTile decode(Object result) { @@ -889,12 +764,7 @@ class PlatformEdgeInsets { double right; Object encode() { - return [ - top, - bottom, - left, - right, - ]; + return [top, bottom, left, right]; } static PlatformEdgeInsets decode(Object result) { @@ -910,20 +780,14 @@ class PlatformEdgeInsets { /// Pigeon equivalent of LatLng. class PlatformLatLng { - PlatformLatLng({ - required this.latitude, - required this.longitude, - }); + PlatformLatLng({required this.latitude, required this.longitude}); double latitude; double longitude; Object encode() { - return [ - latitude, - longitude, - ]; + return [latitude, longitude]; } static PlatformLatLng decode(Object result) { @@ -937,20 +801,14 @@ class PlatformLatLng { /// Pigeon equivalent of LatLngBounds. class PlatformLatLngBounds { - PlatformLatLngBounds({ - required this.northeast, - required this.southwest, - }); + PlatformLatLngBounds({required this.northeast, required this.southwest}); PlatformLatLng northeast; PlatformLatLng southwest; Object encode() { - return [ - northeast, - southwest, - ]; + return [northeast, southwest]; } static PlatformLatLngBounds decode(Object result) { @@ -980,12 +838,7 @@ class PlatformCluster { List markerIds; Object encode() { - return [ - clusterManagerId, - position, - bounds, - markerIds, - ]; + return [clusterManagerId, position, bounds, markerIds]; } static PlatformCluster decode(Object result) { @@ -1081,16 +934,12 @@ class PlatformGroundOverlay { /// As with the Dart version, it exists to distinguish between not setting a /// a target, and having an explicitly unbounded target (null [bounds]). class PlatformCameraTargetBounds { - PlatformCameraTargetBounds({ - this.bounds, - }); + PlatformCameraTargetBounds({this.bounds}); PlatformLatLngBounds? bounds; Object encode() { - return [ - bounds, - ]; + return [bounds]; } static PlatformCameraTargetBounds decode(Object result) { @@ -1290,28 +1139,19 @@ class PlatformMapConfiguration { /// Pigeon representation of an x,y coordinate. class PlatformPoint { - PlatformPoint({ - required this.x, - required this.y, - }); + PlatformPoint({required this.x, required this.y}); int x; int y; Object encode() { - return [ - x, - y, - ]; + return [x, y]; } static PlatformPoint decode(Object result) { result as List; - return PlatformPoint( - x: result[0]! as int, - y: result[1]! as int, - ); + return PlatformPoint(x: result[0]! as int, y: result[1]! as int); } } @@ -1333,12 +1173,7 @@ class PlatformTileLayer { double zIndex; Object encode() { - return [ - visible, - fadeIn, - transparency, - zIndex, - ]; + return [visible, fadeIn, transparency, zIndex]; } static PlatformTileLayer decode(Object result) { @@ -1354,20 +1189,14 @@ class PlatformTileLayer { /// Possible outcomes of launching a URL. class PlatformZoomRange { - PlatformZoomRange({ - this.min, - this.max, - }); + PlatformZoomRange({this.min, this.max}); double? min; double? max; Object encode() { - return [ - min, - max, - ]; + return [min, max]; } static PlatformZoomRange decode(Object result) { @@ -1383,9 +1212,7 @@ class PlatformZoomRange { /// types of [BitmapDescriptor], [PlatformBitmap] contains a single field which /// may hold the pigeon equivalent type of any of them. class PlatformBitmap { - PlatformBitmap({ - required this.bitmap, - }); + PlatformBitmap({required this.bitmap}); /// One of [PlatformBitmapAssetMap], [PlatformBitmapAsset], /// [PlatformBitmapAssetImage], [PlatformBitmapBytesMap], @@ -1397,59 +1224,43 @@ class PlatformBitmap { Object bitmap; Object encode() { - return [ - bitmap, - ]; + return [bitmap]; } static PlatformBitmap decode(Object result) { result as List; - return PlatformBitmap( - bitmap: result[0]!, - ); + return PlatformBitmap(bitmap: result[0]!); } } /// Pigeon equivalent of [DefaultMarker]. See /// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#defaultMarker(float) class PlatformBitmapDefaultMarker { - PlatformBitmapDefaultMarker({ - this.hue, - }); + PlatformBitmapDefaultMarker({this.hue}); double? hue; Object encode() { - return [ - hue, - ]; + return [hue]; } static PlatformBitmapDefaultMarker decode(Object result) { result as List; - return PlatformBitmapDefaultMarker( - hue: result[0] as double?, - ); + return PlatformBitmapDefaultMarker(hue: result[0] as double?); } } /// Pigeon equivalent of [BytesBitmap]. See /// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#fromBitmap(android.graphics.Bitmap) class PlatformBitmapBytes { - PlatformBitmapBytes({ - required this.byteData, - this.size, - }); + PlatformBitmapBytes({required this.byteData, this.size}); Uint8List byteData; PlatformDoublePair? size; Object encode() { - return [ - byteData, - size, - ]; + return [byteData, size]; } static PlatformBitmapBytes decode(Object result) { @@ -1464,20 +1275,14 @@ class PlatformBitmapBytes { /// Pigeon equivalent of [AssetBitmap]. See /// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname class PlatformBitmapAsset { - PlatformBitmapAsset({ - required this.name, - this.pkg, - }); + PlatformBitmapAsset({required this.name, this.pkg}); String name; String? pkg; Object encode() { - return [ - name, - pkg, - ]; + return [name, pkg]; } static PlatformBitmapAsset decode(Object result) { @@ -1505,11 +1310,7 @@ class PlatformBitmapAssetImage { PlatformDoublePair? size; Object encode() { - return [ - name, - scale, - size, - ]; + return [name, scale, size]; } static PlatformBitmapAssetImage decode(Object result) { @@ -1544,13 +1345,7 @@ class PlatformBitmapAssetMap { double? height; Object encode() { - return [ - assetName, - bitmapScaling, - imagePixelRatio, - width, - height, - ]; + return [assetName, bitmapScaling, imagePixelRatio, width, height]; } static PlatformBitmapAssetMap decode(Object result) { @@ -1587,13 +1382,7 @@ class PlatformBitmapBytesMap { double? height; Object encode() { - return [ - byteData, - bitmapScaling, - imagePixelRatio, - width, - height, - ]; + return [byteData, bitmapScaling, imagePixelRatio, width, height]; } static PlatformBitmapBytesMap decode(Object result) { @@ -1873,9 +1662,9 @@ class MapsApi { /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. MapsApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -1888,10 +1677,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.waitForMap$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -1912,17 +1701,19 @@ class MapsApi { /// Only non-null configuration values will result in updates; options with /// null values will remain unchanged. Future updateMapConfiguration( - PlatformMapConfiguration configuration) async { + PlatformMapConfiguration configuration, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.updateMapConfiguration$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([configuration]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([configuration]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -1937,18 +1728,22 @@ class MapsApi { } /// Updates the set of circles on the map. - Future updateCircles(List toAdd, - List toChange, List idsToRemove) async { + Future updateCircles( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.updateCircles$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -1963,18 +1758,22 @@ class MapsApi { } /// Updates the set of heatmaps on the map. - Future updateHeatmaps(List toAdd, - List toChange, List idsToRemove) async { + Future updateHeatmaps( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.updateHeatmaps$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -1990,17 +1789,20 @@ class MapsApi { /// Updates the set of custer managers for clusters on the map. Future updateClusterManagers( - List toAdd, List idsToRemove) async { + List toAdd, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.updateClusterManagers$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2015,18 +1817,22 @@ class MapsApi { } /// Updates the set of markers on the map. - Future updateMarkers(List toAdd, - List toChange, List idsToRemove) async { + Future updateMarkers( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.updateMarkers$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2041,18 +1847,22 @@ class MapsApi { } /// Updates the set of polygonss on the map. - Future updatePolygons(List toAdd, - List toChange, List idsToRemove) async { + Future updatePolygons( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.updatePolygons$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2067,18 +1877,22 @@ class MapsApi { } /// Updates the set of polylines on the map. - Future updatePolylines(List toAdd, - List toChange, List idsToRemove) async { + Future updatePolylines( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.updatePolylines$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2093,18 +1907,22 @@ class MapsApi { } /// Updates the set of tile overlays on the map. - Future updateTileOverlays(List toAdd, - List toChange, List idsToRemove) async { + Future updateTileOverlays( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.updateTileOverlays$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2119,18 +1937,22 @@ class MapsApi { } /// Updates the set of ground overlays on the map. - Future updateGroundOverlays(List toAdd, - List toChange, List idsToRemove) async { + Future updateGroundOverlays( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.updateGroundOverlays$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2150,10 +1972,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.getScreenCoordinate$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([latLng]) as List?; if (pigeonVar_replyList == null) { @@ -2180,12 +2002,13 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.getLatLng$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([screenCoordinate]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([screenCoordinate]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2210,10 +2033,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.getVisibleRegion$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -2241,10 +2064,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.moveCamera$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([cameraUpdate]) as List?; if (pigeonVar_replyList == null) { @@ -2263,17 +2086,23 @@ class MapsApi { /// Moves the camera according to [cameraUpdate], animating the update using a /// duration in milliseconds if provided. Future animateCamera( - PlatformCameraUpdate cameraUpdate, int? durationMilliseconds) async { + PlatformCameraUpdate cameraUpdate, + int? durationMilliseconds, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.animateCamera$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([cameraUpdate, durationMilliseconds]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([ + cameraUpdate, + durationMilliseconds, + ]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2293,10 +2122,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.getZoomLevel$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -2323,10 +2152,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.showInfoWindow$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([markerId]) as List?; if (pigeonVar_replyList == null) { @@ -2348,10 +2177,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.hideInfoWindow$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([markerId]) as List?; if (pigeonVar_replyList == null) { @@ -2374,10 +2203,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.isInfoWindowShown$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([markerId]) as List?; if (pigeonVar_replyList == null) { @@ -2408,10 +2237,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.setStyle$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([style]) as List?; if (pigeonVar_replyList == null) { @@ -2442,10 +2271,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.didLastStyleSucceed$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -2472,12 +2301,13 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.clearTileCache$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([tileOverlayId]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([tileOverlayId]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2497,10 +2327,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsApi.takeSnapshot$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -2572,7 +2402,10 @@ abstract class MapsCallbackApi { /// Called to get data for a map tile. Future getTileOverlayTile( - String tileOverlayId, PlatformPoint location, int zoom); + String tileOverlayId, + PlatformPoint location, + int zoom, + ); static void setUp( MapsCallbackApi? api, { @@ -2582,12 +2415,12 @@ abstract class MapsCallbackApi { messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCameraMoveStarted$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCameraMoveStarted$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { @@ -2599,29 +2432,34 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCameraMove$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCameraMove$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCameraMove was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCameraMove was null.', + ); final List args = (message as List?)!; final PlatformCameraPosition? arg_cameraPosition = (args[0] as PlatformCameraPosition?); - assert(arg_cameraPosition != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCameraMove was null, expected non-null PlatformCameraPosition.'); + assert( + arg_cameraPosition != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCameraMove was null, expected non-null PlatformCameraPosition.', + ); try { api.onCameraMove(arg_cameraPosition!); return wrapResponse(empty: true); @@ -2629,18 +2467,19 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCameraIdle$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCameraIdle$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { @@ -2652,28 +2491,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onTap was null.', + ); final List args = (message as List?)!; final PlatformLatLng? arg_position = (args[0] as PlatformLatLng?); - assert(arg_position != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onTap was null, expected non-null PlatformLatLng.'); + assert( + arg_position != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onTap was null, expected non-null PlatformLatLng.', + ); try { api.onTap(arg_position!); return wrapResponse(empty: true); @@ -2681,28 +2525,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onLongPress$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onLongPress$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onLongPress was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onLongPress was null.', + ); final List args = (message as List?)!; final PlatformLatLng? arg_position = (args[0] as PlatformLatLng?); - assert(arg_position != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onLongPress was null, expected non-null PlatformLatLng.'); + assert( + arg_position != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onLongPress was null, expected non-null PlatformLatLng.', + ); try { api.onLongPress(arg_position!); return wrapResponse(empty: true); @@ -2710,28 +2559,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerTap was null.', + ); final List args = (message as List?)!; final String? arg_markerId = (args[0] as String?); - assert(arg_markerId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerTap was null, expected non-null String.'); + assert( + arg_markerId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerTap was null, expected non-null String.', + ); try { api.onMarkerTap(arg_markerId!); return wrapResponse(empty: true); @@ -2739,31 +2593,38 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragStart$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragStart$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragStart was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragStart was null.', + ); final List args = (message as List?)!; final String? arg_markerId = (args[0] as String?); - assert(arg_markerId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragStart was null, expected non-null String.'); + assert( + arg_markerId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragStart was null, expected non-null String.', + ); final PlatformLatLng? arg_position = (args[1] as PlatformLatLng?); - assert(arg_position != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragStart was null, expected non-null PlatformLatLng.'); + assert( + arg_position != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragStart was null, expected non-null PlatformLatLng.', + ); try { api.onMarkerDragStart(arg_markerId!, arg_position!); return wrapResponse(empty: true); @@ -2771,31 +2632,38 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDrag$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDrag$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDrag was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDrag was null.', + ); final List args = (message as List?)!; final String? arg_markerId = (args[0] as String?); - assert(arg_markerId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDrag was null, expected non-null String.'); + assert( + arg_markerId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDrag was null, expected non-null String.', + ); final PlatformLatLng? arg_position = (args[1] as PlatformLatLng?); - assert(arg_position != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDrag was null, expected non-null PlatformLatLng.'); + assert( + arg_position != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDrag was null, expected non-null PlatformLatLng.', + ); try { api.onMarkerDrag(arg_markerId!, arg_position!); return wrapResponse(empty: true); @@ -2803,31 +2671,38 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragEnd$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragEnd$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragEnd was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragEnd was null.', + ); final List args = (message as List?)!; final String? arg_markerId = (args[0] as String?); - assert(arg_markerId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragEnd was null, expected non-null String.'); + assert( + arg_markerId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragEnd was null, expected non-null String.', + ); final PlatformLatLng? arg_position = (args[1] as PlatformLatLng?); - assert(arg_position != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragEnd was null, expected non-null PlatformLatLng.'); + assert( + arg_position != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onMarkerDragEnd was null, expected non-null PlatformLatLng.', + ); try { api.onMarkerDragEnd(arg_markerId!, arg_position!); return wrapResponse(empty: true); @@ -2835,28 +2710,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onInfoWindowTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onInfoWindowTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onInfoWindowTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onInfoWindowTap was null.', + ); final List args = (message as List?)!; final String? arg_markerId = (args[0] as String?); - assert(arg_markerId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onInfoWindowTap was null, expected non-null String.'); + assert( + arg_markerId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onInfoWindowTap was null, expected non-null String.', + ); try { api.onInfoWindowTap(arg_markerId!); return wrapResponse(empty: true); @@ -2864,28 +2744,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCircleTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCircleTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCircleTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCircleTap was null.', + ); final List args = (message as List?)!; final String? arg_circleId = (args[0] as String?); - assert(arg_circleId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCircleTap was null, expected non-null String.'); + assert( + arg_circleId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onCircleTap was null, expected non-null String.', + ); try { api.onCircleTap(arg_circleId!); return wrapResponse(empty: true); @@ -2893,28 +2778,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onClusterTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onClusterTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onClusterTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onClusterTap was null.', + ); final List args = (message as List?)!; final PlatformCluster? arg_cluster = (args[0] as PlatformCluster?); - assert(arg_cluster != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onClusterTap was null, expected non-null PlatformCluster.'); + assert( + arg_cluster != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onClusterTap was null, expected non-null PlatformCluster.', + ); try { api.onClusterTap(arg_cluster!); return wrapResponse(empty: true); @@ -2922,28 +2812,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolygonTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolygonTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolygonTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolygonTap was null.', + ); final List args = (message as List?)!; final String? arg_polygonId = (args[0] as String?); - assert(arg_polygonId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolygonTap was null, expected non-null String.'); + assert( + arg_polygonId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolygonTap was null, expected non-null String.', + ); try { api.onPolygonTap(arg_polygonId!); return wrapResponse(empty: true); @@ -2951,28 +2846,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolylineTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolylineTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolylineTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolylineTap was null.', + ); final List args = (message as List?)!; final String? arg_polylineId = (args[0] as String?); - assert(arg_polylineId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolylineTap was null, expected non-null String.'); + assert( + arg_polylineId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onPolylineTap was null, expected non-null String.', + ); try { api.onPolylineTap(arg_polylineId!); return wrapResponse(empty: true); @@ -2980,28 +2880,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onGroundOverlayTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onGroundOverlayTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onGroundOverlayTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onGroundOverlayTap was null.', + ); final List args = (message as List?)!; final String? arg_groundOverlayId = (args[0] as String?); - assert(arg_groundOverlayId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onGroundOverlayTap was null, expected non-null String.'); + assert( + arg_groundOverlayId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.onGroundOverlayTap was null, expected non-null String.', + ); try { api.onGroundOverlayTap(arg_groundOverlayId!); return wrapResponse(empty: true); @@ -3009,43 +2914,56 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.getTileOverlayTile$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.getTileOverlayTile$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.getTileOverlayTile was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.getTileOverlayTile was null.', + ); final List args = (message as List?)!; final String? arg_tileOverlayId = (args[0] as String?); - assert(arg_tileOverlayId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.getTileOverlayTile was null, expected non-null String.'); + assert( + arg_tileOverlayId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.getTileOverlayTile was null, expected non-null String.', + ); final PlatformPoint? arg_location = (args[1] as PlatformPoint?); - assert(arg_location != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.getTileOverlayTile was null, expected non-null PlatformPoint.'); + assert( + arg_location != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.getTileOverlayTile was null, expected non-null PlatformPoint.', + ); final int? arg_zoom = (args[2] as int?); - assert(arg_zoom != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.getTileOverlayTile was null, expected non-null int.'); + assert( + arg_zoom != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_android.MapsCallbackApi.getTileOverlayTile was null, expected non-null int.', + ); try { final PlatformTile output = await api.getTileOverlayTile( - arg_tileOverlayId!, arg_location!, arg_zoom!); + arg_tileOverlayId!, + arg_location!, + arg_zoom!, + ); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } @@ -3058,11 +2976,12 @@ class MapsInitializerApi { /// Constructor for [MapsInitializerApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - MapsInitializerApi( - {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + MapsInitializerApi({ + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -3076,15 +2995,16 @@ class MapsInitializerApi { /// Calling this more than once in the lifetime of an application will result /// in an error. Future initializeWithPreferredRenderer( - PlatformRendererType? type) async { + PlatformRendererType? type, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsInitializerApi.initializeWithPreferredRenderer$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([type]) as List?; if (pigeonVar_replyList == null) { @@ -3112,10 +3032,10 @@ class MapsInitializerApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInitializerApi.warmup$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3139,11 +3059,12 @@ class MapsPlatformViewApi { /// Constructor for [MapsPlatformViewApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - MapsPlatformViewApi( - {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + MapsPlatformViewApi({ + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -3155,10 +3076,10 @@ class MapsPlatformViewApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsPlatformViewApi.createView$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([type]) as List?; if (pigeonVar_replyList == null) { @@ -3180,11 +3101,12 @@ class MapsInspectorApi { /// Constructor for [MapsInspectorApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - MapsInspectorApi( - {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + MapsInspectorApi({ + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -3196,10 +3118,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.areBuildingsEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3225,10 +3147,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.areRotateGesturesEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3254,10 +3176,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.areZoomControlsEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3283,10 +3205,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.areScrollGesturesEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3312,10 +3234,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.areTiltGesturesEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3341,10 +3263,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.areZoomGesturesEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3370,10 +3292,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.isCompassEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3399,10 +3321,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.isLiteModeEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3423,10 +3345,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.isMapToolbarEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3452,10 +3374,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.isMyLocationButtonEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3481,10 +3403,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.isTrafficEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3510,12 +3432,13 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.getTileOverlayInfo$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([tileOverlayId]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([tileOverlayId]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -3530,17 +3453,19 @@ class MapsInspectorApi { } Future getGroundOverlayInfo( - String groundOverlayId) async { + String groundOverlayId, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.getGroundOverlayInfo$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([groundOverlayId]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([groundOverlayId]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -3559,10 +3484,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.getZoomRange$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3588,12 +3513,13 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.getClusters$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([clusterManagerId]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([clusterManagerId]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -3618,10 +3544,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_android.MapsInspectorApi.getCameraPosition$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { diff --git a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/serialization.dart b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/serialization.dart index fee4828fe71..ce4f9094ac4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/lib/src/serialization.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/lib/src/serialization.dart @@ -36,7 +36,10 @@ Map serializeHeatmap(Heatmap heatmap) { final HeatmapGradient? gradient = heatmap.gradient; if (gradient != null) { _addIfNonNull( - json, _heatmapGradientKey, serializeHeatmapGradient(gradient)); + json, + _heatmapGradientKey, + serializeHeatmapGradient(gradient), + ); } _addIfNonNull(json, _heatmapMaxIntensityKey, heatmap.maxIntensity); _addIfNonNull(json, _heatmapOpacityKey, heatmap.opacity); @@ -102,10 +105,11 @@ HeatmapGradient? deserializeHeatmapGradient(Object? json) { } assert(json is Map); final Map map = (json as Map).cast(); - final List colors = (map[_heatmapGradientColorsKey]! as List) - .whereType() - .map((int e) => Color(e)) - .toList(); + final List colors = + (map[_heatmapGradientColorsKey]! as List) + .whereType() + .map((int e) => Color(e)) + .toList(); final List startPoints = (map[_heatmapGradientStartPointsKey]! as List) .whereType() diff --git a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart index 42b85904d26..b4bfd45fbea 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/pigeons/messages.dart @@ -4,21 +4,17 @@ import 'package:pigeon/pigeon.dart'; -@ConfigurePigeon(PigeonOptions( - dartOut: 'lib/src/messages.g.dart', - javaOptions: JavaOptions(package: 'io.flutter.plugins.googlemaps'), - javaOut: 'android/src/main/java/io/flutter/plugins/googlemaps/Messages.java', - copyrightHeader: 'pigeons/copyright.txt', -)) - +@ConfigurePigeon( + PigeonOptions( + dartOut: 'lib/src/messages.g.dart', + javaOptions: JavaOptions(package: 'io.flutter.plugins.googlemaps'), + javaOut: + 'android/src/main/java/io/flutter/plugins/googlemaps/Messages.java', + copyrightHeader: 'pigeons/copyright.txt', + ), +) /// Pigeon equivalent of MapType -enum PlatformMapType { - none, - normal, - satellite, - terrain, - hybrid, -} +enum PlatformMapType { none, normal, satellite, terrain, hybrid } // Pigeon equivalent of the Java MapsInitializer.Renderer. enum PlatformRendererType { legacy, latest } @@ -157,11 +153,7 @@ class PlatformDoublePair { /// Pigeon equivalent of the InfoWindow class. class PlatformInfoWindow { - PlatformInfoWindow({ - required this.anchor, - this.title, - this.snippet, - }); + PlatformInfoWindow({required this.anchor, this.title, this.snippet}); final String? title; final String? snippet; @@ -230,11 +222,7 @@ class PlatformPolygon { } /// Join types for polyline joints. -enum PlatformJointType { - mitered, - bevel, - round, -} +enum PlatformJointType { mitered, bevel, round } /// Pigeon equivalent of the Polyline class. class PlatformPolyline { @@ -278,12 +266,7 @@ class PlatformPolyline { /// Enumeration of possible types of PlatformCap, corresponding to the /// subclasses of Cap in the Google Maps Android SDK. /// See https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/Cap. -enum PlatformCapType { - buttCap, - roundCap, - squareCap, - customCap, -} +enum PlatformCapType { buttCap, roundCap, squareCap, customCap } /// Pigeon equivalent of Cap from the platform interface. /// https://github.com/flutter/packages/blob/main/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart @@ -297,11 +280,7 @@ class PlatformCap { } /// Enumeration of possible types for PatternItem. -enum PlatformPatternItemType { - dot, - dash, - gap, -} +enum PlatformPatternItemType { dot, dash, gap } /// Pigeon equivalent of the PatternItem class. class PlatformPatternItem { @@ -576,28 +555,29 @@ class PlatformBitmapAsset { /// Pigeon equivalent of [AssetImageBitmap]. See /// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname class PlatformBitmapAssetImage { - PlatformBitmapAssetImage( - {required this.name, required this.scale, this.size}); + PlatformBitmapAssetImage({ + required this.name, + required this.scale, + this.size, + }); final String name; final double scale; final PlatformDoublePair? size; } /// Pigeon equivalent of [MapBitmapScaling]. -enum PlatformMapBitmapScaling { - auto, - none, -} +enum PlatformMapBitmapScaling { auto, none } /// Pigeon equivalent of [AssetMapBitmap]. See /// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-fromasset-string-assetname class PlatformBitmapAssetMap { - PlatformBitmapAssetMap( - {required this.assetName, - required this.bitmapScaling, - required this.imagePixelRatio, - this.width, - this.height}); + PlatformBitmapAssetMap({ + required this.assetName, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height, + }); final String assetName; final PlatformMapBitmapScaling bitmapScaling; final double imagePixelRatio; @@ -608,12 +588,13 @@ class PlatformBitmapAssetMap { /// Pigeon equivalent of [BytesMapBitmap]. See /// https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/model/BitmapDescriptorFactory#public-static-bitmapdescriptor-frombitmap-bitmap-image class PlatformBitmapBytesMap { - PlatformBitmapBytesMap( - {required this.byteData, - required this.bitmapScaling, - required this.imagePixelRatio, - this.width, - this.height}); + PlatformBitmapBytesMap({ + required this.byteData, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height, + }); final Uint8List byteData; final PlatformMapBitmapScaling bitmapScaling; final double imagePixelRatio; @@ -637,36 +618,59 @@ abstract class MapsApi { void updateMapConfiguration(PlatformMapConfiguration configuration); /// Updates the set of circles on the map. - void updateCircles(List toAdd, List toChange, - List idsToRemove); + void updateCircles( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of heatmaps on the map. - void updateHeatmaps(List toAdd, - List toChange, List idsToRemove); + void updateHeatmaps( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of custer managers for clusters on the map. void updateClusterManagers( - List toAdd, List idsToRemove); + List toAdd, + List idsToRemove, + ); /// Updates the set of markers on the map. - void updateMarkers(List toAdd, List toChange, - List idsToRemove); + void updateMarkers( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of polygonss on the map. - void updatePolygons(List toAdd, - List toChange, List idsToRemove); + void updatePolygons( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of polylines on the map. - void updatePolylines(List toAdd, - List toChange, List idsToRemove); + void updatePolylines( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of tile overlays on the map. - void updateTileOverlays(List toAdd, - List toChange, List idsToRemove); + void updateTileOverlays( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of ground overlays on the map. - void updateGroundOverlays(List toAdd, - List toChange, List idsToRemove); + void updateGroundOverlays( + List toAdd, + List toChange, + List idsToRemove, + ); /// Gets the screen coordinate for the given map location. PlatformPoint getScreenCoordinate(PlatformLatLng latLng); @@ -684,7 +688,9 @@ abstract class MapsApi { /// Moves the camera according to [cameraUpdate], animating the update using a /// duration in milliseconds if provided. void animateCamera( - PlatformCameraUpdate cameraUpdate, int? durationMilliseconds); + PlatformCameraUpdate cameraUpdate, + int? durationMilliseconds, + ); /// Gets the current map zoom level. double getZoomLevel(); @@ -771,7 +777,10 @@ abstract class MapsCallbackApi { /// Called to get data for a map tile. @async PlatformTile getTileOverlayTile( - String tileOverlayId, PlatformPoint location, int zoom); + String tileOverlayId, + PlatformPoint location, + int zoom, + ); } /// Interface for global SDK initialization. @@ -785,7 +794,8 @@ abstract class MapsInitializerApi { /// in an error. @async PlatformRendererType initializeWithPreferredRenderer( - PlatformRendererType? type); + PlatformRendererType? type, + ); /// Attempts to trigger any thread-blocking work /// the Google Maps SDK normally does when a map is shown for the first time. 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 642f1973f87..9e2bea80407 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml @@ -5,8 +5,8 @@ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+ version: 2.18.1 environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" flutter: plugin: diff --git a/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart b/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart index 1f455614726..a64917810ba 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart @@ -15,15 +15,18 @@ import 'package:mockito/mockito.dart'; import 'google_maps_flutter_android_test.mocks.dart'; -@GenerateNiceMocks( - >[MockSpec(), MockSpec()]) +@GenerateNiceMocks(>[ + MockSpec(), + MockSpec(), +]) void main() { TestWidgetsFlutterBinding.ensureInitialized(); (GoogleMapsFlutterAndroid, MockMapsApi) setUpMockMap({required int mapId}) { final MockMapsApi api = MockMapsApi(); - final GoogleMapsFlutterAndroid maps = - GoogleMapsFlutterAndroid(apiProvider: (_) => api); + final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( + apiProvider: (_) => api, + ); maps.ensureApiInitialized(mapId); return (maps, api); } @@ -37,7 +40,9 @@ void main() { final MockMapsApi api = MockMapsApi(); final MockMapsInitializerApi initializerApi = MockMapsInitializerApi(); final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( - apiProvider: (_) => api, initializerApi: initializerApi); + apiProvider: (_) => api, + initializerApi: initializerApi, + ); const int mapId = 1; maps.ensureApiInitialized(mapId); await maps.init(1); @@ -45,23 +50,32 @@ void main() { verifyZeroInteractions(initializerApi); }); - test('initializeWithPreferredRenderer forwards the initialization call', - () async { - final MockMapsApi api = MockMapsApi(); - final MockMapsInitializerApi initializerApi = MockMapsInitializerApi(); - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( - apiProvider: (_) => api, initializerApi: initializerApi); - await maps.initializeWithRenderer(AndroidMapRenderer.latest); - - verify(initializerApi - .initializeWithPreferredRenderer(PlatformRendererType.latest)); - }); + test( + 'initializeWithPreferredRenderer forwards the initialization call', + () async { + final MockMapsApi api = MockMapsApi(); + final MockMapsInitializerApi initializerApi = MockMapsInitializerApi(); + final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( + apiProvider: (_) => api, + initializerApi: initializerApi, + ); + await maps.initializeWithRenderer(AndroidMapRenderer.latest); + + verify( + initializerApi.initializeWithPreferredRenderer( + PlatformRendererType.latest, + ), + ); + }, + ); test('warmup forwards the initialization call', () async { final MockMapsApi api = MockMapsApi(); final MockMapsInitializerApi initializerApi = MockMapsInitializerApi(); final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( - apiProvider: (_) => api, initializerApi: initializerApi); + apiProvider: (_) => api, + initializerApi: initializerApi, + ); await maps.warmup(); verify(initializerApi.warmup()); @@ -69,8 +83,9 @@ void main() { test('init calls waitForMap', () async { final MockMapsApi api = MockMapsApi(); - final GoogleMapsFlutterAndroid maps = - GoogleMapsFlutterAndroid(apiProvider: (_) => api); + final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( + apiProvider: (_) => api, + ); await maps.init(1); @@ -79,20 +94,25 @@ void main() { test('getScreenCoordinate converts and passes values correctly', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); // Arbitrary values that are all different from each other. const LatLng latLng = LatLng(10, 20); const ScreenCoordinate expectedCoord = ScreenCoordinate(x: 30, y: 40); when(api.getScreenCoordinate(any)).thenAnswer( - (_) async => PlatformPoint(x: expectedCoord.x, y: expectedCoord.y)); + (_) async => PlatformPoint(x: expectedCoord.x, y: expectedCoord.y), + ); - final ScreenCoordinate coord = - await maps.getScreenCoordinate(latLng, mapId: mapId); + final ScreenCoordinate coord = await maps.getScreenCoordinate( + latLng, + mapId: mapId, + ); expect(coord, expectedCoord); - final VerificationResult verification = - verify(api.getScreenCoordinate(captureAny)); + final VerificationResult verification = verify( + api.getScreenCoordinate(captureAny), + ); final PlatformLatLng passedLatLng = verification.captured[0] as PlatformLatLng; expect(passedLatLng.latitude, latLng.latitude); @@ -101,15 +121,19 @@ void main() { test('getLatLng converts and passes values correctly', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); // Arbitrary values that are all different from each other. const LatLng expectedLatLng = LatLng(10, 20); const ScreenCoordinate coord = ScreenCoordinate(x: 30, y: 40); - when(api.getLatLng(any)).thenAnswer((_) async => PlatformLatLng( + when(api.getLatLng(any)).thenAnswer( + (_) async => PlatformLatLng( latitude: expectedLatLng.latitude, - longitude: expectedLatLng.longitude)); + longitude: expectedLatLng.longitude, + ), + ); final LatLng latLng = await maps.getLatLng(coord, mapId: mapId); expect(latLng, expectedLatLng); @@ -121,19 +145,27 @@ void main() { test('getVisibleRegion converts and passes values correctly', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); // Arbitrary values that are all different from each other. final LatLngBounds expectedBounds = LatLngBounds( - southwest: const LatLng(10, 20), northeast: const LatLng(30, 40)); - when(api.getVisibleRegion()).thenAnswer((_) async => PlatformLatLngBounds( + southwest: const LatLng(10, 20), + northeast: const LatLng(30, 40), + ); + when(api.getVisibleRegion()).thenAnswer( + (_) async => PlatformLatLngBounds( southwest: PlatformLatLng( - latitude: expectedBounds.southwest.latitude, - longitude: expectedBounds.southwest.longitude), + latitude: expectedBounds.southwest.latitude, + longitude: expectedBounds.southwest.longitude, + ), northeast: PlatformLatLng( - latitude: expectedBounds.northeast.latitude, - longitude: expectedBounds.northeast.longitude))); + latitude: expectedBounds.northeast.latitude, + longitude: expectedBounds.northeast.longitude, + ), + ), + ); final LatLngBounds bounds = await maps.getVisibleRegion(mapId: mapId); expect(bounds, expectedBounds); @@ -141,8 +173,9 @@ void main() { test('moveCamera calls through with expected scrollBy', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.scrollBy(10, 20); await maps.moveCamera(update, mapId: mapId); @@ -159,14 +192,16 @@ void main() { test('animateCamera calls through with expected scrollBy', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.scrollBy(10, 20); await maps.animateCamera(update, mapId: mapId); - final VerificationResult verification = - verify(api.animateCamera(captureAny, captureAny)); + final VerificationResult verification = verify( + api.animateCamera(captureAny, captureAny), + ); final PlatformCameraUpdate passedUpdate = verification.captured[0] as PlatformCameraUpdate; final PlatformCameraUpdateScrollBy scroll = @@ -180,18 +215,23 @@ void main() { test('animateCameraWithConfiguration calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.scrollBy(10, 20); const CameraUpdateAnimationConfiguration configuration = CameraUpdateAnimationConfiguration(duration: Duration(seconds: 1)); expect(configuration.duration?.inSeconds, 1); - await maps.animateCameraWithConfiguration(update, configuration, - mapId: mapId); + await maps.animateCameraWithConfiguration( + update, + configuration, + mapId: mapId, + ); - final VerificationResult verification = - verify(api.animateCamera(captureAny, captureAny)); + final VerificationResult verification = verify( + api.animateCamera(captureAny, captureAny), + ); final PlatformCameraUpdate passedUpdate = verification.captured[0] as PlatformCameraUpdate; final PlatformCameraUpdateScrollBy scroll = @@ -206,8 +246,9 @@ void main() { test('getZoomLevel passes values correctly', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const double expectedZoom = 4.2; when(api.getZoomLevel()).thenAnswer((_) async => expectedZoom); @@ -218,8 +259,9 @@ void main() { test('showInfoWindow calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const String markedId = 'a_marker'; await maps.showMarkerInfoWindow(const MarkerId(markedId), mapId: mapId); @@ -229,8 +271,9 @@ void main() { test('hideInfoWindow calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const String markedId = 'a_marker'; await maps.hideMarkerInfoWindow(const MarkerId(markedId), mapId: mapId); @@ -240,22 +283,27 @@ void main() { test('isInfoWindowShown calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const String markedId = 'a_marker'; when(api.isInfoWindowShown(markedId)).thenAnswer((_) async => true); expect( - await maps.isMarkerInfoWindowShown(const MarkerId(markedId), - mapId: mapId), - true); + await maps.isMarkerInfoWindowShown( + const MarkerId(markedId), + mapId: mapId, + ), + true, + ); }); test('takeSnapshot calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final Uint8List fakeSnapshot = Uint8List(10); when(api.takeSnapshot()).thenAnswer((_) async => fakeSnapshot); @@ -265,8 +313,9 @@ void main() { test('clearTileCache calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const String tileOverlayId = 'overlay'; await maps.clearTileCache(const TileOverlayId(tileOverlayId), mapId: mapId); @@ -276,12 +325,17 @@ void main() { test('updateMapConfiguration passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); // Set some arbitrary options. - final CameraTargetBounds cameraBounds = CameraTargetBounds(LatLngBounds( - southwest: const LatLng(10, 20), northeast: const LatLng(30, 40))); + final CameraTargetBounds cameraBounds = CameraTargetBounds( + LatLngBounds( + southwest: const LatLng(10, 20), + northeast: const LatLng(30, 40), + ), + ); final MapConfiguration config = MapConfiguration( compassEnabled: true, mapType: MapType.terrain, @@ -289,21 +343,30 @@ void main() { ); await maps.updateMapConfiguration(config, mapId: mapId); - final VerificationResult verification = - verify(api.updateMapConfiguration(captureAny)); + final VerificationResult verification = verify( + api.updateMapConfiguration(captureAny), + ); final PlatformMapConfiguration passedConfig = verification.captured[0] as PlatformMapConfiguration; // Each set option should be present. expect(passedConfig.compassEnabled, true); expect(passedConfig.mapType, PlatformMapType.terrain); - expect(passedConfig.cameraTargetBounds?.bounds?.northeast.latitude, - cameraBounds.bounds?.northeast.latitude); - expect(passedConfig.cameraTargetBounds?.bounds?.northeast.longitude, - cameraBounds.bounds?.northeast.longitude); - expect(passedConfig.cameraTargetBounds?.bounds?.southwest.latitude, - cameraBounds.bounds?.southwest.latitude); - expect(passedConfig.cameraTargetBounds?.bounds?.southwest.longitude, - cameraBounds.bounds?.southwest.longitude); + expect( + passedConfig.cameraTargetBounds?.bounds?.northeast.latitude, + cameraBounds.bounds?.northeast.latitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.northeast.longitude, + cameraBounds.bounds?.northeast.longitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.southwest.latitude, + cameraBounds.bounds?.southwest.latitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.southwest.longitude, + cameraBounds.bounds?.southwest.longitude, + ); // Spot-check that unset options are not be present. expect(passedConfig.myLocationEnabled, isNull); expect(passedConfig.minMaxZoomPreference, isNull); @@ -312,12 +375,17 @@ void main() { test('updateMapOptions passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); // Set some arbitrary options. - final CameraTargetBounds cameraBounds = CameraTargetBounds(LatLngBounds( - southwest: const LatLng(10, 20), northeast: const LatLng(30, 40))); + final CameraTargetBounds cameraBounds = CameraTargetBounds( + LatLngBounds( + southwest: const LatLng(10, 20), + northeast: const LatLng(30, 40), + ), + ); final Map config = { 'compassEnabled': true, 'mapType': MapType.terrain.index, @@ -325,21 +393,30 @@ void main() { }; await maps.updateMapOptions(config, mapId: mapId); - final VerificationResult verification = - verify(api.updateMapConfiguration(captureAny)); + final VerificationResult verification = verify( + api.updateMapConfiguration(captureAny), + ); final PlatformMapConfiguration passedConfig = verification.captured[0] as PlatformMapConfiguration; // Each set option should be present. expect(passedConfig.compassEnabled, true); expect(passedConfig.mapType, PlatformMapType.terrain); - expect(passedConfig.cameraTargetBounds?.bounds?.northeast.latitude, - cameraBounds.bounds?.northeast.latitude); - expect(passedConfig.cameraTargetBounds?.bounds?.northeast.longitude, - cameraBounds.bounds?.northeast.longitude); - expect(passedConfig.cameraTargetBounds?.bounds?.southwest.latitude, - cameraBounds.bounds?.southwest.latitude); - expect(passedConfig.cameraTargetBounds?.bounds?.southwest.longitude, - cameraBounds.bounds?.southwest.longitude); + expect( + passedConfig.cameraTargetBounds?.bounds?.northeast.latitude, + cameraBounds.bounds?.northeast.latitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.northeast.longitude, + cameraBounds.bounds?.northeast.longitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.southwest.latitude, + cameraBounds.bounds?.southwest.latitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.southwest.longitude, + cameraBounds.bounds?.southwest.longitude, + ); // Spot-check that unset options are not be present. expect(passedConfig.myLocationEnabled, isNull); expect(passedConfig.minMaxZoomPreference, isNull); @@ -348,20 +425,25 @@ void main() { test('updateCircles passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const Circle object1 = Circle(circleId: CircleId('1')); const Circle object2old = Circle(circleId: CircleId('2')); final Circle object2new = object2old.copyWith(radiusParam: 42); const Circle object3 = Circle(circleId: CircleId('3')); await maps.updateCircles( - CircleUpdates.from( - {object1, object2old}, {object2new, object3}), - mapId: mapId); + CircleUpdates.from( + {object1, object2old}, + {object2new, object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updateCircles(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updateCircles(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toChange = @@ -404,20 +486,27 @@ void main() { test('updateClusterManagers passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); - const ClusterManager object1 = - ClusterManager(clusterManagerId: ClusterManagerId('1')); - const ClusterManager object3 = - ClusterManager(clusterManagerId: ClusterManagerId('3')); + const ClusterManager object1 = ClusterManager( + clusterManagerId: ClusterManagerId('1'), + ); + const ClusterManager object3 = ClusterManager( + clusterManagerId: ClusterManagerId('3'), + ); await maps.updateClusterManagers( - ClusterManagerUpdates.from( - {object1}, {object3}), - mapId: mapId); + ClusterManagerUpdates.from( + {object1}, + {object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updateClusterManagers(captureAny, captureAny)); + final VerificationResult verification = verify( + api.updateClusterManagers(captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toRemove = verification.captured[1] as List; @@ -433,20 +522,25 @@ void main() { test('updateMarkers passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const Marker object1 = Marker(markerId: MarkerId('1')); const Marker object2old = Marker(markerId: MarkerId('2')); final Marker object2new = object2old.copyWith(rotationParam: 42); const Marker object3 = Marker(markerId: MarkerId('3')); await maps.updateMarkers( - MarkerUpdates.from( - {object1, object2old}, {object2new, object3}), - mapId: mapId); + MarkerUpdates.from( + {object1, object2old}, + {object2new, object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updateMarkers(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updateMarkers(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toChange = @@ -466,11 +560,11 @@ void main() { expect(firstChanged.draggable, object2new.draggable); expect(firstChanged.flat, object2new.flat); expect( - firstChanged.icon.bitmap.runtimeType, - GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( - object2new.icon) - .bitmap - .runtimeType); + firstChanged.icon.bitmap.runtimeType, + GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( + object2new.icon, + ).bitmap.runtimeType, + ); expect(firstChanged.infoWindow.title, object2new.infoWindow.title); expect(firstChanged.infoWindow.snippet, object2new.infoWindow.snippet); expect(firstChanged.infoWindow.anchor.x, object2new.infoWindow.anchor.dx); @@ -495,11 +589,11 @@ void main() { expect(firstAdded.draggable, object3.draggable); expect(firstAdded.flat, object3.flat); expect( - firstAdded.icon.bitmap.runtimeType, - GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( - object3.icon) - .bitmap - .runtimeType); + firstAdded.icon.bitmap.runtimeType, + GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( + object3.icon, + ).bitmap.runtimeType, + ); expect(firstAdded.infoWindow.title, object3.infoWindow.title); expect(firstAdded.infoWindow.snippet, object3.infoWindow.snippet); expect(firstAdded.infoWindow.anchor.x, object3.infoWindow.anchor.dx); @@ -517,20 +611,25 @@ void main() { test('updatePolygons passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const Polygon object1 = Polygon(polygonId: PolygonId('1')); const Polygon object2old = Polygon(polygonId: PolygonId('2')); final Polygon object2new = object2old.copyWith(strokeWidthParam: 42); const Polygon object3 = Polygon(polygonId: PolygonId('3')); await maps.updatePolygons( - PolygonUpdates.from( - {object1, object2old}, {object2new, object3}), - mapId: mapId); + PolygonUpdates.from( + {object1, object2old}, + {object2new, object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updatePolygons(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updatePolygons(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toChange = @@ -573,26 +672,37 @@ void main() { test('updatePolylines passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const Polyline object1 = Polyline(polylineId: PolylineId('1')); const Polyline object2old = Polyline(polylineId: PolylineId('2')); final Polyline object2new = object2old.copyWith( - widthParam: 42, startCapParam: Cap.squareCap, endCapParam: Cap.buttCap); - final Cap customCap = - Cap.customCapFromBitmap(BitmapDescriptor.defaultMarker, refWidth: 15); + widthParam: 42, + startCapParam: Cap.squareCap, + endCapParam: Cap.buttCap, + ); + final Cap customCap = Cap.customCapFromBitmap( + BitmapDescriptor.defaultMarker, + refWidth: 15, + ); final Polyline object3 = Polyline( - polylineId: const PolylineId('3'), - startCap: customCap, - endCap: Cap.roundCap); + polylineId: const PolylineId('3'), + startCap: customCap, + endCap: Cap.roundCap, + ); await maps.updatePolylines( - PolylineUpdates.from( - {object1, object2old}, {object2new, object3}), - mapId: mapId); + PolylineUpdates.from( + {object1, object2old}, + {object2new, object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updatePolylines(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updatePolylines(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toChange = @@ -604,7 +714,9 @@ void main() { expect(actual.color, expected.color.value); expect(actual.geodesic, expected.geodesic); expect( - actual.jointType, platformJointTypeFromJointType(expected.jointType)); + actual.jointType, + platformJointTypeFromJointType(expected.jointType), + ); expect(actual.visible, expected.visible); expect(actual.width, expected.width); expect(actual.zIndex, expected.zIndex); @@ -616,8 +728,10 @@ void main() { expect(actual.patterns.length, expected.patterns.length); for (final (int i, PlatformPatternItem? pattern) in actual.patterns.indexed) { - expect(pattern?.encode(), - platformPatternItemFromPatternItem(expected.patterns[i]).encode()); + expect( + pattern?.encode(), + platformPatternItemFromPatternItem(expected.patterns[i]).encode(), + ); } final PlatformCap expectedStartCap = GoogleMapsFlutterAndroid.platformCapFromCap(expected.startCap); @@ -625,12 +739,16 @@ void main() { GoogleMapsFlutterAndroid.platformCapFromCap(expected.endCap); expect(actual.startCap.type, expectedStartCap.type); expect(actual.startCap.refWidth, expectedStartCap.refWidth); - expect(actual.startCap.bitmapDescriptor?.bitmap.runtimeType, - expectedStartCap.bitmapDescriptor?.bitmap.runtimeType); + expect( + actual.startCap.bitmapDescriptor?.bitmap.runtimeType, + expectedStartCap.bitmapDescriptor?.bitmap.runtimeType, + ); expect(actual.endCap.type, expectedEndCap.type); expect(actual.endCap.refWidth, expectedEndCap.refWidth); - expect(actual.endCap.bitmapDescriptor?.bitmap.runtimeType, - expectedEndCap.bitmapDescriptor?.bitmap.runtimeType); + expect( + actual.endCap.bitmapDescriptor?.bitmap.runtimeType, + expectedEndCap.bitmapDescriptor?.bitmap.runtimeType, + ); } // Object one should be removed. @@ -646,25 +764,32 @@ void main() { test('updateTileOverlays passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const TileOverlay object1 = TileOverlay(tileOverlayId: TileOverlayId('1')); - const TileOverlay object2old = - TileOverlay(tileOverlayId: TileOverlayId('2')); + const TileOverlay object2old = TileOverlay( + tileOverlayId: TileOverlayId('2'), + ); final TileOverlay object2new = object2old.copyWith(zIndexParam: 42); const TileOverlay object3 = TileOverlay(tileOverlayId: TileOverlayId('3')); // Pre-set the initial state, since this update method doesn't take the old // state. await maps.updateTileOverlays( - newTileOverlays: {object1, object2old}, mapId: mapId); + newTileOverlays: {object1, object2old}, + mapId: mapId, + ); clearInteractions(api); await maps.updateTileOverlays( - newTileOverlays: {object2new, object3}, mapId: mapId); + newTileOverlays: {object2new, object3}, + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updateTileOverlays(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updateTileOverlays(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toChange = @@ -692,8 +817,9 @@ void main() { test('updateGroundOverlays passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final AssetMapBitmap image = AssetMapBitmap( 'assets/red_square.png', @@ -702,15 +828,21 @@ void main() { ); final GroundOverlay object1 = GroundOverlay.fromBounds( - groundOverlayId: const GroundOverlayId('1'), - bounds: LatLngBounds( - southwest: const LatLng(10, 20), northeast: const LatLng(30, 40)), - image: image); + groundOverlayId: const GroundOverlayId('1'), + bounds: LatLngBounds( + southwest: const LatLng(10, 20), + northeast: const LatLng(30, 40), + ), + image: image, + ); final GroundOverlay object2old = GroundOverlay.fromBounds( - groundOverlayId: const GroundOverlayId('2'), - bounds: LatLngBounds( - southwest: const LatLng(10, 20), northeast: const LatLng(30, 40)), - image: image); + groundOverlayId: const GroundOverlayId('2'), + bounds: LatLngBounds( + southwest: const LatLng(10, 20), + northeast: const LatLng(30, 40), + ), + image: image, + ); final GroundOverlay object2new = object2old.copyWith( visibleParam: false, bearingParam: 10, @@ -725,12 +857,16 @@ void main() { image: image, ); await maps.updateGroundOverlays( - GroundOverlayUpdates.from({object1, object2old}, - {object2new, object3}), - mapId: mapId); + GroundOverlayUpdates.from( + {object1, object2old}, + {object2new, object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updateGroundOverlays(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updateGroundOverlays(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; @@ -747,14 +883,22 @@ void main() { expect(firstChanged.anchor?.x, object2new.anchor?.dx); expect(firstChanged.anchor?.y, object2new.anchor?.dy); expect(firstChanged.bearing, object2new.bearing); - expect(firstChanged.bounds?.northeast.latitude, - object2new.bounds?.northeast.latitude); - expect(firstChanged.bounds?.northeast.longitude, - object2new.bounds?.northeast.longitude); - expect(firstChanged.bounds?.southwest.latitude, - object2new.bounds?.southwest.latitude); - expect(firstChanged.bounds?.southwest.longitude, - object2new.bounds?.southwest.longitude); + expect( + firstChanged.bounds?.northeast.latitude, + object2new.bounds?.northeast.latitude, + ); + expect( + firstChanged.bounds?.northeast.longitude, + object2new.bounds?.northeast.longitude, + ); + expect( + firstChanged.bounds?.southwest.latitude, + object2new.bounds?.southwest.latitude, + ); + expect( + firstChanged.bounds?.southwest.longitude, + object2new.bounds?.southwest.longitude, + ); expect(firstChanged.visible, object2new.visible); expect(firstChanged.clickable, object2new.clickable); expect(firstChanged.zIndex, object2new.zIndex); @@ -764,11 +908,11 @@ void main() { expect(firstChanged.height, object2new.height); expect(firstChanged.transparency, object2new.transparency); expect( - firstChanged.image.bitmap.runtimeType, - GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( - object2new.image) - .bitmap - .runtimeType); + firstChanged.image.bitmap.runtimeType, + GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( + object2new.image, + ).bitmap.runtimeType, + ); } // Object three should be added. { @@ -777,14 +921,22 @@ void main() { expect(firstAdded.anchor?.x, object3.anchor?.dx); expect(firstAdded.anchor?.y, object3.anchor?.dy); expect(firstAdded.bearing, object3.bearing); - expect(firstAdded.bounds?.northeast.latitude, - object3.bounds?.northeast.latitude); - expect(firstAdded.bounds?.northeast.longitude, - object3.bounds?.northeast.longitude); - expect(firstAdded.bounds?.southwest.latitude, - object3.bounds?.southwest.latitude); - expect(firstAdded.bounds?.southwest.longitude, - object3.bounds?.southwest.longitude); + expect( + firstAdded.bounds?.northeast.latitude, + object3.bounds?.northeast.latitude, + ); + expect( + firstAdded.bounds?.northeast.longitude, + object3.bounds?.northeast.longitude, + ); + expect( + firstAdded.bounds?.southwest.latitude, + object3.bounds?.southwest.latitude, + ); + expect( + firstAdded.bounds?.southwest.longitude, + object3.bounds?.southwest.longitude, + ); expect(firstAdded.visible, object3.visible); expect(firstAdded.clickable, object3.clickable); expect(firstAdded.zIndex, object3.zIndex); @@ -794,68 +946,79 @@ void main() { expect(firstAdded.height, object3.height); expect(firstAdded.transparency, object3.transparency); expect( - firstAdded.image.bitmap.runtimeType, - GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( - object3.image) - .bitmap - .runtimeType); + firstAdded.image.bitmap.runtimeType, + GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor( + object3.image, + ).bitmap.runtimeType, + ); } }); test( - 'updateGroundOverlays throws assertion error on unsupported ground overlays', - () async { - const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); - - final AssetMapBitmap image = AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 1.0, - bitmapScaling: MapBitmapScaling.none, - ); - - final GroundOverlay groundOverlay = GroundOverlay.fromPosition( - groundOverlayId: const GroundOverlayId('1'), - position: const LatLng(10, 20), - // Assert should be thrown because width is not set for position-based - // ground overlay on Android. - // ignore: avoid_redundant_argument_values - width: null, - image: image, - ); + 'updateGroundOverlays throws assertion error on unsupported ground overlays', + () async { + const int mapId = 1; + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); + + final AssetMapBitmap image = AssetMapBitmap( + 'assets/red_square.png', + imagePixelRatio: 1.0, + bitmapScaling: MapBitmapScaling.none, + ); + + final GroundOverlay groundOverlay = GroundOverlay.fromPosition( + groundOverlayId: const GroundOverlayId('1'), + position: const LatLng(10, 20), + // Assert should be thrown because width is not set for position-based + // ground overlay on Android. + // ignore: avoid_redundant_argument_values + width: null, + image: image, + ); - expect( - () async => maps.updateGroundOverlays( - GroundOverlayUpdates.from( - const {}, {groundOverlay}), - mapId: mapId), - throwsAssertionError, - ); + expect( + () async => maps.updateGroundOverlays( + GroundOverlayUpdates.from(const {}, { + groundOverlay, + }), + mapId: mapId, + ), + throwsAssertionError, + ); - expect( - () async => maps.buildViewWithConfiguration(1, (int _) {}, + expect( + () async => maps.buildViewWithConfiguration( + 1, + (int _) {}, widgetConfiguration: const MapWidgetConfiguration( initialCameraPosition: CameraPosition(target: LatLng(0, 0)), textDirection: TextDirection.ltr, ), - mapObjects: - MapObjects(groundOverlays: {groundOverlay})), - throwsAssertionError, - ); - }); + mapObjects: MapObjects( + groundOverlays: {groundOverlay}, + ), + ), + throwsAssertionError, + ); + }, + ); test('markers send drag event to correct streams', () async { const int mapId = 1; const String dragStartId = 'drag-start-marker'; const String dragId = 'drag-marker'; const String dragEndId = 'drag-end-marker'; - final PlatformLatLng fakePosition = - PlatformLatLng(latitude: 1.0, longitude: 1.0); + final PlatformLatLng fakePosition = PlatformLatLng( + latitude: 1.0, + longitude: 1.0, + ); final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); final StreamQueue markerDragStartStream = StreamQueue(maps.onMarkerDragStart(mapId: mapId)); @@ -879,11 +1042,13 @@ void main() { const String objectId = 'object-id'; final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); - final StreamQueue stream = - StreamQueue(maps.onMarkerTap(mapId: mapId)); + final StreamQueue stream = StreamQueue( + maps.onMarkerTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onMarkerTap(objectId); @@ -896,11 +1061,13 @@ void main() { const String objectId = 'object-id'; final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); - final StreamQueue stream = - StreamQueue(maps.onCircleTap(mapId: mapId)); + final StreamQueue stream = StreamQueue( + maps.onCircleTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onCircleTap(objectId); @@ -911,24 +1078,30 @@ void main() { test('clusters send tap events to correct stream', () async { const int mapId = 1; const String managerId = 'manager-id'; - final PlatformLatLng fakePosition = - PlatformLatLng(latitude: 10, longitude: 20); + final PlatformLatLng fakePosition = PlatformLatLng( + latitude: 10, + longitude: 20, + ); final PlatformLatLngBounds fakeBounds = PlatformLatLngBounds( - southwest: PlatformLatLng(latitude: 30, longitude: 40), - northeast: PlatformLatLng(latitude: 50, longitude: 60)); + southwest: PlatformLatLng(latitude: 30, longitude: 40), + northeast: PlatformLatLng(latitude: 50, longitude: 60), + ); const List markerIds = ['marker-1', 'marker-2']; final PlatformCluster cluster = PlatformCluster( - clusterManagerId: managerId, - position: fakePosition, - bounds: fakeBounds, - markerIds: markerIds); + clusterManagerId: managerId, + position: fakePosition, + bounds: fakeBounds, + markerIds: markerIds, + ); final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); - final StreamQueue stream = - StreamQueue(maps.onClusterTap(mapId: mapId)); + final StreamQueue stream = StreamQueue( + maps.onClusterTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onClusterTap(cluster); @@ -939,10 +1112,14 @@ void main() { expect(eventValue.position.longitude, fakePosition.longitude); expect(eventValue.bounds.southwest.latitude, fakeBounds.southwest.latitude); expect( - eventValue.bounds.southwest.longitude, fakeBounds.southwest.longitude); + eventValue.bounds.southwest.longitude, + fakeBounds.southwest.longitude, + ); expect(eventValue.bounds.northeast.latitude, fakeBounds.northeast.latitude); expect( - eventValue.bounds.northeast.longitude, fakeBounds.northeast.longitude); + eventValue.bounds.northeast.longitude, + fakeBounds.northeast.longitude, + ); expect(eventValue.markerIds.length, markerIds.length); expect(eventValue.markerIds.first.value, markerIds.first); }); @@ -952,11 +1129,13 @@ void main() { const String objectId = 'object-id'; final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); - final StreamQueue stream = - StreamQueue(maps.onPolygonTap(mapId: mapId)); + final StreamQueue stream = StreamQueue( + maps.onPolygonTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onPolygonTap(objectId); @@ -969,11 +1148,13 @@ void main() { const String objectId = 'object-id'; final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); - final StreamQueue stream = - StreamQueue(maps.onPolylineTap(mapId: mapId)); + final StreamQueue stream = StreamQueue( + maps.onPolylineTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onPolylineTap(objectId); @@ -986,12 +1167,14 @@ void main() { const String objectId = 'object-id'; final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); final StreamQueue stream = StreamQueue( - maps.onGroundOverlayTap(mapId: mapId)); + maps.onGroundOverlayTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onGroundOverlayTap(objectId); @@ -999,25 +1182,26 @@ void main() { expect((await stream.next).value.value, equals(objectId)); }); - test( - 'Does not use PlatformViewLink when using TLHC', - () async { - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); - maps.useAndroidViewSurface = false; - final Widget widget = maps.buildViewWithConfiguration(1, (int _) {}, - widgetConfiguration: const MapWidgetConfiguration( - initialCameraPosition: - CameraPosition(target: LatLng(0, 0), zoom: 1), - textDirection: TextDirection.ltr)); + test('Does not use PlatformViewLink when using TLHC', () async { + final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + maps.useAndroidViewSurface = false; + final Widget widget = maps.buildViewWithConfiguration( + 1, + (int _) {}, + widgetConfiguration: const MapWidgetConfiguration( + initialCameraPosition: CameraPosition(target: LatLng(0, 0), zoom: 1), + textDirection: TextDirection.ltr, + ), + ); - expect(widget, isA()); - }, - ); + expect(widget, isA()); + }); test('moveCamera calls through with expected newCameraPosition', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const LatLng latLng = LatLng(10.0, 20.0); const CameraPosition position = CameraPosition(target: latLng); @@ -1030,16 +1214,21 @@ void main() { final PlatformCameraUpdateNewCameraPosition typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewCameraPosition; update as CameraUpdateNewCameraPosition; - expect(typedUpdate.cameraPosition.target.latitude, - update.cameraPosition.target.latitude); - expect(typedUpdate.cameraPosition.target.longitude, - update.cameraPosition.target.longitude); + expect( + typedUpdate.cameraPosition.target.latitude, + update.cameraPosition.target.latitude, + ); + expect( + typedUpdate.cameraPosition.target.longitude, + update.cameraPosition.target.longitude, + ); }); test('moveCamera calls through with expected newLatLng', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const LatLng latLng = LatLng(10.0, 20.0); final CameraUpdate update = CameraUpdate.newLatLng(latLng); @@ -1057,12 +1246,14 @@ void main() { test('moveCamera calls through with expected newLatLngBounds', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final LatLngBounds latLng = LatLngBounds( - northeast: const LatLng(10.0, 20.0), - southwest: const LatLng(9.0, 21.0)); + northeast: const LatLng(10.0, 20.0), + southwest: const LatLng(9.0, 21.0), + ); final CameraUpdate update = CameraUpdate.newLatLngBounds(latLng, 1.0); await maps.moveCamera(update, mapId: mapId); @@ -1072,21 +1263,30 @@ void main() { final PlatformCameraUpdateNewLatLngBounds typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLngBounds; update as CameraUpdateNewLatLngBounds; - expect(typedUpdate.bounds.northeast.latitude, - update.bounds.northeast.latitude); - expect(typedUpdate.bounds.northeast.longitude, - update.bounds.northeast.longitude); - expect(typedUpdate.bounds.southwest.latitude, - update.bounds.southwest.latitude); - expect(typedUpdate.bounds.southwest.longitude, - update.bounds.southwest.longitude); + expect( + typedUpdate.bounds.northeast.latitude, + update.bounds.northeast.latitude, + ); + expect( + typedUpdate.bounds.northeast.longitude, + update.bounds.northeast.longitude, + ); + expect( + typedUpdate.bounds.southwest.latitude, + update.bounds.southwest.latitude, + ); + expect( + typedUpdate.bounds.southwest.longitude, + update.bounds.southwest.longitude, + ); expect(typedUpdate.padding, update.padding); }); test('moveCamera calls through with expected newLatLngZoom', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const LatLng latLng = LatLng(10.0, 20.0); final CameraUpdate update = CameraUpdate.newLatLngZoom(latLng, 2.0); @@ -1105,8 +1305,9 @@ void main() { test('moveCamera calls through with expected zoomBy', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const Offset focus = Offset(10.0, 20.0); final CameraUpdate update = CameraUpdate.zoomBy(2.0, focus); @@ -1125,8 +1326,9 @@ void main() { test('moveCamera calls through with expected zoomTo', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.zoomTo(2.0); await maps.moveCamera(update, mapId: mapId); @@ -1142,8 +1344,9 @@ void main() { test('moveCamera calls through with expected zoomIn', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.zoomIn(); await maps.moveCamera(update, mapId: mapId); @@ -1158,8 +1361,9 @@ void main() { test('moveCamera calls through with expected zoomOut', () async { const int mapId = 1; - final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.zoomOut(); await maps.moveCamera(update, mapId: mapId); @@ -1174,13 +1378,17 @@ void main() { test('MapBitmapScaling to PlatformMapBitmapScaling', () { expect( - GoogleMapsFlutterAndroid.platformMapBitmapScalingFromScaling( - MapBitmapScaling.auto), - PlatformMapBitmapScaling.auto); + GoogleMapsFlutterAndroid.platformMapBitmapScalingFromScaling( + MapBitmapScaling.auto, + ), + PlatformMapBitmapScaling.auto, + ); expect( - GoogleMapsFlutterAndroid.platformMapBitmapScalingFromScaling( - MapBitmapScaling.none), - PlatformMapBitmapScaling.none); + GoogleMapsFlutterAndroid.platformMapBitmapScalingFromScaling( + MapBitmapScaling.none, + ), + PlatformMapBitmapScaling.none, + ); }); test('DefaultMarker bitmap to PlatformBitmap', () { @@ -1195,8 +1403,12 @@ void main() { test('BytesMapBitmap bitmap to PlatformBitmap', () { final Uint8List data = Uint8List.fromList([1, 2, 3, 4]); - final BytesMapBitmap bitmap = BitmapDescriptor.bytes(data, - imagePixelRatio: 2.0, width: 100.0, height: 200.0); + final BytesMapBitmap bitmap = BitmapDescriptor.bytes( + data, + imagePixelRatio: 2.0, + width: 100.0, + height: 200.0, + ); final PlatformBitmap platformBitmap = GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor(bitmap); expect(platformBitmap.bitmap, isA()); @@ -1211,8 +1423,12 @@ void main() { test('AssetMapBitmap bitmap to PlatformBitmap', () { const String assetName = 'fake_asset_name'; - final AssetMapBitmap bitmap = AssetMapBitmap(assetName, - imagePixelRatio: 2.0, width: 100.0, height: 200.0); + final AssetMapBitmap bitmap = AssetMapBitmap( + assetName, + imagePixelRatio: 2.0, + width: 100.0, + height: 200.0, + ); final PlatformBitmap platformBitmap = GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor(bitmap); expect(platformBitmap.bitmap, isA()); @@ -1226,31 +1442,42 @@ void main() { }); test('Cap to PlatformCap', () { - expect(GoogleMapsFlutterAndroid.platformCapFromCap(Cap.buttCap).encode(), - PlatformCap(type: PlatformCapType.buttCap).encode()); - expect(GoogleMapsFlutterAndroid.platformCapFromCap(Cap.roundCap).encode(), - PlatformCap(type: PlatformCapType.roundCap).encode()); - expect(GoogleMapsFlutterAndroid.platformCapFromCap(Cap.squareCap).encode(), - PlatformCap(type: PlatformCapType.squareCap).encode()); + expect( + GoogleMapsFlutterAndroid.platformCapFromCap(Cap.buttCap).encode(), + PlatformCap(type: PlatformCapType.buttCap).encode(), + ); + expect( + GoogleMapsFlutterAndroid.platformCapFromCap(Cap.roundCap).encode(), + PlatformCap(type: PlatformCapType.roundCap).encode(), + ); + expect( + GoogleMapsFlutterAndroid.platformCapFromCap(Cap.squareCap).encode(), + PlatformCap(type: PlatformCapType.squareCap).encode(), + ); const BitmapDescriptor bitmap = BitmapDescriptor.defaultMarker; const CustomCap customCap = CustomCap(bitmap, refWidth: 15.0); - final PlatformCap platformCap = - GoogleMapsFlutterAndroid.platformCapFromCap(customCap); + final PlatformCap platformCap = GoogleMapsFlutterAndroid.platformCapFromCap( + customCap, + ); expect(platformCap.type, PlatformCapType.customCap); expect(customCap.refWidth, 15.0); }); - testWidgets('Use PlatformViewLink when using surface view', - (WidgetTester tester) async { + testWidgets('Use PlatformViewLink when using surface view', ( + WidgetTester tester, + ) async { final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); maps.useAndroidViewSurface = true; - final Widget widget = maps.buildViewWithConfiguration(1, (int _) {}, - widgetConfiguration: const MapWidgetConfiguration( - initialCameraPosition: - CameraPosition(target: LatLng(0, 0), zoom: 1), - textDirection: TextDirection.ltr)); + final Widget widget = maps.buildViewWithConfiguration( + 1, + (int _) {}, + widgetConfiguration: const MapWidgetConfiguration( + initialCameraPosition: CameraPosition(target: LatLng(0, 0), zoom: 1), + textDirection: TextDirection.ltr, + ), + ); expect(widget, isA()); }); @@ -1258,11 +1485,14 @@ void main() { testWidgets('Defaults to AndroidView', (WidgetTester tester) async { final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); - final Widget widget = maps.buildViewWithConfiguration(1, (int _) {}, - widgetConfiguration: const MapWidgetConfiguration( - initialCameraPosition: - CameraPosition(target: LatLng(0, 0), zoom: 1), - textDirection: TextDirection.ltr)); + final Widget widget = maps.buildViewWithConfiguration( + 1, + (int _) {}, + widgetConfiguration: const MapWidgetConfiguration( + initialCameraPosition: CameraPosition(target: LatLng(0, 0), zoom: 1), + textDirection: TextDirection.ltr, + ), + ); expect(widget, isA()); }); @@ -1272,39 +1502,44 @@ void main() { final Completer passedCloudMapIdCompleter = Completer(); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler( - SystemChannels.platform_views, - (MethodCall methodCall) async { - if (methodCall.method == 'create') { - final Map args = Map.from( - methodCall.arguments as Map); - if (args.containsKey('params')) { - final Uint8List paramsUint8List = args['params'] as Uint8List; - final ByteData byteData = ByteData.sublistView(paramsUint8List); - final PlatformMapViewCreationParams? creationParams = - MapsApi.pigeonChannelCodec.decodeMessage(byteData) - as PlatformMapViewCreationParams?; - if (creationParams != null) { - final String? passedMapId = - creationParams.mapConfiguration.cloudMapId; - if (passedMapId != null) { - passedCloudMapIdCompleter.complete(passedMapId); + .setMockMethodCallHandler(SystemChannels.platform_views, ( + MethodCall methodCall, + ) async { + if (methodCall.method == 'create') { + final Map args = Map.from( + methodCall.arguments as Map, + ); + if (args.containsKey('params')) { + final Uint8List paramsUint8List = args['params'] as Uint8List; + final ByteData byteData = ByteData.sublistView(paramsUint8List); + final PlatformMapViewCreationParams? creationParams = + MapsApi.pigeonChannelCodec.decodeMessage(byteData) + as PlatformMapViewCreationParams?; + if (creationParams != null) { + final String? passedMapId = + creationParams.mapConfiguration.cloudMapId; + if (passedMapId != null) { + passedCloudMapIdCompleter.complete(passedMapId); + } } } } - } - return 0; - }, - ); + return 0; + }); final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); - await tester.pumpWidget(maps.buildViewWithConfiguration(1, (int id) {}, + await tester.pumpWidget( + maps.buildViewWithConfiguration( + 1, + (int id) {}, widgetConfiguration: const MapWidgetConfiguration( - initialCameraPosition: - CameraPosition(target: LatLng(0, 0), zoom: 1), - textDirection: TextDirection.ltr), - mapConfiguration: const MapConfiguration(cloudMapId: cloudMapId))); + initialCameraPosition: CameraPosition(target: LatLng(0, 0), zoom: 1), + textDirection: TextDirection.ltr, + ), + mapConfiguration: const MapConfiguration(cloudMapId: cloudMapId), + ), + ); expect( await passedCloudMapIdCompleter.future, diff --git a/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.mocks.dart b/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.mocks.dart index 544e28588ee..cfa6b0c5514 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.mocks.dart +++ b/packages/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.mocks.dart @@ -25,35 +25,20 @@ import 'package:mockito/src/dummies.dart' as _i3; // ignore_for_file: subtype_of_sealed_class class _FakePlatformPoint_0 extends _i1.SmartFake implements _i2.PlatformPoint { - _FakePlatformPoint_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakePlatformPoint_0(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakePlatformLatLng_1 extends _i1.SmartFake implements _i2.PlatformLatLng { - _FakePlatformLatLng_1( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakePlatformLatLng_1(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakePlatformLatLngBounds_2 extends _i1.SmartFake implements _i2.PlatformLatLngBounds { - _FakePlatformLatLngBounds_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakePlatformLatLngBounds_2(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } /// A class which mocks [MapsApi]. @@ -61,39 +46,39 @@ class _FakePlatformLatLngBounds_2 extends _i1.SmartFake /// See the documentation for Mockito's code generation for more information. class MockMapsApi extends _i1.Mock implements _i2.MapsApi { @override - String get pigeonVar_messageChannelSuffix => (super.noSuchMethod( - Invocation.getter(#pigeonVar_messageChannelSuffix), - returnValue: _i3.dummyValue( - this, - Invocation.getter(#pigeonVar_messageChannelSuffix), - ), - returnValueForMissingStub: _i3.dummyValue( - this, - Invocation.getter(#pigeonVar_messageChannelSuffix), - ), - ) as String); + String get pigeonVar_messageChannelSuffix => + (super.noSuchMethod( + Invocation.getter(#pigeonVar_messageChannelSuffix), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#pigeonVar_messageChannelSuffix), + ), + returnValueForMissingStub: _i3.dummyValue( + this, + Invocation.getter(#pigeonVar_messageChannelSuffix), + ), + ) + as String); @override - _i4.Future waitForMap() => (super.noSuchMethod( - Invocation.method( - #waitForMap, - [], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future waitForMap() => + (super.noSuchMethod( + Invocation.method(#waitForMap, []), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateMapConfiguration( - _i2.PlatformMapConfiguration? configuration) => + _i2.PlatformMapConfiguration? configuration, + ) => (super.noSuchMethod( - Invocation.method( - #updateMapConfiguration, - [configuration], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateMapConfiguration, [configuration]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateCircles( @@ -102,17 +87,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method( - #updateCircles, - [ - toAdd, - toChange, - idsToRemove, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateCircles, [toAdd, toChange, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateHeatmaps( @@ -121,17 +100,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method( - #updateHeatmaps, - [ - toAdd, - toChange, - idsToRemove, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateHeatmaps, [toAdd, toChange, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateClusterManagers( @@ -139,16 +112,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method( - #updateClusterManagers, - [ - toAdd, - idsToRemove, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateClusterManagers, [toAdd, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateMarkers( @@ -157,17 +125,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method( - #updateMarkers, - [ - toAdd, - toChange, - idsToRemove, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateMarkers, [toAdd, toChange, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updatePolygons( @@ -176,17 +138,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method( - #updatePolygons, - [ - toAdd, - toChange, - idsToRemove, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updatePolygons, [toAdd, toChange, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updatePolylines( @@ -195,17 +151,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method( - #updatePolylines, - [ - toAdd, - toChange, - idsToRemove, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updatePolylines, [toAdd, toChange, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateTileOverlays( @@ -214,17 +164,15 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method( - #updateTileOverlays, - [ - toAdd, - toChange, - idsToRemove, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateTileOverlays, [ + toAdd, + toChange, + idsToRemove, + ]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateGroundOverlays( @@ -233,103 +181,86 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method( - #updateGroundOverlays, - [ - toAdd, - toChange, - idsToRemove, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateGroundOverlays, [ + toAdd, + toChange, + idsToRemove, + ]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future<_i2.PlatformPoint> getScreenCoordinate( - _i2.PlatformLatLng? latLng) => + _i2.PlatformLatLng? latLng, + ) => (super.noSuchMethod( - Invocation.method( - #getScreenCoordinate, - [latLng], - ), - returnValue: _i4.Future<_i2.PlatformPoint>.value(_FakePlatformPoint_0( - this, - Invocation.method( - #getScreenCoordinate, - [latLng], - ), - )), - returnValueForMissingStub: - _i4.Future<_i2.PlatformPoint>.value(_FakePlatformPoint_0( - this, - Invocation.method( - #getScreenCoordinate, - [latLng], - ), - )), - ) as _i4.Future<_i2.PlatformPoint>); + Invocation.method(#getScreenCoordinate, [latLng]), + returnValue: _i4.Future<_i2.PlatformPoint>.value( + _FakePlatformPoint_0( + this, + Invocation.method(#getScreenCoordinate, [latLng]), + ), + ), + returnValueForMissingStub: _i4.Future<_i2.PlatformPoint>.value( + _FakePlatformPoint_0( + this, + Invocation.method(#getScreenCoordinate, [latLng]), + ), + ), + ) + as _i4.Future<_i2.PlatformPoint>); @override _i4.Future<_i2.PlatformLatLng> getLatLng( - _i2.PlatformPoint? screenCoordinate) => + _i2.PlatformPoint? screenCoordinate, + ) => (super.noSuchMethod( - Invocation.method( - #getLatLng, - [screenCoordinate], - ), - returnValue: _i4.Future<_i2.PlatformLatLng>.value(_FakePlatformLatLng_1( - this, - Invocation.method( - #getLatLng, - [screenCoordinate], - ), - )), - returnValueForMissingStub: - _i4.Future<_i2.PlatformLatLng>.value(_FakePlatformLatLng_1( - this, - Invocation.method( - #getLatLng, - [screenCoordinate], - ), - )), - ) as _i4.Future<_i2.PlatformLatLng>); + Invocation.method(#getLatLng, [screenCoordinate]), + returnValue: _i4.Future<_i2.PlatformLatLng>.value( + _FakePlatformLatLng_1( + this, + Invocation.method(#getLatLng, [screenCoordinate]), + ), + ), + returnValueForMissingStub: _i4.Future<_i2.PlatformLatLng>.value( + _FakePlatformLatLng_1( + this, + Invocation.method(#getLatLng, [screenCoordinate]), + ), + ), + ) + as _i4.Future<_i2.PlatformLatLng>); @override _i4.Future<_i2.PlatformLatLngBounds> getVisibleRegion() => (super.noSuchMethod( - Invocation.method( - #getVisibleRegion, - [], - ), - returnValue: _i4.Future<_i2.PlatformLatLngBounds>.value( - _FakePlatformLatLngBounds_2( - this, - Invocation.method( - #getVisibleRegion, - [], - ), - )), - returnValueForMissingStub: _i4.Future<_i2.PlatformLatLngBounds>.value( - _FakePlatformLatLngBounds_2( - this, - Invocation.method( - #getVisibleRegion, - [], - ), - )), - ) as _i4.Future<_i2.PlatformLatLngBounds>); + Invocation.method(#getVisibleRegion, []), + returnValue: _i4.Future<_i2.PlatformLatLngBounds>.value( + _FakePlatformLatLngBounds_2( + this, + Invocation.method(#getVisibleRegion, []), + ), + ), + returnValueForMissingStub: + _i4.Future<_i2.PlatformLatLngBounds>.value( + _FakePlatformLatLngBounds_2( + this, + Invocation.method(#getVisibleRegion, []), + ), + ), + ) + as _i4.Future<_i2.PlatformLatLngBounds>); @override _i4.Future moveCamera(_i2.PlatformCameraUpdate? cameraUpdate) => (super.noSuchMethod( - Invocation.method( - #moveCamera, - [cameraUpdate], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#moveCamera, [cameraUpdate]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future animateCamera( @@ -337,97 +268,88 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { int? durationMilliseconds, ) => (super.noSuchMethod( - Invocation.method( - #animateCamera, - [ - cameraUpdate, - durationMilliseconds, - ], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#animateCamera, [ + cameraUpdate, + durationMilliseconds, + ]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override - _i4.Future getZoomLevel() => (super.noSuchMethod( - Invocation.method( - #getZoomLevel, - [], - ), - returnValue: _i4.Future.value(0.0), - returnValueForMissingStub: _i4.Future.value(0.0), - ) as _i4.Future); + _i4.Future getZoomLevel() => + (super.noSuchMethod( + Invocation.method(#getZoomLevel, []), + returnValue: _i4.Future.value(0.0), + returnValueForMissingStub: _i4.Future.value(0.0), + ) + as _i4.Future); @override - _i4.Future showInfoWindow(String? markerId) => (super.noSuchMethod( - Invocation.method( - #showInfoWindow, - [markerId], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future showInfoWindow(String? markerId) => + (super.noSuchMethod( + Invocation.method(#showInfoWindow, [markerId]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override - _i4.Future hideInfoWindow(String? markerId) => (super.noSuchMethod( - Invocation.method( - #hideInfoWindow, - [markerId], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future hideInfoWindow(String? markerId) => + (super.noSuchMethod( + Invocation.method(#hideInfoWindow, [markerId]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override - _i4.Future isInfoWindowShown(String? markerId) => (super.noSuchMethod( - Invocation.method( - #isInfoWindowShown, - [markerId], - ), - returnValue: _i4.Future.value(false), - returnValueForMissingStub: _i4.Future.value(false), - ) as _i4.Future); + _i4.Future isInfoWindowShown(String? markerId) => + (super.noSuchMethod( + Invocation.method(#isInfoWindowShown, [markerId]), + returnValue: _i4.Future.value(false), + returnValueForMissingStub: _i4.Future.value(false), + ) + as _i4.Future); @override - _i4.Future setStyle(String? style) => (super.noSuchMethod( - Invocation.method( - #setStyle, - [style], - ), - returnValue: _i4.Future.value(false), - returnValueForMissingStub: _i4.Future.value(false), - ) as _i4.Future); + _i4.Future setStyle(String? style) => + (super.noSuchMethod( + Invocation.method(#setStyle, [style]), + returnValue: _i4.Future.value(false), + returnValueForMissingStub: _i4.Future.value(false), + ) + as _i4.Future); @override - _i4.Future didLastStyleSucceed() => (super.noSuchMethod( - Invocation.method( - #didLastStyleSucceed, - [], - ), - returnValue: _i4.Future.value(false), - returnValueForMissingStub: _i4.Future.value(false), - ) as _i4.Future); + _i4.Future didLastStyleSucceed() => + (super.noSuchMethod( + Invocation.method(#didLastStyleSucceed, []), + returnValue: _i4.Future.value(false), + returnValueForMissingStub: _i4.Future.value(false), + ) + as _i4.Future); @override - _i4.Future clearTileCache(String? tileOverlayId) => (super.noSuchMethod( - Invocation.method( - #clearTileCache, - [tileOverlayId], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future clearTileCache(String? tileOverlayId) => + (super.noSuchMethod( + Invocation.method(#clearTileCache, [tileOverlayId]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override - _i4.Future<_i5.Uint8List> takeSnapshot() => (super.noSuchMethod( - Invocation.method( - #takeSnapshot, - [], - ), - returnValue: _i4.Future<_i5.Uint8List>.value(_i5.Uint8List(0)), - returnValueForMissingStub: - _i4.Future<_i5.Uint8List>.value(_i5.Uint8List(0)), - ) as _i4.Future<_i5.Uint8List>); + _i4.Future<_i5.Uint8List> takeSnapshot() => + (super.noSuchMethod( + Invocation.method(#takeSnapshot, []), + returnValue: _i4.Future<_i5.Uint8List>.value(_i5.Uint8List(0)), + returnValueForMissingStub: _i4.Future<_i5.Uint8List>.value( + _i5.Uint8List(0), + ), + ) + as _i4.Future<_i5.Uint8List>); } /// A class which mocks [MapsInitializerApi]. @@ -436,39 +358,42 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { class MockMapsInitializerApi extends _i1.Mock implements _i2.MapsInitializerApi { @override - String get pigeonVar_messageChannelSuffix => (super.noSuchMethod( - Invocation.getter(#pigeonVar_messageChannelSuffix), - returnValue: _i3.dummyValue( - this, - Invocation.getter(#pigeonVar_messageChannelSuffix), - ), - returnValueForMissingStub: _i3.dummyValue( - this, - Invocation.getter(#pigeonVar_messageChannelSuffix), - ), - ) as String); + String get pigeonVar_messageChannelSuffix => + (super.noSuchMethod( + Invocation.getter(#pigeonVar_messageChannelSuffix), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#pigeonVar_messageChannelSuffix), + ), + returnValueForMissingStub: _i3.dummyValue( + this, + Invocation.getter(#pigeonVar_messageChannelSuffix), + ), + ) + as String); @override _i4.Future<_i2.PlatformRendererType> initializeWithPreferredRenderer( - _i2.PlatformRendererType? type) => + _i2.PlatformRendererType? type, + ) => (super.noSuchMethod( - Invocation.method( - #initializeWithPreferredRenderer, - [type], - ), - returnValue: _i4.Future<_i2.PlatformRendererType>.value( - _i2.PlatformRendererType.legacy), - returnValueForMissingStub: _i4.Future<_i2.PlatformRendererType>.value( - _i2.PlatformRendererType.legacy), - ) as _i4.Future<_i2.PlatformRendererType>); + Invocation.method(#initializeWithPreferredRenderer, [type]), + returnValue: _i4.Future<_i2.PlatformRendererType>.value( + _i2.PlatformRendererType.legacy, + ), + returnValueForMissingStub: + _i4.Future<_i2.PlatformRendererType>.value( + _i2.PlatformRendererType.legacy, + ), + ) + as _i4.Future<_i2.PlatformRendererType>); @override - _i4.Future warmup() => (super.noSuchMethod( - Invocation.method( - #warmup, - [], - ), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future warmup() => + (super.noSuchMethod( + Invocation.method(#warmup, []), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md index 457136cbe56..8d82f086aeb 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_ios/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. + ## 2.15.5 * Fixes `kCGImageAlphaPremultipliedLast` implicit conversion from enumeration type warning. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/integration_test/google_maps_test.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/integration_test/google_maps_test.dart index 21347358665..7c3cdb52aca 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/integration_test/google_maps_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/integration_test/google_maps_test.dart @@ -38,7 +38,9 @@ const CameraPosition _kTestCameraPosition = CameraPosition( tilt: 1.0, ); final LatLngBounds _testCameraBounds = LatLngBounds( - northeast: const LatLng(50, -65), southwest: const LatLng(28.5, -123)); + northeast: const LatLng(50, -65), + southwest: const LatLng(28.5, -123), +); final ValueVariant _cameraUpdateTypeVariants = ValueVariant(CameraUpdateType.values.toSet()); @@ -49,17 +51,19 @@ void main() { testWidgets('testCompassToggle', (WidgetTester tester) async { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - compassEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + compassEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = @@ -67,16 +71,18 @@ void main() { bool compassEnabled = await inspector.isCompassEnabled(mapId: mapId); expect(compassEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); compassEnabled = await inspector.isCompassEnabled(mapId: mapId); expect(compassEnabled, true); @@ -86,22 +92,25 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - final bool mapToolbarEnabled = - await inspector.isMapToolbarEnabled(mapId: mapId); + final bool mapToolbarEnabled = await inspector.isMapToolbarEnabled( + mapId: mapId, + ); // This is only supported on Android, so should always return false. expect(mapToolbarEnabled, false); }); @@ -114,38 +123,43 @@ void main() { const MinMaxZoomPreference initialZoomLevel = MinMaxZoomPreference(4, 8); const MinMaxZoomPreference finalZoomLevel = MinMaxZoomPreference(6, 10); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - minMaxZoomPreference: initialZoomLevel, - onMapCreated: (ExampleGoogleMapController c) async { - controllerCompleter.complete(c); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + minMaxZoomPreference: initialZoomLevel, + onMapCreated: (ExampleGoogleMapController c) async { + controllerCompleter.complete(c); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - MinMaxZoomPreference zoomLevel = - await inspector.getMinMaxZoomLevels(mapId: controller.mapId); + MinMaxZoomPreference zoomLevel = await inspector.getMinMaxZoomLevels( + mapId: controller.mapId, + ); expect(zoomLevel, equals(initialZoomLevel)); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - minMaxZoomPreference: finalZoomLevel, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + minMaxZoomPreference: finalZoomLevel, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); zoomLevel = await inspector.getMinMaxZoomLevels(mapId: controller.mapId); expect(zoomLevel, equals(finalZoomLevel)); @@ -155,35 +169,40 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - zoomGesturesEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + zoomGesturesEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - bool zoomGesturesEnabled = - await inspector.areZoomGesturesEnabled(mapId: mapId); + bool zoomGesturesEnabled = await inspector.areZoomGesturesEnabled( + mapId: mapId, + ); expect(zoomGesturesEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); zoomGesturesEnabled = await inspector.areZoomGesturesEnabled(mapId: mapId); expect(zoomGesturesEnabled, true); @@ -193,22 +212,25 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - final bool zoomControlsEnabled = - await inspector.areZoomControlsEnabled(mapId: mapId); + final bool zoomControlsEnabled = await inspector.areZoomControlsEnabled( + mapId: mapId, + ); /// Zoom Controls functionality is not available on iOS at the moment. expect(zoomControlsEnabled, false); @@ -218,38 +240,44 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - rotateGesturesEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + rotateGesturesEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - bool rotateGesturesEnabled = - await inspector.areRotateGesturesEnabled(mapId: mapId); + bool rotateGesturesEnabled = await inspector.areRotateGesturesEnabled( + mapId: mapId, + ); expect(rotateGesturesEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); - rotateGesturesEnabled = - await inspector.areRotateGesturesEnabled(mapId: mapId); + rotateGesturesEnabled = await inspector.areRotateGesturesEnabled( + mapId: mapId, + ); expect(rotateGesturesEnabled, true); }); @@ -257,35 +285,40 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - tiltGesturesEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + tiltGesturesEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - bool tiltGesturesEnabled = - await inspector.areTiltGesturesEnabled(mapId: mapId); + bool tiltGesturesEnabled = await inspector.areTiltGesturesEnabled( + mapId: mapId, + ); expect(tiltGesturesEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); tiltGesturesEnabled = await inspector.areTiltGesturesEnabled(mapId: mapId); expect(tiltGesturesEnabled, true); @@ -295,47 +328,28 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - scrollGesturesEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + scrollGesturesEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - bool scrollGesturesEnabled = - await inspector.areScrollGesturesEnabled(mapId: mapId); + bool scrollGesturesEnabled = await inspector.areScrollGesturesEnabled( + mapId: mapId, + ); expect(scrollGesturesEnabled, false); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, - ), - )); - - scrollGesturesEnabled = - await inspector.areScrollGesturesEnabled(mapId: mapId); - expect(scrollGesturesEnabled, true); - }); - - testWidgets('testInitialCenterLocationAtCenter', (WidgetTester tester) async { - await tester.binding.setSurfaceSize(const Size(800, 600)); - - final Completer mapControllerCompleter = - Completer(); - final Key key = GlobalKey(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -343,117 +357,161 @@ void main() { key: key, initialCameraPosition: _kInitialCameraPosition, onMapCreated: (ExampleGoogleMapController controller) { - mapControllerCompleter.complete(controller); + fail('OnMapCreated should get called only once.'); }, ), ), ); - final ExampleGoogleMapController mapController = - await mapControllerCompleter.future; - await tester.pumpAndSettle(); + scrollGesturesEnabled = await inspector.areScrollGesturesEnabled( + mapId: mapId, + ); + expect(scrollGesturesEnabled, true); + }); - // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen - // in `mapRendered`. - // https://github.com/flutter/flutter/issues/54758 - await Future.delayed(const Duration(seconds: 1)); + testWidgets( + 'testInitialCenterLocationAtCenter', + (WidgetTester tester) async { + await tester.binding.setSurfaceSize(const Size(800, 600)); - final ScreenCoordinate coordinate = - await mapController.getScreenCoordinate(_kInitialCameraPosition.target); - final Rect rect = tester.getRect(find.byKey(key)); - expect(coordinate.x, (rect.center.dx - rect.topLeft.dx).round()); - expect(coordinate.y, (rect.center.dy - rect.topLeft.dy).round()); + final Completer mapControllerCompleter = + Completer(); + final Key key = GlobalKey(); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapControllerCompleter.complete(controller); + }, + ), + ), + ); + final ExampleGoogleMapController mapController = + await mapControllerCompleter.future; - await tester.binding.setSurfaceSize(null); - }, - // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 - skip: true); + await tester.pumpAndSettle(); - testWidgets('testGetVisibleRegion', (WidgetTester tester) async { - final Key key = GlobalKey(); - final LatLngBounds zeroLatLngBounds = LatLngBounds( - southwest: const LatLng(0, 0), northeast: const LatLng(0, 0)); + // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen + // in `mapRendered`. + // https://github.com/flutter/flutter/issues/54758 + await Future.delayed(const Duration(seconds: 1)); - final Completer mapControllerCompleter = - Completer(); + final ScreenCoordinate coordinate = await mapController + .getScreenCoordinate(_kInitialCameraPosition.target); + final Rect rect = tester.getRect(find.byKey(key)); + expect(coordinate.x, (rect.center.dx - rect.topLeft.dx).round()); + expect(coordinate.y, (rect.center.dy - rect.topLeft.dy).round()); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapControllerCompleter.complete(controller); - }, - ), - )); - await tester.pumpAndSettle(); + await tester.binding.setSurfaceSize(null); + }, + // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 + skip: true, + ); + + testWidgets( + 'testGetVisibleRegion', + (WidgetTester tester) async { + final Key key = GlobalKey(); + final LatLngBounds zeroLatLngBounds = LatLngBounds( + southwest: const LatLng(0, 0), + northeast: const LatLng(0, 0), + ); + + final Completer mapControllerCompleter = + Completer(); + + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapControllerCompleter.complete(controller); + }, + ), + ), + ); + await tester.pumpAndSettle(); - final ExampleGoogleMapController mapController = - await mapControllerCompleter.future; + final ExampleGoogleMapController mapController = + await mapControllerCompleter.future; - final LatLngBounds firstVisibleRegion = - await mapController.getVisibleRegion(); + final LatLngBounds firstVisibleRegion = + await mapController.getVisibleRegion(); - expect(firstVisibleRegion, isNotNull); - expect(firstVisibleRegion.southwest, isNotNull); - expect(firstVisibleRegion.northeast, isNotNull); - expect(firstVisibleRegion, isNot(zeroLatLngBounds)); - expect(firstVisibleRegion.contains(_kInitialMapCenter), isTrue); + expect(firstVisibleRegion, isNotNull); + expect(firstVisibleRegion.southwest, isNotNull); + expect(firstVisibleRegion.northeast, isNotNull); + expect(firstVisibleRegion, isNot(zeroLatLngBounds)); + expect(firstVisibleRegion.contains(_kInitialMapCenter), isTrue); - // Making a new `LatLngBounds` about (10, 10) distance south west to the `firstVisibleRegion`. - // The size of the `LatLngBounds` is 10 by 10. - final LatLng southWest = LatLng(firstVisibleRegion.southwest.latitude - 20, - firstVisibleRegion.southwest.longitude - 20); - final LatLng northEast = LatLng(firstVisibleRegion.southwest.latitude - 10, - firstVisibleRegion.southwest.longitude - 10); - final LatLng newCenter = LatLng( - (northEast.latitude + southWest.latitude) / 2, - (northEast.longitude + southWest.longitude) / 2, - ); + // Making a new `LatLngBounds` about (10, 10) distance south west to the `firstVisibleRegion`. + // The size of the `LatLngBounds` is 10 by 10. + final LatLng southWest = LatLng( + firstVisibleRegion.southwest.latitude - 20, + firstVisibleRegion.southwest.longitude - 20, + ); + final LatLng northEast = LatLng( + firstVisibleRegion.southwest.latitude - 10, + firstVisibleRegion.southwest.longitude - 10, + ); + final LatLng newCenter = LatLng( + (northEast.latitude + southWest.latitude) / 2, + (northEast.longitude + southWest.longitude) / 2, + ); - expect(firstVisibleRegion.contains(northEast), isFalse); - expect(firstVisibleRegion.contains(southWest), isFalse); + expect(firstVisibleRegion.contains(northEast), isFalse); + expect(firstVisibleRegion.contains(southWest), isFalse); - final LatLngBounds latLngBounds = - LatLngBounds(southwest: southWest, northeast: northEast); + final LatLngBounds latLngBounds = LatLngBounds( + southwest: southWest, + northeast: northEast, + ); - // TODO(iskakaushik): non-zero padding is needed for some device configurations - // https://github.com/flutter/flutter/issues/30575 - const double padding = 0; - await mapController - .moveCamera(CameraUpdate.newLatLngBounds(latLngBounds, padding)); - await tester.pumpAndSettle(const Duration(seconds: 3)); + // TODO(iskakaushik): non-zero padding is needed for some device configurations + // https://github.com/flutter/flutter/issues/30575 + const double padding = 0; + await mapController.moveCamera( + CameraUpdate.newLatLngBounds(latLngBounds, padding), + ); + await tester.pumpAndSettle(const Duration(seconds: 3)); - final LatLngBounds secondVisibleRegion = - await mapController.getVisibleRegion(); + final LatLngBounds secondVisibleRegion = + await mapController.getVisibleRegion(); - expect(secondVisibleRegion, isNotNull); - expect(secondVisibleRegion.southwest, isNotNull); - expect(secondVisibleRegion.northeast, isNotNull); - expect(secondVisibleRegion, isNot(zeroLatLngBounds)); + expect(secondVisibleRegion, isNotNull); + expect(secondVisibleRegion.southwest, isNotNull); + expect(secondVisibleRegion.northeast, isNotNull); + expect(secondVisibleRegion, isNot(zeroLatLngBounds)); - expect(firstVisibleRegion, isNot(secondVisibleRegion)); - expect(secondVisibleRegion.contains(newCenter), isTrue); - }, - // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 - skip: true); + expect(firstVisibleRegion, isNot(secondVisibleRegion)); + expect(secondVisibleRegion.contains(newCenter), isTrue); + }, + // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 + skip: true, + ); testWidgets('testTraffic', (WidgetTester tester) async { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - trafficEnabled: true, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + trafficEnabled: true, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = @@ -461,16 +519,18 @@ void main() { bool isTrafficEnabled = await inspector.isTrafficEnabled(mapId: mapId); expect(isTrafficEnabled, true); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); isTrafficEnabled = await inspector.isTrafficEnabled(mapId: mapId); expect(isTrafficEnabled, false); @@ -480,110 +540,125 @@ void main() { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), - )); - - final int mapId = await mapIdCompleter.future; - final GoogleMapsInspectorPlatform inspector = - GoogleMapsInspectorPlatform.instance!; - final bool isBuildingsEnabled = - await inspector.areBuildingsEnabled(mapId: mapId); - expect(isBuildingsEnabled, true); - }); - + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), + ), + ); + + final int mapId = await mapIdCompleter.future; + final GoogleMapsInspectorPlatform inspector = + GoogleMapsInspectorPlatform.instance!; + final bool isBuildingsEnabled = await inspector.areBuildingsEnabled( + mapId: mapId, + ); + expect(isBuildingsEnabled, true); + }); + testWidgets('testMyLocationButtonToggle', (WidgetTester tester) async { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); + bool myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled( + mapId: mapId, + ); expect(myLocationButtonEnabled, true); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - myLocationButtonEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + myLocationButtonEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, + ), ), - )); + ); - myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); + myLocationButtonEnabled = await inspector.isMyLocationButtonEnabled( + mapId: mapId, + ); expect(myLocationButtonEnabled, false); }); - testWidgets('testMyLocationButton initial value false', - (WidgetTester tester) async { + testWidgets('testMyLocationButton initial value false', ( + WidgetTester tester, + ) async { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - myLocationButtonEnabled: false, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + myLocationButtonEnabled: false, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - final bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); + final bool myLocationButtonEnabled = await inspector + .isMyLocationButtonEnabled(mapId: mapId); expect(myLocationButtonEnabled, false); }); - testWidgets('testMyLocationButton initial value true', - (WidgetTester tester) async { + testWidgets('testMyLocationButton initial value true', ( + WidgetTester tester, + ) async { final Key key = GlobalKey(); final Completer mapIdCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), ), - )); + ); final int mapId = await mapIdCompleter.future; final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - final bool myLocationButtonEnabled = - await inspector.isMyLocationButtonEnabled(mapId: mapId); + final bool myLocationButtonEnabled = await inspector + .isMyLocationButtonEnabled(mapId: mapId); expect(myLocationButtonEnabled, true); }); @@ -592,48 +667,57 @@ void main() { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; const String mapStyle = '[{"elementType":"geometry","stylers":[{"color":"#242f3e"}]}]'; - await GoogleMapsFlutterPlatform.instance - .setMapStyle(mapStyle, mapId: controller.mapId); + await GoogleMapsFlutterPlatform.instance.setMapStyle( + mapStyle, + mapId: controller.mapId, + ); }); - testWidgets('testSetMapStyle invalid Json String', - (WidgetTester tester) async { + testWidgets('testSetMapStyle invalid Json String', ( + WidgetTester tester, + ) async { final Key key = GlobalKey(); final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; try { - await GoogleMapsFlutterPlatform.instance - .setMapStyle('invalid_value', mapId: controller.mapId); + await GoogleMapsFlutterPlatform.instance.setMapStyle( + 'invalid_value', + mapId: controller.mapId, + ); fail('expected MapStyleException'); } on MapStyleException catch (e) { expect(e.cause, isNotNull); @@ -646,21 +730,25 @@ void main() { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; - await GoogleMapsFlutterPlatform.instance - .setMapStyle(null, mapId: controller.mapId); + await GoogleMapsFlutterPlatform.instance.setMapStyle( + null, + mapId: controller.mapId, + ); }); testWidgets('testGetLatLng', (WidgetTester tester) async { @@ -668,16 +756,18 @@ void main() { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -689,8 +779,9 @@ void main() { await Future.delayed(const Duration(seconds: 1)); final LatLngBounds visibleRegion = await controller.getVisibleRegion(); - final LatLng topLeft = - await controller.getLatLng(const ScreenCoordinate(x: 0, y: 0)); + final LatLng topLeft = await controller.getLatLng( + const ScreenCoordinate(x: 0, y: 0), + ); final LatLng northWest = LatLng( visibleRegion.northeast.latitude, visibleRegion.southwest.longitude, @@ -699,77 +790,88 @@ void main() { expect(topLeft, northWest); }); - testWidgets('testGetZoomLevel', (WidgetTester tester) async { - final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + testWidgets( + 'testGetZoomLevel', + (WidgetTester tester) async { + final Key key = GlobalKey(); + final Completer controllerCompleter = + Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, - ), - )); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), + ), + ); - final ExampleGoogleMapController controller = - await controllerCompleter.future; + final ExampleGoogleMapController controller = + await controllerCompleter.future; - await tester.pumpAndSettle(); - // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen - // in `mapRendered`. - // https://github.com/flutter/flutter/issues/54758 - await Future.delayed(const Duration(seconds: 1)); + await tester.pumpAndSettle(); + // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen + // in `mapRendered`. + // https://github.com/flutter/flutter/issues/54758 + await Future.delayed(const Duration(seconds: 1)); - double zoom = await controller.getZoomLevel(); - expect(zoom, _kInitialZoomLevel); + double zoom = await controller.getZoomLevel(); + expect(zoom, _kInitialZoomLevel); - await controller.moveCamera(CameraUpdate.zoomTo(7)); - await tester.pumpAndSettle(); - zoom = await controller.getZoomLevel(); - expect(zoom, equals(7)); - }, - // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 - skip: true); + await controller.moveCamera(CameraUpdate.zoomTo(7)); + await tester.pumpAndSettle(); + zoom = await controller.getZoomLevel(); + expect(zoom, equals(7)); + }, + // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 + skip: true, + ); - testWidgets('testScreenCoordinate', (WidgetTester tester) async { - final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + testWidgets( + 'testScreenCoordinate', + (WidgetTester tester) async { + final Key key = GlobalKey(); + final Completer controllerCompleter = + Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, - ), - )); - final ExampleGoogleMapController controller = - await controllerCompleter.future; + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), + ), + ); + final ExampleGoogleMapController controller = + await controllerCompleter.future; - await tester.pumpAndSettle(); - // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen - // in `mapRendered`. - // https://github.com/flutter/flutter/issues/54758 - await Future.delayed(const Duration(seconds: 1)); + await tester.pumpAndSettle(); + // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen + // in `mapRendered`. + // https://github.com/flutter/flutter/issues/54758 + await Future.delayed(const Duration(seconds: 1)); - final LatLngBounds visibleRegion = await controller.getVisibleRegion(); - final LatLng northWest = LatLng( - visibleRegion.northeast.latitude, - visibleRegion.southwest.longitude, - ); - final ScreenCoordinate topLeft = - await controller.getScreenCoordinate(northWest); - expect(topLeft, const ScreenCoordinate(x: 0, y: 0)); - }, - // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 - skip: true); + final LatLngBounds visibleRegion = await controller.getVisibleRegion(); + final LatLng northWest = LatLng( + visibleRegion.northeast.latitude, + visibleRegion.southwest.longitude, + ); + final ScreenCoordinate topLeft = await controller.getScreenCoordinate( + northWest, + ); + expect(topLeft, const ScreenCoordinate(x: 0, y: 0)); + }, + // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 + skip: true, + ); testWidgets('testResizeWidget', (WidgetTester tester) async { final Completer controllerCompleter = @@ -780,19 +882,25 @@ void main() { controllerCompleter.complete(controller); }, ); - await tester.pumpWidget(Directionality( + await tester.pumpWidget( + Directionality( textDirection: TextDirection.ltr, child: MaterialApp( - home: Scaffold( - body: SizedBox(height: 100, width: 100, child: map))))); + home: Scaffold(body: SizedBox(height: 100, width: 100, child: map)), + ), + ), + ); final ExampleGoogleMapController controller = await controllerCompleter.future; - await tester.pumpWidget(Directionality( + await tester.pumpWidget( + Directionality( textDirection: TextDirection.ltr, child: MaterialApp( - home: Scaffold( - body: SizedBox(height: 400, width: 400, child: map))))); + home: Scaffold(body: SizedBox(height: 400, width: 400, child: map)), + ), + ), + ); await tester.pumpAndSettle(); // TODO(cyanglaz): Remove this after we added `mapRendered` callback, and `mapControllerCompleter.complete(controller)` above should happen @@ -808,29 +916,35 @@ void main() { testWidgets('testToggleInfoWindow', (WidgetTester tester) async { const Marker marker = Marker( - markerId: MarkerId('marker'), - infoWindow: InfoWindow(title: 'InfoWindow')); + markerId: MarkerId('marker'), + infoWindow: InfoWindow(title: 'InfoWindow'), + ); final Set markers = {marker}; final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, - onMapCreated: (ExampleGoogleMapController googleMapController) { - controllerCompleter.complete(googleMapController); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + onMapCreated: (ExampleGoogleMapController googleMapController) { + controllerCompleter.complete(googleMapController); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; - bool iwVisibleStatus = - await controller.isMarkerInfoWindowShown(marker.markerId); + bool iwVisibleStatus = await controller.isMarkerInfoWindowShown( + marker.markerId, + ); expect(iwVisibleStatus, false); await controller.showMarkerInfoWindow(marker.markerId); @@ -842,42 +956,50 @@ void main() { expect(iwVisibleStatus, false); }); - testWidgets('updating a marker does not hide its info window', - (WidgetTester tester) async { + testWidgets('updating a marker does not hide its info window', ( + WidgetTester tester, + ) async { final Key key = GlobalKey(); const Marker marker = Marker( - markerId: MarkerId('marker'), - infoWindow: InfoWindow(title: 'InfoWindow')); + markerId: MarkerId('marker'), + infoWindow: InfoWindow(title: 'InfoWindow'), + ); Set markers = {marker}; - const ClusterManager clusterManager = - ClusterManager(clusterManagerId: ClusterManagerId('cluster_manager')); + const ClusterManager clusterManager = ClusterManager( + clusterManagerId: ClusterManagerId('cluster_manager'), + ); final Set clusterManagers = { - clusterManager + clusterManager, }; final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, - clusterManagers: clusterManagers, - onMapCreated: (ExampleGoogleMapController googleMapController) { - controllerCompleter.complete(googleMapController); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + clusterManagers: clusterManagers, + onMapCreated: (ExampleGoogleMapController googleMapController) { + controllerCompleter.complete(googleMapController); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; await controller.showMarkerInfoWindow(marker.markerId); - bool iwVisibleStatus = - await controller.isMarkerInfoWindowShown(marker.markerId); + bool iwVisibleStatus = await controller.isMarkerInfoWindowShown( + marker.markerId, + ); expect(iwVisibleStatus, true); // Update marker and ensure the info window remains visible when added to a @@ -888,227 +1010,243 @@ void main() { ); markers = {updatedMarker}; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - clusterManagers: clusterManagers, - markers: Set.of(markers)), - )); - - iwVisibleStatus = await controller.isMarkerInfoWindowShown(marker.markerId); - expect(iwVisibleStatus, true); - }); - - testWidgets('testTakeSnapshot', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); - await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, child: ExampleGoogleMap( + key: key, initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + clusterManagers: clusterManagers, + markers: Set.of(markers), ), ), ); - await tester.pumpAndSettle(const Duration(seconds: 3)); - - final ExampleGoogleMapController controller = - await controllerCompleter.future; - final Uint8List? bytes = await controller.takeSnapshot(); - expect(bytes?.isNotEmpty, true); - }, - // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 - skip: true); + iwVisibleStatus = await controller.isMarkerInfoWindowShown(marker.markerId); + expect(iwVisibleStatus, true); + }); testWidgets( - 'set tileOverlay correctly', + 'testTakeSnapshot', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final TileOverlay tileOverlay1 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 2, - transparency: 0.2, - ); + final Completer controllerCompleter = + Completer(); - final TileOverlay tileOverlay2 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_2'), - tileProvider: _DebugTileProvider(), - zIndex: 1, - visible: false, - transparency: 0.3, - fadeIn: false, - ); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, child: ExampleGoogleMap( initialCameraPosition: _kInitialCameraPosition, - tileOverlays: {tileOverlay1, tileOverlay2}, onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); + controllerCompleter.complete(controller); }, ), ), ); + await tester.pumpAndSettle(const Duration(seconds: 3)); - final int mapId = await mapIdCompleter.future; - final GoogleMapsInspectorPlatform inspector = - GoogleMapsInspectorPlatform.instance!; + final ExampleGoogleMapController controller = + await controllerCompleter.future; + final Uint8List? bytes = await controller.takeSnapshot(); + expect(bytes?.isNotEmpty, true); + }, + // TODO(stuartmorgan): Re-enable; see https://github.com/flutter/flutter/issues/139825 + skip: true, + ); - final TileOverlay tileOverlayInfo1 = (await inspector - .getTileOverlayInfo(tileOverlay1.mapsId, mapId: mapId))!; - final TileOverlay tileOverlayInfo2 = (await inspector - .getTileOverlayInfo(tileOverlay2.mapsId, mapId: mapId))!; + testWidgets('set tileOverlay correctly', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final TileOverlay tileOverlay1 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 2, + transparency: 0.2, + ); - expect(tileOverlayInfo1.visible, isTrue); - expect(tileOverlayInfo1.fadeIn, isTrue); - expect( - tileOverlayInfo1.transparency, moreOrLessEquals(0.2, epsilon: 0.001)); - expect(tileOverlayInfo1.zIndex, 2); + final TileOverlay tileOverlay2 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_2'), + tileProvider: _DebugTileProvider(), + zIndex: 1, + visible: false, + transparency: 0.3, + fadeIn: false, + ); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: _kInitialCameraPosition, + tileOverlays: {tileOverlay1, tileOverlay2}, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, + ), + ), + ); + await tester.pumpAndSettle(const Duration(seconds: 3)); - expect(tileOverlayInfo2.visible, isFalse); - expect(tileOverlayInfo2.fadeIn, isFalse); - expect( - tileOverlayInfo2.transparency, moreOrLessEquals(0.3, epsilon: 0.001)); - expect(tileOverlayInfo2.zIndex, 1); - }, - ); + final int mapId = await mapIdCompleter.future; + final GoogleMapsInspectorPlatform inspector = + GoogleMapsInspectorPlatform.instance!; - testWidgets( - 'update tileOverlays correctly', - (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 2, - transparency: 0.2, - ); + final TileOverlay tileOverlayInfo1 = + (await inspector.getTileOverlayInfo( + tileOverlay1.mapsId, + mapId: mapId, + ))!; + final TileOverlay tileOverlayInfo2 = + (await inspector.getTileOverlayInfo( + tileOverlay2.mapsId, + mapId: mapId, + ))!; + + expect(tileOverlayInfo1.visible, isTrue); + expect(tileOverlayInfo1.fadeIn, isTrue); + expect( + tileOverlayInfo1.transparency, + moreOrLessEquals(0.2, epsilon: 0.001), + ); + expect(tileOverlayInfo1.zIndex, 2); - final TileOverlay tileOverlay2 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_2'), - tileProvider: _DebugTileProvider(), - zIndex: 3, - transparency: 0.5, - ); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - tileOverlays: {tileOverlay1, tileOverlay2}, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), + expect(tileOverlayInfo2.visible, isFalse); + expect(tileOverlayInfo2.fadeIn, isFalse); + expect( + tileOverlayInfo2.transparency, + moreOrLessEquals(0.3, epsilon: 0.001), + ); + expect(tileOverlayInfo2.zIndex, 1); + }); + + testWidgets('update tileOverlays correctly', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final Key key = GlobalKey(); + final TileOverlay tileOverlay1 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 2, + transparency: 0.2, + ); + + final TileOverlay tileOverlay2 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_2'), + tileProvider: _DebugTileProvider(), + zIndex: 3, + transparency: 0.5, + ); + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + tileOverlays: {tileOverlay1, tileOverlay2}, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, ), - ); + ), + ); - final int mapId = await mapIdCompleter.future; - final GoogleMapsInspectorPlatform inspector = - GoogleMapsInspectorPlatform.instance!; + final int mapId = await mapIdCompleter.future; + final GoogleMapsInspectorPlatform inspector = + GoogleMapsInspectorPlatform.instance!; - final TileOverlay tileOverlay1New = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 1, - visible: false, - transparency: 0.3, - fadeIn: false, - ); + final TileOverlay tileOverlay1New = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 1, + visible: false, + transparency: 0.3, + fadeIn: false, + ); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - tileOverlays: {tileOverlay1New}, - onMapCreated: (ExampleGoogleMapController controller) { - fail('update: OnMapCreated should get called only once.'); - }, - ), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + tileOverlays: {tileOverlay1New}, + onMapCreated: (ExampleGoogleMapController controller) { + fail('update: OnMapCreated should get called only once.'); + }, ), - ); + ), + ); - await tester.pumpAndSettle(const Duration(seconds: 3)); + await tester.pumpAndSettle(const Duration(seconds: 3)); - final TileOverlay tileOverlayInfo1 = (await inspector - .getTileOverlayInfo(tileOverlay1.mapsId, mapId: mapId))!; - final TileOverlay? tileOverlayInfo2 = - await inspector.getTileOverlayInfo(tileOverlay2.mapsId, mapId: mapId); + final TileOverlay tileOverlayInfo1 = + (await inspector.getTileOverlayInfo( + tileOverlay1.mapsId, + mapId: mapId, + ))!; + final TileOverlay? tileOverlayInfo2 = await inspector.getTileOverlayInfo( + tileOverlay2.mapsId, + mapId: mapId, + ); - expect(tileOverlayInfo1.visible, isFalse); - expect(tileOverlayInfo1.fadeIn, isFalse); - expect( - tileOverlayInfo1.transparency, moreOrLessEquals(0.3, epsilon: 0.001)); - expect(tileOverlayInfo1.zIndex, 1); + expect(tileOverlayInfo1.visible, isFalse); + expect(tileOverlayInfo1.fadeIn, isFalse); + expect( + tileOverlayInfo1.transparency, + moreOrLessEquals(0.3, epsilon: 0.001), + ); + expect(tileOverlayInfo1.zIndex, 1); - expect(tileOverlayInfo2, isNull); - }, - ); + expect(tileOverlayInfo2, isNull); + }); - testWidgets( - 'remove tileOverlays correctly', - (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( - tileOverlayId: const TileOverlayId('tile_overlay_1'), - tileProvider: _DebugTileProvider(), - zIndex: 2, - transparency: 0.2, - ); + testWidgets('remove tileOverlays correctly', (WidgetTester tester) async { + final Completer mapIdCompleter = Completer(); + final Key key = GlobalKey(); + final TileOverlay tileOverlay1 = TileOverlay( + tileOverlayId: const TileOverlayId('tile_overlay_1'), + tileProvider: _DebugTileProvider(), + zIndex: 2, + transparency: 0.2, + ); - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - tileOverlays: {tileOverlay1}, - onMapCreated: (ExampleGoogleMapController controller) { - mapIdCompleter.complete(controller.mapId); - }, - ), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + tileOverlays: {tileOverlay1}, + onMapCreated: (ExampleGoogleMapController controller) { + mapIdCompleter.complete(controller.mapId); + }, ), - ); + ), + ); - final int mapId = await mapIdCompleter.future; - final GoogleMapsInspectorPlatform inspector = - GoogleMapsInspectorPlatform.instance!; + final int mapId = await mapIdCompleter.future; + final GoogleMapsInspectorPlatform inspector = + GoogleMapsInspectorPlatform.instance!; - await tester.pumpWidget( - Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onMapCreated: (ExampleGoogleMapController controller) { - fail('OnMapCreated should get called only once.'); - }, - ), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onMapCreated: (ExampleGoogleMapController controller) { + fail('OnMapCreated should get called only once.'); + }, ), - ); + ), + ); - await tester.pumpAndSettle(const Duration(seconds: 3)); - final TileOverlay? tileOverlayInfo1 = - await inspector.getTileOverlayInfo(tileOverlay1.mapsId, mapId: mapId); + await tester.pumpAndSettle(const Duration(seconds: 3)); + final TileOverlay? tileOverlayInfo1 = await inspector.getTileOverlayInfo( + tileOverlay1.mapsId, + mapId: mapId, + ); - expect(tileOverlayInfo1, isNull); - }, - ); + expect(tileOverlayInfo1, isNull); + }); testWidgets('marker clustering', (WidgetTester tester) async { final Key key = GlobalKey(); @@ -1118,22 +1256,28 @@ void main() { final Set clusterManagers = {}; for (int i = 0; i < clusterManagersAmount; i++) { - final ClusterManagerId clusterManagerId = - ClusterManagerId('cluster_manager_$i'); - final ClusterManager clusterManager = - ClusterManager(clusterManagerId: clusterManagerId); + final ClusterManagerId clusterManagerId = ClusterManagerId( + 'cluster_manager_$i', + ); + final ClusterManager clusterManager = ClusterManager( + clusterManagerId: clusterManagerId, + ); clusterManagers.add(clusterManager); } for (final ClusterManager cm in clusterManagers) { for (int i = 0; i < markersPerClusterManager; i++) { - final MarkerId markerId = - MarkerId('${cm.clusterManagerId.value}_marker_$i'); + final MarkerId markerId = MarkerId( + '${cm.clusterManagerId.value}_marker_$i', + ); final Marker marker = Marker( - markerId: markerId, - clusterManagerId: cm.clusterManagerId, - position: LatLng( - _kInitialMapCenter.latitude + i, _kInitialMapCenter.longitude)); + markerId: markerId, + clusterManagerId: cm.clusterManagerId, + position: LatLng( + _kInitialMapCenter.latitude + i, + _kInitialMapCenter.longitude, + ), + ); markers[markerId] = marker; } } @@ -1144,25 +1288,29 @@ void main() { final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - clusterManagers: clusterManagers, - markers: Set.of(markers.values), - onMapCreated: (ExampleGoogleMapController googleMapController) { - controllerCompleter.complete(googleMapController); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + clusterManagers: clusterManagers, + markers: Set.of(markers.values), + onMapCreated: (ExampleGoogleMapController googleMapController) { + controllerCompleter.complete(googleMapController); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; for (final ClusterManager cm in clusterManagers) { final List clusters = await inspector.getClusters( - mapId: controller.mapId, clusterManagerId: cm.clusterManagerId); + mapId: controller.mapId, + clusterManagerId: cm.clusterManagerId, + ); final int markersAmountForClusterManager = clusters .map((Cluster cluster) => cluster.count) .reduce((int value, int element) => value + element); @@ -1170,27 +1318,36 @@ void main() { } // Move marker from the first cluster manager to the last. - final MarkerId markerIdToMove = markers.entries - .firstWhere((MapEntry entry) => - entry.value.clusterManagerId == - clusterManagers.first.clusterManagerId) - .key; + final MarkerId markerIdToMove = + markers.entries + .firstWhere( + (MapEntry entry) => + entry.value.clusterManagerId == + clusterManagers.first.clusterManagerId, + ) + .key; markers[markerIdToMove] = _copyMarkerWithClusterManagerId( - markers[markerIdToMove]!, clusterManagers.last.clusterManagerId); + markers[markerIdToMove]!, + clusterManagers.last.clusterManagerId, + ); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( key: key, initialCameraPosition: _kInitialCameraPosition, clusterManagers: clusterManagers, - markers: Set.of(markers.values)), - )); + markers: Set.of(markers.values), + ), + ), + ); { final List clusters = await inspector.getClusters( - mapId: controller.mapId, - clusterManagerId: clusterManagers.first.clusterManagerId); + mapId: controller.mapId, + clusterManagerId: clusterManagers.first.clusterManagerId, + ); final int markersAmountForClusterManager = clusters .map((Cluster cluster) => cluster.count) .reduce((int value, int element) => value + element); @@ -1200,8 +1357,9 @@ void main() { { final List clusters = await inspector.getClusters( - mapId: controller.mapId, - clusterManagerId: clusterManagers.last.clusterManagerId); + mapId: controller.mapId, + clusterManagerId: clusterManagers.last.clusterManagerId, + ); final int markersAmountForClusterManager = clusters .map((Cluster cluster) => cluster.count) .reduce((int value, int element) => value + element); @@ -1213,18 +1371,23 @@ void main() { for (final MapEntry entry in markers.entries) { markers[entry.key] = _copyMarkerWithClusterManagerId(entry.value, null); } - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( key: key, initialCameraPosition: _kInitialCameraPosition, clusterManagers: clusterManagers, - markers: Set.of(markers.values)), - )); + markers: Set.of(markers.values), + ), + ), + ); for (final ClusterManager cm in clusterManagers) { final List clusters = await inspector.getClusters( - mapId: controller.mapId, clusterManagerId: cm.clusterManagerId); + mapId: controller.mapId, + clusterManagerId: cm.clusterManagerId, + ); expect(clusters.length, 0); } }); @@ -1232,14 +1395,16 @@ void main() { testWidgets('testSetStyleMapId', (WidgetTester tester) async { final Key key = GlobalKey(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - cloudMapId: _kCloudMapId, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + cloudMapId: _kCloudMapId, + ), ), - )); + ); }); testWidgets('getStyleError reports last error', (WidgetTester tester) async { @@ -1247,17 +1412,19 @@ void main() { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - style: '[[[this is an invalid style', - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + style: '[[[this is an invalid style', + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -1265,24 +1432,27 @@ void main() { expect(error, isNotNull); }); - testWidgets('getStyleError returns null for a valid style', - (WidgetTester tester) async { + testWidgets('getStyleError returns null for a valid style', ( + WidgetTester tester, + ) async { final Key key = GlobalKey(); final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - // An empty array is the simplest valid style. - style: '[]', - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + // An empty array is the simplest valid style. + style: '[]', + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -1293,19 +1463,21 @@ void main() { testWidgets('markerWithAssetMapBitmap', (WidgetTester tester) async { final Set markers = { Marker( - markerId: const MarkerId('1'), - icon: AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 1.0, - )), + markerId: const MarkerId('1'), + icon: AssetMapBitmap('assets/red_square.png', imagePixelRatio: 1.0), + ), }; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + ), ), - )); + ); await tester.pumpAndSettle(); }); @@ -1316,19 +1488,24 @@ void main() { ); final Set markers = { Marker( - markerId: const MarkerId('1'), - icon: await AssetMapBitmap.create( - imageConfiguration, - 'assets/red_square.png', - )), + markerId: const MarkerId('1'), + icon: await AssetMapBitmap.create( + imageConfiguration, + 'assets/red_square.png', + ), + ), }; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + ), ), - )); + ); await tester.pumpAndSettle(); }); @@ -1345,13 +1522,17 @@ void main() { ), }; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + ), ), - )); + ); await tester.pumpAndSettle(); }); @@ -1364,25 +1545,31 @@ void main() { ); final Set markers = { Marker( - markerId: const MarkerId('1'), - // Intentionally testing the deprecated code path. - // ignore: deprecated_member_use - icon: await BitmapDescriptor.fromAssetImage( - imageConfiguration, - 'assets/red_square.png', - )), + markerId: const MarkerId('1'), + // Intentionally testing the deprecated code path. + // ignore: deprecated_member_use + icon: await BitmapDescriptor.fromAssetImage( + imageConfiguration, + 'assets/red_square.png', + ), + ), }; final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, - onMapCreated: (ExampleGoogleMapController controller) => - controllerCompleter.complete(controller), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + onMapCreated: + (ExampleGoogleMapController controller) => + controllerCompleter.complete(controller), + ), ), - )); + ); await controllerCompleter.future; }); @@ -1392,24 +1579,27 @@ void main() { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); // Intentionally testing the deprecated code path. // ignore: deprecated_member_use - final BitmapDescriptor icon = BitmapDescriptor.fromBytes( - bytes, - ); + final BitmapDescriptor icon = BitmapDescriptor.fromBytes(bytes); final Set markers = { Marker(markerId: const MarkerId('1'), icon: icon), }; final Completer controllerCompleter = Completer(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition(target: LatLng(10.0, 15.0)), - markers: markers, - onMapCreated: (ExampleGoogleMapController controller) => - controllerCompleter.complete(controller), + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(10.0, 15.0), + ), + markers: markers, + onMapCreated: + (ExampleGoogleMapController controller) => + controllerCompleter.complete(controller), + ), ), - )); + ); await controllerCompleter.future; }); @@ -1430,20 +1620,23 @@ void main() { ); final GroundOverlay groundOverlayPosition1 = GroundOverlay.fromPosition( - groundOverlayId: const GroundOverlayId('position_1'), - position: kGroundOverlayBounds.northeast, - width: 100, - height: 100, - anchor: const Offset(0.1, 0.2), - zoomLevel: 14.0, - image: AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 1.0, - bitmapScaling: MapBitmapScaling.none, - )); + groundOverlayId: const GroundOverlayId('position_1'), + position: kGroundOverlayBounds.northeast, + width: 100, + height: 100, + anchor: const Offset(0.1, 0.2), + zoomLevel: 14.0, + image: AssetMapBitmap( + 'assets/red_square.png', + imagePixelRatio: 1.0, + bitmapScaling: MapBitmapScaling.none, + ), + ); void expectGroundOverlayEquals( - GroundOverlay source, GroundOverlay response) { + GroundOverlay source, + GroundOverlay response, + ) { expect(response.groundOverlayId, source.groundOverlayId); expect( response.transparency, @@ -1508,13 +1701,21 @@ void main() { GoogleMapsInspectorPlatform.instance!; if (inspector.supportsGettingGroundOverlayInfo()) { - final GroundOverlay groundOverlayBoundsInfo1 = (await inspector - .getGroundOverlayInfo(groundOverlayBounds1.mapsId, mapId: mapId))!; - final GroundOverlay groundOverlayBoundsInfo2 = (await inspector - .getGroundOverlayInfo(groundOverlayBounds2.mapsId, mapId: mapId))!; + final GroundOverlay groundOverlayBoundsInfo1 = + (await inspector.getGroundOverlayInfo( + groundOverlayBounds1.mapsId, + mapId: mapId, + ))!; + final GroundOverlay groundOverlayBoundsInfo2 = + (await inspector.getGroundOverlayInfo( + groundOverlayBounds2.mapsId, + mapId: mapId, + ))!; final GroundOverlay groundOverlayPositionInfo1 = - (await inspector.getGroundOverlayInfo(groundOverlayPosition1.mapsId, - mapId: mapId))!; + (await inspector.getGroundOverlayInfo( + groundOverlayPosition1.mapsId, + mapId: mapId, + ))!; expectGroundOverlayEquals( groundOverlayBounds1, @@ -1531,8 +1732,9 @@ void main() { } }); - testWidgets('update ground overlays correctly', - (WidgetTester tester) async { + testWidgets('update ground overlays correctly', ( + WidgetTester tester, + ) async { final Completer mapIdCompleter = Completer(); final Key key = GlobalKey(); @@ -1544,7 +1746,7 @@ void main() { initialCameraPosition: _kInitialCameraPosition, groundOverlays: { groundOverlayBounds1, - groundOverlayPosition1 + groundOverlayPosition1, }, onMapCreated: (ExampleGoogleMapController controller) { mapIdCompleter.complete(controller.mapId); @@ -1557,23 +1759,23 @@ void main() { final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - final GroundOverlay groundOverlayBounds1New = - groundOverlayBounds1.copyWith( - bearingParam: 10, - clickableParam: false, - transparencyParam: 0.5, - visibleParam: false, - zIndexParam: 10, - ); - - final GroundOverlay groundOverlayPosition1New = - groundOverlayPosition1.copyWith( - bearingParam: 10, - clickableParam: false, - transparencyParam: 0.5, - visibleParam: false, - zIndexParam: 10, - ); + final GroundOverlay groundOverlayBounds1New = groundOverlayBounds1 + .copyWith( + bearingParam: 10, + clickableParam: false, + transparencyParam: 0.5, + visibleParam: false, + zIndexParam: 10, + ); + + final GroundOverlay groundOverlayPosition1New = groundOverlayPosition1 + .copyWith( + bearingParam: 10, + clickableParam: false, + transparencyParam: 0.5, + visibleParam: false, + zIndexParam: 10, + ); await tester.pumpWidget( Directionality( @@ -1583,7 +1785,7 @@ void main() { initialCameraPosition: _kInitialCameraPosition, groundOverlays: { groundOverlayBounds1New, - groundOverlayPosition1New + groundOverlayPosition1New, }, onMapCreated: (ExampleGoogleMapController controller) { fail('update: OnMapCreated should get called only once.'); @@ -1595,11 +1797,16 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 3)); if (inspector.supportsGettingGroundOverlayInfo()) { - final GroundOverlay groundOverlayBounds1Info = (await inspector - .getGroundOverlayInfo(groundOverlayBounds1.mapsId, mapId: mapId))!; + final GroundOverlay groundOverlayBounds1Info = + (await inspector.getGroundOverlayInfo( + groundOverlayBounds1.mapsId, + mapId: mapId, + ))!; final GroundOverlay groundOverlayPosition1Info = - (await inspector.getGroundOverlayInfo(groundOverlayPosition1.mapsId, - mapId: mapId))!; + (await inspector.getGroundOverlayInfo( + groundOverlayPosition1.mapsId, + mapId: mapId, + ))!; expectGroundOverlayEquals( groundOverlayBounds1New, @@ -1612,8 +1819,9 @@ void main() { } }); - testWidgets('remove ground overlays correctly', - (WidgetTester tester) async { + testWidgets('remove ground overlays correctly', ( + WidgetTester tester, + ) async { final Completer mapIdCompleter = Completer(); final Key key = GlobalKey(); @@ -1625,7 +1833,7 @@ void main() { initialCameraPosition: _kInitialCameraPosition, groundOverlays: { groundOverlayBounds1, - groundOverlayPosition1 + groundOverlayPosition1, }, onMapCreated: (ExampleGoogleMapController controller) { mapIdCompleter.complete(controller.mapId); @@ -1677,22 +1885,24 @@ void main() { /// Completer to track when the camera has come to rest. Completer? cameraIdleCompleter; - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onCameraIdle: () { - if (cameraIdleCompleter != null && - !cameraIdleCompleter.isCompleted) { - cameraIdleCompleter.complete(); - } - }, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onCameraIdle: () { + if (cameraIdleCompleter != null && + !cameraIdleCompleter.isCompleted) { + cameraIdleCompleter.complete(); + } + }, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -1707,36 +1917,39 @@ void main() { // Create completer for camera idle event. cameraIdleCompleter = Completer(); - final CameraUpdate cameraUpdate = - _getCameraUpdateForType(_cameraUpdateTypeVariants.currentValue!); + final CameraUpdate cameraUpdate = _getCameraUpdateForType( + _cameraUpdateTypeVariants.currentValue!, + ); await controller.animateCamera(cameraUpdate); // Immediately after calling animateCamera, check that the camera hasn't // reached its final position. This relies on the assumption that the // camera move is animated and won't complete instantly. - final CameraPosition beforeFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + final CameraPosition beforeFinishedPosition = await inspector + .getCameraPosition(mapId: controller.mapId); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - beforeFinishedPosition, - null, - controller, - (Matcher matcher) => isNot(matcher)); + _cameraUpdateTypeVariants.currentValue!, + beforeFinishedPosition, + null, + controller, + (Matcher matcher) => isNot(matcher), + ); // Wait for the animation to complete (onCameraIdle). expect(cameraIdleCompleter.isCompleted, isFalse); await cameraIdleCompleter.future; // After onCameraIdle event, the camera should be at the final position. - final CameraPosition afterFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + final CameraPosition afterFinishedPosition = await inspector + .getCameraPosition(mapId: controller.mapId); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - afterFinishedPosition, - beforeFinishedPosition, - controller, - (Matcher matcher) => matcher); + _cameraUpdateTypeVariants.currentValue!, + afterFinishedPosition, + beforeFinishedPosition, + controller, + (Matcher matcher) => matcher, + ); await tester.pumpAndSettle(); }, @@ -1778,23 +1991,25 @@ void main() { // Stopwatch to measure the time taken for the animation to complete. final Stopwatch stopwatch = Stopwatch(); - await tester.pumpWidget(Directionality( - textDirection: TextDirection.ltr, - child: ExampleGoogleMap( - key: key, - initialCameraPosition: _kInitialCameraPosition, - onCameraIdle: () { - if (cameraIdleCompleter != null && - !cameraIdleCompleter.isCompleted) { - stopwatch.stop(); - cameraIdleCompleter.complete(); - } - }, - onMapCreated: (ExampleGoogleMapController controller) { - controllerCompleter.complete(controller); - }, + await tester.pumpWidget( + Directionality( + textDirection: TextDirection.ltr, + child: ExampleGoogleMap( + key: key, + initialCameraPosition: _kInitialCameraPosition, + onCameraIdle: () { + if (cameraIdleCompleter != null && + !cameraIdleCompleter.isCompleted) { + stopwatch.stop(); + cameraIdleCompleter.complete(); + } + }, + onMapCreated: (ExampleGoogleMapController controller) { + controllerCompleter.complete(controller); + }, + ), ), - )); + ); final ExampleGoogleMapController controller = await controllerCompleter.future; @@ -1815,8 +2030,9 @@ void main() { stopwatch.start(); // First phase with shorter animation duration. - final CameraUpdate cameraUpdateShort = - _getCameraUpdateForType(_cameraUpdateTypeVariants.currentValue!); + final CameraUpdate cameraUpdateShort = _getCameraUpdateForType( + _cameraUpdateTypeVariants.currentValue!, + ); await controller.animateCamera( cameraUpdateShort, duration: const Duration(milliseconds: shortCameraAnimationDurationMS), @@ -1828,12 +2044,15 @@ void main() { // For short animation duration, check that the animation is completed // faster than the midpoint benchmark. - expect(stopwatch.elapsedMilliseconds, - lessThan(animationDurationMiddlePoint)); + expect( + stopwatch.elapsedMilliseconds, + lessThan(animationDurationMiddlePoint), + ); // Reset camera to initial position before testing long duration. - await controller - .moveCamera(CameraUpdate.newCameraPosition(_kInitialCameraPosition)); + await controller.moveCamera( + CameraUpdate.newCameraPosition(_kInitialCameraPosition), + ); await tester.pumpAndSettle(); // Create completer for camera idle event. @@ -1845,8 +2064,9 @@ void main() { stopwatch.start(); // Second phase with longer animation duration. - final CameraUpdate cameraUpdateLong = - _getCameraUpdateForType(_cameraUpdateTypeVariants.currentValue!); + final CameraUpdate cameraUpdateLong = _getCameraUpdateForType( + _cameraUpdateTypeVariants.currentValue!, + ); await controller.animateCamera( cameraUpdateLong, duration: const Duration(milliseconds: longCameraAnimationDurationMS), @@ -1855,15 +2075,16 @@ void main() { // Immediately after calling animateCamera, check that the camera hasn't // reached its final position. This relies on the assumption that the // camera move is animated and won't complete instantly. - final CameraPosition beforeFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + final CameraPosition beforeFinishedPosition = await inspector + .getCameraPosition(mapId: controller.mapId); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - beforeFinishedPosition, - null, - controller, - (Matcher matcher) => isNot(matcher)); + _cameraUpdateTypeVariants.currentValue!, + beforeFinishedPosition, + null, + controller, + (Matcher matcher) => isNot(matcher), + ); // Wait for the animation to complete (onCameraIdle). expect(cameraIdleCompleter.isCompleted, isFalse); @@ -1871,18 +2092,21 @@ void main() { // For longer animation duration, check that the animation is completed // slower than the midpoint benchmark. - expect(stopwatch.elapsedMilliseconds, - greaterThan(animationDurationMiddlePoint)); + expect( + stopwatch.elapsedMilliseconds, + greaterThan(animationDurationMiddlePoint), + ); // Camera should be at the final position. - final CameraPosition afterFinishedPosition = - await inspector.getCameraPosition(mapId: controller.mapId); + final CameraPosition afterFinishedPosition = await inspector + .getCameraPosition(mapId: controller.mapId); await _checkCameraUpdateByType( - _cameraUpdateTypeVariants.currentValue!, - afterFinishedPosition, - beforeFinishedPosition, - controller, - (Matcher matcher) => matcher); + _cameraUpdateTypeVariants.currentValue!, + afterFinishedPosition, + beforeFinishedPosition, + controller, + (Matcher matcher) => matcher, + ); await tester.pumpAndSettle(); }, @@ -1903,41 +2127,38 @@ class _DebugTileProvider implements TileProvider { static const int width = 100; static const int height = 100; static final Paint boxPaint = Paint(); - static const TextStyle textStyle = TextStyle( - color: Colors.red, - fontSize: 20, - ); + static const TextStyle textStyle = TextStyle(color: Colors.red, fontSize: 20); @override Future getTile(int x, int y, int? zoom) async { final ui.PictureRecorder recorder = ui.PictureRecorder(); final Canvas canvas = Canvas(recorder); - final TextSpan textSpan = TextSpan( - text: '$x,$y', - style: textStyle, - ); + final TextSpan textSpan = TextSpan(text: '$x,$y', style: textStyle); final TextPainter textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); - textPainter.layout( - maxWidth: width.toDouble(), - ); + textPainter.layout(maxWidth: width.toDouble()); textPainter.paint(canvas, Offset.zero); canvas.drawRect( - Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), boxPaint); + Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), + boxPaint, + ); final ui.Picture picture = recorder.endRecording(); final Uint8List byteData = await picture .toImage(width, height) - .then((ui.Image image) => - image.toByteData(format: ui.ImageByteFormat.png)) + .then( + (ui.Image image) => image.toByteData(format: ui.ImageByteFormat.png), + ) .then((ByteData? byteData) => byteData!.buffer.asUint8List()); return Tile(width, height, byteData); } } Marker _copyMarkerWithClusterManagerId( - Marker marker, ClusterManagerId? clusterManagerId) { + Marker marker, + ClusterManagerId? clusterManagerId, +) { return Marker( markerId: marker.markerId, alpha: marker.alpha, @@ -1961,16 +2182,23 @@ Marker _copyMarkerWithClusterManagerId( CameraUpdate _getCameraUpdateForType(CameraUpdateType type) { return switch (type) { - CameraUpdateType.newCameraPosition => - CameraUpdate.newCameraPosition(_kTestCameraPosition), + CameraUpdateType.newCameraPosition => CameraUpdate.newCameraPosition( + _kTestCameraPosition, + ), CameraUpdateType.newLatLng => CameraUpdate.newLatLng(_kTestMapCenter), - CameraUpdateType.newLatLngBounds => - CameraUpdate.newLatLngBounds(_testCameraBounds, 0), - CameraUpdateType.newLatLngZoom => - CameraUpdate.newLatLngZoom(_kTestMapCenter, _kTestCameraZoomLevel), + CameraUpdateType.newLatLngBounds => CameraUpdate.newLatLngBounds( + _testCameraBounds, + 0, + ), + CameraUpdateType.newLatLngZoom => CameraUpdate.newLatLngZoom( + _kTestMapCenter, + _kTestCameraZoomLevel, + ), CameraUpdateType.scrollBy => CameraUpdate.scrollBy(10, 10), - CameraUpdateType.zoomBy => - CameraUpdate.zoomBy(_kTestZoomByAmount, const Offset(1, 1)), + CameraUpdateType.zoomBy => CameraUpdate.zoomBy( + _kTestZoomByAmount, + const Offset(1, 1), + ), CameraUpdateType.zoomTo => CameraUpdate.zoomTo(_kTestCameraZoomLevel), CameraUpdateType.zoomIn => CameraUpdate.zoomIn(), CameraUpdateType.zoomOut => CameraUpdate.zoomOut(), @@ -1990,52 +2218,80 @@ Future _checkCameraUpdateByType( switch (type) { case CameraUpdateType.newCameraPosition: - expect(currentPosition.bearing, - wrapMatcher(equals(_kTestCameraPosition.bearing))); expect( - currentPosition.zoom, wrapMatcher(equals(_kTestCameraPosition.zoom))); + currentPosition.bearing, + wrapMatcher(equals(_kTestCameraPosition.bearing)), + ); expect( - currentPosition.tilt, wrapMatcher(equals(_kTestCameraPosition.tilt))); + currentPosition.zoom, + wrapMatcher(equals(_kTestCameraPosition.zoom)), + ); expect( - currentPosition.target.latitude, - wrapMatcher( - closeTo(_kTestCameraPosition.target.latitude, latLngThreshold))); + currentPosition.tilt, + wrapMatcher(equals(_kTestCameraPosition.tilt)), + ); expect( - currentPosition.target.longitude, - wrapMatcher( - closeTo(_kTestCameraPosition.target.longitude, latLngThreshold))); + currentPosition.target.latitude, + wrapMatcher( + closeTo(_kTestCameraPosition.target.latitude, latLngThreshold), + ), + ); + expect( + currentPosition.target.longitude, + wrapMatcher( + closeTo(_kTestCameraPosition.target.longitude, latLngThreshold), + ), + ); case CameraUpdateType.newLatLng: - expect(currentPosition.target.latitude, - wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold))); - expect(currentPosition.target.longitude, - wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold))); + expect( + currentPosition.target.latitude, + wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold)), + ); + expect( + currentPosition.target.longitude, + wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold)), + ); case CameraUpdateType.newLatLngBounds: final LatLngBounds bounds = await controller.getVisibleRegion(); expect( - bounds.northeast.longitude, - wrapMatcher( - closeTo(_testCameraBounds.northeast.longitude, latLngThreshold))); + bounds.northeast.longitude, + wrapMatcher( + closeTo(_testCameraBounds.northeast.longitude, latLngThreshold), + ), + ); expect( - bounds.southwest.longitude, - wrapMatcher( - closeTo(_testCameraBounds.southwest.longitude, latLngThreshold))); + bounds.southwest.longitude, + wrapMatcher( + closeTo(_testCameraBounds.southwest.longitude, latLngThreshold), + ), + ); case CameraUpdateType.newLatLngZoom: - expect(currentPosition.target.latitude, - wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold))); - expect(currentPosition.target.longitude, - wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold))); + expect( + currentPosition.target.latitude, + wrapMatcher(closeTo(_kTestMapCenter.latitude, latLngThreshold)), + ); + expect( + currentPosition.target.longitude, + wrapMatcher(closeTo(_kTestMapCenter.longitude, latLngThreshold)), + ); expect(currentPosition.zoom, wrapMatcher(equals(_kTestCameraZoomLevel))); case CameraUpdateType.scrollBy: // For scrollBy, just check that the location has changed. if (oldPosition != null) { - expect(currentPosition.target.latitude, - isNot(equals(oldPosition.target.latitude))); - expect(currentPosition.target.longitude, - isNot(equals(oldPosition.target.longitude))); + expect( + currentPosition.target.latitude, + isNot(equals(oldPosition.target.latitude)), + ); + expect( + currentPosition.target.longitude, + isNot(equals(oldPosition.target.longitude)), + ); } case CameraUpdateType.zoomBy: - expect(currentPosition.zoom, - wrapMatcher(equals(_kInitialZoomLevel + _kTestZoomByAmount))); + expect( + currentPosition.zoom, + wrapMatcher(equals(_kInitialZoomLevel + _kTestZoomByAmount)), + ); case CameraUpdateType.zoomTo: expect(currentPosition.zoom, wrapMatcher(equals(_kTestCameraZoomLevel))); case CameraUpdateType.zoomIn: diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/lib/main.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/lib/main.dart index d1d736a659a..d9824763add 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/lib/main.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/lib/main.dart @@ -25,25 +25,28 @@ import 'package:maps_example_dart/snapshot.dart'; import 'package:maps_example_dart/tile_overlay.dart'; void main() { - runApp(const MaterialApp( + runApp( + const MaterialApp( home: MapsDemo([ - MapUiPage(), - MapCoordinatesPage(), - MapClickPage(), - AnimateCameraPage(), - MoveCameraPage(), - PlaceMarkerPage(), - MarkerIconsPage(), - ScrollingMapPage(), - PlacePolylinePage(), - PlacePolygonPage(), - PlaceCirclePage(), - PaddingPage(), - SnapshotPage(), - LiteModePage(), - TileOverlayPage(), - GroundOverlayPage(), - ClusteringPage(), - MapIdPage(), - ]))); + MapUiPage(), + MapCoordinatesPage(), + MapClickPage(), + AnimateCameraPage(), + MoveCameraPage(), + PlaceMarkerPage(), + MarkerIconsPage(), + ScrollingMapPage(), + PlacePolylinePage(), + PlacePolygonPage(), + PlaceCirclePage(), + PaddingPage(), + SnapshotPage(), + LiteModePage(), + TileOverlayPage(), + GroundOverlayPage(), + ClusteringPage(), + MapIdPage(), + ]), + ), + ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/pubspec.yaml index 96319023995..fa834998717 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the google_maps_flutter plugin. publish_to: none environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" dependencies: cupertino_icons: ^1.0.5 diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios15/lib/main.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios15/lib/main.dart index d1d736a659a..d9824763add 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios15/lib/main.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios15/lib/main.dart @@ -25,25 +25,28 @@ import 'package:maps_example_dart/snapshot.dart'; import 'package:maps_example_dart/tile_overlay.dart'; void main() { - runApp(const MaterialApp( + runApp( + const MaterialApp( home: MapsDemo([ - MapUiPage(), - MapCoordinatesPage(), - MapClickPage(), - AnimateCameraPage(), - MoveCameraPage(), - PlaceMarkerPage(), - MarkerIconsPage(), - ScrollingMapPage(), - PlacePolylinePage(), - PlacePolygonPage(), - PlaceCirclePage(), - PaddingPage(), - SnapshotPage(), - LiteModePage(), - TileOverlayPage(), - GroundOverlayPage(), - ClusteringPage(), - MapIdPage(), - ]))); + MapUiPage(), + MapCoordinatesPage(), + MapClickPage(), + AnimateCameraPage(), + MoveCameraPage(), + PlaceMarkerPage(), + MarkerIconsPage(), + ScrollingMapPage(), + PlacePolylinePage(), + PlacePolygonPage(), + PlaceCirclePage(), + PaddingPage(), + SnapshotPage(), + LiteModePage(), + TileOverlayPage(), + GroundOverlayPage(), + ClusteringPage(), + MapIdPage(), + ]), + ), + ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios15/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios15/pubspec.yaml index 96319023995..fa834998717 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios15/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios15/pubspec.yaml @@ -3,8 +3,8 @@ description: Demonstrates how to use the google_maps_flutter plugin. publish_to: none environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" dependencies: cupertino_icons: ^1.0.5 diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/animate_camera.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/animate_camera.dart index ed4c744c48b..a5a83a95059 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/animate_camera.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/animate_camera.dart @@ -12,7 +12,7 @@ import 'page.dart'; class AnimateCameraPage extends GoogleMapExampleAppPage { const AnimateCameraPage({Key? key}) - : super(const Icon(Icons.map), 'Camera control, animated', key: key); + : super(const Icon(Icons.map), 'Camera control, animated', key: key); @override Widget build(BuildContext context) { @@ -40,9 +40,10 @@ class AnimateCameraState extends State { void _toggleAnimationDuration() { setState(() { - _cameraUpdateAnimationDuration = _cameraUpdateAnimationDuration != null - ? null - : const Duration(seconds: _durationSeconds); + _cameraUpdateAnimationDuration = + _cameraUpdateAnimationDuration != null + ? null + : const Duration(seconds: _durationSeconds); }); } @@ -58,8 +59,9 @@ class AnimateCameraState extends State { height: 200.0, child: ExampleGoogleMap( onMapCreated: _onMapCreated, - initialCameraPosition: - const CameraPosition(target: LatLng(0.0, 0.0)), + initialCameraPosition: const CameraPosition( + target: LatLng(0.0, 0.0), + ), ), ), ), @@ -138,10 +140,7 @@ class AnimateCameraState extends State { TextButton( onPressed: () { mapController?.animateCamera( - CameraUpdate.zoomBy( - -0.5, - const Offset(30.0, 20.0), - ), + CameraUpdate.zoomBy(-0.5, const Offset(30.0, 20.0)), duration: _cameraUpdateAnimationDuration, ); }, @@ -190,10 +189,7 @@ class AnimateCameraState extends State { Row( mainAxisAlignment: MainAxisAlignment.center, children: [ - const Text( - 'With 10 second duration', - textAlign: TextAlign.right, - ), + const Text('With 10 second duration', textAlign: TextAlign.right), const SizedBox(width: 5), Switch( value: _cameraUpdateAnimationDuration != null, diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/clustering.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/clustering.dart index f6860f7bf42..a1364a6d5e5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/clustering.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/clustering.dart @@ -14,7 +14,7 @@ import 'page.dart'; class ClusteringPage extends GoogleMapExampleAppPage { /// Default Constructor. const ClusteringPage({Key? key}) - : super(const Icon(Icons.place), 'Manage clustering', key: key); + : super(const Icon(Icons.place), 'Manage clustering', key: key); @override Widget build(BuildContext context) { @@ -95,8 +95,9 @@ class ClusteringBodyState extends State { setState(() { final MarkerId? previousMarkerId = selectedMarker; if (previousMarkerId != null && markers.containsKey(previousMarkerId)) { - final Marker resetOld = markers[previousMarkerId]! - .copyWith(iconParam: BitmapDescriptor.defaultMarker); + final Marker resetOld = markers[previousMarkerId]!.copyWith( + iconParam: BitmapDescriptor.defaultMarker, + ); markers[previousMarkerId] = resetOld; } selectedMarker = markerId; @@ -118,14 +119,16 @@ class ClusteringBodyState extends State { final String clusterManagerIdVal = 'cluster_manager_id_$_clusterManagerIdCounter'; _clusterManagerIdCounter++; - final ClusterManagerId clusterManagerId = - ClusterManagerId(clusterManagerIdVal); + final ClusterManagerId clusterManagerId = ClusterManagerId( + clusterManagerIdVal, + ); final ClusterManager clusterManager = ClusterManager( clusterManagerId: clusterManagerId, - onClusterTap: (Cluster cluster) => setState(() { - lastCluster = cluster; - }), + onClusterTap: + (Cluster cluster) => setState(() { + lastCluster = cluster; + }), ); setState(() { @@ -137,8 +140,10 @@ class ClusteringBodyState extends State { void _removeClusterManager(ClusterManager clusterManager) { setState(() { // Remove markers managed by cluster manager to be removed. - markers.removeWhere((MarkerId key, Marker marker) => - marker.clusterManagerId == clusterManager.clusterManagerId); + markers.removeWhere( + (MarkerId key, Marker marker) => + marker.clusterManagerId == clusterManager.clusterManagerId, + ); // Remove cluster manager. clusterManagers.remove(clusterManager.clusterManagerId); }); @@ -151,8 +156,9 @@ class ClusteringBodyState extends State { _markerIdCounter++; final MarkerId markerId = MarkerId(markerIdVal); - final int clusterManagerIndex = - clusterManagers.values.toList().indexOf(clusterManager); + final int clusterManagerIndex = clusterManagers.values.toList().indexOf( + clusterManager, + ); // Add additional offset to longitude for each cluster manager to space // out markers in different cluster managers. @@ -191,9 +197,10 @@ class ClusteringBodyState extends State { final Marker marker = markers[markerId]!; final double current = marker.alpha; markers[markerId] = marker.copyWith( - alphaParam: current == _fullyVisibleAlpha - ? _halfVisibleAlpha - : _fullyVisibleAlpha, + alphaParam: + current == _fullyVisibleAlpha + ? _halfVisibleAlpha + : _fullyVisibleAlpha, ); } setState(() {}); @@ -217,61 +224,72 @@ class ClusteringBodyState extends State { clusterManagers: Set.of(clusterManagers.values), ), ), - Column(children: [ - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - onPressed: clusterManagers.length >= _clusterManagerMaxCount - ? null - : () => _addClusterManager(), - child: const Text('Add cluster manager'), - ), - TextButton( - onPressed: clusterManagers.isEmpty - ? null - : () => _removeClusterManager(clusterManagers.values.last), - child: const Text('Remove cluster manager'), - ), - ], - ), - Wrap( - alignment: WrapAlignment.spaceEvenly, - children: [ - for (final MapEntry clusterEntry - in clusterManagers.entries) + Column( + children: [ + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ TextButton( - onPressed: () => _addMarkersToCluster(clusterEntry.value), - child: Text('Add markers to ${clusterEntry.key.value}'), + onPressed: + clusterManagers.length >= _clusterManagerMaxCount + ? null + : () => _addClusterManager(), + child: const Text('Add cluster manager'), ), - ], - ), - Wrap( - alignment: WrapAlignment.spaceEvenly, - children: [ - TextButton( - onPressed: selectedId == null - ? null - : () { - _remove(selectedId); - setState(() { - selectedMarker = null; - }); - }, - child: const Text('Remove selected marker'), - ), - TextButton( - onPressed: markers.isEmpty ? null : () => _changeMarkersAlpha(), - child: const Text('Change all markers alpha'), - ), - ], - ), - if (lastCluster != null) - Padding( + TextButton( + onPressed: + clusterManagers.isEmpty + ? null + : () => _removeClusterManager( + clusterManagers.values.last, + ), + child: const Text('Remove cluster manager'), + ), + ], + ), + Wrap( + alignment: WrapAlignment.spaceEvenly, + children: [ + for (final MapEntry + clusterEntry + in clusterManagers.entries) + TextButton( + onPressed: () => _addMarkersToCluster(clusterEntry.value), + child: Text('Add markers to ${clusterEntry.key.value}'), + ), + ], + ), + Wrap( + alignment: WrapAlignment.spaceEvenly, + children: [ + TextButton( + onPressed: + selectedId == null + ? null + : () { + _remove(selectedId); + setState(() { + selectedMarker = null; + }); + }, + child: const Text('Remove selected marker'), + ), + TextButton( + onPressed: + markers.isEmpty ? null : () => _changeMarkersAlpha(), + child: const Text('Change all markers alpha'), + ), + ], + ), + if (lastCluster != null) + Padding( padding: const EdgeInsets.all(10), child: Text( - 'Cluster with ${lastCluster!.count} markers clicked at ${lastCluster!.position}')), - ]), + 'Cluster with ${lastCluster!.count} markers clicked at ${lastCluster!.position}', + ), + ), + ], + ), ], ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/custom_marker_icon.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/custom_marker_icon.dart index 8940762f02e..02daad7a52e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/custom_marker_icon.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/custom_marker_icon.dart @@ -15,12 +15,14 @@ Future createCustomMarkerIconImage({required Size size}) async { painter.paint(canvas, size); - final ui.Image image = await recorder - .endRecording() - .toImage(size.width.floor(), size.height.floor()); - - final ByteData? bytes = - await image.toByteData(format: ui.ImageByteFormat.png); + final ui.Image image = await recorder.endRecording().toImage( + size.width.floor(), + size.height.floor(), + ); + + final ByteData? bytes = await image.toByteData( + format: ui.ImageByteFormat.png, + ); return bytes!; } @@ -34,10 +36,7 @@ class _MarkerPainter extends CustomPainter { ); // Draw radial gradient - canvas.drawRect( - rect, - Paint()..shader = gradient.createShader(rect), - ); + canvas.drawRect(rect, Paint()..shader = gradient.createShader(rect)); // Draw diagonal black line canvas.drawLine( diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/example_google_map.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/example_google_map.dart index 351e1c117c4..b1132c8c6f4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/example_google_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/example_google_map.dart @@ -16,10 +16,7 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf /// Controller for a single ExampleGoogleMap instance running on the host platform. class ExampleGoogleMapController { - ExampleGoogleMapController._( - this._googleMapState, { - required this.mapId, - }) { + ExampleGoogleMapController._(this._googleMapState, {required this.mapId}) { _connectStreams(mapId); } @@ -36,10 +33,7 @@ class ExampleGoogleMapController { _ExampleGoogleMapState googleMapState, ) async { await GoogleMapsFlutterPlatform.instance.init(id); - return ExampleGoogleMapController._( - googleMapState, - mapId: id, - ); + return ExampleGoogleMapController._(googleMapState, mapId: id); } final _ExampleGoogleMapState _googleMapState; @@ -51,8 +45,12 @@ class ExampleGoogleMapController { .listen((_) => _googleMapState.widget.onCameraMoveStarted!()); } if (_googleMapState.widget.onCameraMove != null) { - GoogleMapsFlutterPlatform.instance.onCameraMove(mapId: mapId).listen( - (CameraMoveEvent e) => _googleMapState.widget.onCameraMove!(e.value)); + GoogleMapsFlutterPlatform.instance + .onCameraMove(mapId: mapId) + .listen( + (CameraMoveEvent e) => + _googleMapState.widget.onCameraMove!(e.value), + ); } if (_googleMapState.widget.onCameraIdle != null) { GoogleMapsFlutterPlatform.instance @@ -62,17 +60,29 @@ class ExampleGoogleMapController { GoogleMapsFlutterPlatform.instance .onMarkerTap(mapId: mapId) .listen((MarkerTapEvent e) => _googleMapState.onMarkerTap(e.value)); - GoogleMapsFlutterPlatform.instance.onMarkerDragStart(mapId: mapId).listen( - (MarkerDragStartEvent e) => - _googleMapState.onMarkerDragStart(e.value, e.position)); - GoogleMapsFlutterPlatform.instance.onMarkerDrag(mapId: mapId).listen( - (MarkerDragEvent e) => - _googleMapState.onMarkerDrag(e.value, e.position)); - GoogleMapsFlutterPlatform.instance.onMarkerDragEnd(mapId: mapId).listen( - (MarkerDragEndEvent e) => - _googleMapState.onMarkerDragEnd(e.value, e.position)); - GoogleMapsFlutterPlatform.instance.onInfoWindowTap(mapId: mapId).listen( - (InfoWindowTapEvent e) => _googleMapState.onInfoWindowTap(e.value)); + GoogleMapsFlutterPlatform.instance + .onMarkerDragStart(mapId: mapId) + .listen( + (MarkerDragStartEvent e) => + _googleMapState.onMarkerDragStart(e.value, e.position), + ); + GoogleMapsFlutterPlatform.instance + .onMarkerDrag(mapId: mapId) + .listen( + (MarkerDragEvent e) => + _googleMapState.onMarkerDrag(e.value, e.position), + ); + GoogleMapsFlutterPlatform.instance + .onMarkerDragEnd(mapId: mapId) + .listen( + (MarkerDragEndEvent e) => + _googleMapState.onMarkerDragEnd(e.value, e.position), + ); + GoogleMapsFlutterPlatform.instance + .onInfoWindowTap(mapId: mapId) + .listen( + (InfoWindowTapEvent e) => _googleMapState.onInfoWindowTap(e.value), + ); GoogleMapsFlutterPlatform.instance .onPolylineTap(mapId: mapId) .listen((PolylineTapEvent e) => _googleMapState.onPolylineTap(e.value)); @@ -82,14 +92,20 @@ class ExampleGoogleMapController { GoogleMapsFlutterPlatform.instance .onCircleTap(mapId: mapId) .listen((CircleTapEvent e) => _googleMapState.onCircleTap(e.value)); - GoogleMapsFlutterPlatform.instance.onGroundOverlayTap(mapId: mapId).listen( - (GroundOverlayTapEvent e) => - _googleMapState.onGroundOverlayTap(e.value)); + GoogleMapsFlutterPlatform.instance + .onGroundOverlayTap(mapId: mapId) + .listen( + (GroundOverlayTapEvent e) => + _googleMapState.onGroundOverlayTap(e.value), + ); GoogleMapsFlutterPlatform.instance .onTap(mapId: mapId) .listen((MapTapEvent e) => _googleMapState.onTap(e.position)); - GoogleMapsFlutterPlatform.instance.onLongPress(mapId: mapId).listen( - (MapLongPressEvent e) => _googleMapState.onLongPress(e.position)); + GoogleMapsFlutterPlatform.instance + .onLongPress(mapId: mapId) + .listen( + (MapLongPressEvent e) => _googleMapState.onLongPress(e.position), + ); GoogleMapsFlutterPlatform.instance .onClusterTap(mapId: mapId) .listen((ClusterTapEvent e) => _googleMapState.onClusterTap(e.value)); @@ -97,72 +113,96 @@ class ExampleGoogleMapController { /// Updates configuration options of the map user interface. Future _updateMapConfiguration(MapConfiguration update) { - return GoogleMapsFlutterPlatform.instance - .updateMapConfiguration(update, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateMapConfiguration( + update, + mapId: mapId, + ); } /// Updates marker configuration. Future _updateMarkers(MarkerUpdates markerUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateMarkers(markerUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateMarkers( + markerUpdates, + mapId: mapId, + ); } /// Updates cluster manager configuration. Future _updateClusterManagers( - ClusterManagerUpdates clusterManagerUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateClusterManagers(clusterManagerUpdates, mapId: mapId); + ClusterManagerUpdates clusterManagerUpdates, + ) { + return GoogleMapsFlutterPlatform.instance.updateClusterManagers( + clusterManagerUpdates, + mapId: mapId, + ); } /// Updates ground overlay configuration. Future _updateGroundOverlays( - GroundOverlayUpdates groundOverlayUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateGroundOverlays(groundOverlayUpdates, mapId: mapId); + GroundOverlayUpdates groundOverlayUpdates, + ) { + return GoogleMapsFlutterPlatform.instance.updateGroundOverlays( + groundOverlayUpdates, + mapId: mapId, + ); } /// Updates polygon configuration. Future _updatePolygons(PolygonUpdates polygonUpdates) { - return GoogleMapsFlutterPlatform.instance - .updatePolygons(polygonUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updatePolygons( + polygonUpdates, + mapId: mapId, + ); } /// Updates polyline configuration. Future _updatePolylines(PolylineUpdates polylineUpdates) { - return GoogleMapsFlutterPlatform.instance - .updatePolylines(polylineUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updatePolylines( + polylineUpdates, + mapId: mapId, + ); } /// Updates circle configuration. Future _updateCircles(CircleUpdates circleUpdates) { - return GoogleMapsFlutterPlatform.instance - .updateCircles(circleUpdates, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateCircles( + circleUpdates, + mapId: mapId, + ); } /// Updates tile overlays configuration. Future _updateTileOverlays(Set newTileOverlays) { - return GoogleMapsFlutterPlatform.instance - .updateTileOverlays(newTileOverlays: newTileOverlays, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.updateTileOverlays( + newTileOverlays: newTileOverlays, + mapId: mapId, + ); } /// Clears the tile cache so that all tiles will be requested again from the /// [TileProvider]. Future clearTileCache(TileOverlayId tileOverlayId) async { - return GoogleMapsFlutterPlatform.instance - .clearTileCache(tileOverlayId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.clearTileCache( + tileOverlayId, + mapId: mapId, + ); } /// Starts an animated change of the map camera position. Future animateCamera(CameraUpdate cameraUpdate, {Duration? duration}) { return GoogleMapsFlutterPlatform.instance.animateCameraWithConfiguration( - cameraUpdate, CameraUpdateAnimationConfiguration(duration: duration), - mapId: mapId); + cameraUpdate, + CameraUpdateAnimationConfiguration(duration: duration), + mapId: mapId, + ); } /// Changes the map camera position. Future moveCamera(CameraUpdate cameraUpdate) { - return GoogleMapsFlutterPlatform.instance - .moveCamera(cameraUpdate, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.moveCamera( + cameraUpdate, + mapId: mapId, + ); } /// Return [LatLngBounds] defining the region that is visible in a map. @@ -172,32 +212,42 @@ class ExampleGoogleMapController { /// Return [ScreenCoordinate] of the [LatLng] in the current map view. Future getScreenCoordinate(LatLng latLng) { - return GoogleMapsFlutterPlatform.instance - .getScreenCoordinate(latLng, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.getScreenCoordinate( + latLng, + mapId: mapId, + ); } /// Returns [LatLng] corresponding to the [ScreenCoordinate] in the current map view. Future getLatLng(ScreenCoordinate screenCoordinate) { - return GoogleMapsFlutterPlatform.instance - .getLatLng(screenCoordinate, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.getLatLng( + screenCoordinate, + mapId: mapId, + ); } /// Programmatically show the Info Window for a [Marker]. Future showMarkerInfoWindow(MarkerId markerId) { - return GoogleMapsFlutterPlatform.instance - .showMarkerInfoWindow(markerId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.showMarkerInfoWindow( + markerId, + mapId: mapId, + ); } /// Programmatically hide the Info Window for a [Marker]. Future hideMarkerInfoWindow(MarkerId markerId) { - return GoogleMapsFlutterPlatform.instance - .hideMarkerInfoWindow(markerId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.hideMarkerInfoWindow( + markerId, + mapId: mapId, + ); } /// Returns `true` when the [InfoWindow] is showing, `false` otherwise. Future isMarkerInfoWindowShown(MarkerId markerId) { - return GoogleMapsFlutterPlatform.instance - .isMarkerInfoWindowShown(markerId, mapId: mapId); + return GoogleMapsFlutterPlatform.instance.isMarkerInfoWindowShown( + markerId, + mapId: mapId, + ); } /// Returns the current zoom level of the map @@ -404,7 +454,8 @@ class _ExampleGoogleMapState extends State { _mapId, onPlatformViewCreated, widgetConfiguration: MapWidgetConfiguration( - textDirection: widget.layoutDirection ?? + textDirection: + widget.layoutDirection ?? Directionality.maybeOf(context) ?? TextDirection.ltr, initialCameraPosition: widget.initialCameraPosition, @@ -436,8 +487,9 @@ class _ExampleGoogleMapState extends State { @override void dispose() { - _controller.future - .then((ExampleGoogleMapController controller) => controller.dispose()); + _controller.future.then( + (ExampleGoogleMapController controller) => controller.dispose(), + ); super.dispose(); } @@ -467,43 +519,67 @@ class _ExampleGoogleMapState extends State { Future _updateMarkers() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updateMarkers( - MarkerUpdates.from(_markers.values.toSet(), widget.markers))); + unawaited( + controller._updateMarkers( + MarkerUpdates.from(_markers.values.toSet(), widget.markers), + ), + ); _markers = keyByMarkerId(widget.markers); } Future _updateClusterManagers() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updateClusterManagers(ClusterManagerUpdates.from( - _clusterManagers.values.toSet(), widget.clusterManagers))); + unawaited( + controller._updateClusterManagers( + ClusterManagerUpdates.from( + _clusterManagers.values.toSet(), + widget.clusterManagers, + ), + ), + ); _clusterManagers = keyByClusterManagerId(widget.clusterManagers); } Future _updateGroundOverlays() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updateGroundOverlays(GroundOverlayUpdates.from( - _groundOverlays.values.toSet(), widget.groundOverlays))); + unawaited( + controller._updateGroundOverlays( + GroundOverlayUpdates.from( + _groundOverlays.values.toSet(), + widget.groundOverlays, + ), + ), + ); _groundOverlays = keyByGroundOverlayId(widget.groundOverlays); } Future _updatePolygons() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updatePolygons( - PolygonUpdates.from(_polygons.values.toSet(), widget.polygons))); + unawaited( + controller._updatePolygons( + PolygonUpdates.from(_polygons.values.toSet(), widget.polygons), + ), + ); _polygons = keyByPolygonId(widget.polygons); } Future _updatePolylines() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updatePolylines( - PolylineUpdates.from(_polylines.values.toSet(), widget.polylines))); + unawaited( + controller._updatePolylines( + PolylineUpdates.from(_polylines.values.toSet(), widget.polylines), + ), + ); _polylines = keyByPolylineId(widget.polylines); } Future _updateCircles() async { final ExampleGoogleMapController controller = await _controller.future; - unawaited(controller._updateCircles( - CircleUpdates.from(_circles.values.toSet(), widget.circles))); + unawaited( + controller._updateCircles( + CircleUpdates.from(_circles.values.toSet(), widget.circles), + ), + ); _circles = keyByCircleId(widget.circles); } @@ -515,10 +591,10 @@ class _ExampleGoogleMapState extends State { Future onPlatformViewCreated(int id) async { final ExampleGoogleMapController controller = await ExampleGoogleMapController._init( - id, - widget.initialCameraPosition, - this, - ); + id, + widget.initialCameraPosition, + this, + ); _controller.complete(controller); unawaited(_updateTileOverlays()); widget.onMapCreated?.call(controller); diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/ground_overlay.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/ground_overlay.dart index 24563450031..7032fbac84a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/ground_overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/ground_overlay.dart @@ -14,7 +14,7 @@ enum _GroundOverlayPlacing { position, bounds } class GroundOverlayPage extends GoogleMapExampleAppPage { const GroundOverlayPage({Key? key}) - : super(const Icon(Icons.map), 'Ground overlay', key: key); + : super(const Icon(Icons.map), 'Ground overlay', key: key); @override Widget build(BuildContext context) { @@ -48,11 +48,13 @@ class GroundOverlayBodyState extends State { // Bounds for demonstranting placing ground overlays with bounds, and // changing bounds. final LatLngBounds _groundOverlayBounds1 = LatLngBounds( - southwest: const LatLng(37.42, -122.09), - northeast: const LatLng(37.423, -122.084)); + southwest: const LatLng(37.42, -122.09), + northeast: const LatLng(37.423, -122.084), + ); final LatLngBounds _groundOverlayBounds2 = LatLngBounds( - southwest: const LatLng(37.421, -122.091), - northeast: const LatLng(37.424, -122.08)); + southwest: const LatLng(37.421, -122.091), + northeast: const LatLng(37.424, -122.08), + ); late LatLngBounds _currentGroundOverlayBounds; Offset _anchor = const Offset(0.5, 0.5); @@ -91,29 +93,30 @@ class GroundOverlayBodyState extends State { _groundOverlayIndex += 1; - final GroundOverlayId id = - GroundOverlayId('ground_overlay_$_groundOverlayIndex'); + final GroundOverlayId id = GroundOverlayId( + 'ground_overlay_$_groundOverlayIndex', + ); final GroundOverlay groundOverlay = switch (_placingType) { _GroundOverlayPlacing.position => GroundOverlay.fromPosition( - groundOverlayId: id, - image: assetMapBitmap, - position: _currentGroundOverlayPos, - anchor: _anchor, - onTap: () { - _onGroundOverlayTapped(); - }, - zoomLevel: 14.0, - ), + groundOverlayId: id, + image: assetMapBitmap, + position: _currentGroundOverlayPos, + anchor: _anchor, + onTap: () { + _onGroundOverlayTapped(); + }, + zoomLevel: 14.0, + ), _GroundOverlayPlacing.bounds => GroundOverlay.fromBounds( - groundOverlayId: id, - image: assetMapBitmap, - bounds: _currentGroundOverlayBounds, - anchor: _anchor, - onTap: () { - _onGroundOverlayTapped(); - }, - ), + groundOverlayId: id, + image: assetMapBitmap, + bounds: _currentGroundOverlayBounds, + anchor: _anchor, + onTap: () { + _onGroundOverlayTapped(); + }, + ), }; setState(() { @@ -131,9 +134,9 @@ class GroundOverlayBodyState extends State { // Adjusts the bearing by 10 degrees, wrapping around at 360 degrees. // 10 is the increment, 350 degrees of the full circle -10. _groundOverlay = _groundOverlay!.copyWith( - bearingParam: _groundOverlay!.bearing >= 350 - ? 0 - : _groundOverlay!.bearing + 10); + bearingParam: + _groundOverlay!.bearing >= 350 ? 0 : _groundOverlay!.bearing + 10, + ); }); } @@ -142,8 +145,9 @@ class GroundOverlayBodyState extends State { setState(() { final double transparency = _groundOverlay!.transparency == 0.0 ? 0.5 : 0.0; - _groundOverlay = - _groundOverlay!.copyWith(transparencyParam: transparency); + _groundOverlay = _groundOverlay!.copyWith( + transparencyParam: transparency, + ); }); } @@ -151,9 +155,10 @@ class GroundOverlayBodyState extends State { assert(_groundOverlay != null); assert(_placingType == _GroundOverlayPlacing.position); setState(() { - _currentGroundOverlayPos = _currentGroundOverlayPos == _groundOverlayPos1 - ? _groundOverlayPos2 - : _groundOverlayPos1; + _currentGroundOverlayPos = + _currentGroundOverlayPos == _groundOverlayPos1 + ? _groundOverlayPos2 + : _groundOverlayPos1; }); // Re-add the ground overlay to apply the new position, as the position @@ -179,8 +184,9 @@ class GroundOverlayBodyState extends State { void _toggleVisible() { assert(_groundOverlay != null); setState(() { - _groundOverlay = - _groundOverlay!.copyWith(visibleParam: !_groundOverlay!.visible); + _groundOverlay = _groundOverlay!.copyWith( + visibleParam: !_groundOverlay!.visible, + ); }); } @@ -195,9 +201,10 @@ class GroundOverlayBodyState extends State { Future _changeType() async { setState(() { - _placingType = _placingType == _GroundOverlayPlacing.position - ? _GroundOverlayPlacing.bounds - : _GroundOverlayPlacing.position; + _placingType = + _placingType == _GroundOverlayPlacing.position + ? _GroundOverlayPlacing.bounds + : _GroundOverlayPlacing.position; }); // Re-add the ground overlay to apply the new position, as the position @@ -208,9 +215,10 @@ class GroundOverlayBodyState extends State { Future _changeAnchor() async { assert(_groundOverlay != null); setState(() { - _anchor = _groundOverlay!.anchor == const Offset(0.5, 0.5) - ? const Offset(1.0, 1.0) - : const Offset(0.5, 0.5); + _anchor = + _groundOverlay!.anchor == const Offset(0.5, 0.5) + ? const Offset(1.0, 1.0) + : const Offset(0.5, 0.5); }); // Re-add the ground overlay to apply the new anchor, as anchor cannot be @@ -277,22 +285,26 @@ class GroundOverlayBodyState extends State { ), TextButton( onPressed: _groundOverlay == null ? null : () => _changeType(), - child: Text(_placingType == _GroundOverlayPlacing.position - ? 'use bounds' - : 'use position'), + child: Text( + _placingType == _GroundOverlayPlacing.position + ? 'use bounds' + : 'use position', + ), ), TextButton( - onPressed: _placingType != _GroundOverlayPlacing.position || - _groundOverlay == null - ? null - : () => _changePosition(), + onPressed: + _placingType != _GroundOverlayPlacing.position || + _groundOverlay == null + ? null + : () => _changePosition(), child: const Text('change position'), ), TextButton( - onPressed: _placingType != _GroundOverlayPlacing.bounds || - _groundOverlay == null - ? null - : () => _changeBounds(), + onPressed: + _placingType != _GroundOverlayPlacing.bounds || + _groundOverlay == null + ? null + : () => _changeBounds(), child: const Text('change bounds'), ), ], diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/lite_mode.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/lite_mode.dart index a70ff98a4e7..11e9923195b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/lite_mode.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/lite_mode.dart @@ -10,12 +10,14 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf import 'example_google_map.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class LiteModePage extends GoogleMapExampleAppPage { const LiteModePage({Key? key}) - : super(const Icon(Icons.map), 'Lite mode', key: key); + : super(const Icon(Icons.map), 'Lite mode', key: key); @override Widget build(BuildContext context) { @@ -35,9 +37,7 @@ class _LiteModeBody extends StatelessWidget { child: SizedBox( width: 300.0, height: 300.0, - child: ExampleGoogleMap( - initialCameraPosition: _kInitialPosition, - ), + child: ExampleGoogleMap(initialCameraPosition: _kInitialPosition), ), ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_click.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_click.dart index 4017a9fccce..098f3f1a5a5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_click.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_click.dart @@ -10,12 +10,14 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf import 'example_google_map.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class MapClickPage extends GoogleMapExampleAppPage { const MapClickPage({Key? key}) - : super(const Icon(Icons.mouse), 'Map click', key: key); + : super(const Icon(Icons.mouse), 'Map click', key: key); @override Widget build(BuildContext context) { @@ -58,11 +60,7 @@ class _MapClickBodyState extends State<_MapClickBody> { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), ]; @@ -70,26 +68,28 @@ class _MapClickBodyState extends State<_MapClickBody> { if (mapController != null) { final String lastTap = 'Tap:\n${_lastTap ?? ""}\n'; final String lastLongPress = 'Long press:\n${_lastLongPress ?? ""}'; - columnChildren.add(Center( - child: Text( - lastTap, - textAlign: TextAlign.center, - ))); - columnChildren.add(Center( + columnChildren.add( + Center(child: Text(lastTap, textAlign: TextAlign.center)), + ); + columnChildren.add( + Center( child: Text( - _lastTap != null ? 'Tapped' : '', - textAlign: TextAlign.center, - ))); - columnChildren.add(Center( - child: Text( - lastLongPress, - textAlign: TextAlign.center, - ))); - columnChildren.add(Center( + _lastTap != null ? 'Tapped' : '', + textAlign: TextAlign.center, + ), + ), + ); + columnChildren.add( + Center(child: Text(lastLongPress, textAlign: TextAlign.center)), + ); + columnChildren.add( + Center( child: Text( - _lastLongPress != null ? 'Long pressed' : '', - textAlign: TextAlign.center, - ))); + _lastLongPress != null ? 'Long pressed' : '', + textAlign: TextAlign.center, + ), + ), + ); } return Column( crossAxisAlignment: CrossAxisAlignment.stretch, diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_coordinates.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_coordinates.dart index 25247bc7c7b..b834fa6a3b9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_coordinates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_coordinates.dart @@ -10,12 +10,14 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf import 'example_google_map.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class MapCoordinatesPage extends GoogleMapExampleAppPage { const MapCoordinatesPage({Key? key}) - : super(const Icon(Icons.map), 'Map coordinates', key: key); + : super(const Icon(Icons.map), 'Map coordinates', key: key); @override Widget build(BuildContext context) { @@ -70,17 +72,16 @@ class _MapCoordinatesBodyState extends State<_MapCoordinatesBody> { // Add a block at the bottom of this list to allow validation that the visible region of the map // does not change when scrolled under the safe view on iOS. // https://github.com/flutter/flutter/issues/107913 - const SizedBox( - width: 300, - height: 1000, - ), + const SizedBox(width: 300, height: 1000), ], ), if (mapController != null) Center( - child: Text('VisibleRegion:' - '\nnortheast: ${_visibleRegion.northeast},' - '\nsouthwest: ${_visibleRegion.southwest}'), + child: Text( + 'VisibleRegion:' + '\nnortheast: ${_visibleRegion.northeast},' + '\nsouthwest: ${_visibleRegion.southwest}', + ), ), ], ), diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_map_id.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_map_id.dart index 037bafd8a35..9e475c66aaa 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_map_id.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_map_id.dart @@ -12,7 +12,7 @@ import 'page.dart'; class MapIdPage extends GoogleMapExampleAppPage { const MapIdPage({Key? key}) - : super(const Icon(Icons.map), 'Cloud-based maps styling', key: key); + : super(const Icon(Icons.map), 'Cloud-based maps styling', key: key); @override Widget build(BuildContext context) { @@ -61,31 +61,23 @@ class MapIdBodyState extends State { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), Padding( padding: const EdgeInsets.all(10.0), child: TextField( controller: _mapIdController, - decoration: const InputDecoration( - hintText: 'Map Id', - ), + decoration: const InputDecoration(hintText: 'Map Id'), ), ), Padding( padding: const EdgeInsets.all(10.0), child: ElevatedButton( onPressed: () => _setMapId(), - child: const Text( - 'Press to use specified map Id', - ), + child: const Text('Press to use specified map Id'), ), - ) + ), ]; return Column( diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_ui.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_ui.dart index 0038ec6f339..ec8bf16c134 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_ui.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/map_ui.dart @@ -18,7 +18,7 @@ final LatLngBounds sydneyBounds = LatLngBounds( class MapUiPage extends GoogleMapExampleAppPage { const MapUiPage({Key? key}) - : super(const Icon(Icons.map), 'User interface', key: key); + : super(const Icon(Icons.map), 'User interface', key: key); @override Widget build(BuildContext context) { @@ -91,9 +91,10 @@ class MapUiBodyState extends State { ), onPressed: () { setState(() { - _cameraTargetBounds = _cameraTargetBounds.bounds == null - ? CameraTargetBounds(sydneyBounds) - : CameraTargetBounds.unbounded; + _cameraTargetBounds = + _cameraTargetBounds.bounds == null + ? CameraTargetBounds(sydneyBounds) + : CameraTargetBounds.unbounded; }); }, ); @@ -101,14 +102,15 @@ class MapUiBodyState extends State { Widget _zoomBoundsToggler() { return TextButton( - child: Text(_minMaxZoomPreference.minZoom == null - ? 'bound zoom' - : 'release zoom'), + child: Text( + _minMaxZoomPreference.minZoom == null ? 'bound zoom' : 'release zoom', + ), onPressed: () { setState(() { - _minMaxZoomPreference = _minMaxZoomPreference.minZoom == null - ? const MinMaxZoomPreference(12.0, 16.0) - : MinMaxZoomPreference.unbounded; + _minMaxZoomPreference = + _minMaxZoomPreference.minZoom == null + ? const MinMaxZoomPreference(12.0, 16.0) + : MinMaxZoomPreference.unbounded; }); }, ); @@ -173,8 +175,9 @@ class MapUiBodyState extends State { Widget _zoomControlsToggler() { return TextButton( - child: - Text('${_zoomControlsEnabled ? 'disable' : 'enable'} zoom controls'), + child: Text( + '${_zoomControlsEnabled ? 'disable' : 'enable'} zoom controls', + ), onPressed: () { setState(() { _zoomControlsEnabled = !_zoomControlsEnabled; @@ -197,7 +200,8 @@ class MapUiBodyState extends State { Widget _myLocationToggler() { return TextButton( child: Text( - '${_myLocationEnabled ? 'disable' : 'enable'} my location marker'), + '${_myLocationEnabled ? 'disable' : 'enable'} my location marker', + ), onPressed: () { setState(() { _myLocationEnabled = !_myLocationEnabled; @@ -209,7 +213,8 @@ class MapUiBodyState extends State { Widget _myLocationButtonToggler() { return TextButton( child: Text( - '${_myLocationButtonEnabled ? 'disable' : 'enable'} my location button'), + '${_myLocationButtonEnabled ? 'disable' : 'enable'} my location button', + ), onPressed: () { setState(() { _myLocationButtonEnabled = !_myLocationButtonEnabled; @@ -273,11 +278,7 @@ class MapUiBodyState extends State { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), ]; @@ -289,8 +290,9 @@ class MapUiBodyState extends State { children: [ Text('camera bearing: ${_position.bearing}'), Text( - 'camera target: ${_position.target.latitude.toStringAsFixed(4)},' - '${_position.target.longitude.toStringAsFixed(4)}'), + 'camera target: ${_position.target.latitude.toStringAsFixed(4)},' + '${_position.target.longitude.toStringAsFixed(4)}', + ), Text('camera zoom: ${_position.zoom}'), Text('camera tilt: ${_position.tilt}'), Text(_isMoving ? '(Camera moving)' : '(Camera idle)'), diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/maps_demo.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/maps_demo.dart index 15dd4794058..eb740cac882 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/maps_demo.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/maps_demo.dart @@ -15,11 +15,13 @@ class MapsDemo extends StatelessWidget { final List pages; void _pushPage(BuildContext context, GoogleMapExampleAppPage page) { - Navigator.of(context).push(MaterialPageRoute( - builder: (_) => Scaffold( - appBar: AppBar(title: Text(page.title)), - body: page, - ))); + Navigator.of(context).push( + MaterialPageRoute( + builder: + (_) => + Scaffold(appBar: AppBar(title: Text(page.title)), body: page), + ), + ); } @override @@ -28,11 +30,12 @@ class MapsDemo extends StatelessWidget { appBar: AppBar(title: const Text('GoogleMaps examples')), body: ListView.builder( itemCount: pages.length, - itemBuilder: (_, int index) => ListTile( - leading: pages[index].leading, - title: Text(pages[index].title), - onTap: () => _pushPage(context, pages[index]), - ), + itemBuilder: + (_, int index) => ListTile( + leading: pages[index].leading, + title: Text(pages[index].title), + onTap: () => _pushPage(context, pages[index]), + ), ), ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/marker_icons.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/marker_icons.dart index df4f79205e8..2b18c56c60e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/marker_icons.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/marker_icons.dart @@ -17,7 +17,7 @@ import 'page.dart'; class MarkerIconsPage extends GoogleMapExampleAppPage { const MarkerIconsPage({Key? key}) - : super(const Icon(Icons.image), 'Marker icons', key: key); + : super(const Icon(Icons.image), 'Marker icons', key: key); @override Widget build(BuildContext context) { @@ -34,13 +34,7 @@ class MarkerIconsBody extends StatefulWidget { const LatLng _kMapCenter = LatLng(52.4478, -3.5402); -enum _MarkerSizeOption { - original, - width30, - height40, - size30x60, - size120x60, -} +enum _MarkerSizeOption { original, width30, height40, size30x60, size120x60 } class MarkerIconsBodyState extends State { final Size _markerAssetImageSize = const Size(48, 48); @@ -63,75 +57,82 @@ class MarkerIconsBodyState extends State { mainAxisAlignment: MainAxisAlignment.spaceEvenly, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - Column(children: [ - Center( - child: SizedBox( - width: 350.0, - height: 300.0, - child: ExampleGoogleMap( - initialCameraPosition: const CameraPosition( - target: _kMapCenter, - zoom: 7.0, + Column( + children: [ + Center( + child: SizedBox( + width: 350.0, + height: 300.0, + child: ExampleGoogleMap( + initialCameraPosition: const CameraPosition( + target: _kMapCenter, + zoom: 7.0, + ), + markers: _markers, + onMapCreated: _onMapCreated, ), - markers: _markers, - onMapCreated: _onMapCreated, ), ), - ), - TextButton( - onPressed: () => _toggleScaling(context), - child: Text(_scalingEnabled - ? 'Disable auto scaling' - : 'Enable auto scaling'), - ), - if (_scalingEnabled) ...[ - Container( - width: referenceSize.width, - height: referenceSize.height, - decoration: BoxDecoration( - border: Border.all(), + TextButton( + onPressed: () => _toggleScaling(context), + child: Text( + _scalingEnabled + ? 'Disable auto scaling' + : 'Enable auto scaling', ), ), - Text( - 'Reference box with size of ${referenceSize.width} x ${referenceSize.height} in logical pixels.'), - const SizedBox(height: 10), - Image.asset( - 'assets/red_square.png', - scale: _mipMapsEnabled ? null : 1.0, - ), - const Text('Asset image rendered with flutter'), - const SizedBox(height: 10), - Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - const Text('Marker size:'), - const SizedBox(width: 10), - DropdownButton<_MarkerSizeOption>( - value: _currentSizeOption, - onChanged: (_MarkerSizeOption? newValue) { - if (newValue != null) { - setState(() { - _currentSizeOption = newValue; - _updateMarkerImages(context); - }); - } - }, - items: - _MarkerSizeOption.values.map((_MarkerSizeOption option) { - return DropdownMenuItem<_MarkerSizeOption>( - value: option, - child: Text(_getMarkerSizeOptionName(option)), - ); - }).toList(), - ) - ], + if (_scalingEnabled) ...[ + Container( + width: referenceSize.width, + height: referenceSize.height, + decoration: BoxDecoration(border: Border.all()), + ), + Text( + 'Reference box with size of ${referenceSize.width} x ${referenceSize.height} in logical pixels.', + ), + const SizedBox(height: 10), + Image.asset( + 'assets/red_square.png', + scale: _mipMapsEnabled ? null : 1.0, + ), + const Text('Asset image rendered with flutter'), + const SizedBox(height: 10), + Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + const Text('Marker size:'), + const SizedBox(width: 10), + DropdownButton<_MarkerSizeOption>( + value: _currentSizeOption, + onChanged: (_MarkerSizeOption? newValue) { + if (newValue != null) { + setState(() { + _currentSizeOption = newValue; + _updateMarkerImages(context); + }); + } + }, + items: + _MarkerSizeOption.values.map(( + _MarkerSizeOption option, + ) { + return DropdownMenuItem<_MarkerSizeOption>( + value: option, + child: Text(_getMarkerSizeOptionName(option)), + ); + }).toList(), + ), + ], + ), + ], + TextButton( + onPressed: () => _toggleMipMaps(context), + child: Text( + _mipMapsEnabled ? 'Disable mipmaps' : 'Enable mipmaps', + ), ), ], - TextButton( - onPressed: () => _toggleMipMaps(context), - child: Text(_mipMapsEnabled ? 'Disable mipmaps' : 'Enable mipmaps'), - ), - ]) + ), ], ); } @@ -179,12 +180,15 @@ class MarkerIconsBodyState extends State { if (width != null && height != null) { return Size(width, height); } else if (width != null) { - return Size(width, - width * _markerAssetImageSize.height / _markerAssetImageSize.width); + return Size( + width, + width * _markerAssetImageSize.height / _markerAssetImageSize.width, + ); } else if (height != null) { return Size( - height * _markerAssetImageSize.width / _markerAssetImageSize.height, - height); + height * _markerAssetImageSize.width / _markerAssetImageSize.height, + height, + ); } else { return _markerAssetImageSize; } @@ -207,8 +211,10 @@ class MarkerIconsBodyState extends State { } Marker _createAssetMarker(int index) { - final LatLng position = - LatLng(_kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude - 1); + final LatLng position = LatLng( + _kMapCenter.latitude - (index * 0.5), + _kMapCenter.longitude - 1, + ); return Marker( markerId: MarkerId('marker_asset_$index'), @@ -218,8 +224,10 @@ class MarkerIconsBodyState extends State { } Marker _createBytesMarker(int index) { - final LatLng position = - LatLng(_kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude + 1); + final LatLng position = LatLng( + _kMapCenter.latitude - (index * 0.5), + _kMapCenter.longitude + 1, + ); return Marker( markerId: MarkerId('marker_bytes_$index'), @@ -253,9 +261,7 @@ class MarkerIconsBodyState extends State { AssetMapBitmap assetMapBitmap; if (_mipMapsEnabled) { final ImageConfiguration imageConfiguration = - createLocalImageConfiguration( - context, - ); + createLocalImageConfiguration(context); assetMapBitmap = await AssetMapBitmap.create( imageConfiguration, @@ -282,16 +288,18 @@ class MarkerIconsBodyState extends State { } Future _updateMarkerBytesImage(BuildContext context) async { - final double? devicePixelRatio = - MediaQuery.maybeDevicePixelRatioOf(context); + final double? devicePixelRatio = MediaQuery.maybeDevicePixelRatioOf( + context, + ); final Size bitmapLogicalSize = _getMarkerReferenceSize(); final double? imagePixelRatio = _scalingEnabled ? devicePixelRatio : null; // Create canvasSize with physical marker size final Size canvasSize = Size( - bitmapLogicalSize.width * (imagePixelRatio ?? 1.0), - bitmapLogicalSize.height * (imagePixelRatio ?? 1.0)); + bitmapLogicalSize.width * (imagePixelRatio ?? 1.0), + bitmapLogicalSize.height * (imagePixelRatio ?? 1.0), + ); final ByteData bytes = await createCustomMarkerIconImage(size: canvasSize); @@ -301,12 +309,14 @@ class MarkerIconsBodyState extends State { ? _getCurrentMarkerSize() : (null, null); - final BytesMapBitmap bitmap = BytesMapBitmap(bytes.buffer.asUint8List(), - imagePixelRatio: imagePixelRatio, - width: width, - height: height, - bitmapScaling: - _scalingEnabled ? MapBitmapScaling.auto : MapBitmapScaling.none); + final BytesMapBitmap bitmap = BytesMapBitmap( + bytes.buffer.asUint8List(), + imagePixelRatio: imagePixelRatio, + width: width, + height: height, + bitmapScaling: + _scalingEnabled ? MapBitmapScaling.auto : MapBitmapScaling.none, + ); _updateBytesBitmap(bitmap); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/move_camera.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/move_camera.dart index b1fb55cad54..b41d3d65fae 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/move_camera.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/move_camera.dart @@ -12,7 +12,7 @@ import 'page.dart'; class MoveCameraPage extends GoogleMapExampleAppPage { const MoveCameraPage({Key? key}) - : super(const Icon(Icons.map), 'Camera control', key: key); + : super(const Icon(Icons.map), 'Camera control', key: key); @override Widget build(BuildContext context) { @@ -46,8 +46,9 @@ class MoveCameraState extends State { height: 200.0, child: ExampleGoogleMap( onMapCreated: _onMapCreated, - initialCameraPosition: - const CameraPosition(target: LatLng(0.0, 0.0)), + initialCameraPosition: const CameraPosition( + target: LatLng(0.0, 0.0), + ), ), ), ), @@ -121,50 +122,39 @@ class MoveCameraState extends State { TextButton( onPressed: () { mapController?.moveCamera( - CameraUpdate.zoomBy( - -0.5, - const Offset(30.0, 20.0), - ), + CameraUpdate.zoomBy(-0.5, const Offset(30.0, 20.0)), ); }, child: const Text('zoomBy with focus'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomBy(-0.5), - ); + mapController?.moveCamera(CameraUpdate.zoomBy(-0.5)); }, child: const Text('zoomBy'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomIn(), - ); + mapController?.moveCamera(CameraUpdate.zoomIn()); }, child: const Text('zoomIn'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomOut(), - ); + mapController?.moveCamera(CameraUpdate.zoomOut()); }, child: const Text('zoomOut'), ), TextButton( onPressed: () { - mapController?.moveCamera( - CameraUpdate.zoomTo(16.0), - ); + mapController?.moveCamera(CameraUpdate.zoomTo(16.0)); }, child: const Text('zoomTo'), ), ], ), ], - ) + ), ], ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/padding.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/padding.dart index bfddb167d43..aadac26f96b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/padding.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/padding.dart @@ -12,7 +12,7 @@ import 'page.dart'; class PaddingPage extends GoogleMapExampleAppPage { const PaddingPage({Key? key}) - : super(const Icon(Icons.map), 'Add padding to the map', key: key); + : super(const Icon(Icons.map), 'Add padding to the map', key: key); @override Widget build(BuildContext context) { @@ -49,11 +49,7 @@ class MarkerIconsBodyState extends State { Padding( padding: const EdgeInsets.all(10.0), child: Center( - child: SizedBox( - width: 300.0, - height: 200.0, - child: googleMap, - ), + child: SizedBox(width: 300.0, height: 200.0, child: googleMap), ), ), const Padding( @@ -97,9 +93,7 @@ class MarkerIconsBodyState extends State { controller: _topController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Top', - ), + decoration: const InputDecoration(hintText: 'Top'), ), ), const Spacer(), @@ -109,9 +103,7 @@ class MarkerIconsBodyState extends State { controller: _bottomController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Bottom', - ), + decoration: const InputDecoration(hintText: 'Bottom'), ), ), const Spacer(), @@ -121,9 +113,7 @@ class MarkerIconsBodyState extends State { controller: _leftController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Left', - ), + decoration: const InputDecoration(hintText: 'Left'), ), ), const Spacer(), @@ -133,9 +123,7 @@ class MarkerIconsBodyState extends State { controller: _rightController, keyboardType: TextInputType.number, textAlign: TextAlign.center, - decoration: const InputDecoration( - hintText: 'Right', - ), + decoration: const InputDecoration(hintText: 'Right'), ), ), ], @@ -154,10 +142,11 @@ class MarkerIconsBodyState extends State { onPressed: () { setState(() { _padding = EdgeInsets.fromLTRB( - double.tryParse(_leftController.value.text) ?? 0, - double.tryParse(_topController.value.text) ?? 0, - double.tryParse(_rightController.value.text) ?? 0, - double.tryParse(_bottomController.value.text) ?? 0); + double.tryParse(_leftController.value.text) ?? 0, + double.tryParse(_topController.value.text) ?? 0, + double.tryParse(_rightController.value.text) ?? 0, + double.tryParse(_bottomController.value.text) ?? 0, + ); }); }, ), @@ -172,7 +161,7 @@ class MarkerIconsBodyState extends State { _padding = EdgeInsets.zero; }); }, - ) + ), ], ), ); diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_circle.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_circle.dart index 29be7442965..00092afab7a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_circle.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_circle.dart @@ -12,7 +12,7 @@ import 'page.dart'; class PlaceCirclePage extends GoogleMapExampleAppPage { const PlaceCirclePage({Key? key}) - : super(const Icon(Icons.linear_scale), 'Place circle', key: key); + : super(const Icon(Icons.linear_scale), 'Place circle', key: key); @override Widget build(BuildContext context) { @@ -108,9 +108,7 @@ class PlaceCircleBodyState extends State { void _toggleVisible(CircleId circleId) { final Circle circle = circles[circleId]!; setState(() { - circles[circleId] = circle.copyWith( - visibleParam: !circle.visible, - ); + circles[circleId] = circle.copyWith(visibleParam: !circle.visible); }); } @@ -171,20 +169,19 @@ class PlaceCircleBodyState extends State { children: [ Column( children: [ + TextButton(onPressed: _add, child: const Text('add')), TextButton( - onPressed: _add, - child: const Text('add'), - ), - TextButton( - onPressed: (selectedId == null) - ? null - : () => _remove(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _remove(selectedId), child: const Text('remove'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleVisible(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleVisible(selectedId), child: const Text('toggle visible'), ), ], @@ -192,27 +189,30 @@ class PlaceCircleBodyState extends State { Column( children: [ TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeStrokeWidth(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeStrokeWidth(selectedId), child: const Text('change stroke width'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeStrokeColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeStrokeColor(selectedId), child: const Text('change stroke color'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeFillColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeFillColor(selectedId), child: const Text('change fill color'), ), ], - ) + ), ], - ) + ), ], ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_marker.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_marker.dart index 4291aec8c15..6b63a7ca96c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_marker.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_marker.dart @@ -17,7 +17,7 @@ import 'page.dart'; class PlaceMarkerPage extends GoogleMapExampleAppPage { const PlaceMarkerPage({Key? key}) - : super(const Icon(Icons.place), 'Place marker', key: key); + : super(const Icon(Icons.place), 'Place marker', key: key); @override Widget build(BuildContext context) { @@ -62,8 +62,9 @@ class PlaceMarkerBodyState extends State { setState(() { final MarkerId? previousMarkerId = selectedMarker; if (previousMarkerId != null && markers.containsKey(previousMarkerId)) { - final Marker resetOld = markers[previousMarkerId]! - .copyWith(iconParam: BitmapDescriptor.defaultMarker); + final Marker resetOld = markers[previousMarkerId]!.copyWith( + iconParam: BitmapDescriptor.defaultMarker, + ); markers[previousMarkerId] = resetOld; } selectedMarker = markerId; @@ -104,29 +105,32 @@ class PlaceMarkerBodyState extends State { markerPosition = null; }); await showDialog( - context: context, - builder: (BuildContext context) { - return AlertDialog( - actions: [ - TextButton( - child: const Text('OK'), - onPressed: () { - _onDragXcodeUITestHelperText = ''; - Navigator.of(context).pop(); - }) + context: context, + builder: (BuildContext context) { + return AlertDialog( + actions: [ + TextButton( + child: const Text('OK'), + onPressed: () { + _onDragXcodeUITestHelperText = ''; + Navigator.of(context).pop(); + }, + ), + ], + content: Padding( + padding: const EdgeInsets.symmetric(vertical: 66), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + Text('iOS delegate called: \n $_onDragXcodeUITestHelperText'), + Text('Old position: ${tappedMarker.position}'), + Text('New position: $newPosition'), ], - content: Padding( - padding: const EdgeInsets.symmetric(vertical: 66), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - Text( - 'iOS delegate called: \n $_onDragXcodeUITestHelperText'), - Text('Old position: ${tappedMarker.position}'), - Text('New position: $newPosition'), - ], - ))); - }); + ), + ), + ); + }, + ); } } @@ -189,9 +193,7 @@ class PlaceMarkerBodyState extends State { final Offset currentAnchor = marker.anchor; final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { - markers[markerId] = marker.copyWith( - anchorParam: newAnchor, - ); + markers[markerId] = marker.copyWith(anchorParam: newAnchor); }); } @@ -201,9 +203,7 @@ class PlaceMarkerBodyState extends State { final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { markers[markerId] = marker.copyWith( - infoWindowParam: marker.infoWindow.copyWith( - anchorParam: newAnchor, - ), + infoWindowParam: marker.infoWindow.copyWith(anchorParam: newAnchor), ); }); } @@ -211,18 +211,14 @@ class PlaceMarkerBodyState extends State { Future _toggleDraggable(MarkerId markerId) async { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - draggableParam: !marker.draggable, - ); + markers[markerId] = marker.copyWith(draggableParam: !marker.draggable); }); } Future _toggleFlat(MarkerId markerId) async { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - flatParam: !marker.flat, - ); + markers[markerId] = marker.copyWith(flatParam: !marker.flat); }); } @@ -231,9 +227,7 @@ class PlaceMarkerBodyState extends State { final String newSnippet = '${marker.infoWindow.snippet!}*'; setState(() { markers[markerId] = marker.copyWith( - infoWindowParam: marker.infoWindow.copyWith( - snippetParam: newSnippet, - ), + infoWindowParam: marker.infoWindow.copyWith(snippetParam: newSnippet), ); }); } @@ -261,9 +255,7 @@ class PlaceMarkerBodyState extends State { Future _toggleVisible(MarkerId markerId) async { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - visibleParam: !marker.visible, - ); + markers[markerId] = marker.copyWith(visibleParam: !marker.visible); }); } @@ -280,9 +272,7 @@ class PlaceMarkerBodyState extends State { void _setMarkerIcon(MarkerId markerId, BitmapDescriptor assetIcon) { final Marker marker = markers[markerId]!; setState(() { - markers[markerId] = marker.copyWith( - iconParam: assetIcon, - ); + markers[markerId] = marker.copyWith(iconParam: assetIcon); }); } @@ -295,130 +285,141 @@ class PlaceMarkerBodyState extends State { @override Widget build(BuildContext context) { final MarkerId? selectedId = selectedMarker; - return Stack(children: [ - Column( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - crossAxisAlignment: CrossAxisAlignment.stretch, - children: [ - Expanded( - child: ExampleGoogleMap( - onMapCreated: _onMapCreated, - initialCameraPosition: const CameraPosition( - target: LatLng(-33.852, 151.211), - zoom: 11.0, + return Stack( + children: [ + Column( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + crossAxisAlignment: CrossAxisAlignment.stretch, + children: [ + Expanded( + child: ExampleGoogleMap( + onMapCreated: _onMapCreated, + initialCameraPosition: const CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, + ), + markers: Set.of(markers.values), ), - markers: Set.of(markers.values), ), - ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - TextButton( - onPressed: _add, - child: const Text('Add'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _remove(selectedId), - child: const Text('Remove'), - ), - ], - ), - Wrap( - alignment: WrapAlignment.spaceEvenly, - children: [ - TextButton( - onPressed: - selectedId == null ? null : () => _changeInfo(selectedId), - child: const Text('change info'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _changeInfoAnchor(selectedId), - child: const Text('change info anchor'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _changeAlpha(selectedId), - child: const Text('change alpha'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _changeAnchor(selectedId), - child: const Text('change anchor'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _toggleDraggable(selectedId), - child: const Text('toggle draggable'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _toggleFlat(selectedId), - child: const Text('toggle flat'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _changePosition(selectedId), - child: const Text('change position'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _changeRotation(selectedId), - child: const Text('change rotation'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () => _toggleVisible(selectedId), - child: const Text('toggle visible'), - ), - TextButton( - onPressed: - selectedId == null ? null : () => _changeZIndex(selectedId), - child: const Text('change zIndex'), - ), - TextButton( - onPressed: selectedId == null - ? null - : () { - _getMarkerIcon(context).then( - (BitmapDescriptor icon) { - _setMarkerIcon(selectedId, icon); + Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + TextButton(onPressed: _add, child: const Text('Add')), + TextButton( + onPressed: + selectedId == null ? null : () => _remove(selectedId), + child: const Text('Remove'), + ), + ], + ), + Wrap( + alignment: WrapAlignment.spaceEvenly, + children: [ + TextButton( + onPressed: + selectedId == null ? null : () => _changeInfo(selectedId), + child: const Text('change info'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeInfoAnchor(selectedId), + child: const Text('change info anchor'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeAlpha(selectedId), + child: const Text('change alpha'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeAnchor(selectedId), + child: const Text('change anchor'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _toggleDraggable(selectedId), + child: const Text('toggle draggable'), + ), + TextButton( + onPressed: + selectedId == null ? null : () => _toggleFlat(selectedId), + child: const Text('toggle flat'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changePosition(selectedId), + child: const Text('change position'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeRotation(selectedId), + child: const Text('change rotation'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _toggleVisible(selectedId), + child: const Text('toggle visible'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () => _changeZIndex(selectedId), + child: const Text('change zIndex'), + ), + TextButton( + onPressed: + selectedId == null + ? null + : () { + _getMarkerIcon(context).then(( + BitmapDescriptor icon, + ) { + _setMarkerIcon(selectedId, icon); + }); }, - ); - }, - child: const Text('set marker icon'), - ), - ], - ), - ], - ), - Visibility( - visible: markerPosition != null, - child: Container( - color: Colors.white70, - height: 30, - padding: const EdgeInsets.only(left: 12, right: 12), - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceAround, - children: [ - if (markerPosition == null) - Container() - else - Expanded(child: Text('lat: ${markerPosition!.latitude}')), - if (markerPosition == null) - Container() - else - Expanded(child: Text('lng: ${markerPosition!.longitude}')), - ], + child: const Text('set marker icon'), + ), + ], + ), + ], + ), + Visibility( + visible: markerPosition != null, + child: Container( + color: Colors.white70, + height: 30, + padding: const EdgeInsets.only(left: 12, right: 12), + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceAround, + children: [ + if (markerPosition == null) + Container() + else + Expanded(child: Text('lat: ${markerPosition!.latitude}')), + if (markerPosition == null) + Container() + else + Expanded(child: Text('lng: ${markerPosition!.longitude}')), + ], + ), ), ), - ), - ]); + ], + ); } } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polygon.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polygon.dart index a1fdafd7a31..b40e83cec7a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polygon.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polygon.dart @@ -12,7 +12,7 @@ import 'page.dart'; class PlacePolygonPage extends GoogleMapExampleAppPage { const PlacePolygonPage({Key? key}) - : super(const Icon(Icons.linear_scale), 'Place polygon', key: key); + : super(const Icon(Icons.linear_scale), 'Place polygon', key: key); @override Widget build(BuildContext context) { @@ -108,18 +108,14 @@ class PlacePolygonBodyState extends State { void _toggleGeodesic(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = polygon.copyWith( - geodesicParam: !polygon.geodesic, - ); + polygons[polygonId] = polygon.copyWith(geodesicParam: !polygon.geodesic); }); } void _toggleVisible(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = polygon.copyWith( - visibleParam: !polygon.visible, - ); + polygons[polygonId] = polygon.copyWith(visibleParam: !polygon.visible); }); } @@ -153,17 +149,16 @@ class PlacePolygonBodyState extends State { void _addHoles(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = - polygon.copyWith(holesParam: _createHoles(polygonId)); + polygons[polygonId] = polygon.copyWith( + holesParam: _createHoles(polygonId), + ); }); } void _removeHoles(PolygonId polygonId) { final Polygon polygon = polygons[polygonId]!; setState(() { - polygons[polygonId] = polygon.copyWith( - holesParam: >[], - ); + polygons[polygonId] = polygon.copyWith(holesParam: >[]); }); } @@ -197,26 +192,26 @@ class PlacePolygonBodyState extends State { children: [ Column( children: [ + TextButton(onPressed: _add, child: const Text('add')), TextButton( - onPressed: _add, - child: const Text('add'), - ), - TextButton( - onPressed: (selectedId == null) - ? null - : () => _remove(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _remove(selectedId), child: const Text('remove'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleVisible(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleVisible(selectedId), child: const Text('toggle visible'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleGeodesic(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleGeodesic(selectedId), child: const Text('toggle geodesic'), ), ], @@ -224,43 +219,48 @@ class PlacePolygonBodyState extends State { Column( children: [ TextButton( - onPressed: (selectedId == null) - ? null - : (polygons[selectedId]!.holes.isNotEmpty + onPressed: + (selectedId == null) ? null - : () => _addHoles(selectedId)), + : (polygons[selectedId]!.holes.isNotEmpty + ? null + : () => _addHoles(selectedId)), child: const Text('add holes'), ), TextButton( - onPressed: (selectedId == null) - ? null - : (polygons[selectedId]!.holes.isEmpty + onPressed: + (selectedId == null) ? null - : () => _removeHoles(selectedId)), + : (polygons[selectedId]!.holes.isEmpty + ? null + : () => _removeHoles(selectedId)), child: const Text('remove holes'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeWidth(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeWidth(selectedId), child: const Text('change stroke width'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeStrokeColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeStrokeColor(selectedId), child: const Text('change stroke color'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeFillColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeFillColor(selectedId), child: const Text('change fill color'), ), ], - ) + ), ], - ) + ), ], ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart index d008b7d3b97..e0510cd67d4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/place_polyline.dart @@ -13,7 +13,7 @@ import 'page.dart'; class PlacePolylinePage extends GoogleMapExampleAppPage { const PlacePolylinePage({Key? key}) - : super(const Icon(Icons.linear_scale), 'Place polyline', key: key); + : super(const Icon(Icons.linear_scale), 'Place polyline', key: key); @override Widget build(BuildContext context) { @@ -53,7 +53,7 @@ class PlacePolylineBodyState extends State { List jointTypes = [ JointType.mitered, JointType.bevel, - JointType.round + JointType.round, ]; // Values when toggling polyline end cap type @@ -72,7 +72,7 @@ class PlacePolylineBodyState extends State { PatternItem.dash(30.0), PatternItem.gap(20.0), PatternItem.dot, - PatternItem.gap(20.0) + PatternItem.gap(20.0), ], [PatternItem.dash(30.0), PatternItem.gap(20.0)], [PatternItem.dot, PatternItem.gap(10.0)], @@ -235,26 +235,26 @@ class PlacePolylineBodyState extends State { children: [ Column( children: [ + TextButton(onPressed: _add, child: const Text('add')), TextButton( - onPressed: _add, - child: const Text('add'), - ), - TextButton( - onPressed: (selectedId == null) - ? null - : () => _remove(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _remove(selectedId), child: const Text('remove'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleVisible(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleVisible(selectedId), child: const Text('toggle visible'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _toggleGeodesic(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _toggleGeodesic(selectedId), child: const Text('toggle geodesic'), ), ], @@ -262,45 +262,51 @@ class PlacePolylineBodyState extends State { Column( children: [ TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeWidth(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeWidth(selectedId), child: const Text('change width'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changeColor(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changeColor(selectedId), child: const Text('change color'), ), TextButton( - onPressed: isIOS || (selectedId == null) - ? null - : () => _changeStartCap(selectedId), + onPressed: + isIOS || (selectedId == null) + ? null + : () => _changeStartCap(selectedId), child: const Text('change start cap [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) - ? null - : () => _changeEndCap(selectedId), + onPressed: + isIOS || (selectedId == null) + ? null + : () => _changeEndCap(selectedId), child: const Text('change end cap [Android only]'), ), TextButton( - onPressed: isIOS || (selectedId == null) - ? null - : () => _changeJointType(selectedId), + onPressed: + isIOS || (selectedId == null) + ? null + : () => _changeJointType(selectedId), child: const Text('change joint type [Android only]'), ), TextButton( - onPressed: (selectedId == null) - ? null - : () => _changePattern(selectedId), + onPressed: + (selectedId == null) + ? null + : () => _changePattern(selectedId), child: const Text('change pattern'), ), ], - ) + ), ], - ) + ), ], ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/scrolling_map.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/scrolling_map.dart index a4901f2ce5f..e203fee7a45 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/scrolling_map.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/scrolling_map.dart @@ -16,7 +16,7 @@ const LatLng _center = LatLng(32.080664, 34.9563837); class ScrollingMapPage extends GoogleMapExampleAppPage { const ScrollingMapPage({Key? key}) - : super(const Icon(Icons.map), 'Scrolling map', key: key); + : super(const Icon(Icons.map), 'Scrolling map', key: key); @override Widget build(BuildContext context) { @@ -70,8 +70,9 @@ class ScrollingMapBody extends StatelessWidget { const Text("This map doesn't consume the vertical drags."), const Padding( padding: EdgeInsets.only(bottom: 12.0), - child: - Text('It still gets other gestures (e.g scale or tap).'), + child: Text( + 'It still gets other gestures (e.g scale or tap).', + ), ), Center( child: SizedBox( @@ -85,22 +86,19 @@ class ScrollingMapBody extends StatelessWidget { markers: { Marker( markerId: const MarkerId('test_marker_id'), - position: LatLng( - _center.latitude, - _center.longitude, - ), + position: LatLng(_center.latitude, _center.longitude), infoWindow: const InfoWindow( title: 'An interesting location', snippet: '*', ), ), }, - gestureRecognizers: >{ - Factory( - () => ScaleGestureRecognizer(), - ), - }, + gestureRecognizers: + >{ + Factory( + () => ScaleGestureRecognizer(), + ), + }, ), ), ), diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/snapshot.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/snapshot.dart index 56a90a8e49f..1eaef239947 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/snapshot.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/snapshot.dart @@ -12,13 +12,18 @@ import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platf import 'example_google_map.dart'; import 'page.dart'; -const CameraPosition _kInitialPosition = - CameraPosition(target: LatLng(-33.852, 151.211), zoom: 11.0); +const CameraPosition _kInitialPosition = CameraPosition( + target: LatLng(-33.852, 151.211), + zoom: 11.0, +); class SnapshotPage extends GoogleMapExampleAppPage { const SnapshotPage({Key? key}) - : super(const Icon(Icons.camera_alt), 'Take a snapshot of the map', - key: key); + : super( + const Icon(Icons.camera_alt), + 'Take a snapshot of the map', + key: key, + ); @override Widget build(BuildContext context) { diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/tile_overlay.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/tile_overlay.dart index 9122fda76ce..26bdde9bd69 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/tile_overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/lib/tile_overlay.dart @@ -15,7 +15,7 @@ import 'page.dart'; class TileOverlayPage extends GoogleMapExampleAppPage { const TileOverlayPage({Key? key}) - : super(const Icon(Icons.map), 'Tile overlay', key: key); + : super(const Icon(Icons.map), 'Tile overlay', key: key); @override Widget build(BuildContext context) { @@ -120,34 +120,29 @@ class _DebugTileProvider implements TileProvider { static const int width = 100; static const int height = 100; static final Paint boxPaint = Paint(); - static const TextStyle textStyle = TextStyle( - color: Colors.red, - fontSize: 20, - ); + static const TextStyle textStyle = TextStyle(color: Colors.red, fontSize: 20); @override Future getTile(int x, int y, int? zoom) async { final ui.PictureRecorder recorder = ui.PictureRecorder(); final Canvas canvas = Canvas(recorder); - final TextSpan textSpan = TextSpan( - text: '$x,$y', - style: textStyle, - ); + final TextSpan textSpan = TextSpan(text: '$x,$y', style: textStyle); final TextPainter textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); - textPainter.layout( - maxWidth: width.toDouble(), - ); + textPainter.layout(maxWidth: width.toDouble()); textPainter.paint(canvas, Offset.zero); canvas.drawRect( - Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), boxPaint); + Rect.fromLTRB(0, 0, width.toDouble(), width.toDouble()), + boxPaint, + ); final ui.Picture picture = recorder.endRecording(); final Uint8List byteData = await picture .toImage(width, height) - .then((ui.Image image) => - image.toByteData(format: ui.ImageByteFormat.png)) + .then( + (ui.Image image) => image.toByteData(format: ui.ImageByteFormat.png), + ) .then((ByteData? byteData) => byteData!.buffer.asUint8List()); return Tile(width, height, byteData); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/pubspec.yaml index d1404b7077b..e61b27c1084 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/pubspec.yaml @@ -3,8 +3,8 @@ description: Shared Dart code for the example apps. publish_to: none environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" dependencies: cupertino_icons: ^1.0.5 diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/test/example_google_map_test.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/test/example_google_map_test.dart index 4a1d02c7b65..b830ec1d66c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/test/example_google_map_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/test/example_google_map_test.dart @@ -75,8 +75,10 @@ void main() { const Marker m1 = Marker(markerId: MarkerId('marker_1')); const Marker m2 = Marker(markerId: MarkerId('marker_2')); const Marker m3 = Marker(markerId: MarkerId('marker_3')); - const Marker m3updated = - Marker(markerId: MarkerId('marker_3'), draggable: true); + const Marker m3updated = Marker( + markerId: MarkerId('marker_3'), + draggable: true, + ); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithObjects(markers: {m1, m2})); @@ -107,16 +109,21 @@ void main() { const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); const Polygon p2 = Polygon(polygonId: PolygonId('polygon_2')); - const Polygon p3 = - Polygon(polygonId: PolygonId('polygon_3'), strokeWidth: 1); - const Polygon p3updated = - Polygon(polygonId: PolygonId('polygon_3'), strokeWidth: 2); + const Polygon p3 = Polygon( + polygonId: PolygonId('polygon_3'), + strokeWidth: 1, + ); + const Polygon p3updated = Polygon( + polygonId: PolygonId('polygon_3'), + strokeWidth: 2, + ); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithObjects(polygons: {p1, p2})); await tester.pumpWidget(_mapWithObjects(polygons: {p1, p3})); - await tester - .pumpWidget(_mapWithObjects(polygons: {p1, p3updated})); + await tester.pumpWidget( + _mapWithObjects(polygons: {p1, p3updated}), + ); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -142,16 +149,21 @@ void main() { const Polyline p1 = Polyline(polylineId: PolylineId('polyline_1')); const Polyline p2 = Polyline(polylineId: PolylineId('polyline_2')); - const Polyline p3 = - Polyline(polylineId: PolylineId('polyline_3'), width: 1); - const Polyline p3updated = - Polyline(polylineId: PolylineId('polyline_3'), width: 2); + const Polyline p3 = Polyline( + polylineId: PolylineId('polyline_3'), + width: 1, + ); + const Polyline p3updated = Polyline( + polylineId: PolylineId('polyline_3'), + width: 2, + ); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithObjects(polylines: {p1, p2})); await tester.pumpWidget(_mapWithObjects(polylines: {p1, p3})); - await tester - .pumpWidget(_mapWithObjects(polylines: {p1, p3updated})); + await tester.pumpWidget( + _mapWithObjects(polylines: {p1, p3updated}), + ); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -163,8 +175,9 @@ void main() { expect(map.polylineUpdates[1].polylinesToChange.isEmpty, true); expect(map.polylineUpdates[1].polylinesToAdd, {p3}); - expect(map.polylineUpdates[1].polylineIdsToRemove, - {p2.polylineId}); + expect(map.polylineUpdates[1].polylineIdsToRemove, { + p2.polylineId, + }); expect(map.polylineUpdates[2].polylinesToChange, {p3updated}); expect(map.polylineUpdates[2].polylinesToAdd.isEmpty, true); diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/test/fake_google_maps_flutter_platform.dart b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/test/fake_google_maps_flutter_platform.dart index 7e35a4e0bd9..1ceab34102b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/test/fake_google_maps_flutter_platform.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/shared/maps_example_dart/test/fake_google_maps_flutter_platform.dart @@ -138,17 +138,14 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { }) async {} @override - Future setMapStyle( - String? mapStyle, { - required int mapId, - }) async {} + Future setMapStyle(String? mapStyle, {required int mapId}) async {} @override - Future getVisibleRegion({ - required int mapId, - }) async { + Future getVisibleRegion({required int mapId}) async { return LatLngBounds( - southwest: const LatLng(0, 0), northeast: const LatLng(0, 0)); + southwest: const LatLng(0, 0), + northeast: const LatLng(0, 0), + ); } @override @@ -188,16 +185,12 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { } @override - Future getZoomLevel({ - required int mapId, - }) async { + Future getZoomLevel({required int mapId}) async { return 0.0; } @override - Future takeSnapshot({ - required int mapId, - }) async { + Future takeSnapshot({required int mapId}) async { return null; } @@ -293,9 +286,10 @@ class FakeGoogleMapsFlutterPlatform extends GoogleMapsFlutterPlatform { if (instance == null) { createdIds.add(creationId); mapInstances[creationId] = PlatformMapStateRecorder( - widgetConfiguration: widgetConfiguration, - mapConfiguration: mapConfiguration, - mapObjects: mapObjects); + widgetConfiguration: widgetConfiguration, + mapConfiguration: mapConfiguration, + mapObjects: mapObjects, + ); onPlatformViewCreated(creationId); } return Container(); @@ -317,15 +311,25 @@ class PlatformMapStateRecorder { this.mapObjects = const MapObjects(), this.mapConfiguration = const MapConfiguration(), }) { - clusterManagerUpdates.add(ClusterManagerUpdates.from( - const {}, mapObjects.clusterManagers)); - groundOverlayUpdates.add(GroundOverlayUpdates.from( - const {}, mapObjects.groundOverlays)); + clusterManagerUpdates.add( + ClusterManagerUpdates.from( + const {}, + mapObjects.clusterManagers, + ), + ); + groundOverlayUpdates.add( + GroundOverlayUpdates.from( + const {}, + mapObjects.groundOverlays, + ), + ); markerUpdates.add(MarkerUpdates.from(const {}, mapObjects.markers)); - polygonUpdates - .add(PolygonUpdates.from(const {}, mapObjects.polygons)); - polylineUpdates - .add(PolylineUpdates.from(const {}, mapObjects.polylines)); + polygonUpdates.add( + PolygonUpdates.from(const {}, mapObjects.polygons), + ); + polylineUpdates.add( + PolylineUpdates.from(const {}, mapObjects.polylines), + ); circleUpdates.add(CircleUpdates.from(const {}, mapObjects.circles)); tileOverlaySets.add(mapObjects.tileOverlays); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_map_inspector_ios.dart b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_map_inspector_ios.dart index 0c12fe3efef..e1837bc0f44 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_map_inspector_ios.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_map_inspector_ios.dart @@ -16,8 +16,8 @@ class GoogleMapsInspectorIOS extends GoogleMapsInspectorPlatform { /// Creates an inspector API instance for a given map ID from /// [inspectorProvider]. GoogleMapsInspectorIOS( - MapsInspectorApi? Function(int mapId) inspectorProvider) - : _inspectorProvider = inspectorProvider; + MapsInspectorApi? Function(int mapId) inspectorProvider, + ) : _inspectorProvider = inspectorProvider; final MapsInspectorApi? Function(int mapId) _inspectorProvider; @@ -60,10 +60,13 @@ class GoogleMapsInspectorIOS extends GoogleMapsInspectorPlatform { } @override - Future getTileOverlayInfo(TileOverlayId tileOverlayId, - {required int mapId}) async { - final PlatformTileLayer? tileInfo = await _inspectorProvider(mapId)! - .getTileOverlayInfo(tileOverlayId.value); + Future getTileOverlayInfo( + TileOverlayId tileOverlayId, { + required int mapId, + }) async { + final PlatformTileLayer? tileInfo = await _inspectorProvider( + mapId, + )!.getTileOverlayInfo(tileOverlayId.value); if (tileInfo == null) { return null; } @@ -80,10 +83,13 @@ class GoogleMapsInspectorIOS extends GoogleMapsInspectorPlatform { bool supportsGettingHeatmapInfo() => true; @override - Future getHeatmapInfo(HeatmapId heatmapId, - {required int mapId}) async { - final PlatformHeatmap? heatmapInfo = - await _inspectorProvider(mapId)!.getHeatmapInfo(heatmapId.value); + Future getHeatmapInfo( + HeatmapId heatmapId, { + required int mapId, + }) async { + final PlatformHeatmap? heatmapInfo = await _inspectorProvider( + mapId, + )!.getHeatmapInfo(heatmapId.value); if (heatmapInfo == null) { return null; } @@ -92,10 +98,11 @@ class GoogleMapsInspectorIOS extends GoogleMapsInspectorPlatform { (heatmapInfo.json as Map).cast(); return Heatmap( heatmapId: heatmapId, - data: (json['data']! as List) - .map(deserializeWeightedLatLng) - .whereType() - .toList(), + data: + (json['data']! as List) + .map(deserializeWeightedLatLng) + .whereType() + .toList(), gradient: deserializeHeatmapGradient(json['gradient']), opacity: json['opacity']! as double, radius: HeatmapRadius.fromPixels(json['radius']! as int), @@ -108,11 +115,13 @@ class GoogleMapsInspectorIOS extends GoogleMapsInspectorPlatform { bool supportsGettingGroundOverlayInfo() => true; @override - Future getGroundOverlayInfo(GroundOverlayId groundOverlayId, - {required int mapId}) async { - final PlatformGroundOverlay? groundOverlayInfo = - await _inspectorProvider(mapId)! - .getGroundOverlayInfo(groundOverlayId.value); + Future getGroundOverlayInfo( + GroundOverlayId groundOverlayId, { + required int mapId, + }) async { + final PlatformGroundOverlay? groundOverlayInfo = await _inspectorProvider( + mapId, + )!.getGroundOverlayInfo(groundOverlayId.value); if (groundOverlayInfo == null) { return null; @@ -137,18 +146,25 @@ class GoogleMapsInspectorIOS extends GoogleMapsInspectorPlatform { transparency: groundOverlayInfo.transparency, visible: groundOverlayInfo.visible, clickable: groundOverlayInfo.clickable, - anchor: - Offset(groundOverlayInfo.anchor!.x, groundOverlayInfo.anchor!.y), + anchor: Offset( + groundOverlayInfo.anchor!.x, + groundOverlayInfo.anchor!.y, + ), zoomLevel: groundOverlayInfo.zoomLevel, ); } else if (bounds != null) { return GroundOverlay.fromBounds( groundOverlayId: groundOverlayId, bounds: LatLngBounds( - southwest: - LatLng(bounds.southwest.latitude, bounds.southwest.longitude), - northeast: - LatLng(bounds.northeast.latitude, bounds.northeast.longitude)), + southwest: LatLng( + bounds.southwest.latitude, + bounds.southwest.longitude, + ), + northeast: LatLng( + bounds.northeast.latitude, + bounds.northeast.longitude, + ), + ), image: dummyImage, zIndex: groundOverlayInfo.zIndex, bearing: groundOverlayInfo.bearing, @@ -192,10 +208,13 @@ class GoogleMapsInspectorIOS extends GoogleMapsInspectorPlatform { required int mapId, required ClusterManagerId clusterManagerId, }) async { - return (await _inspectorProvider(mapId)! - .getClusters(clusterManagerId.value)) - .map((PlatformCluster cluster) => - GoogleMapsFlutterIOS.clusterFromPlatformCluster(cluster)) + return (await _inspectorProvider( + mapId, + )!.getClusters(clusterManagerId.value)) + .map( + (PlatformCluster cluster) => + GoogleMapsFlutterIOS.clusterFromPlatformCluster(cluster), + ) .toList(); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart index de501b9f71d..9682bcbb51d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/google_maps_flutter_ios.dart @@ -131,9 +131,9 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { StreamController>.broadcast(); // Returns a filtered view of the events in the _controller, by mapId. - Stream> _events(int mapId) => - _mapEventStreamController.stream - .where((MapEvent event) => event.mapId == mapId); + Stream> _events(int mapId) => _mapEventStreamController + .stream + .where((MapEvent event) => event.mapId == mapId); @override Stream onCameraMoveStarted({required int mapId}) { @@ -216,7 +216,8 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { required int mapId, }) { return _hostApi(mapId).updateMapConfiguration( - _platformMapConfigurationFromMapConfiguration(configuration)); + _platformMapConfigurationFromMapConfiguration(configuration), + ); } @override @@ -225,7 +226,8 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { required int mapId, }) { return _hostApi(mapId).updateMapConfiguration( - _platformMapConfigurationFromOptionsJson(optionsUpdate)); + _platformMapConfigurationFromOptionsJson(optionsUpdate), + ); } @override @@ -305,11 +307,14 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { }) { final Map? currentTileOverlays = _tileOverlays[mapId]; - final Set previousSet = currentTileOverlays != null - ? currentTileOverlays.values.toSet() - : {}; - final _TileOverlayUpdates updates = - _TileOverlayUpdates.from(previousSet, newTileOverlays); + final Set previousSet = + currentTileOverlays != null + ? currentTileOverlays.values.toSet() + : {}; + final _TileOverlayUpdates updates = _TileOverlayUpdates.from( + previousSet, + newTileOverlays, + ); _tileOverlays[mapId] = keyTileOverlayId(newTileOverlays); return _hostApi(mapId).updateTileOverlays( updates.tileOverlaysToAdd @@ -345,11 +350,12 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { required int mapId, }) { assert( - groundOverlayUpdates.groundOverlaysToAdd.every( - (GroundOverlay groundOverlay) => - groundOverlay.position == null || - groundOverlay.zoomLevel != null), - 'On iOS zoom level must be set when position is set for ground overlays.'); + groundOverlayUpdates.groundOverlaysToAdd.every( + (GroundOverlay groundOverlay) => + groundOverlay.position == null || groundOverlay.zoomLevel != null, + ), + 'On iOS zoom level must be set when position is set for ground overlays.', + ); return _hostApi(mapId).updateGroundOverlays( groundOverlayUpdates.groundOverlaysToAdd @@ -373,13 +379,12 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { } @override - Future animateCamera( - CameraUpdate cameraUpdate, { - required int mapId, - }) { + Future animateCamera(CameraUpdate cameraUpdate, {required int mapId}) { return animateCameraWithConfiguration( - cameraUpdate, const CameraUpdateAnimationConfiguration(), - mapId: mapId); + cameraUpdate, + const CameraUpdateAnimationConfiguration(), + mapId: mapId, + ); } @override @@ -389,37 +394,33 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { required int mapId, }) { return _hostApi(mapId).animateCamera( - _platformCameraUpdateFromCameraUpdate(cameraUpdate), - configuration.duration?.inMilliseconds); + _platformCameraUpdateFromCameraUpdate(cameraUpdate), + configuration.duration?.inMilliseconds, + ); } @override - Future moveCamera( - CameraUpdate cameraUpdate, { - required int mapId, - }) { - return _hostApi(mapId) - .moveCamera(_platformCameraUpdateFromCameraUpdate(cameraUpdate)); + Future moveCamera(CameraUpdate cameraUpdate, {required int mapId}) { + return _hostApi( + mapId, + ).moveCamera(_platformCameraUpdateFromCameraUpdate(cameraUpdate)); } @override - Future setMapStyle( - String? mapStyle, { - required int mapId, - }) async { - final String? errorDescription = - await _hostApi(mapId).setStyle(mapStyle ?? ''); + Future setMapStyle(String? mapStyle, {required int mapId}) async { + final String? errorDescription = await _hostApi( + mapId, + ).setStyle(mapStyle ?? ''); if (errorDescription != null) { throw MapStyleException(errorDescription); } } @override - Future getVisibleRegion({ - required int mapId, - }) async { + Future getVisibleRegion({required int mapId}) async { return _latLngBoundsFromPlatformLatLngBounds( - await _hostApi(mapId).getVisibleRegion()); + await _hostApi(mapId).getVisibleRegion(), + ); } @override @@ -427,8 +428,11 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { LatLng latLng, { required int mapId, }) async { - return _screenCoordinateFromPlatformPoint(await _hostApi(mapId) - .getScreenCoordinate(_platformLatLngFromLatLng(latLng))); + return _screenCoordinateFromPlatformPoint( + await _hostApi( + mapId, + ).getScreenCoordinate(_platformLatLngFromLatLng(latLng)), + ); } @override @@ -436,23 +440,20 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { ScreenCoordinate screenCoordinate, { required int mapId, }) async { - return _latLngFromPlatformLatLng(await _hostApi(mapId) - .getLatLng(_platformPointFromScreenCoordinate(screenCoordinate))); + return _latLngFromPlatformLatLng( + await _hostApi( + mapId, + ).getLatLng(_platformPointFromScreenCoordinate(screenCoordinate)), + ); } @override - Future showMarkerInfoWindow( - MarkerId markerId, { - required int mapId, - }) { + Future showMarkerInfoWindow(MarkerId markerId, {required int mapId}) { return _hostApi(mapId).showInfoWindow(markerId.value); } @override - Future hideMarkerInfoWindow( - MarkerId markerId, { - required int mapId, - }) { + Future hideMarkerInfoWindow(MarkerId markerId, {required int mapId}) { return _hostApi(mapId).hideInfoWindow(markerId.value); } @@ -465,16 +466,12 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { } @override - Future getZoomLevel({ - required int mapId, - }) { + Future getZoomLevel({required int mapId}) { return _hostApi(mapId).getZoomLevel(); } @override - Future takeSnapshot({ - required int mapId, - }) { + Future takeSnapshot({required int mapId}) { return _hostApi(mapId).takeSnapshot(); } @@ -491,35 +488,42 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { MapObjects mapObjects = const MapObjects(), }) { assert( - mapObjects.groundOverlays.every((GroundOverlay groundOverlay) => - groundOverlay.position == null || groundOverlay.zoomLevel != null), - 'On iOS zoom level must be set when position is set for ground overlays.'); + mapObjects.groundOverlays.every( + (GroundOverlay groundOverlay) => + groundOverlay.position == null || groundOverlay.zoomLevel != null, + ), + 'On iOS zoom level must be set when position is set for ground overlays.', + ); final PlatformMapViewCreationParams creationParams = PlatformMapViewCreationParams( - initialCameraPosition: _platformCameraPositionFromCameraPosition( - widgetConfiguration.initialCameraPosition), - mapConfiguration: mapConfiguration, - initialMarkers: - mapObjects.markers.map(_platformMarkerFromMarker).toList(), - initialPolygons: - mapObjects.polygons.map(_platformPolygonFromPolygon).toList(), - initialPolylines: - mapObjects.polylines.map(_platformPolylineFromPolyline).toList(), - initialCircles: - mapObjects.circles.map(_platformCircleFromCircle).toList(), - initialHeatmaps: - mapObjects.heatmaps.map(_platformHeatmapFromHeatmap).toList(), - initialTileOverlays: mapObjects.tileOverlays - .map(_platformTileOverlayFromTileOverlay) - .toList(), - initialClusterManagers: mapObjects.clusterManagers - .map(_platformClusterManagerFromClusterManager) - .toList(), - initialGroundOverlays: mapObjects.groundOverlays - .map(_platformGroundOverlayFromGroundOverlay) - .toList(), - ); + initialCameraPosition: _platformCameraPositionFromCameraPosition( + widgetConfiguration.initialCameraPosition, + ), + mapConfiguration: mapConfiguration, + initialMarkers: + mapObjects.markers.map(_platformMarkerFromMarker).toList(), + initialPolygons: + mapObjects.polygons.map(_platformPolygonFromPolygon).toList(), + initialPolylines: + mapObjects.polylines.map(_platformPolylineFromPolyline).toList(), + initialCircles: + mapObjects.circles.map(_platformCircleFromCircle).toList(), + initialHeatmaps: + mapObjects.heatmaps.map(_platformHeatmapFromHeatmap).toList(), + initialTileOverlays: + mapObjects.tileOverlays + .map(_platformTileOverlayFromTileOverlay) + .toList(), + initialClusterManagers: + mapObjects.clusterManagers + .map(_platformClusterManagerFromClusterManager) + .toList(), + initialGroundOverlays: + mapObjects.groundOverlays + .map(_platformGroundOverlayFromGroundOverlay) + .toList(), + ); return UiKitView( viewType: 'plugins.flutter.dev/google_maps_ios', @@ -543,8 +547,9 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { onPlatformViewCreated, widgetConfiguration: widgetConfiguration, mapObjects: mapObjects, - mapConfiguration: - _platformMapConfigurationFromMapConfiguration(mapConfiguration), + mapConfiguration: _platformMapConfigurationFromMapConfiguration( + mapConfiguration, + ), ); } @@ -566,14 +571,16 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { creationId, onPlatformViewCreated, widgetConfiguration: MapWidgetConfiguration( - initialCameraPosition: initialCameraPosition, - textDirection: textDirection), + initialCameraPosition: initialCameraPosition, + textDirection: textDirection, + ), mapObjects: MapObjects( - markers: markers, - polygons: polygons, - polylines: polylines, - circles: circles, - tileOverlays: tileOverlays), + markers: markers, + polygons: polygons, + polylines: polylines, + circles: circles, + tileOverlays: tileOverlays, + ), mapConfiguration: _platformMapConfigurationFromOptionsJson(mapOptions), ); } @@ -609,27 +616,34 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { @override @visibleForTesting void enableDebugInspection() { - GoogleMapsInspectorPlatform.instance = GoogleMapsInspectorIOS((int mapId) => - MapsInspectorApi(messageChannelSuffix: mapId.toString())); + GoogleMapsInspectorPlatform.instance = GoogleMapsInspectorIOS( + (int mapId) => MapsInspectorApi(messageChannelSuffix: mapId.toString()), + ); } /// Converts a Pigeon [PlatformCluster] to the corresponding [Cluster]. static Cluster clusterFromPlatformCluster(PlatformCluster cluster) { - return Cluster(ClusterManagerId(cluster.clusterManagerId), - cluster.markerIds.map((String markerId) => MarkerId(markerId)).toList(), - position: _latLngFromPlatformLatLng(cluster.position), - bounds: _latLngBoundsFromPlatformLatLngBounds(cluster.bounds)); + return Cluster( + ClusterManagerId(cluster.clusterManagerId), + cluster.markerIds.map((String markerId) => MarkerId(markerId)).toList(), + position: _latLngFromPlatformLatLng(cluster.position), + bounds: _latLngBoundsFromPlatformLatLngBounds(cluster.bounds), + ); } static ScreenCoordinate _screenCoordinateFromPlatformPoint( - PlatformPoint point) { + PlatformPoint point, + ) { return ScreenCoordinate(x: point.x.round(), y: point.y.round()); } static PlatformPoint _platformPointFromScreenCoordinate( - ScreenCoordinate coordinate) { + ScreenCoordinate coordinate, + ) { return PlatformPoint( - x: coordinate.x.toDouble(), y: coordinate.y.toDouble()); + x: coordinate.x.toDouble(), + y: coordinate.y.toDouble(), + ); } static PlatformPoint _platformPointFromOffset(Offset offset) { @@ -659,11 +673,13 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { } static PlatformInfoWindow _platformInfoWindowFromInfoWindow( - InfoWindow window) { + InfoWindow window, + ) { return PlatformInfoWindow( - title: window.title, - snippet: window.snippet, - anchor: _platformPointFromOffset(window.anchor)); + title: window.title, + snippet: window.snippet, + anchor: _platformPointFromOffset(window.anchor), + ); } static PlatformMarker _platformMarkerFromMarker(Marker marker) { @@ -685,16 +701,19 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { } static PlatformGroundOverlay _platformGroundOverlayFromGroundOverlay( - GroundOverlay groundOverlay) { + GroundOverlay groundOverlay, + ) { return PlatformGroundOverlay( groundOverlayId: groundOverlay.groundOverlayId.value, - anchor: groundOverlay.anchor != null - ? _platformPointFromOffset(groundOverlay.anchor!) - : null, + anchor: + groundOverlay.anchor != null + ? _platformPointFromOffset(groundOverlay.anchor!) + : null, image: platformBitmapFromBitmapDescriptor(groundOverlay.image), - position: groundOverlay.position != null - ? _platformLatLngFromLatLng(groundOverlay.position!) - : null, + position: + groundOverlay.position != null + ? _platformLatLngFromLatLng(groundOverlay.position!) + : null, bounds: _platformLatLngBoundsFromLatLngBounds(groundOverlay.bounds), visible: groundOverlay.visible, zIndex: groundOverlay.zIndex, @@ -710,8 +729,8 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { polygon.points.map(_platformLatLngFromLatLng).toList(); final List> holes = polygon.holes.map((List hole) { - return hole.map(_platformLatLngFromLatLng).toList(); - }).toList(); + return hole.map(_platformLatLngFromLatLng).toList(); + }).toList(); return PlatformPolygon( polygonId: polygon.polygonId.value, fillColor: polygon.fillColor.value, @@ -746,7 +765,8 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { } static PlatformTileOverlay _platformTileOverlayFromTileOverlay( - TileOverlay tileOverlay) { + TileOverlay tileOverlay, + ) { return PlatformTileOverlay( tileOverlayId: tileOverlay.tileOverlayId.value, fadeIn: tileOverlay.fadeIn, @@ -758,68 +778,89 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { } static PlatformClusterManager _platformClusterManagerFromClusterManager( - ClusterManager clusterManager) { + ClusterManager clusterManager, + ) { return PlatformClusterManager( - identifier: clusterManager.clusterManagerId.value); + identifier: clusterManager.clusterManagerId.value, + ); } static PlatformCameraUpdate _platformCameraUpdateFromCameraUpdate( - CameraUpdate update) { + CameraUpdate update, + ) { switch (update.updateType) { case CameraUpdateType.newCameraPosition: update as CameraUpdateNewCameraPosition; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateNewCameraPosition( - cameraPosition: _platformCameraPositionFromCameraPosition( - update.cameraPosition))); + cameraUpdate: PlatformCameraUpdateNewCameraPosition( + cameraPosition: _platformCameraPositionFromCameraPosition( + update.cameraPosition, + ), + ), + ); case CameraUpdateType.newLatLng: update as CameraUpdateNewLatLng; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateNewLatLng( - latLng: _platformLatLngFromLatLng(update.latLng))); + cameraUpdate: PlatformCameraUpdateNewLatLng( + latLng: _platformLatLngFromLatLng(update.latLng), + ), + ); case CameraUpdateType.newLatLngZoom: update as CameraUpdateNewLatLngZoom; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateNewLatLngZoom( - latLng: _platformLatLngFromLatLng(update.latLng), - zoom: update.zoom)); + cameraUpdate: PlatformCameraUpdateNewLatLngZoom( + latLng: _platformLatLngFromLatLng(update.latLng), + zoom: update.zoom, + ), + ); case CameraUpdateType.newLatLngBounds: update as CameraUpdateNewLatLngBounds; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateNewLatLngBounds( - bounds: _platformLatLngBoundsFromLatLngBounds(update.bounds)!, - padding: update.padding)); + cameraUpdate: PlatformCameraUpdateNewLatLngBounds( + bounds: _platformLatLngBoundsFromLatLngBounds(update.bounds)!, + padding: update.padding, + ), + ); case CameraUpdateType.zoomTo: update as CameraUpdateZoomTo; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateZoomTo(zoom: update.zoom)); + cameraUpdate: PlatformCameraUpdateZoomTo(zoom: update.zoom), + ); case CameraUpdateType.zoomBy: update as CameraUpdateZoomBy; final Offset? focus = update.focus; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateZoomBy( - amount: update.amount, - focus: focus == null ? null : _platformPointFromOffset(focus))); + cameraUpdate: PlatformCameraUpdateZoomBy( + amount: update.amount, + focus: focus == null ? null : _platformPointFromOffset(focus), + ), + ); case CameraUpdateType.zoomIn: update as CameraUpdateZoomIn; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateZoom(out: false)); + cameraUpdate: PlatformCameraUpdateZoom(out: false), + ); case CameraUpdateType.zoomOut: update as CameraUpdateZoomOut; return PlatformCameraUpdate( - cameraUpdate: PlatformCameraUpdateZoom(out: true)); + cameraUpdate: PlatformCameraUpdateZoom(out: true), + ); case CameraUpdateType.scrollBy: update as CameraUpdateScrollBy; return PlatformCameraUpdate( - cameraUpdate: - PlatformCameraUpdateScrollBy(dx: update.dx, dy: update.dy)); + cameraUpdate: PlatformCameraUpdateScrollBy( + dx: update.dx, + dy: update.dy, + ), + ); } } /// Converts [MapBitmapScaling] from platform interface to [PlatformMapBitmapScaling] Pigeon. @visibleForTesting static PlatformMapBitmapScaling platformMapBitmapScalingFromScaling( - MapBitmapScaling scaling) { + MapBitmapScaling scaling, + ) { switch (scaling) { case MapBitmapScaling.auto: return PlatformMapBitmapScaling.auto; @@ -839,52 +880,67 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { /// Converts [BitmapDescriptor] from platform interface to [PlatformBitmap] pigeon. @visibleForTesting static PlatformBitmap platformBitmapFromBitmapDescriptor( - BitmapDescriptor bitmap) { + BitmapDescriptor bitmap, + ) { switch (bitmap) { case final DefaultMarker marker: return PlatformBitmap( - bitmap: PlatformBitmapDefaultMarker(hue: marker.hue?.toDouble())); + bitmap: PlatformBitmapDefaultMarker(hue: marker.hue?.toDouble()), + ); // Clients may still use this deprecated format, so it must be supported. // ignore: deprecated_member_use case final BytesBitmap bytes: final Size? size = bytes.size; return PlatformBitmap( - bitmap: PlatformBitmapBytes( - byteData: bytes.byteData, - size: (size == null) ? null : _platformSizeFromSize(size))); + bitmap: PlatformBitmapBytes( + byteData: bytes.byteData, + size: (size == null) ? null : _platformSizeFromSize(size), + ), + ); case final AssetBitmap asset: return PlatformBitmap( - bitmap: PlatformBitmapAsset(name: asset.name, pkg: asset.package)); + bitmap: PlatformBitmapAsset(name: asset.name, pkg: asset.package), + ); // Clients may still use this deprecated format, so it must be supported. // ignore: deprecated_member_use case final AssetImageBitmap asset: final Size? size = asset.size; return PlatformBitmap( - bitmap: PlatformBitmapAssetImage( - name: asset.name, - scale: asset.scale, - size: (size == null) ? null : _platformSizeFromSize(size))); + bitmap: PlatformBitmapAssetImage( + name: asset.name, + scale: asset.scale, + size: (size == null) ? null : _platformSizeFromSize(size), + ), + ); case final AssetMapBitmap asset: return PlatformBitmap( - bitmap: PlatformBitmapAssetMap( - assetName: asset.assetName, - bitmapScaling: - platformMapBitmapScalingFromScaling(asset.bitmapScaling), - imagePixelRatio: asset.imagePixelRatio, - width: asset.width, - height: asset.height)); + bitmap: PlatformBitmapAssetMap( + assetName: asset.assetName, + bitmapScaling: platformMapBitmapScalingFromScaling( + asset.bitmapScaling, + ), + imagePixelRatio: asset.imagePixelRatio, + width: asset.width, + height: asset.height, + ), + ); case final BytesMapBitmap bytes: return PlatformBitmap( - bitmap: PlatformBitmapBytesMap( - byteData: bytes.byteData, - bitmapScaling: - platformMapBitmapScalingFromScaling(bytes.bitmapScaling), - imagePixelRatio: bytes.imagePixelRatio, - width: bytes.width, - height: bytes.height)); + bitmap: PlatformBitmapBytesMap( + byteData: bytes.byteData, + bitmapScaling: platformMapBitmapScalingFromScaling( + bytes.bitmapScaling, + ), + imagePixelRatio: bytes.imagePixelRatio, + width: bytes.width, + height: bytes.height, + ), + ); default: throw ArgumentError( - 'Unrecognized type of bitmap ${bitmap.runtimeType}', 'bitmap'); + 'Unrecognized type of bitmap ${bitmap.runtimeType}', + 'bitmap', + ); } } } @@ -923,13 +979,18 @@ class HostMapMessageHandler implements MapsCallbackApi { PlatformPoint location, int zoom, ) async { - final TileOverlay? tileOverlay = - tileOverlayProvider(TileOverlayId(tileOverlayId)); + final TileOverlay? tileOverlay = tileOverlayProvider( + TileOverlayId(tileOverlayId), + ); final TileProvider? tileProvider = tileOverlay?.tileProvider; - final Tile tile = tileProvider == null - ? TileProvider.noTile - : await tileProvider.getTile( - location.x.round(), location.y.round(), zoom); + final Tile tile = + tileProvider == null + ? TileProvider.noTile + : await tileProvider.getTile( + location.x.round(), + location.y.round(), + zoom, + ); return _platformTileFromTile(tile); } @@ -940,15 +1001,17 @@ class HostMapMessageHandler implements MapsCallbackApi { @override void onCameraMove(PlatformCameraPosition cameraPosition) { - streamController.add(CameraMoveEvent( - mapId, - CameraPosition( - target: _latLngFromPlatformLatLng(cameraPosition.target), - bearing: cameraPosition.bearing, - tilt: cameraPosition.tilt, - zoom: cameraPosition.zoom, + streamController.add( + CameraMoveEvent( + mapId, + CameraPosition( + target: _latLngFromPlatformLatLng(cameraPosition.target), + bearing: cameraPosition.bearing, + tilt: cameraPosition.tilt, + zoom: cameraPosition.zoom, + ), ), - )); + ); } @override @@ -963,10 +1026,12 @@ class HostMapMessageHandler implements MapsCallbackApi { @override void onClusterTap(PlatformCluster cluster) { - streamController.add(ClusterTapEvent( - mapId, - GoogleMapsFlutterIOS.clusterFromPlatformCluster(cluster), - )); + streamController.add( + ClusterTapEvent( + mapId, + GoogleMapsFlutterIOS.clusterFromPlatformCluster(cluster), + ), + ); } @override @@ -976,26 +1041,42 @@ class HostMapMessageHandler implements MapsCallbackApi { @override void onLongPress(PlatformLatLng position) { - streamController - .add(MapLongPressEvent(mapId, _latLngFromPlatformLatLng(position))); + streamController.add( + MapLongPressEvent(mapId, _latLngFromPlatformLatLng(position)), + ); } @override void onMarkerDrag(String markerId, PlatformLatLng position) { - streamController.add(MarkerDragEvent( - mapId, _latLngFromPlatformLatLng(position), MarkerId(markerId))); + streamController.add( + MarkerDragEvent( + mapId, + _latLngFromPlatformLatLng(position), + MarkerId(markerId), + ), + ); } @override void onMarkerDragStart(String markerId, PlatformLatLng position) { - streamController.add(MarkerDragStartEvent( - mapId, _latLngFromPlatformLatLng(position), MarkerId(markerId))); + streamController.add( + MarkerDragStartEvent( + mapId, + _latLngFromPlatformLatLng(position), + MarkerId(markerId), + ), + ); } @override void onMarkerDragEnd(String markerId, PlatformLatLng position) { - streamController.add(MarkerDragEndEvent( - mapId, _latLngFromPlatformLatLng(position), MarkerId(markerId))); + streamController.add( + MarkerDragEndEvent( + mapId, + _latLngFromPlatformLatLng(position), + MarkerId(markerId), + ), + ); } @override @@ -1015,14 +1096,16 @@ class HostMapMessageHandler implements MapsCallbackApi { @override void onGroundOverlayTap(String groundOverlayId) { - streamController - .add(GroundOverlayTapEvent(mapId, GroundOverlayId(groundOverlayId))); + streamController.add( + GroundOverlayTapEvent(mapId, GroundOverlayId(groundOverlayId)), + ); } @override void onTap(PlatformLatLng position) { - streamController - .add(MapTapEvent(mapId, _latLngFromPlatformLatLng(position))); + streamController.add( + MapTapEvent(mapId, _latLngFromPlatformLatLng(position)), + ); } } @@ -1031,10 +1114,12 @@ LatLng _latLngFromPlatformLatLng(PlatformLatLng latLng) { } LatLngBounds _latLngBoundsFromPlatformLatLngBounds( - PlatformLatLngBounds bounds) { + PlatformLatLngBounds bounds, +) { return LatLngBounds( - southwest: _latLngFromPlatformLatLng(bounds.southwest), - northeast: _latLngFromPlatformLatLng(bounds.northeast)); + southwest: _latLngFromPlatformLatLng(bounds.southwest), + northeast: _latLngFromPlatformLatLng(bounds.northeast), + ); } PlatformLatLng _platformLatLngFromLatLng(LatLng latLng) { @@ -1042,21 +1127,25 @@ PlatformLatLng _platformLatLngFromLatLng(LatLng latLng) { } PlatformLatLngBounds? _platformLatLngBoundsFromLatLngBounds( - LatLngBounds? bounds) { + LatLngBounds? bounds, +) { if (bounds == null) { return null; } return PlatformLatLngBounds( - northeast: _platformLatLngFromLatLng(bounds.northeast), - southwest: _platformLatLngFromLatLng(bounds.southwest)); + northeast: _platformLatLngFromLatLng(bounds.northeast), + southwest: _platformLatLngFromLatLng(bounds.southwest), + ); } PlatformCameraTargetBounds? _platformCameraTargetBoundsFromCameraTargetBounds( - CameraTargetBounds? bounds) { + CameraTargetBounds? bounds, +) { return bounds == null ? null : PlatformCameraTargetBounds( - bounds: _platformLatLngBoundsFromLatLngBounds(bounds.bounds)); + bounds: _platformLatLngBoundsFromLatLngBounds(bounds.bounds), + ); } PlatformTile _platformTileFromTile(Tile tile) { @@ -1088,7 +1177,8 @@ PlatformMapType? _platformMapTypeFromMapType(MapType? type) { } PlatformZoomRange? _platformZoomRangeFromMinMaxZoomPreference( - MinMaxZoomPreference? zoomPref) { + MinMaxZoomPreference? zoomPref, +) { return zoomPref == null ? null : PlatformZoomRange(min: zoomPref.minZoom, max: zoomPref.maxZoom); @@ -1098,21 +1188,25 @@ PlatformEdgeInsets? _platformEdgeInsetsFromEdgeInsets(EdgeInsets? insets) { return insets == null ? null : PlatformEdgeInsets( - top: insets.top, - bottom: insets.bottom, - left: insets.left, - right: insets.right); + top: insets.top, + bottom: insets.bottom, + left: insets.left, + right: insets.right, + ); } PlatformMapConfiguration _platformMapConfigurationFromMapConfiguration( - MapConfiguration config) { + MapConfiguration config, +) { return PlatformMapConfiguration( compassEnabled: config.compassEnabled, cameraTargetBounds: _platformCameraTargetBoundsFromCameraTargetBounds( - config.cameraTargetBounds), + config.cameraTargetBounds, + ), mapType: _platformMapTypeFromMapType(config.mapType), - minMaxZoomPreference: - _platformZoomRangeFromMinMaxZoomPreference(config.minMaxZoomPreference), + minMaxZoomPreference: _platformZoomRangeFromMinMaxZoomPreference( + config.minMaxZoomPreference, + ), rotateGesturesEnabled: config.rotateGesturesEnabled, scrollGesturesEnabled: config.scrollGesturesEnabled, tiltGesturesEnabled: config.tiltGesturesEnabled, @@ -1131,7 +1225,8 @@ PlatformMapConfiguration _platformMapConfigurationFromMapConfiguration( // For supporting the deprecated updateMapOptions API. PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( - Map options) { + Map options, +) { // All of these hard-coded values and structures come from // google_maps_flutter_platform_interface/lib/src/types/utils/map_configuration_serialization.dart // to support this legacy API that relied on cross-package magic strings. @@ -1141,10 +1236,12 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( return PlatformMapConfiguration( compassEnabled: options['compassEnabled'] as bool?, cameraTargetBounds: _platformCameraTargetBoundsFromCameraTargetBoundsJson( - options['cameraTargetBounds']), + options['cameraTargetBounds'], + ), mapType: mapType == null ? null : _platformMapTypeFromMapTypeIndex(mapType), minMaxZoomPreference: _platformZoomRangeFromMinMaxZoomPreferenceJson( - options['minMaxZoomPreference']), + options['minMaxZoomPreference'], + ), rotateGesturesEnabled: options['rotateGesturesEnabled'] as bool?, scrollGesturesEnabled: options['scrollGesturesEnabled'] as bool?, tiltGesturesEnabled: options['tiltGesturesEnabled'] as bool?, @@ -1152,13 +1249,15 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( zoomGesturesEnabled: options['zoomGesturesEnabled'] as bool?, myLocationEnabled: options['myLocationEnabled'] as bool?, myLocationButtonEnabled: options['myLocationButtonEnabled'] as bool?, - padding: padding == null - ? null - : PlatformEdgeInsets( - top: padding[0], - left: padding[1], - bottom: padding[2], - right: padding[3]), + padding: + padding == null + ? null + : PlatformEdgeInsets( + top: padding[0], + left: padding[1], + bottom: padding[2], + right: padding[3], + ), indoorViewEnabled: options['indoorEnabled'] as bool?, trafficEnabled: options['trafficEnabled'] as bool?, buildingsEnabled: options['buildingsEnabled'] as bool?, @@ -1168,12 +1267,14 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( } PlatformCameraPosition _platformCameraPositionFromCameraPosition( - CameraPosition position) { + CameraPosition position, +) { return PlatformCameraPosition( - bearing: position.bearing, - target: _platformLatLngFromLatLng(position.target), - tilt: position.tilt, - zoom: position.zoom); + bearing: position.bearing, + target: _platformLatLngFromLatLng(position.target), + tilt: position.tilt, + zoom: position.zoom, + ); } PlatformMapType _platformMapTypeFromMapTypeIndex(int index) { @@ -1196,30 +1297,35 @@ PlatformLatLng _platformLatLngFromLatLngJson(Object latLngJson) { } PlatformLatLngBounds? _platformLatLngBoundsFromLatLngBoundsJson( - Object? boundsJson) { + Object? boundsJson, +) { if (boundsJson == null) { return null; } // See `LatLngBounds.toJson`. final List boundsList = (boundsJson as List).cast(); return PlatformLatLngBounds( - southwest: _platformLatLngFromLatLngJson(boundsList[0]), - northeast: _platformLatLngFromLatLngJson(boundsList[1])); + southwest: _platformLatLngFromLatLngJson(boundsList[0]), + northeast: _platformLatLngFromLatLngJson(boundsList[1]), + ); } PlatformCameraTargetBounds? - _platformCameraTargetBoundsFromCameraTargetBoundsJson(Object? targetJson) { +_platformCameraTargetBoundsFromCameraTargetBoundsJson(Object? targetJson) { if (targetJson == null) { return null; } // See `CameraTargetBounds.toJson`. return PlatformCameraTargetBounds( - bounds: _platformLatLngBoundsFromLatLngBoundsJson( - (targetJson as List)[0])); + bounds: _platformLatLngBoundsFromLatLngBoundsJson( + (targetJson as List)[0], + ), + ); } PlatformZoomRange? _platformZoomRangeFromMinMaxZoomPreferenceJson( - Object? zoomPrefsJson) { + Object? zoomPrefsJson, +) { if (zoomPrefsJson == null) { return null; } @@ -1259,11 +1365,15 @@ PlatformPatternItem platformPatternItemFromPatternItem(PatternItem item) { case PatternItemType.dash: final double length = (item as VariableLengthPatternItem).length; return PlatformPatternItem( - type: PlatformPatternItemType.dash, length: length); + type: PlatformPatternItemType.dash, + length: length, + ); case PatternItemType.gap: final double length = (item as VariableLengthPatternItem).length; return PlatformPatternItem( - type: PlatformPatternItemType.gap, length: length); + type: PlatformPatternItemType.gap, + length: length, + ); } // The enum comes from a different package, which could get a new value at @@ -1281,7 +1391,7 @@ PlatformPatternItem platformPatternItemFromPatternItem(PatternItem item) { class _TileOverlayUpdates extends MapsObjectUpdates { /// Computes [TileOverlayUpdates] given previous and current [TileOverlay]s. _TileOverlayUpdates.from(super.previous, super.current) - : super.from(objectName: 'tileOverlay'); + : super.from(objectName: 'tileOverlay'); /// Set of TileOverlays to be added in this update. Set get tileOverlaysToAdd => objectsToAdd; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/messages.g.dart b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/messages.g.dart index 0a91b92465b..00e9469ff94 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/messages.g.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/messages.g.dart @@ -18,8 +18,11 @@ PlatformException _createConnectionError(String channelName) { ); } -List wrapResponse( - {Object? result, PlatformException? error, bool empty = false}) { +List wrapResponse({ + Object? result, + PlatformException? error, + bool empty = false, +}) { if (empty) { return []; } @@ -30,33 +33,16 @@ List wrapResponse( } /// Pigeon equivalent of MapType -enum PlatformMapType { - none, - normal, - satellite, - terrain, - hybrid, -} +enum PlatformMapType { none, normal, satellite, terrain, hybrid } /// Join types for polyline joints. -enum PlatformJointType { - mitered, - bevel, - round, -} +enum PlatformJointType { mitered, bevel, round } /// Enumeration of possible types for PatternItem. -enum PlatformPatternItemType { - dot, - dash, - gap, -} +enum PlatformPatternItemType { dot, dash, gap } /// Pigeon equivalent of [MapBitmapScaling]. -enum PlatformMapBitmapScaling { - auto, - none, -} +enum PlatformMapBitmapScaling { auto, none } /// Pigeon representatation of a CameraPosition. class PlatformCameraPosition { @@ -76,12 +62,7 @@ class PlatformCameraPosition { double zoom; Object encode() { - return [ - bearing, - target, - tilt, - zoom, - ]; + return [bearing, target, tilt, zoom]; } static PlatformCameraPosition decode(Object result) { @@ -97,9 +78,7 @@ class PlatformCameraPosition { /// Pigeon representation of a CameraUpdate. class PlatformCameraUpdate { - PlatformCameraUpdate({ - required this.cameraUpdate, - }); + PlatformCameraUpdate({required this.cameraUpdate}); /// This Object must be one of the classes below prefixed with /// PlatformCameraUpdate. Each such class represents a different type of @@ -108,31 +87,23 @@ class PlatformCameraUpdate { Object cameraUpdate; Object encode() { - return [ - cameraUpdate, - ]; + return [cameraUpdate]; } static PlatformCameraUpdate decode(Object result) { result as List; - return PlatformCameraUpdate( - cameraUpdate: result[0]!, - ); + return PlatformCameraUpdate(cameraUpdate: result[0]!); } } /// Pigeon equivalent of NewCameraPosition class PlatformCameraUpdateNewCameraPosition { - PlatformCameraUpdateNewCameraPosition({ - required this.cameraPosition, - }); + PlatformCameraUpdateNewCameraPosition({required this.cameraPosition}); PlatformCameraPosition cameraPosition; Object encode() { - return [ - cameraPosition, - ]; + return [cameraPosition]; } static PlatformCameraUpdateNewCameraPosition decode(Object result) { @@ -145,23 +116,17 @@ class PlatformCameraUpdateNewCameraPosition { /// Pigeon equivalent of NewLatLng class PlatformCameraUpdateNewLatLng { - PlatformCameraUpdateNewLatLng({ - required this.latLng, - }); + PlatformCameraUpdateNewLatLng({required this.latLng}); PlatformLatLng latLng; Object encode() { - return [ - latLng, - ]; + return [latLng]; } static PlatformCameraUpdateNewLatLng decode(Object result) { result as List; - return PlatformCameraUpdateNewLatLng( - latLng: result[0]! as PlatformLatLng, - ); + return PlatformCameraUpdateNewLatLng(latLng: result[0]! as PlatformLatLng); } } @@ -177,10 +142,7 @@ class PlatformCameraUpdateNewLatLngBounds { double padding; Object encode() { - return [ - bounds, - padding, - ]; + return [bounds, padding]; } static PlatformCameraUpdateNewLatLngBounds decode(Object result) { @@ -194,20 +156,14 @@ class PlatformCameraUpdateNewLatLngBounds { /// Pigeon equivalent of NewLatLngZoom class PlatformCameraUpdateNewLatLngZoom { - PlatformCameraUpdateNewLatLngZoom({ - required this.latLng, - required this.zoom, - }); + PlatformCameraUpdateNewLatLngZoom({required this.latLng, required this.zoom}); PlatformLatLng latLng; double zoom; Object encode() { - return [ - latLng, - zoom, - ]; + return [latLng, zoom]; } static PlatformCameraUpdateNewLatLngZoom decode(Object result) { @@ -221,20 +177,14 @@ class PlatformCameraUpdateNewLatLngZoom { /// Pigeon equivalent of ScrollBy class PlatformCameraUpdateScrollBy { - PlatformCameraUpdateScrollBy({ - required this.dx, - required this.dy, - }); + PlatformCameraUpdateScrollBy({required this.dx, required this.dy}); double dx; double dy; Object encode() { - return [ - dx, - dy, - ]; + return [dx, dy]; } static PlatformCameraUpdateScrollBy decode(Object result) { @@ -248,20 +198,14 @@ class PlatformCameraUpdateScrollBy { /// Pigeon equivalent of ZoomBy class PlatformCameraUpdateZoomBy { - PlatformCameraUpdateZoomBy({ - required this.amount, - this.focus, - }); + PlatformCameraUpdateZoomBy({required this.amount, this.focus}); double amount; PlatformPoint? focus; Object encode() { - return [ - amount, - focus, - ]; + return [amount, focus]; } static PlatformCameraUpdateZoomBy decode(Object result) { @@ -275,45 +219,33 @@ class PlatformCameraUpdateZoomBy { /// Pigeon equivalent of ZoomIn/ZoomOut class PlatformCameraUpdateZoom { - PlatformCameraUpdateZoom({ - required this.out, - }); + PlatformCameraUpdateZoom({required this.out}); bool out; Object encode() { - return [ - out, - ]; + return [out]; } static PlatformCameraUpdateZoom decode(Object result) { result as List; - return PlatformCameraUpdateZoom( - out: result[0]! as bool, - ); + return PlatformCameraUpdateZoom(out: result[0]! as bool); } } /// Pigeon equivalent of ZoomTo class PlatformCameraUpdateZoomTo { - PlatformCameraUpdateZoomTo({ - required this.zoom, - }); + PlatformCameraUpdateZoomTo({required this.zoom}); double zoom; Object encode() { - return [ - zoom, - ]; + return [zoom]; } static PlatformCameraUpdateZoomTo decode(Object result) { result as List; - return PlatformCameraUpdateZoomTo( - zoom: result[0]! as double, - ); + return PlatformCameraUpdateZoomTo(zoom: result[0]! as double); } } @@ -381,9 +313,7 @@ class PlatformCircle { /// Pigeon equivalent of the Heatmap class. class PlatformHeatmap { - PlatformHeatmap({ - required this.json, - }); + PlatformHeatmap({required this.json}); /// The heatmap data, as JSON. This should only be set from /// Heatmap.toJson, and the native code must interpret it according to the @@ -391,26 +321,18 @@ class PlatformHeatmap { Object json; Object encode() { - return [ - json, - ]; + return [json]; } static PlatformHeatmap decode(Object result) { result as List; - return PlatformHeatmap( - json: result[0]!, - ); + return PlatformHeatmap(json: result[0]!); } } /// Pigeon equivalent of the InfoWindow class. class PlatformInfoWindow { - PlatformInfoWindow({ - this.title, - this.snippet, - required this.anchor, - }); + PlatformInfoWindow({this.title, this.snippet, required this.anchor}); String? title; @@ -419,11 +341,7 @@ class PlatformInfoWindow { PlatformPoint anchor; Object encode() { - return [ - title, - snippet, - anchor, - ]; + return [title, snippet, anchor]; } static PlatformInfoWindow decode(Object result) { @@ -454,12 +372,7 @@ class PlatformCluster { List markerIds; Object encode() { - return [ - clusterManagerId, - position, - bounds, - markerIds, - ]; + return [clusterManagerId, position, bounds, markerIds]; } static PlatformCluster decode(Object result) { @@ -475,23 +388,17 @@ class PlatformCluster { /// Pigeon equivalent of the ClusterManager class. class PlatformClusterManager { - PlatformClusterManager({ - required this.identifier, - }); + PlatformClusterManager({required this.identifier}); String identifier; Object encode() { - return [ - identifier, - ]; + return [identifier]; } static PlatformClusterManager decode(Object result) { result as List; - return PlatformClusterManager( - identifier: result[0]! as String, - ); + return PlatformClusterManager(identifier: result[0]! as String); } } @@ -715,20 +622,14 @@ class PlatformPolyline { /// Pigeon equivalent of the PatternItem class. class PlatformPatternItem { - PlatformPatternItem({ - required this.type, - this.length, - }); + PlatformPatternItem({required this.type, this.length}); PlatformPatternItemType type; double? length; Object encode() { - return [ - type, - length, - ]; + return [type, length]; } static PlatformPatternItem decode(Object result) { @@ -742,11 +643,7 @@ class PlatformPatternItem { /// Pigeon equivalent of the Tile class. class PlatformTile { - PlatformTile({ - required this.width, - required this.height, - this.data, - }); + PlatformTile({required this.width, required this.height, this.data}); int width; @@ -755,11 +652,7 @@ class PlatformTile { Uint8List? data; Object encode() { - return [ - width, - height, - data, - ]; + return [width, height, data]; } static PlatformTile decode(Object result) { @@ -837,12 +730,7 @@ class PlatformEdgeInsets { double right; Object encode() { - return [ - top, - bottom, - left, - right, - ]; + return [top, bottom, left, right]; } static PlatformEdgeInsets decode(Object result) { @@ -858,20 +746,14 @@ class PlatformEdgeInsets { /// Pigeon equivalent of LatLng. class PlatformLatLng { - PlatformLatLng({ - required this.latitude, - required this.longitude, - }); + PlatformLatLng({required this.latitude, required this.longitude}); double latitude; double longitude; Object encode() { - return [ - latitude, - longitude, - ]; + return [latitude, longitude]; } static PlatformLatLng decode(Object result) { @@ -885,20 +767,14 @@ class PlatformLatLng { /// Pigeon equivalent of LatLngBounds. class PlatformLatLngBounds { - PlatformLatLngBounds({ - required this.northeast, - required this.southwest, - }); + PlatformLatLngBounds({required this.northeast, required this.southwest}); PlatformLatLng northeast; PlatformLatLng southwest; Object encode() { - return [ - northeast, - southwest, - ]; + return [northeast, southwest]; } static PlatformLatLngBounds decode(Object result) { @@ -915,16 +791,12 @@ class PlatformLatLngBounds { /// As with the Dart version, it exists to distinguish between not setting a /// a target, and having an explicitly unbounded target (null [bounds]). class PlatformCameraTargetBounds { - PlatformCameraTargetBounds({ - this.bounds, - }); + PlatformCameraTargetBounds({this.bounds}); PlatformLatLngBounds? bounds; Object encode() { - return [ - bounds, - ]; + return [bounds]; } static PlatformCameraTargetBounds decode(Object result) { @@ -1181,47 +1053,32 @@ class PlatformMapConfiguration { /// Pigeon representation of an x,y coordinate. class PlatformPoint { - PlatformPoint({ - required this.x, - required this.y, - }); + PlatformPoint({required this.x, required this.y}); double x; double y; Object encode() { - return [ - x, - y, - ]; + return [x, y]; } static PlatformPoint decode(Object result) { result as List; - return PlatformPoint( - x: result[0]! as double, - y: result[1]! as double, - ); + return PlatformPoint(x: result[0]! as double, y: result[1]! as double); } } /// Pigeon representation of a size. class PlatformSize { - PlatformSize({ - required this.width, - required this.height, - }); + PlatformSize({required this.width, required this.height}); double width; double height; Object encode() { - return [ - width, - height, - ]; + return [width, height]; } static PlatformSize decode(Object result) { @@ -1251,12 +1108,7 @@ class PlatformTileLayer { int zIndex; Object encode() { - return [ - visible, - fadeIn, - opacity, - zIndex, - ]; + return [visible, fadeIn, opacity, zIndex]; } static PlatformTileLayer decode(Object result) { @@ -1272,20 +1124,14 @@ class PlatformTileLayer { /// Pigeon equivalent of MinMaxZoomPreference. class PlatformZoomRange { - PlatformZoomRange({ - this.min, - this.max, - }); + PlatformZoomRange({this.min, this.max}); double? min; double? max; Object encode() { - return [ - min, - max, - ]; + return [min, max]; } static PlatformZoomRange decode(Object result) { @@ -1301,9 +1147,7 @@ class PlatformZoomRange { /// types of [BitmapDescriptor], [PlatformBitmap] contains a single field which /// may hold the pigeon equivalent type of any of them. class PlatformBitmap { - PlatformBitmap({ - required this.bitmap, - }); + PlatformBitmap({required this.bitmap}); /// One of [PlatformBitmapAssetMap], [PlatformBitmapAsset], /// [PlatformBitmapAssetImage], [PlatformBitmapBytesMap], @@ -1315,57 +1159,41 @@ class PlatformBitmap { Object bitmap; Object encode() { - return [ - bitmap, - ]; + return [bitmap]; } static PlatformBitmap decode(Object result) { result as List; - return PlatformBitmap( - bitmap: result[0]!, - ); + return PlatformBitmap(bitmap: result[0]!); } } /// Pigeon equivalent of [DefaultMarker]. class PlatformBitmapDefaultMarker { - PlatformBitmapDefaultMarker({ - this.hue, - }); + PlatformBitmapDefaultMarker({this.hue}); double? hue; Object encode() { - return [ - hue, - ]; + return [hue]; } static PlatformBitmapDefaultMarker decode(Object result) { result as List; - return PlatformBitmapDefaultMarker( - hue: result[0] as double?, - ); + return PlatformBitmapDefaultMarker(hue: result[0] as double?); } } /// Pigeon equivalent of [BytesBitmap]. class PlatformBitmapBytes { - PlatformBitmapBytes({ - required this.byteData, - this.size, - }); + PlatformBitmapBytes({required this.byteData, this.size}); Uint8List byteData; PlatformSize? size; Object encode() { - return [ - byteData, - size, - ]; + return [byteData, size]; } static PlatformBitmapBytes decode(Object result) { @@ -1379,20 +1207,14 @@ class PlatformBitmapBytes { /// Pigeon equivalent of [AssetBitmap]. class PlatformBitmapAsset { - PlatformBitmapAsset({ - required this.name, - this.pkg, - }); + PlatformBitmapAsset({required this.name, this.pkg}); String name; String? pkg; Object encode() { - return [ - name, - pkg, - ]; + return [name, pkg]; } static PlatformBitmapAsset decode(Object result) { @@ -1419,11 +1241,7 @@ class PlatformBitmapAssetImage { PlatformSize? size; Object encode() { - return [ - name, - scale, - size, - ]; + return [name, scale, size]; } static PlatformBitmapAssetImage decode(Object result) { @@ -1457,13 +1275,7 @@ class PlatformBitmapAssetMap { double? height; Object encode() { - return [ - assetName, - bitmapScaling, - imagePixelRatio, - width, - height, - ]; + return [assetName, bitmapScaling, imagePixelRatio, width, height]; } static PlatformBitmapAssetMap decode(Object result) { @@ -1499,13 +1311,7 @@ class PlatformBitmapBytesMap { double? height; Object encode() { - return [ - byteData, - bitmapScaling, - imagePixelRatio, - width, - height, - ]; + return [byteData, bitmapScaling, imagePixelRatio, width, height]; } static PlatformBitmapBytesMap decode(Object result) { @@ -1768,9 +1574,9 @@ class MapsApi { /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. MapsApi({BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -1783,10 +1589,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.waitForMap$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -1807,17 +1613,19 @@ class MapsApi { /// Only non-null configuration values will result in updates; options with /// null values will remain unchanged. Future updateMapConfiguration( - PlatformMapConfiguration configuration) async { + PlatformMapConfiguration configuration, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.updateMapConfiguration$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([configuration]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([configuration]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -1832,18 +1640,22 @@ class MapsApi { } /// Updates the set of circles on the map. - Future updateCircles(List toAdd, - List toChange, List idsToRemove) async { + Future updateCircles( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.updateCircles$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -1858,18 +1670,22 @@ class MapsApi { } /// Updates the set of heatmaps on the map. - Future updateHeatmaps(List toAdd, - List toChange, List idsToRemove) async { + Future updateHeatmaps( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.updateHeatmaps$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -1885,17 +1701,20 @@ class MapsApi { /// Updates the set of custer managers for clusters on the map. Future updateClusterManagers( - List toAdd, List idsToRemove) async { + List toAdd, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.updateClusterManagers$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -1910,18 +1729,22 @@ class MapsApi { } /// Updates the set of markers on the map. - Future updateMarkers(List toAdd, - List toChange, List idsToRemove) async { + Future updateMarkers( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.updateMarkers$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -1936,18 +1759,22 @@ class MapsApi { } /// Updates the set of polygonss on the map. - Future updatePolygons(List toAdd, - List toChange, List idsToRemove) async { + Future updatePolygons( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.updatePolygons$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -1962,18 +1789,22 @@ class MapsApi { } /// Updates the set of polylines on the map. - Future updatePolylines(List toAdd, - List toChange, List idsToRemove) async { + Future updatePolylines( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.updatePolylines$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -1988,18 +1819,22 @@ class MapsApi { } /// Updates the set of tile overlays on the map. - Future updateTileOverlays(List toAdd, - List toChange, List idsToRemove) async { + Future updateTileOverlays( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.updateTileOverlays$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2014,18 +1849,22 @@ class MapsApi { } /// Updates the set of ground overlays on the map. - Future updateGroundOverlays(List toAdd, - List toChange, List idsToRemove) async { + Future updateGroundOverlays( + List toAdd, + List toChange, + List idsToRemove, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.updateGroundOverlays$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([toAdd, toChange, idsToRemove]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([toAdd, toChange, idsToRemove]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2045,10 +1884,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.getScreenCoordinate$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([latLng]) as List?; if (pigeonVar_replyList == null) { @@ -2075,12 +1914,13 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.getLatLng$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([screenCoordinate]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([screenCoordinate]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2105,10 +1945,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.getVisibleRegion$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -2136,10 +1976,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.moveCamera$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([cameraUpdate]) as List?; if (pigeonVar_replyList == null) { @@ -2158,17 +1998,23 @@ class MapsApi { /// Moves the camera according to [cameraUpdate], animating the update using a /// duration in milliseconds if provided. Future animateCamera( - PlatformCameraUpdate cameraUpdate, int? durationMilliseconds) async { + PlatformCameraUpdate cameraUpdate, + int? durationMilliseconds, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.animateCamera$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([cameraUpdate, durationMilliseconds]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([ + cameraUpdate, + durationMilliseconds, + ]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2188,10 +2034,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.getZoomLevel$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -2218,10 +2064,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.showInfoWindow$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([markerId]) as List?; if (pigeonVar_replyList == null) { @@ -2243,10 +2089,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.hideInfoWindow$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([markerId]) as List?; if (pigeonVar_replyList == null) { @@ -2269,10 +2115,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.isInfoWindowShown$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([markerId]) as List?; if (pigeonVar_replyList == null) { @@ -2303,10 +2149,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.setStyle$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([style]) as List?; if (pigeonVar_replyList == null) { @@ -2332,10 +2178,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.getLastStyleError$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -2357,12 +2203,13 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.clearTileCache$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([tileOverlayId]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([tileOverlayId]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -2382,10 +2229,10 @@ class MapsApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsApi.takeSnapshot$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -2453,7 +2300,10 @@ abstract class MapsCallbackApi { /// Called to get data for a map tile. Future getTileOverlayTile( - String tileOverlayId, PlatformPoint location, int zoom); + String tileOverlayId, + PlatformPoint location, + int zoom, + ); static void setUp( MapsCallbackApi? api, { @@ -2463,12 +2313,12 @@ abstract class MapsCallbackApi { messageChannelSuffix = messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCameraMoveStarted$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCameraMoveStarted$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { @@ -2480,29 +2330,34 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCameraMove$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCameraMove$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCameraMove was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCameraMove was null.', + ); final List args = (message as List?)!; final PlatformCameraPosition? arg_cameraPosition = (args[0] as PlatformCameraPosition?); - assert(arg_cameraPosition != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCameraMove was null, expected non-null PlatformCameraPosition.'); + assert( + arg_cameraPosition != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCameraMove was null, expected non-null PlatformCameraPosition.', + ); try { api.onCameraMove(arg_cameraPosition!); return wrapResponse(empty: true); @@ -2510,18 +2365,19 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCameraIdle$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCameraIdle$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { @@ -2533,28 +2389,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onTap was null.', + ); final List args = (message as List?)!; final PlatformLatLng? arg_position = (args[0] as PlatformLatLng?); - assert(arg_position != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onTap was null, expected non-null PlatformLatLng.'); + assert( + arg_position != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onTap was null, expected non-null PlatformLatLng.', + ); try { api.onTap(arg_position!); return wrapResponse(empty: true); @@ -2562,28 +2423,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onLongPress$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onLongPress$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onLongPress was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onLongPress was null.', + ); final List args = (message as List?)!; final PlatformLatLng? arg_position = (args[0] as PlatformLatLng?); - assert(arg_position != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onLongPress was null, expected non-null PlatformLatLng.'); + assert( + arg_position != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onLongPress was null, expected non-null PlatformLatLng.', + ); try { api.onLongPress(arg_position!); return wrapResponse(empty: true); @@ -2591,28 +2457,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerTap was null.', + ); final List args = (message as List?)!; final String? arg_markerId = (args[0] as String?); - assert(arg_markerId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerTap was null, expected non-null String.'); + assert( + arg_markerId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerTap was null, expected non-null String.', + ); try { api.onMarkerTap(arg_markerId!); return wrapResponse(empty: true); @@ -2620,31 +2491,38 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragStart$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragStart$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragStart was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragStart was null.', + ); final List args = (message as List?)!; final String? arg_markerId = (args[0] as String?); - assert(arg_markerId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragStart was null, expected non-null String.'); + assert( + arg_markerId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragStart was null, expected non-null String.', + ); final PlatformLatLng? arg_position = (args[1] as PlatformLatLng?); - assert(arg_position != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragStart was null, expected non-null PlatformLatLng.'); + assert( + arg_position != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragStart was null, expected non-null PlatformLatLng.', + ); try { api.onMarkerDragStart(arg_markerId!, arg_position!); return wrapResponse(empty: true); @@ -2652,31 +2530,38 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDrag$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDrag$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDrag was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDrag was null.', + ); final List args = (message as List?)!; final String? arg_markerId = (args[0] as String?); - assert(arg_markerId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDrag was null, expected non-null String.'); + assert( + arg_markerId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDrag was null, expected non-null String.', + ); final PlatformLatLng? arg_position = (args[1] as PlatformLatLng?); - assert(arg_position != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDrag was null, expected non-null PlatformLatLng.'); + assert( + arg_position != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDrag was null, expected non-null PlatformLatLng.', + ); try { api.onMarkerDrag(arg_markerId!, arg_position!); return wrapResponse(empty: true); @@ -2684,31 +2569,38 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragEnd$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragEnd$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragEnd was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragEnd was null.', + ); final List args = (message as List?)!; final String? arg_markerId = (args[0] as String?); - assert(arg_markerId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragEnd was null, expected non-null String.'); + assert( + arg_markerId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragEnd was null, expected non-null String.', + ); final PlatformLatLng? arg_position = (args[1] as PlatformLatLng?); - assert(arg_position != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragEnd was null, expected non-null PlatformLatLng.'); + assert( + arg_position != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onMarkerDragEnd was null, expected non-null PlatformLatLng.', + ); try { api.onMarkerDragEnd(arg_markerId!, arg_position!); return wrapResponse(empty: true); @@ -2716,28 +2608,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onInfoWindowTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onInfoWindowTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onInfoWindowTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onInfoWindowTap was null.', + ); final List args = (message as List?)!; final String? arg_markerId = (args[0] as String?); - assert(arg_markerId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onInfoWindowTap was null, expected non-null String.'); + assert( + arg_markerId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onInfoWindowTap was null, expected non-null String.', + ); try { api.onInfoWindowTap(arg_markerId!); return wrapResponse(empty: true); @@ -2745,28 +2642,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCircleTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCircleTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCircleTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCircleTap was null.', + ); final List args = (message as List?)!; final String? arg_circleId = (args[0] as String?); - assert(arg_circleId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCircleTap was null, expected non-null String.'); + assert( + arg_circleId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onCircleTap was null, expected non-null String.', + ); try { api.onCircleTap(arg_circleId!); return wrapResponse(empty: true); @@ -2774,28 +2676,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onClusterTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onClusterTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onClusterTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onClusterTap was null.', + ); final List args = (message as List?)!; final PlatformCluster? arg_cluster = (args[0] as PlatformCluster?); - assert(arg_cluster != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onClusterTap was null, expected non-null PlatformCluster.'); + assert( + arg_cluster != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onClusterTap was null, expected non-null PlatformCluster.', + ); try { api.onClusterTap(arg_cluster!); return wrapResponse(empty: true); @@ -2803,28 +2710,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolygonTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolygonTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolygonTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolygonTap was null.', + ); final List args = (message as List?)!; final String? arg_polygonId = (args[0] as String?); - assert(arg_polygonId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolygonTap was null, expected non-null String.'); + assert( + arg_polygonId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolygonTap was null, expected non-null String.', + ); try { api.onPolygonTap(arg_polygonId!); return wrapResponse(empty: true); @@ -2832,28 +2744,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolylineTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolylineTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolylineTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolylineTap was null.', + ); final List args = (message as List?)!; final String? arg_polylineId = (args[0] as String?); - assert(arg_polylineId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolylineTap was null, expected non-null String.'); + assert( + arg_polylineId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onPolylineTap was null, expected non-null String.', + ); try { api.onPolylineTap(arg_polylineId!); return wrapResponse(empty: true); @@ -2861,28 +2778,33 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onGroundOverlayTap$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onGroundOverlayTap$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onGroundOverlayTap was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onGroundOverlayTap was null.', + ); final List args = (message as List?)!; final String? arg_groundOverlayId = (args[0] as String?); - assert(arg_groundOverlayId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onGroundOverlayTap was null, expected non-null String.'); + assert( + arg_groundOverlayId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.onGroundOverlayTap was null, expected non-null String.', + ); try { api.onGroundOverlayTap(arg_groundOverlayId!); return wrapResponse(empty: true); @@ -2890,43 +2812,56 @@ abstract class MapsCallbackApi { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } } { - final BasicMessageChannel< - Object?> pigeonVar_channel = BasicMessageChannel< - Object?>( - 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.getTileOverlayTile$messageChannelSuffix', - pigeonChannelCodec, - binaryMessenger: binaryMessenger); + final BasicMessageChannel + pigeonVar_channel = BasicMessageChannel( + 'dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.getTileOverlayTile$messageChannelSuffix', + pigeonChannelCodec, + binaryMessenger: binaryMessenger, + ); if (api == null) { pigeonVar_channel.setMessageHandler(null); } else { pigeonVar_channel.setMessageHandler((Object? message) async { - assert(message != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.getTileOverlayTile was null.'); + assert( + message != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.getTileOverlayTile was null.', + ); final List args = (message as List?)!; final String? arg_tileOverlayId = (args[0] as String?); - assert(arg_tileOverlayId != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.getTileOverlayTile was null, expected non-null String.'); + assert( + arg_tileOverlayId != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.getTileOverlayTile was null, expected non-null String.', + ); final PlatformPoint? arg_location = (args[1] as PlatformPoint?); - assert(arg_location != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.getTileOverlayTile was null, expected non-null PlatformPoint.'); + assert( + arg_location != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.getTileOverlayTile was null, expected non-null PlatformPoint.', + ); final int? arg_zoom = (args[2] as int?); - assert(arg_zoom != null, - 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.getTileOverlayTile was null, expected non-null int.'); + assert( + arg_zoom != null, + 'Argument for dev.flutter.pigeon.google_maps_flutter_ios.MapsCallbackApi.getTileOverlayTile was null, expected non-null int.', + ); try { final PlatformTile output = await api.getTileOverlayTile( - arg_tileOverlayId!, arg_location!, arg_zoom!); + arg_tileOverlayId!, + arg_location!, + arg_zoom!, + ); return wrapResponse(result: output); } on PlatformException catch (e) { return wrapResponse(error: e); } catch (e) { return wrapResponse( - error: PlatformException(code: 'error', message: e.toString())); + error: PlatformException(code: 'error', message: e.toString()), + ); } }); } @@ -2941,11 +2876,12 @@ class MapsPlatformViewApi { /// Constructor for [MapsPlatformViewApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - MapsPlatformViewApi( - {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + MapsPlatformViewApi({ + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -2957,10 +2893,10 @@ class MapsPlatformViewApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsPlatformViewApi.createView$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([type]) as List?; if (pigeonVar_replyList == null) { @@ -2982,11 +2918,12 @@ class MapsInspectorApi { /// Constructor for [MapsInspectorApi]. The [binaryMessenger] named argument is /// available for dependency injection. If it is left null, the default /// BinaryMessenger will be used which routes to the host platform. - MapsInspectorApi( - {BinaryMessenger? binaryMessenger, String messageChannelSuffix = ''}) - : pigeonVar_binaryMessenger = binaryMessenger, - pigeonVar_messageChannelSuffix = - messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; + MapsInspectorApi({ + BinaryMessenger? binaryMessenger, + String messageChannelSuffix = '', + }) : pigeonVar_binaryMessenger = binaryMessenger, + pigeonVar_messageChannelSuffix = + messageChannelSuffix.isNotEmpty ? '.$messageChannelSuffix' : ''; final BinaryMessenger? pigeonVar_binaryMessenger; static const MessageCodec pigeonChannelCodec = _PigeonCodec(); @@ -2998,10 +2935,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.areBuildingsEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3027,10 +2964,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.areRotateGesturesEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3056,10 +2993,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.areScrollGesturesEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3085,10 +3022,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.areTiltGesturesEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3114,10 +3051,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.areZoomGesturesEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3143,10 +3080,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.isCompassEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3172,10 +3109,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.isMyLocationButtonEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3201,10 +3138,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.isTrafficEnabled$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3230,12 +3167,13 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.getTileOverlayInfo$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([tileOverlayId]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([tileOverlayId]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -3250,17 +3188,19 @@ class MapsInspectorApi { } Future getGroundOverlayInfo( - String groundOverlayId) async { + String groundOverlayId, + ) async { final String pigeonVar_channelName = 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.getGroundOverlayInfo$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([groundOverlayId]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([groundOverlayId]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -3279,10 +3219,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.getHeatmapInfo$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send([heatmapId]) as List?; if (pigeonVar_replyList == null) { @@ -3303,10 +3243,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.getZoomRange$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { @@ -3332,12 +3272,13 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.getClusters$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); - final List? pigeonVar_replyList = await pigeonVar_channel - .send([clusterManagerId]) as List?; + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); + final List? pigeonVar_replyList = + await pigeonVar_channel.send([clusterManagerId]) + as List?; if (pigeonVar_replyList == null) { throw _createConnectionError(pigeonVar_channelName); } else if (pigeonVar_replyList.length > 1) { @@ -3362,10 +3303,10 @@ class MapsInspectorApi { 'dev.flutter.pigeon.google_maps_flutter_ios.MapsInspectorApi.getCameraPosition$pigeonVar_messageChannelSuffix'; final BasicMessageChannel pigeonVar_channel = BasicMessageChannel( - pigeonVar_channelName, - pigeonChannelCodec, - binaryMessenger: pigeonVar_binaryMessenger, - ); + pigeonVar_channelName, + pigeonChannelCodec, + binaryMessenger: pigeonVar_binaryMessenger, + ); final List? pigeonVar_replyList = await pigeonVar_channel.send(null) as List?; if (pigeonVar_replyList == null) { diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/serialization.dart b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/serialization.dart index 8c80f19fb61..97db05b828d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/serialization.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/lib/src/serialization.dart @@ -37,14 +37,23 @@ Object serializeHeatmap(Heatmap heatmap) { final HeatmapGradient? gradient = heatmap.gradient; if (gradient != null) { _addIfNonNull( - json, _heatmapGradientKey, serializeHeatmapGradient(gradient)); + json, + _heatmapGradientKey, + serializeHeatmapGradient(gradient), + ); } _addIfNonNull(json, _heatmapOpacityKey, heatmap.opacity); _addIfNonNull(json, _heatmapRadiusKey, heatmap.radius.radius); _addIfNonNull( - json, _heatmapMinimumZoomIntensityKey, heatmap.minimumZoomIntensity); + json, + _heatmapMinimumZoomIntensityKey, + heatmap.minimumZoomIntensity, + ); _addIfNonNull( - json, _heatmapMaximumZoomIntensityKey, heatmap.maximumZoomIntensity); + json, + _heatmapMaximumZoomIntensityKey, + heatmap.maximumZoomIntensity, + ); return json; } @@ -106,10 +115,11 @@ HeatmapGradient? deserializeHeatmapGradient(Object? json) { } assert(json is Map); final Map map = (json as Map).cast(); - final List colors = (map[_heatmapGradientColorsKey]! as List) - .whereType() - .map((int e) => Color(e)) - .toList(); + final List colors = + (map[_heatmapGradientColorsKey]! as List) + .whereType() + .map((int e) => Color(e)) + .toList(); final List startPoints = (map[_heatmapGradientStartPointsKey]! as List) .whereType() diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart b/packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart index 8f66adc44b8..3aebc438b64 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pigeons/messages.dart @@ -4,22 +4,17 @@ import 'package:pigeon/pigeon.dart'; -@ConfigurePigeon(PigeonOptions( - dartOut: 'lib/src/messages.g.dart', - objcHeaderOut: 'ios/Classes/messages.g.h', - objcSourceOut: 'ios/Classes/messages.g.m', - objcOptions: ObjcOptions(prefix: 'FGM'), - copyrightHeader: 'pigeons/copyright.txt', -)) - +@ConfigurePigeon( + PigeonOptions( + dartOut: 'lib/src/messages.g.dart', + objcHeaderOut: 'ios/Classes/messages.g.h', + objcSourceOut: 'ios/Classes/messages.g.m', + objcOptions: ObjcOptions(prefix: 'FGM'), + copyrightHeader: 'pigeons/copyright.txt', + ), +) /// Pigeon equivalent of MapType -enum PlatformMapType { - none, - normal, - satellite, - terrain, - hybrid, -} +enum PlatformMapType { none, normal, satellite, terrain, hybrid } /// Pigeon representatation of a CameraPosition. class PlatformCameraPosition { @@ -140,11 +135,7 @@ class PlatformHeatmap { /// Pigeon equivalent of the InfoWindow class. class PlatformInfoWindow { - PlatformInfoWindow({ - required this.anchor, - this.title, - this.snippet, - }); + PlatformInfoWindow({required this.anchor, this.title, this.snippet}); final String? title; final String? snippet; @@ -235,11 +226,7 @@ class PlatformPolygon { } /// Join types for polyline joints. -enum PlatformJointType { - mitered, - bevel, - round, -} +enum PlatformJointType { mitered, bevel, round } /// Pigeon equivalent of the Polyline class. class PlatformPolyline { @@ -274,11 +261,7 @@ class PlatformPolyline { } /// Enumeration of possible types for PatternItem. -enum PlatformPatternItemType { - dot, - dash, - gap, -} +enum PlatformPatternItemType { dot, dash, gap } /// Pigeon equivalent of the PatternItem class. class PlatformPatternItem { @@ -534,8 +517,11 @@ class PlatformBitmapAsset { /// Pigeon equivalent of [AssetImageBitmap]. class PlatformBitmapAssetImage { - PlatformBitmapAssetImage( - {required this.name, required this.scale, this.size}); + PlatformBitmapAssetImage({ + required this.name, + required this.scale, + this.size, + }); final String name; final double scale; final PlatformSize? size; @@ -543,12 +529,13 @@ class PlatformBitmapAssetImage { /// Pigeon equivalent of [AssetMapBitmap]. class PlatformBitmapAssetMap { - PlatformBitmapAssetMap( - {required this.assetName, - required this.bitmapScaling, - required this.imagePixelRatio, - this.width, - this.height}); + PlatformBitmapAssetMap({ + required this.assetName, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height, + }); final String assetName; final PlatformMapBitmapScaling bitmapScaling; final double imagePixelRatio; @@ -558,12 +545,13 @@ class PlatformBitmapAssetMap { /// Pigeon equivalent of [BytesMapBitmap]. class PlatformBitmapBytesMap { - PlatformBitmapBytesMap( - {required this.byteData, - required this.bitmapScaling, - required this.imagePixelRatio, - this.width, - this.height}); + PlatformBitmapBytesMap({ + required this.byteData, + required this.bitmapScaling, + required this.imagePixelRatio, + this.width, + this.height, + }); final Uint8List byteData; final PlatformMapBitmapScaling bitmapScaling; final double imagePixelRatio; @@ -572,10 +560,7 @@ class PlatformBitmapBytesMap { } /// Pigeon equivalent of [MapBitmapScaling]. -enum PlatformMapBitmapScaling { - auto, - none, -} +enum PlatformMapBitmapScaling { auto, none } /// Interface for non-test interactions with the native SDK. /// @@ -594,43 +579,66 @@ abstract class MapsApi { /// Updates the set of circles on the map. @ObjCSelector('updateCirclesByAdding:changing:removing:') - void updateCircles(List toAdd, List toChange, - List idsToRemove); + void updateCircles( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of heatmaps on the map. @ObjCSelector('updateHeatmapsByAdding:changing:removing:') - void updateHeatmaps(List toAdd, - List toChange, List idsToRemove); + void updateHeatmaps( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of custer managers for clusters on the map. @ObjCSelector('updateClusterManagersByAdding:removing:') void updateClusterManagers( - List toAdd, List idsToRemove); + List toAdd, + List idsToRemove, + ); /// Updates the set of markers on the map. @ObjCSelector('updateMarkersByAdding:changing:removing:') - void updateMarkers(List toAdd, List toChange, - List idsToRemove); + void updateMarkers( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of polygonss on the map. @ObjCSelector('updatePolygonsByAdding:changing:removing:') - void updatePolygons(List toAdd, - List toChange, List idsToRemove); + void updatePolygons( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of polylines on the map. @ObjCSelector('updatePolylinesByAdding:changing:removing:') - void updatePolylines(List toAdd, - List toChange, List idsToRemove); + void updatePolylines( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of tile overlays on the map. @ObjCSelector('updateTileOverlaysByAdding:changing:removing:') - void updateTileOverlays(List toAdd, - List toChange, List idsToRemove); + void updateTileOverlays( + List toAdd, + List toChange, + List idsToRemove, + ); /// Updates the set of ground overlays on the map. @ObjCSelector('updateGroundOverlaysByAdding:changing:removing:') - void updateGroundOverlays(List toAdd, - List toChange, List idsToRemove); + void updateGroundOverlays( + List toAdd, + List toChange, + List idsToRemove, + ); /// Gets the screen coordinate for the given map location. @ObjCSelector('screenCoordinatesForLatLng:') @@ -653,7 +661,9 @@ abstract class MapsApi { /// duration in milliseconds if provided. @ObjCSelector('animateCameraWithUpdate:duration:') void animateCamera( - PlatformCameraUpdate cameraUpdate, int? durationMilliseconds); + PlatformCameraUpdate cameraUpdate, + int? durationMilliseconds, + ); /// Gets the current map zoom level. @ObjCSelector('currentZoomLevel') @@ -763,7 +773,10 @@ abstract class MapsCallbackApi { @async @ObjCSelector('tileWithOverlayIdentifier:location:zoom:') PlatformTile getTileOverlayTile( - String tileOverlayId, PlatformPoint location, int zoom); + String tileOverlayId, + PlatformPoint location, + int zoom, + ); } /// Dummy interface to force generation of the platform view creation params, diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml index 334bd86c020..50eadd0efc7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml @@ -5,8 +5,8 @@ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+ version: 2.15.5 environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" flutter: plugin: diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart b/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart index 47bafa0ac0d..3f46bb1b1fb 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart @@ -21,8 +21,9 @@ void main() { (GoogleMapsFlutterIOS, MockMapsApi) setUpMockMap({required int mapId}) { final MockMapsApi api = MockMapsApi(); - final GoogleMapsFlutterIOS maps = - GoogleMapsFlutterIOS(apiProvider: (_) => api); + final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS( + apiProvider: (_) => api, + ); maps.ensureApiInitialized(mapId); return (maps, api); } @@ -34,8 +35,9 @@ void main() { test('init calls waitForMap', () async { final MockMapsApi api = MockMapsApi(); - final GoogleMapsFlutterIOS maps = - GoogleMapsFlutterIOS(apiProvider: (_) => api); + final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS( + apiProvider: (_) => api, + ); await maps.init(1); @@ -44,20 +46,28 @@ void main() { test('getScreenCoordinate converts and passes values correctly', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); // Arbitrary values that are all different from each other. const LatLng latLng = LatLng(10, 20); const ScreenCoordinate expectedCoord = ScreenCoordinate(x: 30, y: 40); - when(api.getScreenCoordinate(any)).thenAnswer((_) async => PlatformPoint( - x: expectedCoord.x.toDouble(), y: expectedCoord.y.toDouble())); + when(api.getScreenCoordinate(any)).thenAnswer( + (_) async => PlatformPoint( + x: expectedCoord.x.toDouble(), + y: expectedCoord.y.toDouble(), + ), + ); - final ScreenCoordinate coord = - await maps.getScreenCoordinate(latLng, mapId: mapId); + final ScreenCoordinate coord = await maps.getScreenCoordinate( + latLng, + mapId: mapId, + ); expect(coord, expectedCoord); - final VerificationResult verification = - verify(api.getScreenCoordinate(captureAny)); + final VerificationResult verification = verify( + api.getScreenCoordinate(captureAny), + ); final PlatformLatLng passedLatLng = verification.captured[0] as PlatformLatLng; expect(passedLatLng.latitude, latLng.latitude); @@ -66,15 +76,19 @@ void main() { test('getLatLng converts and passes values correctly', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); // Arbitrary values that are all different from each other. const LatLng expectedLatLng = LatLng(10, 20); const ScreenCoordinate coord = ScreenCoordinate(x: 30, y: 40); - when(api.getLatLng(any)).thenAnswer((_) async => PlatformLatLng( + when(api.getLatLng(any)).thenAnswer( + (_) async => PlatformLatLng( latitude: expectedLatLng.latitude, - longitude: expectedLatLng.longitude)); + longitude: expectedLatLng.longitude, + ), + ); final LatLng latLng = await maps.getLatLng(coord, mapId: mapId); expect(latLng, expectedLatLng); @@ -86,19 +100,27 @@ void main() { test('getVisibleRegion converts and passes values correctly', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); // Arbitrary values that are all different from each other. final LatLngBounds expectedBounds = LatLngBounds( - southwest: const LatLng(10, 20), northeast: const LatLng(30, 40)); - when(api.getVisibleRegion()).thenAnswer((_) async => PlatformLatLngBounds( + southwest: const LatLng(10, 20), + northeast: const LatLng(30, 40), + ); + when(api.getVisibleRegion()).thenAnswer( + (_) async => PlatformLatLngBounds( southwest: PlatformLatLng( - latitude: expectedBounds.southwest.latitude, - longitude: expectedBounds.southwest.longitude), + latitude: expectedBounds.southwest.latitude, + longitude: expectedBounds.southwest.longitude, + ), northeast: PlatformLatLng( - latitude: expectedBounds.northeast.latitude, - longitude: expectedBounds.northeast.longitude))); + latitude: expectedBounds.northeast.latitude, + longitude: expectedBounds.northeast.longitude, + ), + ), + ); final LatLngBounds bounds = await maps.getVisibleRegion(mapId: mapId); expect(bounds, expectedBounds); @@ -106,8 +128,9 @@ void main() { test('moveCamera calls through with expected scrollBy', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.scrollBy(10, 20); await maps.moveCamera(update, mapId: mapId); @@ -124,14 +147,16 @@ void main() { test('animateCamera calls through with expected scrollBy', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.scrollBy(10, 20); await maps.animateCamera(update, mapId: mapId); - final VerificationResult verification = - verify(api.animateCamera(captureAny, captureAny)); + final VerificationResult verification = verify( + api.animateCamera(captureAny, captureAny), + ); final PlatformCameraUpdate passedUpdate = verification.captured[0] as PlatformCameraUpdate; final PlatformCameraUpdateScrollBy scroll = @@ -144,8 +169,9 @@ void main() { test('animateCameraWithConfiguration calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.scrollBy(10, 20); const CameraUpdateAnimationConfiguration configuration = @@ -157,8 +183,9 @@ void main() { mapId: mapId, ); - final VerificationResult verification = - verify(api.animateCamera(captureAny, captureAny)); + final VerificationResult verification = verify( + api.animateCamera(captureAny, captureAny), + ); final PlatformCameraUpdate passedUpdate = verification.captured[0] as PlatformCameraUpdate; final PlatformCameraUpdateScrollBy scroll = @@ -173,8 +200,9 @@ void main() { test('getZoomLevel passes values correctly', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const double expectedZoom = 4.2; when(api.getZoomLevel()).thenAnswer((_) async => expectedZoom); @@ -185,8 +213,9 @@ void main() { test('showInfoWindow calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const String markedId = 'a_marker'; await maps.showMarkerInfoWindow(const MarkerId(markedId), mapId: mapId); @@ -196,8 +225,9 @@ void main() { test('hideInfoWindow calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const String markedId = 'a_marker'; await maps.hideMarkerInfoWindow(const MarkerId(markedId), mapId: mapId); @@ -207,22 +237,27 @@ void main() { test('isInfoWindowShown calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const String markedId = 'a_marker'; when(api.isInfoWindowShown(markedId)).thenAnswer((_) async => true); expect( - await maps.isMarkerInfoWindowShown(const MarkerId(markedId), - mapId: mapId), - true); + await maps.isMarkerInfoWindowShown( + const MarkerId(markedId), + mapId: mapId, + ), + true, + ); }); test('takeSnapshot calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final Uint8List fakeSnapshot = Uint8List(10); when(api.takeSnapshot()).thenAnswer((_) async => fakeSnapshot); @@ -232,8 +267,9 @@ void main() { test('clearTileCache calls through', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const String tileOverlayId = 'overlay'; await maps.clearTileCache(const TileOverlayId(tileOverlayId), mapId: mapId); @@ -243,12 +279,17 @@ void main() { test('updateMapConfiguration passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); // Set some arbitrary options. - final CameraTargetBounds cameraBounds = CameraTargetBounds(LatLngBounds( - southwest: const LatLng(10, 20), northeast: const LatLng(30, 40))); + final CameraTargetBounds cameraBounds = CameraTargetBounds( + LatLngBounds( + southwest: const LatLng(10, 20), + northeast: const LatLng(30, 40), + ), + ); final MapConfiguration config = MapConfiguration( compassEnabled: true, mapType: MapType.terrain, @@ -256,21 +297,30 @@ void main() { ); await maps.updateMapConfiguration(config, mapId: mapId); - final VerificationResult verification = - verify(api.updateMapConfiguration(captureAny)); + final VerificationResult verification = verify( + api.updateMapConfiguration(captureAny), + ); final PlatformMapConfiguration passedConfig = verification.captured[0] as PlatformMapConfiguration; // Each set option should be present. expect(passedConfig.compassEnabled, true); expect(passedConfig.mapType, PlatformMapType.terrain); - expect(passedConfig.cameraTargetBounds?.bounds?.northeast.latitude, - cameraBounds.bounds?.northeast.latitude); - expect(passedConfig.cameraTargetBounds?.bounds?.northeast.longitude, - cameraBounds.bounds?.northeast.longitude); - expect(passedConfig.cameraTargetBounds?.bounds?.southwest.latitude, - cameraBounds.bounds?.southwest.latitude); - expect(passedConfig.cameraTargetBounds?.bounds?.southwest.longitude, - cameraBounds.bounds?.southwest.longitude); + expect( + passedConfig.cameraTargetBounds?.bounds?.northeast.latitude, + cameraBounds.bounds?.northeast.latitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.northeast.longitude, + cameraBounds.bounds?.northeast.longitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.southwest.latitude, + cameraBounds.bounds?.southwest.latitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.southwest.longitude, + cameraBounds.bounds?.southwest.longitude, + ); // Spot-check that unset options are not be present. expect(passedConfig.myLocationEnabled, isNull); expect(passedConfig.minMaxZoomPreference, isNull); @@ -279,12 +329,17 @@ void main() { test('updateMapOptions passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); // Set some arbitrary options. - final CameraTargetBounds cameraBounds = CameraTargetBounds(LatLngBounds( - southwest: const LatLng(10, 20), northeast: const LatLng(30, 40))); + final CameraTargetBounds cameraBounds = CameraTargetBounds( + LatLngBounds( + southwest: const LatLng(10, 20), + northeast: const LatLng(30, 40), + ), + ); final Map config = { 'compassEnabled': true, 'mapType': MapType.terrain.index, @@ -292,21 +347,30 @@ void main() { }; await maps.updateMapOptions(config, mapId: mapId); - final VerificationResult verification = - verify(api.updateMapConfiguration(captureAny)); + final VerificationResult verification = verify( + api.updateMapConfiguration(captureAny), + ); final PlatformMapConfiguration passedConfig = verification.captured[0] as PlatformMapConfiguration; // Each set option should be present. expect(passedConfig.compassEnabled, true); expect(passedConfig.mapType, PlatformMapType.terrain); - expect(passedConfig.cameraTargetBounds?.bounds?.northeast.latitude, - cameraBounds.bounds?.northeast.latitude); - expect(passedConfig.cameraTargetBounds?.bounds?.northeast.longitude, - cameraBounds.bounds?.northeast.longitude); - expect(passedConfig.cameraTargetBounds?.bounds?.southwest.latitude, - cameraBounds.bounds?.southwest.latitude); - expect(passedConfig.cameraTargetBounds?.bounds?.southwest.longitude, - cameraBounds.bounds?.southwest.longitude); + expect( + passedConfig.cameraTargetBounds?.bounds?.northeast.latitude, + cameraBounds.bounds?.northeast.latitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.northeast.longitude, + cameraBounds.bounds?.northeast.longitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.southwest.latitude, + cameraBounds.bounds?.southwest.latitude, + ); + expect( + passedConfig.cameraTargetBounds?.bounds?.southwest.longitude, + cameraBounds.bounds?.southwest.longitude, + ); // Spot-check that unset options are not be present. expect(passedConfig.myLocationEnabled, isNull); expect(passedConfig.minMaxZoomPreference, isNull); @@ -315,20 +379,25 @@ void main() { test('updateCircles passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const Circle object1 = Circle(circleId: CircleId('1')); const Circle object2old = Circle(circleId: CircleId('2')); final Circle object2new = object2old.copyWith(radiusParam: 42); const Circle object3 = Circle(circleId: CircleId('3')); await maps.updateCircles( - CircleUpdates.from( - {object1, object2old}, {object2new, object3}), - mapId: mapId); + CircleUpdates.from( + {object1, object2old}, + {object2new, object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updateCircles(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updateCircles(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toChange = @@ -371,20 +440,27 @@ void main() { test('updateClusterManagers passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); - const ClusterManager object1 = - ClusterManager(clusterManagerId: ClusterManagerId('1')); - const ClusterManager object3 = - ClusterManager(clusterManagerId: ClusterManagerId('3')); + const ClusterManager object1 = ClusterManager( + clusterManagerId: ClusterManagerId('1'), + ); + const ClusterManager object3 = ClusterManager( + clusterManagerId: ClusterManagerId('3'), + ); await maps.updateClusterManagers( - ClusterManagerUpdates.from( - {object1}, {object3}), - mapId: mapId); + ClusterManagerUpdates.from( + {object1}, + {object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updateClusterManagers(captureAny, captureAny)); + final VerificationResult verification = verify( + api.updateClusterManagers(captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toRemove = verification.captured[1] as List; @@ -400,20 +476,25 @@ void main() { test('updateMarkers passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const Marker object1 = Marker(markerId: MarkerId('1')); const Marker object2old = Marker(markerId: MarkerId('2')); final Marker object2new = object2old.copyWith(rotationParam: 42); const Marker object3 = Marker(markerId: MarkerId('3')); await maps.updateMarkers( - MarkerUpdates.from( - {object1, object2old}, {object2new, object3}), - mapId: mapId); + MarkerUpdates.from( + {object1, object2old}, + {object2new, object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updateMarkers(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updateMarkers(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toChange = @@ -433,11 +514,11 @@ void main() { expect(firstChanged.draggable, object2new.draggable); expect(firstChanged.flat, object2new.flat); expect( - firstChanged.icon.bitmap.runtimeType, - GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor( - object2new.icon) - .bitmap - .runtimeType); + firstChanged.icon.bitmap.runtimeType, + GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor( + object2new.icon, + ).bitmap.runtimeType, + ); expect(firstChanged.infoWindow.title, object2new.infoWindow.title); expect(firstChanged.infoWindow.snippet, object2new.infoWindow.snippet); expect(firstChanged.infoWindow.anchor.x, object2new.infoWindow.anchor.dx); @@ -461,10 +542,11 @@ void main() { expect(firstAdded.draggable, object3.draggable); expect(firstAdded.flat, object3.flat); expect( - firstAdded.icon.bitmap.runtimeType, - GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(object3.icon) - .bitmap - .runtimeType); + firstAdded.icon.bitmap.runtimeType, + GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor( + object3.icon, + ).bitmap.runtimeType, + ); expect(firstAdded.infoWindow.title, object3.infoWindow.title); expect(firstAdded.infoWindow.snippet, object3.infoWindow.snippet); expect(firstAdded.infoWindow.anchor.x, object3.infoWindow.anchor.dx); @@ -481,20 +563,25 @@ void main() { test('updatePolygons passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const Polygon object1 = Polygon(polygonId: PolygonId('1')); const Polygon object2old = Polygon(polygonId: PolygonId('2')); final Polygon object2new = object2old.copyWith(strokeWidthParam: 42); const Polygon object3 = Polygon(polygonId: PolygonId('3')); await maps.updatePolygons( - PolygonUpdates.from( - {object1, object2old}, {object2new, object3}), - mapId: mapId); + PolygonUpdates.from( + {object1, object2old}, + {object2new, object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updatePolygons(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updatePolygons(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toChange = @@ -537,26 +624,37 @@ void main() { test('updatePolylines passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const Polyline object1 = Polyline(polylineId: PolylineId('1')); const Polyline object2old = Polyline(polylineId: PolylineId('2')); final Polyline object2new = object2old.copyWith( - widthParam: 42, startCapParam: Cap.squareCap, endCapParam: Cap.buttCap); - final Cap customCap = - Cap.customCapFromBitmap(BitmapDescriptor.defaultMarker, refWidth: 15); + widthParam: 42, + startCapParam: Cap.squareCap, + endCapParam: Cap.buttCap, + ); + final Cap customCap = Cap.customCapFromBitmap( + BitmapDescriptor.defaultMarker, + refWidth: 15, + ); final Polyline object3 = Polyline( - polylineId: const PolylineId('3'), - startCap: customCap, - endCap: Cap.roundCap); + polylineId: const PolylineId('3'), + startCap: customCap, + endCap: Cap.roundCap, + ); await maps.updatePolylines( - PolylineUpdates.from( - {object1, object2old}, {object2new, object3}), - mapId: mapId); + PolylineUpdates.from( + {object1, object2old}, + {object2new, object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updatePolylines(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updatePolylines(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toChange = @@ -568,7 +666,9 @@ void main() { expect(actual.color, expected.color.value); expect(actual.geodesic, expected.geodesic); expect( - actual.jointType, platformJointTypeFromJointType(expected.jointType)); + actual.jointType, + platformJointTypeFromJointType(expected.jointType), + ); expect(actual.visible, expected.visible); expect(actual.width, expected.width); expect(actual.zIndex, expected.zIndex); @@ -580,8 +680,10 @@ void main() { expect(actual.patterns.length, expected.patterns.length); for (final (int i, PlatformPatternItem? pattern) in actual.patterns.indexed) { - expect(pattern?.encode(), - platformPatternItemFromPatternItem(expected.patterns[i]).encode()); + expect( + pattern?.encode(), + platformPatternItemFromPatternItem(expected.patterns[i]).encode(), + ); } } @@ -598,25 +700,32 @@ void main() { test('updateTileOverlays passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const TileOverlay object1 = TileOverlay(tileOverlayId: TileOverlayId('1')); - const TileOverlay object2old = - TileOverlay(tileOverlayId: TileOverlayId('2')); + const TileOverlay object2old = TileOverlay( + tileOverlayId: TileOverlayId('2'), + ); final TileOverlay object2new = object2old.copyWith(zIndexParam: 42); const TileOverlay object3 = TileOverlay(tileOverlayId: TileOverlayId('3')); // Pre-set the initial state, since this update method doesn't take the old // state. await maps.updateTileOverlays( - newTileOverlays: {object1, object2old}, mapId: mapId); + newTileOverlays: {object1, object2old}, + mapId: mapId, + ); clearInteractions(api); await maps.updateTileOverlays( - newTileOverlays: {object2new, object3}, mapId: mapId); + newTileOverlays: {object2new, object3}, + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updateTileOverlays(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updateTileOverlays(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; final List toChange = @@ -644,8 +753,9 @@ void main() { test('updateGroundOverlays passes expected arguments', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final AssetMapBitmap image = AssetMapBitmap( 'assets/red_square.png', @@ -656,13 +766,17 @@ void main() { final GroundOverlay object1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('1'), bounds: LatLngBounds( - southwest: const LatLng(10, 20), northeast: const LatLng(30, 40)), + southwest: const LatLng(10, 20), + northeast: const LatLng(30, 40), + ), image: image, ); final GroundOverlay object2old = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('2'), bounds: LatLngBounds( - southwest: const LatLng(10, 20), northeast: const LatLng(30, 40)), + southwest: const LatLng(10, 20), + northeast: const LatLng(30, 40), + ), image: image, ); final GroundOverlay object2new = object2old.copyWith( @@ -680,12 +794,16 @@ void main() { zoomLevel: 14.0, ); await maps.updateGroundOverlays( - GroundOverlayUpdates.from({object1, object2old}, - {object2new, object3}), - mapId: mapId); + GroundOverlayUpdates.from( + {object1, object2old}, + {object2new, object3}, + ), + mapId: mapId, + ); - final VerificationResult verification = - verify(api.updateGroundOverlays(captureAny, captureAny, captureAny)); + final VerificationResult verification = verify( + api.updateGroundOverlays(captureAny, captureAny, captureAny), + ); final List toAdd = verification.captured[0] as List; @@ -702,14 +820,22 @@ void main() { expect(firstChanged.anchor?.x, object2new.anchor?.dx); expect(firstChanged.anchor?.y, object2new.anchor?.dy); expect(firstChanged.bearing, object2new.bearing); - expect(firstChanged.bounds?.northeast.latitude, - object2new.bounds?.northeast.latitude); - expect(firstChanged.bounds?.northeast.longitude, - object2new.bounds?.northeast.longitude); - expect(firstChanged.bounds?.southwest.latitude, - object2new.bounds?.southwest.latitude); - expect(firstChanged.bounds?.southwest.longitude, - object2new.bounds?.southwest.longitude); + expect( + firstChanged.bounds?.northeast.latitude, + object2new.bounds?.northeast.latitude, + ); + expect( + firstChanged.bounds?.northeast.longitude, + object2new.bounds?.northeast.longitude, + ); + expect( + firstChanged.bounds?.southwest.latitude, + object2new.bounds?.southwest.latitude, + ); + expect( + firstChanged.bounds?.southwest.longitude, + object2new.bounds?.southwest.longitude, + ); expect(firstChanged.visible, object2new.visible); expect(firstChanged.clickable, object2new.clickable); expect(firstChanged.zIndex, object2new.zIndex); @@ -718,11 +844,11 @@ void main() { expect(firstChanged.zoomLevel, object2new.zoomLevel); expect(firstChanged.transparency, object2new.transparency); expect( - firstChanged.image.bitmap.runtimeType, - GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor( - object2new.image) - .bitmap - .runtimeType); + firstChanged.image.bitmap.runtimeType, + GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor( + object2new.image, + ).bitmap.runtimeType, + ); } // Object three should be added. { @@ -731,14 +857,22 @@ void main() { expect(firstAdded.anchor?.x, object3.anchor?.dx); expect(firstAdded.anchor?.y, object3.anchor?.dy); expect(firstAdded.bearing, object3.bearing); - expect(firstAdded.bounds?.northeast.latitude, - object3.bounds?.northeast.latitude); - expect(firstAdded.bounds?.northeast.longitude, - object3.bounds?.northeast.longitude); - expect(firstAdded.bounds?.southwest.latitude, - object3.bounds?.southwest.latitude); - expect(firstAdded.bounds?.southwest.longitude, - object3.bounds?.southwest.longitude); + expect( + firstAdded.bounds?.northeast.latitude, + object3.bounds?.northeast.latitude, + ); + expect( + firstAdded.bounds?.northeast.longitude, + object3.bounds?.northeast.longitude, + ); + expect( + firstAdded.bounds?.southwest.latitude, + object3.bounds?.southwest.latitude, + ); + expect( + firstAdded.bounds?.southwest.longitude, + object3.bounds?.southwest.longitude, + ); expect(firstAdded.visible, object3.visible); expect(firstAdded.clickable, object3.clickable); expect(firstAdded.zIndex, object3.zIndex); @@ -747,56 +881,64 @@ void main() { expect(firstAdded.zoomLevel, object3.zoomLevel); expect(firstAdded.transparency, object3.transparency); expect( - firstAdded.image.bitmap.runtimeType, - GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(object3.image) - .bitmap - .runtimeType); + firstAdded.image.bitmap.runtimeType, + GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor( + object3.image, + ).bitmap.runtimeType, + ); } }); test( - 'updateGroundOverlays throws assertion error on unsupported ground overlays', - () async { - const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); - - final AssetMapBitmap image = AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 1.0, - bitmapScaling: MapBitmapScaling.none, - ); - - final GroundOverlay object3 = GroundOverlay.fromPosition( - groundOverlayId: const GroundOverlayId('1'), - position: const LatLng(10, 20), - // Assert should be thrown because zoomLevel is not set for position-based - // ground overlay on iOS. - // ignore: avoid_redundant_argument_values - zoomLevel: null, - image: image, - ); + 'updateGroundOverlays throws assertion error on unsupported ground overlays', + () async { + const int mapId = 1; + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); + + final AssetMapBitmap image = AssetMapBitmap( + 'assets/red_square.png', + imagePixelRatio: 1.0, + bitmapScaling: MapBitmapScaling.none, + ); + + final GroundOverlay object3 = GroundOverlay.fromPosition( + groundOverlayId: const GroundOverlayId('1'), + position: const LatLng(10, 20), + // Assert should be thrown because zoomLevel is not set for position-based + // ground overlay on iOS. + // ignore: avoid_redundant_argument_values + zoomLevel: null, + image: image, + ); - expect( - () async => maps.updateGroundOverlays( - GroundOverlayUpdates.from( - const {}, {object3}), - mapId: mapId), - throwsAssertionError, - ); - }); + expect( + () async => maps.updateGroundOverlays( + GroundOverlayUpdates.from(const {}, { + object3, + }), + mapId: mapId, + ), + throwsAssertionError, + ); + }, + ); test('markers send drag event to correct streams', () async { const int mapId = 1; const String dragStartId = 'drag-start-marker'; const String dragId = 'drag-marker'; const String dragEndId = 'drag-end-marker'; - final PlatformLatLng fakePosition = - PlatformLatLng(latitude: 1.0, longitude: 1.0); + final PlatformLatLng fakePosition = PlatformLatLng( + latitude: 1.0, + longitude: 1.0, + ); final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); final StreamQueue markerDragStartStream = StreamQueue(maps.onMarkerDragStart(mapId: mapId)); @@ -820,11 +962,13 @@ void main() { const String objectId = 'object-id'; final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); - final StreamQueue stream = - StreamQueue(maps.onMarkerTap(mapId: mapId)); + final StreamQueue stream = StreamQueue( + maps.onMarkerTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onMarkerTap(objectId); @@ -837,11 +981,13 @@ void main() { const String objectId = 'object-id'; final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); - final StreamQueue stream = - StreamQueue(maps.onCircleTap(mapId: mapId)); + final StreamQueue stream = StreamQueue( + maps.onCircleTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onCircleTap(objectId); @@ -852,24 +998,30 @@ void main() { test('clusters send tap events to correct stream', () async { const int mapId = 1; const String managerId = 'manager-id'; - final PlatformLatLng fakePosition = - PlatformLatLng(latitude: 10, longitude: 20); + final PlatformLatLng fakePosition = PlatformLatLng( + latitude: 10, + longitude: 20, + ); final PlatformLatLngBounds fakeBounds = PlatformLatLngBounds( - southwest: PlatformLatLng(latitude: 30, longitude: 40), - northeast: PlatformLatLng(latitude: 50, longitude: 60)); + southwest: PlatformLatLng(latitude: 30, longitude: 40), + northeast: PlatformLatLng(latitude: 50, longitude: 60), + ); const List markerIds = ['marker-1', 'marker-2']; final PlatformCluster cluster = PlatformCluster( - clusterManagerId: managerId, - position: fakePosition, - bounds: fakeBounds, - markerIds: markerIds); + clusterManagerId: managerId, + position: fakePosition, + bounds: fakeBounds, + markerIds: markerIds, + ); final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); - final StreamQueue stream = - StreamQueue(maps.onClusterTap(mapId: mapId)); + final StreamQueue stream = StreamQueue( + maps.onClusterTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onClusterTap(cluster); @@ -880,10 +1032,14 @@ void main() { expect(eventValue.position.longitude, fakePosition.longitude); expect(eventValue.bounds.southwest.latitude, fakeBounds.southwest.latitude); expect( - eventValue.bounds.southwest.longitude, fakeBounds.southwest.longitude); + eventValue.bounds.southwest.longitude, + fakeBounds.southwest.longitude, + ); expect(eventValue.bounds.northeast.latitude, fakeBounds.northeast.latitude); expect( - eventValue.bounds.northeast.longitude, fakeBounds.northeast.longitude); + eventValue.bounds.northeast.longitude, + fakeBounds.northeast.longitude, + ); expect(eventValue.markerIds.length, markerIds.length); expect(eventValue.markerIds.first.value, markerIds.first); }); @@ -893,11 +1049,13 @@ void main() { const String objectId = 'object-id'; final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); - final StreamQueue stream = - StreamQueue(maps.onPolygonTap(mapId: mapId)); + final StreamQueue stream = StreamQueue( + maps.onPolygonTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onPolygonTap(objectId); @@ -910,11 +1068,13 @@ void main() { const String objectId = 'object-id'; final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); - final StreamQueue stream = - StreamQueue(maps.onPolylineTap(mapId: mapId)); + final StreamQueue stream = StreamQueue( + maps.onPolylineTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onPolylineTap(objectId); @@ -927,12 +1087,14 @@ void main() { const String objectId = 'object-id'; final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); - final HostMapMessageHandler callbackHandler = - maps.ensureHandlerInitialized(mapId); + final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( + mapId, + ); final StreamQueue stream = StreamQueue( - maps.onGroundOverlayTap(mapId: mapId)); + maps.onGroundOverlayTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onGroundOverlayTap(objectId); @@ -942,8 +1104,9 @@ void main() { test('moveCamera calls through with expected newCameraPosition', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const LatLng latLng = LatLng(10.0, 20.0); const CameraPosition position = CameraPosition(target: latLng); @@ -956,16 +1119,21 @@ void main() { final PlatformCameraUpdateNewCameraPosition typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewCameraPosition; update as CameraUpdateNewCameraPosition; - expect(typedUpdate.cameraPosition.target.latitude, - update.cameraPosition.target.latitude); - expect(typedUpdate.cameraPosition.target.longitude, - update.cameraPosition.target.longitude); + expect( + typedUpdate.cameraPosition.target.latitude, + update.cameraPosition.target.latitude, + ); + expect( + typedUpdate.cameraPosition.target.longitude, + update.cameraPosition.target.longitude, + ); }); test('moveCamera calls through with expected newLatLng', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const LatLng latLng = LatLng(10.0, 20.0); final CameraUpdate update = CameraUpdate.newLatLng(latLng); @@ -983,12 +1151,14 @@ void main() { test('moveCamera calls through with expected newLatLngBounds', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final LatLngBounds latLng = LatLngBounds( - northeast: const LatLng(10.0, 20.0), - southwest: const LatLng(9.0, 21.0)); + northeast: const LatLng(10.0, 20.0), + southwest: const LatLng(9.0, 21.0), + ); final CameraUpdate update = CameraUpdate.newLatLngBounds(latLng, 1.0); await maps.moveCamera(update, mapId: mapId); @@ -998,21 +1168,30 @@ void main() { final PlatformCameraUpdateNewLatLngBounds typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLngBounds; update as CameraUpdateNewLatLngBounds; - expect(typedUpdate.bounds.northeast.latitude, - update.bounds.northeast.latitude); - expect(typedUpdate.bounds.northeast.longitude, - update.bounds.northeast.longitude); - expect(typedUpdate.bounds.southwest.latitude, - update.bounds.southwest.latitude); - expect(typedUpdate.bounds.southwest.longitude, - update.bounds.southwest.longitude); + expect( + typedUpdate.bounds.northeast.latitude, + update.bounds.northeast.latitude, + ); + expect( + typedUpdate.bounds.northeast.longitude, + update.bounds.northeast.longitude, + ); + expect( + typedUpdate.bounds.southwest.latitude, + update.bounds.southwest.latitude, + ); + expect( + typedUpdate.bounds.southwest.longitude, + update.bounds.southwest.longitude, + ); expect(typedUpdate.padding, update.padding); }); test('moveCamera calls through with expected newLatLngZoom', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const LatLng latLng = LatLng(10.0, 20.0); final CameraUpdate update = CameraUpdate.newLatLngZoom(latLng, 2.0); @@ -1031,8 +1210,9 @@ void main() { test('moveCamera calls through with expected zoomBy', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); const Offset focus = Offset(10.0, 20.0); final CameraUpdate update = CameraUpdate.zoomBy(2.0, focus); @@ -1051,8 +1231,9 @@ void main() { test('moveCamera calls through with expected zoomTo', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.zoomTo(2.0); await maps.moveCamera(update, mapId: mapId); @@ -1068,8 +1249,9 @@ void main() { test('moveCamera calls through with expected zoomIn', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.zoomIn(); await maps.moveCamera(update, mapId: mapId); @@ -1084,8 +1266,9 @@ void main() { test('moveCamera calls through with expected zoomOut', () async { const int mapId = 1; - final (GoogleMapsFlutterIOS maps, MockMapsApi api) = - setUpMockMap(mapId: mapId); + final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( + mapId: mapId, + ); final CameraUpdate update = CameraUpdate.zoomOut(); await maps.moveCamera(update, mapId: mapId); @@ -1100,13 +1283,17 @@ void main() { test('MapBitmapScaling to PlatformMapBitmapScaling', () { expect( - GoogleMapsFlutterIOS.platformMapBitmapScalingFromScaling( - MapBitmapScaling.auto), - PlatformMapBitmapScaling.auto); + GoogleMapsFlutterIOS.platformMapBitmapScalingFromScaling( + MapBitmapScaling.auto, + ), + PlatformMapBitmapScaling.auto, + ); expect( - GoogleMapsFlutterIOS.platformMapBitmapScalingFromScaling( - MapBitmapScaling.none), - PlatformMapBitmapScaling.none); + GoogleMapsFlutterIOS.platformMapBitmapScalingFromScaling( + MapBitmapScaling.none, + ), + PlatformMapBitmapScaling.none, + ); }); test('DefaultMarker bitmap to PlatformBitmap', () { @@ -1121,8 +1308,12 @@ void main() { test('BytesMapBitmap bitmap to PlatformBitmap', () { final Uint8List data = Uint8List.fromList([1, 2, 3, 4]); - final BytesMapBitmap bitmap = BitmapDescriptor.bytes(data, - imagePixelRatio: 2.0, width: 100.0, height: 200.0); + final BytesMapBitmap bitmap = BitmapDescriptor.bytes( + data, + imagePixelRatio: 2.0, + width: 100.0, + height: 200.0, + ); final PlatformBitmap platformBitmap = GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(bitmap); expect(platformBitmap.bitmap, isA()); @@ -1137,8 +1328,12 @@ void main() { test('AssetMapBitmap bitmap to PlatformBitmap', () { const String assetName = 'fake_asset_name'; - final AssetMapBitmap bitmap = AssetMapBitmap(assetName, - imagePixelRatio: 2.0, width: 100.0, height: 200.0); + final AssetMapBitmap bitmap = AssetMapBitmap( + assetName, + imagePixelRatio: 2.0, + width: 100.0, + height: 200.0, + ); final PlatformBitmap platformBitmap = GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(bitmap); expect(platformBitmap.bitmap, isA()); @@ -1156,41 +1351,50 @@ void main() { final Completer passedCloudMapIdCompleter = Completer(); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler( - SystemChannels.platform_views, - (MethodCall methodCall) { - if (methodCall.method == 'create') { - final Map args = Map.from( - methodCall.arguments as Map); - if (args.containsKey('params')) { - final Uint8List paramsUint8List = args['params'] as Uint8List; - final ByteData byteData = ByteData.sublistView(paramsUint8List); - final PlatformMapViewCreationParams? creationParams = - MapsApi.pigeonChannelCodec.decodeMessage(byteData) - as PlatformMapViewCreationParams?; - if (creationParams != null) { - final String? passedMapId = - creationParams.mapConfiguration.cloudMapId; - if (passedMapId != null) { - passedCloudMapIdCompleter.complete(passedMapId); + .setMockMethodCallHandler(SystemChannels.platform_views, ( + MethodCall methodCall, + ) { + if (methodCall.method == 'create') { + final Map args = Map.from( + methodCall.arguments as Map, + ); + if (args.containsKey('params')) { + final Uint8List paramsUint8List = args['params'] as Uint8List; + final ByteData byteData = ByteData.sublistView(paramsUint8List); + final PlatformMapViewCreationParams? creationParams = + MapsApi.pigeonChannelCodec.decodeMessage(byteData) + as PlatformMapViewCreationParams?; + if (creationParams != null) { + final String? passedMapId = + creationParams.mapConfiguration.cloudMapId; + if (passedMapId != null) { + passedCloudMapIdCompleter.complete(passedMapId); + } } } } - } - return null; - }, - ); + return null; + }); final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); - await tester.pumpWidget(Directionality( + await tester.pumpWidget( + Directionality( textDirection: TextDirection.ltr, - child: maps.buildViewWithConfiguration(1, (int id) {}, - widgetConfiguration: const MapWidgetConfiguration( - initialCameraPosition: - CameraPosition(target: LatLng(0, 0), zoom: 1), - textDirection: TextDirection.ltr), - mapConfiguration: const MapConfiguration(cloudMapId: cloudMapId)))); + child: maps.buildViewWithConfiguration( + 1, + (int id) {}, + widgetConfiguration: const MapWidgetConfiguration( + initialCameraPosition: CameraPosition( + target: LatLng(0, 0), + zoom: 1, + ), + textDirection: TextDirection.ltr, + ), + mapConfiguration: const MapConfiguration(cloudMapId: cloudMapId), + ), + ), + ); expect( await passedCloudMapIdCompleter.future, diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.mocks.dart b/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.mocks.dart index 8d64047847f..d7b768353fe 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.mocks.dart +++ b/packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.mocks.dart @@ -26,19 +26,19 @@ import 'package:mockito/src/dummies.dart' as _i3; class _FakePlatformPoint_0 extends _i1.SmartFake implements _i2.PlatformPoint { _FakePlatformPoint_0(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakePlatformLatLng_1 extends _i1.SmartFake implements _i2.PlatformLatLng { _FakePlatformLatLng_1(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } class _FakePlatformLatLngBounds_2 extends _i1.SmartFake implements _i2.PlatformLatLngBounds { _FakePlatformLatLngBounds_2(Object parent, Invocation parentInvocation) - : super(parent, parentInvocation); + : super(parent, parentInvocation); } /// A class which mocks [MapsApi]. @@ -46,34 +46,39 @@ class _FakePlatformLatLngBounds_2 extends _i1.SmartFake /// See the documentation for Mockito's code generation for more information. class MockMapsApi extends _i1.Mock implements _i2.MapsApi { @override - String get pigeonVar_messageChannelSuffix => (super.noSuchMethod( - Invocation.getter(#pigeonVar_messageChannelSuffix), - returnValue: _i3.dummyValue( - this, - Invocation.getter(#pigeonVar_messageChannelSuffix), - ), - returnValueForMissingStub: _i3.dummyValue( - this, - Invocation.getter(#pigeonVar_messageChannelSuffix), - ), - ) as String); + String get pigeonVar_messageChannelSuffix => + (super.noSuchMethod( + Invocation.getter(#pigeonVar_messageChannelSuffix), + returnValue: _i3.dummyValue( + this, + Invocation.getter(#pigeonVar_messageChannelSuffix), + ), + returnValueForMissingStub: _i3.dummyValue( + this, + Invocation.getter(#pigeonVar_messageChannelSuffix), + ), + ) + as String); @override - _i4.Future waitForMap() => (super.noSuchMethod( - Invocation.method(#waitForMap, []), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future waitForMap() => + (super.noSuchMethod( + Invocation.method(#waitForMap, []), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateMapConfiguration( _i2.PlatformMapConfiguration? configuration, ) => (super.noSuchMethod( - Invocation.method(#updateMapConfiguration, [configuration]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateMapConfiguration, [configuration]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateCircles( @@ -82,10 +87,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method(#updateCircles, [toAdd, toChange, idsToRemove]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateCircles, [toAdd, toChange, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateHeatmaps( @@ -94,10 +100,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method(#updateHeatmaps, [toAdd, toChange, idsToRemove]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateHeatmaps, [toAdd, toChange, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateClusterManagers( @@ -105,10 +112,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method(#updateClusterManagers, [toAdd, idsToRemove]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateClusterManagers, [toAdd, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateMarkers( @@ -117,10 +125,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method(#updateMarkers, [toAdd, toChange, idsToRemove]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateMarkers, [toAdd, toChange, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updatePolygons( @@ -129,10 +138,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method(#updatePolygons, [toAdd, toChange, idsToRemove]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updatePolygons, [toAdd, toChange, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updatePolylines( @@ -141,10 +151,11 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method(#updatePolylines, [toAdd, toChange, idsToRemove]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updatePolylines, [toAdd, toChange, idsToRemove]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateTileOverlays( @@ -153,14 +164,15 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method(#updateTileOverlays, [ - toAdd, - toChange, - idsToRemove, - ]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateTileOverlays, [ + toAdd, + toChange, + idsToRemove, + ]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future updateGroundOverlays( @@ -169,80 +181,86 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { List? idsToRemove, ) => (super.noSuchMethod( - Invocation.method(#updateGroundOverlays, [ - toAdd, - toChange, - idsToRemove, - ]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#updateGroundOverlays, [ + toAdd, + toChange, + idsToRemove, + ]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future<_i2.PlatformPoint> getScreenCoordinate( _i2.PlatformLatLng? latLng, ) => (super.noSuchMethod( - Invocation.method(#getScreenCoordinate, [latLng]), - returnValue: _i4.Future<_i2.PlatformPoint>.value( - _FakePlatformPoint_0( - this, Invocation.method(#getScreenCoordinate, [latLng]), - ), - ), - returnValueForMissingStub: _i4.Future<_i2.PlatformPoint>.value( - _FakePlatformPoint_0( - this, - Invocation.method(#getScreenCoordinate, [latLng]), - ), - ), - ) as _i4.Future<_i2.PlatformPoint>); + returnValue: _i4.Future<_i2.PlatformPoint>.value( + _FakePlatformPoint_0( + this, + Invocation.method(#getScreenCoordinate, [latLng]), + ), + ), + returnValueForMissingStub: _i4.Future<_i2.PlatformPoint>.value( + _FakePlatformPoint_0( + this, + Invocation.method(#getScreenCoordinate, [latLng]), + ), + ), + ) + as _i4.Future<_i2.PlatformPoint>); @override _i4.Future<_i2.PlatformLatLng> getLatLng( _i2.PlatformPoint? screenCoordinate, ) => (super.noSuchMethod( - Invocation.method(#getLatLng, [screenCoordinate]), - returnValue: _i4.Future<_i2.PlatformLatLng>.value( - _FakePlatformLatLng_1( - this, - Invocation.method(#getLatLng, [screenCoordinate]), - ), - ), - returnValueForMissingStub: _i4.Future<_i2.PlatformLatLng>.value( - _FakePlatformLatLng_1( - this, Invocation.method(#getLatLng, [screenCoordinate]), - ), - ), - ) as _i4.Future<_i2.PlatformLatLng>); + returnValue: _i4.Future<_i2.PlatformLatLng>.value( + _FakePlatformLatLng_1( + this, + Invocation.method(#getLatLng, [screenCoordinate]), + ), + ), + returnValueForMissingStub: _i4.Future<_i2.PlatformLatLng>.value( + _FakePlatformLatLng_1( + this, + Invocation.method(#getLatLng, [screenCoordinate]), + ), + ), + ) + as _i4.Future<_i2.PlatformLatLng>); @override _i4.Future<_i2.PlatformLatLngBounds> getVisibleRegion() => (super.noSuchMethod( - Invocation.method(#getVisibleRegion, []), - returnValue: _i4.Future<_i2.PlatformLatLngBounds>.value( - _FakePlatformLatLngBounds_2( - this, Invocation.method(#getVisibleRegion, []), - ), - ), - returnValueForMissingStub: _i4.Future<_i2.PlatformLatLngBounds>.value( - _FakePlatformLatLngBounds_2( - this, - Invocation.method(#getVisibleRegion, []), - ), - ), - ) as _i4.Future<_i2.PlatformLatLngBounds>); + returnValue: _i4.Future<_i2.PlatformLatLngBounds>.value( + _FakePlatformLatLngBounds_2( + this, + Invocation.method(#getVisibleRegion, []), + ), + ), + returnValueForMissingStub: + _i4.Future<_i2.PlatformLatLngBounds>.value( + _FakePlatformLatLngBounds_2( + this, + Invocation.method(#getVisibleRegion, []), + ), + ), + ) + as _i4.Future<_i2.PlatformLatLngBounds>); @override _i4.Future moveCamera(_i2.PlatformCameraUpdate? cameraUpdate) => (super.noSuchMethod( - Invocation.method(#moveCamera, [cameraUpdate]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#moveCamera, [cameraUpdate]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override _i4.Future animateCamera( @@ -250,67 +268,84 @@ class MockMapsApi extends _i1.Mock implements _i2.MapsApi { int? durationMilliseconds, ) => (super.noSuchMethod( - Invocation.method(#animateCamera, [ - cameraUpdate, - durationMilliseconds, - ]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + Invocation.method(#animateCamera, [ + cameraUpdate, + durationMilliseconds, + ]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override - _i4.Future getZoomLevel() => (super.noSuchMethod( - Invocation.method(#getZoomLevel, []), - returnValue: _i4.Future.value(0.0), - returnValueForMissingStub: _i4.Future.value(0.0), - ) as _i4.Future); + _i4.Future getZoomLevel() => + (super.noSuchMethod( + Invocation.method(#getZoomLevel, []), + returnValue: _i4.Future.value(0.0), + returnValueForMissingStub: _i4.Future.value(0.0), + ) + as _i4.Future); @override - _i4.Future showInfoWindow(String? markerId) => (super.noSuchMethod( - Invocation.method(#showInfoWindow, [markerId]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future showInfoWindow(String? markerId) => + (super.noSuchMethod( + Invocation.method(#showInfoWindow, [markerId]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override - _i4.Future hideInfoWindow(String? markerId) => (super.noSuchMethod( - Invocation.method(#hideInfoWindow, [markerId]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future hideInfoWindow(String? markerId) => + (super.noSuchMethod( + Invocation.method(#hideInfoWindow, [markerId]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override - _i4.Future isInfoWindowShown(String? markerId) => (super.noSuchMethod( - Invocation.method(#isInfoWindowShown, [markerId]), - returnValue: _i4.Future.value(false), - returnValueForMissingStub: _i4.Future.value(false), - ) as _i4.Future); + _i4.Future isInfoWindowShown(String? markerId) => + (super.noSuchMethod( + Invocation.method(#isInfoWindowShown, [markerId]), + returnValue: _i4.Future.value(false), + returnValueForMissingStub: _i4.Future.value(false), + ) + as _i4.Future); @override - _i4.Future setStyle(String? style) => (super.noSuchMethod( - Invocation.method(#setStyle, [style]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future setStyle(String? style) => + (super.noSuchMethod( + Invocation.method(#setStyle, [style]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override - _i4.Future getLastStyleError() => (super.noSuchMethod( - Invocation.method(#getLastStyleError, []), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future getLastStyleError() => + (super.noSuchMethod( + Invocation.method(#getLastStyleError, []), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override - _i4.Future clearTileCache(String? tileOverlayId) => (super.noSuchMethod( - Invocation.method(#clearTileCache, [tileOverlayId]), - returnValue: _i4.Future.value(), - returnValueForMissingStub: _i4.Future.value(), - ) as _i4.Future); + _i4.Future clearTileCache(String? tileOverlayId) => + (super.noSuchMethod( + Invocation.method(#clearTileCache, [tileOverlayId]), + returnValue: _i4.Future.value(), + returnValueForMissingStub: _i4.Future.value(), + ) + as _i4.Future); @override - _i4.Future<_i5.Uint8List?> takeSnapshot() => (super.noSuchMethod( - Invocation.method(#takeSnapshot, []), - returnValue: _i4.Future<_i5.Uint8List?>.value(), - returnValueForMissingStub: _i4.Future<_i5.Uint8List?>.value(), - ) as _i4.Future<_i5.Uint8List?>); + _i4.Future<_i5.Uint8List?> takeSnapshot() => + (super.noSuchMethod( + Invocation.method(#takeSnapshot, []), + returnValue: _i4.Future<_i5.Uint8List?>.value(), + returnValueForMissingStub: _i4.Future<_i5.Uint8List?>.value(), + ) + as _i4.Future<_i5.Uint8List?>); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md index ed666da52c9..20585d0257d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. + ## 2.13.0 * Adds Advanced marker support. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart index 254a5444dc7..2bbd3075af4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/method_channel_google_maps_flutter.dart @@ -72,7 +72,8 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { if (channel == null) { channel = MethodChannel('plugins.flutter.io/google_maps_$mapId'); channel.setMethodCallHandler( - (MethodCall call) => _handleMethodCall(call, mapId)); + (MethodCall call) => _handleMethodCall(call, mapId), + ); _channels[mapId] = channel; } return channel; @@ -98,9 +99,9 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { StreamController>.broadcast(); // Returns a filtered view of the events in the _controller, by mapId. - Stream> _events(int mapId) => - _mapEventStreamController.stream - .where((MapEvent event) => event.mapId == mapId); + Stream> _events(int mapId) => _mapEventStreamController + .stream + .where((MapEvent event) => event.mapId == mapId); @override Stream onCameraMoveStarted({required int mapId}) { @@ -178,75 +179,79 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { _mapEventStreamController.add(CameraMoveStartedEvent(mapId)); case 'camera#onMove': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(CameraMoveEvent( - mapId, - CameraPosition.fromMap(arguments['position'])!, - )); + _mapEventStreamController.add( + CameraMoveEvent( + mapId, + CameraPosition.fromMap(arguments['position'])!, + ), + ); case 'camera#onIdle': _mapEventStreamController.add(CameraIdleEvent(mapId)); case 'marker#onTap': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(MarkerTapEvent( - mapId, - MarkerId(arguments['markerId']! as String), - )); + _mapEventStreamController.add( + MarkerTapEvent(mapId, MarkerId(arguments['markerId']! as String)), + ); case 'marker#onDragStart': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(MarkerDragStartEvent( - mapId, - LatLng.fromJson(arguments['position'])!, - MarkerId(arguments['markerId']! as String), - )); + _mapEventStreamController.add( + MarkerDragStartEvent( + mapId, + LatLng.fromJson(arguments['position'])!, + MarkerId(arguments['markerId']! as String), + ), + ); case 'marker#onDrag': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(MarkerDragEvent( - mapId, - LatLng.fromJson(arguments['position'])!, - MarkerId(arguments['markerId']! as String), - )); + _mapEventStreamController.add( + MarkerDragEvent( + mapId, + LatLng.fromJson(arguments['position'])!, + MarkerId(arguments['markerId']! as String), + ), + ); case 'marker#onDragEnd': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(MarkerDragEndEvent( - mapId, - LatLng.fromJson(arguments['position'])!, - MarkerId(arguments['markerId']! as String), - )); + _mapEventStreamController.add( + MarkerDragEndEvent( + mapId, + LatLng.fromJson(arguments['position'])!, + MarkerId(arguments['markerId']! as String), + ), + ); case 'infoWindow#onTap': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(InfoWindowTapEvent( - mapId, - MarkerId(arguments['markerId']! as String), - )); + _mapEventStreamController.add( + InfoWindowTapEvent(mapId, MarkerId(arguments['markerId']! as String)), + ); case 'polyline#onTap': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(PolylineTapEvent( - mapId, - PolylineId(arguments['polylineId']! as String), - )); + _mapEventStreamController.add( + PolylineTapEvent( + mapId, + PolylineId(arguments['polylineId']! as String), + ), + ); case 'polygon#onTap': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(PolygonTapEvent( - mapId, - PolygonId(arguments['polygonId']! as String), - )); + _mapEventStreamController.add( + PolygonTapEvent(mapId, PolygonId(arguments['polygonId']! as String)), + ); case 'circle#onTap': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(CircleTapEvent( - mapId, - CircleId(arguments['circleId']! as String), - )); + _mapEventStreamController.add( + CircleTapEvent(mapId, CircleId(arguments['circleId']! as String)), + ); case 'map#onTap': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(MapTapEvent( - mapId, - LatLng.fromJson(arguments['position'])!, - )); + _mapEventStreamController.add( + MapTapEvent(mapId, LatLng.fromJson(arguments['position'])!), + ); case 'map#onLongPress': final Map arguments = _getArgumentDictionary(call); - _mapEventStreamController.add(MapLongPressEvent( - mapId, - LatLng.fromJson(arguments['position'])!, - )); + _mapEventStreamController.add( + MapLongPressEvent(mapId, LatLng.fromJson(arguments['position'])!), + ); case 'tileOverlay#getTile': final Map arguments = _getArgumentDictionary(call); final Map? tileOverlaysForThisMap = @@ -266,34 +271,40 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { return tile.toJson(); case 'cluster#onTap': final Map arguments = _getArgumentDictionary(call); - final ClusterManagerId clusterManagerId = - ClusterManagerId(arguments['clusterManagerId']! as String); + final ClusterManagerId clusterManagerId = ClusterManagerId( + arguments['clusterManagerId']! as String, + ); final LatLng position = LatLng.fromJson(arguments['position'])!; final Map> latLngData = (arguments['bounds']! as Map).map( - (dynamic key, dynamic object) => - MapEntry>( - key as String, object as List)); + (dynamic key, dynamic object) => MapEntry>( + key as String, + object as List, + ), + ); final LatLngBounds bounds = LatLngBounds( - northeast: LatLng.fromJson(latLngData['northeast'])!, - southwest: LatLng.fromJson(latLngData['southwest'])!); + northeast: LatLng.fromJson(latLngData['northeast'])!, + southwest: LatLng.fromJson(latLngData['southwest'])!, + ); final List markerIds = (arguments['markerIds']! as List) .map((dynamic markerId) => MarkerId(markerId as String)) .toList(); - _mapEventStreamController.add(ClusterTapEvent( - mapId, - Cluster( - clusterManagerId, - markerIds, - position: position, - bounds: bounds, + _mapEventStreamController.add( + ClusterTapEvent( + mapId, + Cluster( + clusterManagerId, + markerIds, + position: position, + bounds: bounds, + ), ), - )); + ); default: throw MissingPluginException(); } @@ -312,12 +323,9 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { Map optionsUpdate, { required int mapId, }) { - return channel(mapId).invokeMethod( - 'map#update', - { - 'options': optionsUpdate, - }, - ); + return channel(mapId).invokeMethod('map#update', { + 'options': optionsUpdate, + }); } @override @@ -325,10 +333,9 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { MarkerUpdates markerUpdates, { required int mapId, }) { - return channel(mapId).invokeMethod( - 'markers#update', - markerUpdates.toJson(), - ); + return channel( + mapId, + ).invokeMethod('markers#update', markerUpdates.toJson()); } @override @@ -336,10 +343,9 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { PolygonUpdates polygonUpdates, { required int mapId, }) { - return channel(mapId).invokeMethod( - 'polygons#update', - polygonUpdates.toJson(), - ); + return channel( + mapId, + ).invokeMethod('polygons#update', polygonUpdates.toJson()); } @override @@ -347,10 +353,9 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { PolylineUpdates polylineUpdates, { required int mapId, }) { - return channel(mapId).invokeMethod( - 'polylines#update', - polylineUpdates.toJson(), - ); + return channel( + mapId, + ).invokeMethod('polylines#update', polylineUpdates.toJson()); } @override @@ -358,10 +363,9 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { CircleUpdates circleUpdates, { required int mapId, }) { - return channel(mapId).invokeMethod( - 'circles#update', - circleUpdates.toJson(), - ); + return channel( + mapId, + ).invokeMethod('circles#update', circleUpdates.toJson()); } @override @@ -382,16 +386,18 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { }) { final Map? currentTileOverlays = _tileOverlays[mapId]; - final Set previousSet = currentTileOverlays != null - ? currentTileOverlays.values.toSet() - : {}; - final TileOverlayUpdates updates = - TileOverlayUpdates.from(previousSet, newTileOverlays); - _tileOverlays[mapId] = keyTileOverlayId(newTileOverlays); - return channel(mapId).invokeMethod( - 'tileOverlays#update', - updates.toJson(), + final Set previousSet = + currentTileOverlays != null + ? currentTileOverlays.values.toSet() + : {}; + final TileOverlayUpdates updates = TileOverlayUpdates.from( + previousSet, + newTileOverlays, ); + _tileOverlays[mapId] = keyTileOverlayId(newTileOverlays); + return channel( + mapId, + ).invokeMethod('tileOverlays#update', updates.toJson()); } @override @@ -410,39 +416,32 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { TileOverlayId tileOverlayId, { required int mapId, }) { - return channel(mapId) - .invokeMethod('tileOverlays#clearTileCache', { - 'tileOverlayId': tileOverlayId.value, - }); + return channel(mapId).invokeMethod( + 'tileOverlays#clearTileCache', + {'tileOverlayId': tileOverlayId.value}, + ); } @override - Future animateCamera( - CameraUpdate cameraUpdate, { - required int mapId, - }) { + Future animateCamera(CameraUpdate cameraUpdate, {required int mapId}) { return channel(mapId).invokeMethod('camera#animate', { 'cameraUpdate': cameraUpdate.toJson(), }); } @override - Future moveCamera( - CameraUpdate cameraUpdate, { - required int mapId, - }) { + Future moveCamera(CameraUpdate cameraUpdate, {required int mapId}) { return channel(mapId).invokeMethod('camera#move', { 'cameraUpdate': cameraUpdate.toJson(), }); } @override - Future setMapStyle( - String? mapStyle, { - required int mapId, - }) async { - final List successAndError = (await channel(mapId) - .invokeMethod>('map#setStyle', mapStyle))!; + Future setMapStyle(String? mapStyle, {required int mapId}) async { + final List successAndError = + (await channel( + mapId, + ).invokeMethod>('map#setStyle', mapStyle))!; final bool success = successAndError[0] as bool; if (!success) { throw MapStyleException(successAndError[1] as String); @@ -450,11 +449,11 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { } @override - Future getVisibleRegion({ - required int mapId, - }) async { - final Map latLngBounds = (await channel(mapId) - .invokeMapMethod('map#getVisibleRegion'))!; + Future getVisibleRegion({required int mapId}) async { + final Map latLngBounds = + (await channel( + mapId, + ).invokeMapMethod('map#getVisibleRegion'))!; final LatLng southwest = LatLng.fromJson(latLngBounds['southwest'])!; final LatLng northeast = LatLng.fromJson(latLngBounds['northeast'])!; @@ -466,9 +465,11 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { LatLng latLng, { required int mapId, }) async { - final Map point = (await channel(mapId) - .invokeMapMethod( - 'map#getScreenCoordinate', latLng.toJson()))!; + final Map point = + (await channel(mapId).invokeMapMethod( + 'map#getScreenCoordinate', + latLng.toJson(), + ))!; return ScreenCoordinate(x: point['x']!, y: point['y']!); } @@ -478,28 +479,28 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { ScreenCoordinate screenCoordinate, { required int mapId, }) async { - final List latLng = (await channel(mapId) - .invokeMethod>( - 'map#getLatLng', screenCoordinate.toJson()))!; + final List latLng = + (await channel(mapId).invokeMethod>( + 'map#getLatLng', + screenCoordinate.toJson(), + ))!; return LatLng(latLng[0] as double, latLng[1] as double); } @override - Future showMarkerInfoWindow( - MarkerId markerId, { - required int mapId, - }) { + Future showMarkerInfoWindow(MarkerId markerId, {required int mapId}) { return channel(mapId).invokeMethod( - 'markers#showInfoWindow', {'markerId': markerId.value}); + 'markers#showInfoWindow', + {'markerId': markerId.value}, + ); } @override - Future hideMarkerInfoWindow( - MarkerId markerId, { - required int mapId, - }) { + Future hideMarkerInfoWindow(MarkerId markerId, {required int mapId}) { return channel(mapId).invokeMethod( - 'markers#hideInfoWindow', {'markerId': markerId.value}); + 'markers#hideInfoWindow', + {'markerId': markerId.value}, + ); } @override @@ -507,21 +508,19 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { MarkerId markerId, { required int mapId, }) async { - return (await channel(mapId).invokeMethod('markers#isInfoWindowShown', - {'markerId': markerId.value}))!; + return (await channel(mapId).invokeMethod( + 'markers#isInfoWindowShown', + {'markerId': markerId.value}, + ))!; } @override - Future getZoomLevel({ - required int mapId, - }) async { + Future getZoomLevel({required int mapId}) async { return (await channel(mapId).invokeMethod('map#getZoomLevel'))!; } @override - Future takeSnapshot({ - required int mapId, - }) { + Future takeSnapshot({required int mapId}) { return channel(mapId).invokeMethod('map#takeSnapshot'); } @@ -575,19 +574,17 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { onCreatePlatformView: (PlatformViewCreationParams params) { final SurfaceAndroidViewController controller = PlatformViewsService.initSurfaceAndroidView( - id: params.id, - viewType: 'plugins.flutter.io/google_maps', - layoutDirection: widgetConfiguration.textDirection, - creationParams: creationParams, - creationParamsCodec: const StandardMessageCodec(), - onFocus: () => params.onFocusChanged(true), - ); + id: params.id, + viewType: 'plugins.flutter.io/google_maps', + layoutDirection: widgetConfiguration.textDirection, + creationParams: creationParams, + creationParamsCodec: const StandardMessageCodec(), + onFocus: () => params.onFocusChanged(true), + ); controller.addOnPlatformViewCreatedListener( params.onPlatformViewCreated, ); - controller.addOnPlatformViewCreatedListener( - onPlatformViewCreated, - ); + controller.addOnPlatformViewCreatedListener(onPlatformViewCreated); controller.create(); return controller; @@ -613,7 +610,8 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { } return Text( - '$defaultTargetPlatform is not yet supported by the maps plugin'); + '$defaultTargetPlatform is not yet supported by the maps plugin', + ); } @override @@ -652,15 +650,17 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { creationId, onPlatformViewCreated, widgetConfiguration: MapWidgetConfiguration( - initialCameraPosition: initialCameraPosition, - textDirection: textDirection), + initialCameraPosition: initialCameraPosition, + textDirection: textDirection, + ), mapObjects: MapObjects( - markers: markers, - polygons: polygons, - polylines: polylines, - circles: circles, - clusterManagers: clusterManagers, - tileOverlays: tileOverlays), + markers: markers, + polygons: polygons, + polylines: polylines, + circles: circles, + clusterManagers: clusterManagers, + tileOverlays: tileOverlays, + ), mapOptions: mapOptions, ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/serialization.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/serialization.dart index 2a82a05565f..5adee114f2d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/serialization.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/method_channel/serialization.dart @@ -70,15 +70,24 @@ Object serializeHeatmap(Heatmap heatmap) { final HeatmapGradient? gradient = heatmap.gradient; if (gradient != null) { _addIfNonNull( - json, _heatmapGradientKey, serializeHeatmapGradient(gradient)); + json, + _heatmapGradientKey, + serializeHeatmapGradient(gradient), + ); } _addIfNonNull(json, _heatmapMaxIntensityKey, heatmap.maxIntensity); _addIfNonNull(json, _heatmapOpacityKey, heatmap.opacity); _addIfNonNull(json, _heatmapRadiusKey, heatmap.radius.radius); _addIfNonNull( - json, _heatmapMinimumZoomIntensityKey, heatmap.minimumZoomIntensity); + json, + _heatmapMinimumZoomIntensityKey, + heatmap.minimumZoomIntensity, + ); _addIfNonNull( - json, _heatmapMaximumZoomIntensityKey, heatmap.maximumZoomIntensity); + json, + _heatmapMaximumZoomIntensityKey, + heatmap.maximumZoomIntensity, + ); return json; } @@ -140,10 +149,11 @@ HeatmapGradient? deserializeHeatmapGradient(Object? json) { } assert(json is Map); final Map map = (json as Map).cast(); - final List colors = (map[_heatmapGradientColorsKey]! as List) - .whereType() - .map((int e) => Color(e)) - .toList(); + final List colors = + (map[_heatmapGradientColorsKey]! as List) + .whereType() + .map((int e) => Color(e)) + .toList(); final List startPoints = (map[_heatmapGradientStartPointsKey]! as List) .whereType() diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart index b5e6457909c..d22aec057c1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_flutter_platform.dart @@ -73,8 +73,10 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { MapConfiguration configuration, { required int mapId, }) { - return updateMapOptions(jsonForMapConfiguration(configuration), - mapId: mapId); + return updateMapOptions( + jsonForMapConfiguration(configuration), + mapId: mapId, + ); } /// Updates marker configuration. @@ -166,7 +168,8 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { required int mapId, }) { throw UnimplementedError( - 'updateClusterManagers() has not been implemented.'); + 'updateClusterManagers() has not been implemented.', + ); } /// Updates ground overlay configuration. @@ -178,7 +181,8 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { required int mapId, }) { throw UnimplementedError( - 'updateGroundOverlays() has not been implemented.'); + 'updateGroundOverlays() has not been implemented.', + ); } /// Clears the tile cache so that all tiles will be requested again from the @@ -199,10 +203,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// /// The returned [Future] completes after the change has been started on the /// platform side. - Future animateCamera( - CameraUpdate cameraUpdate, { - required int mapId, - }) { + Future animateCamera(CameraUpdate cameraUpdate, {required int mapId}) { throw UnimplementedError('animateCamera() has not been implemented.'); } @@ -223,10 +224,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// /// The returned [Future] completes after the change has been made on the /// platform side. - Future moveCamera( - CameraUpdate cameraUpdate, { - required int mapId, - }) { + Future moveCamera(CameraUpdate cameraUpdate, {required int mapId}) { throw UnimplementedError('moveCamera() has not been implemented.'); } @@ -240,17 +238,12 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// style is left unchanged. /// /// The style string can be generated using [map style tool](https://mapstyle.withgoogle.com/). - Future setMapStyle( - String? mapStyle, { - required int mapId, - }) { + Future setMapStyle(String? mapStyle, {required int mapId}) { throw UnimplementedError('setMapStyle() has not been implemented.'); } /// Return the region that is visible in a map. - Future getVisibleRegion({ - required int mapId, - }) { + Future getVisibleRegion({required int mapId}) { throw UnimplementedError('getVisibleRegion() has not been implemented.'); } @@ -286,12 +279,10 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// * See also: /// * [hideMarkerInfoWindow] to hide the Info Window. /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. - Future showMarkerInfoWindow( - MarkerId markerId, { - required int mapId, - }) { + Future showMarkerInfoWindow(MarkerId markerId, {required int mapId}) { throw UnimplementedError( - 'showMarkerInfoWindow() has not been implemented.'); + 'showMarkerInfoWindow() has not been implemented.', + ); } /// Programmatically hide the Info Window for a [Marker]. @@ -302,12 +293,10 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { /// * See also: /// * [showMarkerInfoWindow] to show the Info Window. /// * [isMarkerInfoWindowShown] to check if the Info Window is showing. - Future hideMarkerInfoWindow( - MarkerId markerId, { - required int mapId, - }) { + Future hideMarkerInfoWindow(MarkerId markerId, {required int mapId}) { throw UnimplementedError( - 'hideMarkerInfoWindow() has not been implemented.'); + 'hideMarkerInfoWindow() has not been implemented.', + ); } /// Returns `true` when the [InfoWindow] is showing, `false` otherwise. @@ -326,18 +315,14 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { } /// Returns the current zoom level of the map. - Future getZoomLevel({ - required int mapId, - }) { + Future getZoomLevel({required int mapId}) { throw UnimplementedError('getZoomLevel() has not been implemented.'); } /// Returns the image bytes of the map. /// /// Returns null if a snapshot cannot be created. - Future takeSnapshot({ - required int mapId, - }) { + Future takeSnapshot({required int mapId}) { throw UnimplementedError('takeSnapshot() has not been implemented.'); } @@ -520,6 +505,7 @@ abstract class GoogleMapsFlutterPlatform extends PlatformInterface { @visibleForTesting void enableDebugInspection() { throw UnimplementedError( - 'enableDebugInspection() has not been implemented.'); + 'enableDebugInspection() has not been implemented.', + ); } } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_inspector_platform.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_inspector_platform.dart index e737e5e3e49..4d0a485cd0e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_inspector_platform.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/platform_interface/google_maps_inspector_platform.dart @@ -62,7 +62,8 @@ abstract class GoogleMapsInspectorPlatform extends PlatformInterface { /// Returns true if the "my location" button is enabled. Future isMyLocationButtonEnabled({required int mapId}) { throw UnimplementedError( - 'isMyLocationButtonEnabled() has not been implemented.'); + 'isMyLocationButtonEnabled() has not been implemented.', + ); } /// Returns true if the traffic overlay is enabled. @@ -78,31 +79,36 @@ abstract class GoogleMapsInspectorPlatform extends PlatformInterface { /// Returns true if rotate gestures are enabled. Future areRotateGesturesEnabled({required int mapId}) { throw UnimplementedError( - 'areRotateGesturesEnabled() has not been implemented.'); + 'areRotateGesturesEnabled() has not been implemented.', + ); } /// Returns true if scroll gestures are enabled. Future areScrollGesturesEnabled({required int mapId}) { throw UnimplementedError( - 'areScrollGesturesEnabled() has not been implemented.'); + 'areScrollGesturesEnabled() has not been implemented.', + ); } /// Returns true if tilt gestures are enabled. Future areTiltGesturesEnabled({required int mapId}) { throw UnimplementedError( - 'areTiltGesturesEnabled() has not been implemented.'); + 'areTiltGesturesEnabled() has not been implemented.', + ); } /// Returns true if zoom controls are enabled. Future areZoomControlsEnabled({required int mapId}) { throw UnimplementedError( - 'areZoomControlsEnabled() has not been implemented.'); + 'areZoomControlsEnabled() has not been implemented.', + ); } /// Returns true if zoom gestures are enabled. Future areZoomGesturesEnabled({required int mapId}) { throw UnimplementedError( - 'areZoomGesturesEnabled() has not been implemented.'); + 'areZoomGesturesEnabled() has not been implemented.', + ); } /// Returns information about the tile overlay with the given ID. @@ -111,8 +117,10 @@ abstract class GoogleMapsInspectorPlatform extends PlatformInterface { /// be the same Dart object as the original [TileOverlay] provided to the /// platform interface with that ID, and not all fields (e.g., /// [TileOverlay.tileProvider]) will be populated. - Future getTileOverlayInfo(TileOverlayId tileOverlayId, - {required int mapId}) { + Future getTileOverlayInfo( + TileOverlayId tileOverlayId, { + required int mapId, + }) { throw UnimplementedError('getTileOverlayInfo() has not been implemented.'); } @@ -136,15 +144,20 @@ abstract class GoogleMapsInspectorPlatform extends PlatformInterface { /// The returned object will be synthesized from platform data, so will not /// be the same Dart object as the original [GroundOverlay] provided to the /// platform interface with that ID, and not all fields will be populated. - Future getGroundOverlayInfo(GroundOverlayId groundOverlayId, - {required int mapId}) { + Future getGroundOverlayInfo( + GroundOverlayId groundOverlayId, { + required int mapId, + }) { throw UnimplementedError( - 'getGroundOverlayInfo() has not been implemented.'); + 'getGroundOverlayInfo() has not been implemented.', + ); } /// Returns current clusters from [ClusterManager]. - Future> getClusters( - {required int mapId, required ClusterManagerId clusterManagerId}) { + Future> getClusters({ + required int mapId, + required ClusterManagerId clusterManagerId, + }) { throw UnimplementedError('getClusters() has not been implemented.'); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart index 0598b2c570f..86b5e13278c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/bitmap.dart @@ -33,10 +33,10 @@ enum MapBitmapScaling { /// Convert a string from provided JSON to a MapBitmapScaling enum. @visibleForTesting MapBitmapScaling mapBitmapScalingFromString(String mode) => switch (mode) { - 'auto' => MapBitmapScaling.auto, - 'none' => MapBitmapScaling.none, - _ => throw ArgumentError('Unrecognized MapBitmapScaling $mode', 'mode'), - }; + 'auto' => MapBitmapScaling.auto, + 'none' => MapBitmapScaling.none, + _ => throw ArgumentError('Unrecognized MapBitmapScaling $mode', 'mode'), +}; // The default pixel ratio for custom bitmaps. const double _naturalPixelRatio = 1.0; @@ -88,7 +88,9 @@ abstract class BitmapDescriptor { assert(jsonList[2] != null && jsonList[2] is String); assert((jsonList[2] as String).isNotEmpty); return AssetBitmap( - name: jsonList[1] as String, package: jsonList[2] as String); + name: jsonList[1] as String, + package: jsonList[2] as String, + ); } return AssetBitmap(name: jsonList[1] as String); case _fromAssetImage: @@ -101,13 +103,18 @@ abstract class BitmapDescriptor { assert((jsonList[3] as List).length == 2); final List sizeList = jsonList[3] as List; return AssetImageBitmap( - name: jsonList[1] as String, - scale: jsonList[2] as double, - size: Size((sizeList[0] as num).toDouble(), - (sizeList[1] as num).toDouble())); + name: jsonList[1] as String, + scale: jsonList[2] as double, + size: Size( + (sizeList[0] as num).toDouble(), + (sizeList[1] as num).toDouble(), + ), + ); } return AssetImageBitmap( - name: jsonList[1] as String, scale: jsonList[2] as double); + name: jsonList[1] as String, + scale: jsonList[2] as double, + ); case AssetMapBitmap.type: assert(jsonList.length == 2); assert(jsonList[1] != null && jsonList[1] is Map); @@ -125,12 +132,15 @@ abstract class BitmapDescriptor { jsonMap.containsKey('width') ? jsonMap['width'] as double : null; final double? height = jsonMap.containsKey('height') ? jsonMap['height'] as double : null; - return AssetMapBitmap(jsonMap['assetName'] as String, - bitmapScaling: - mapBitmapScalingFromString(jsonMap['bitmapScaling'] as String), - imagePixelRatio: jsonMap['imagePixelRatio'] as double, - width: width, - height: height); + return AssetMapBitmap( + jsonMap['assetName'] as String, + bitmapScaling: mapBitmapScalingFromString( + jsonMap['bitmapScaling'] as String, + ), + imagePixelRatio: jsonMap['imagePixelRatio'] as double, + width: width, + height: height, + ); case BytesMapBitmap.type: assert(jsonList.length == 2); assert(jsonList[1] != null && jsonList[1] is Map); @@ -148,12 +158,15 @@ abstract class BitmapDescriptor { jsonMap.containsKey('width') ? jsonMap['width'] as double : null; final double? height = jsonMap.containsKey('height') ? jsonMap['height'] as double : null; - return BytesMapBitmap(jsonMap['byteData'] as Uint8List, - bitmapScaling: - mapBitmapScalingFromString(jsonMap['bitmapScaling'] as String), - width: width, - height: height, - imagePixelRatio: jsonMap['imagePixelRatio'] as double); + return BytesMapBitmap( + jsonMap['byteData'] as Uint8List, + bitmapScaling: mapBitmapScalingFromString( + jsonMap['bitmapScaling'] as String, + ), + width: width, + height: height, + imagePixelRatio: jsonMap['imagePixelRatio'] as double, + ); default: break; } @@ -239,15 +252,20 @@ abstract class BitmapDescriptor { if (!mipmaps && devicePixelRatio != null) { return AssetImageBitmap(name: assetName, scale: devicePixelRatio); } - final AssetImage assetImage = - AssetImage(assetName, package: package, bundle: bundle); - final AssetBundleImageKey assetBundleImageKey = - await assetImage.obtainKey(configuration); + final AssetImage assetImage = AssetImage( + assetName, + package: package, + bundle: bundle, + ); + final AssetBundleImageKey assetBundleImageKey = await assetImage.obtainKey( + configuration, + ); final Size? size = kIsWeb ? configuration.size : null; return AssetImageBitmap( - name: assetBundleImageKey.name, - scale: assetBundleImageKey.scale, - size: size); + name: assetBundleImageKey.name, + scale: assetBundleImageKey.scale, + size: size, + ); } /// Creates a BitmapDescriptor using an array of bytes that must be encoded @@ -258,8 +276,10 @@ abstract class BitmapDescriptor { /// `size` is not required (and ignored, if passed) in other platforms. @Deprecated('Use BitmapDescriptor.bytes method instead.') static BitmapDescriptor fromBytes(Uint8List byteData, {Size? size}) { - assert(byteData.isNotEmpty, - 'Cannot create BitmapDescriptor with empty byteData'); + assert( + byteData.isNotEmpty, + 'Cannot create BitmapDescriptor with empty byteData', + ); return BytesBitmap(byteData: byteData, size: size); } @@ -371,9 +391,10 @@ class DefaultMarker extends BitmapDescriptor { final num? hue; @override - Object toJson() => (hue == null) - ? const [BitmapDescriptor._defaultMarker] - : [BitmapDescriptor._defaultMarker, hue!]; + Object toJson() => + (hue == null) + ? const [BitmapDescriptor._defaultMarker] + : [BitmapDescriptor._defaultMarker, hue!]; } /// A BitmapDescriptor using an array of bytes that must be encoded @@ -386,7 +407,7 @@ class BytesBitmap extends BitmapDescriptor { /// `size` is not required (and ignored, if passed) in other platforms. @Deprecated('Use BytesMapBitmap instead') const BytesBitmap({required Uint8List byteData, Size? size}) - : this._(byteData, kIsWeb ? size : null); + : this._(byteData, kIsWeb ? size : null); @Deprecated('Use BytesMapBitmap instead') const BytesBitmap._(this.byteData, this.size) : super._(); @@ -399,10 +420,10 @@ class BytesBitmap extends BitmapDescriptor { @override Object toJson() => [ - BitmapDescriptor._fromBytes, - byteData, - if (size != null) [size!.width, size!.height] - ]; + BitmapDescriptor._fromBytes, + byteData, + if (size != null) [size!.width, size!.height], + ]; } /// A bitmap specified by a name and optional package. @@ -418,10 +439,10 @@ class AssetBitmap extends BitmapDescriptor { @override Object toJson() => [ - BitmapDescriptor._fromAsset, - name, - if (package != null) package! - ]; + BitmapDescriptor._fromAsset, + name, + if (package != null) package!, + ]; } /// A [BitmapDescriptor] from an asset image. @@ -434,7 +455,7 @@ class AssetImageBitmap extends BitmapDescriptor { /// and scales the images to the right resolution depending on the dpi. @Deprecated('Use AssetMapBitmap instead') const AssetImageBitmap({required this.name, required this.scale, this.size}) - : super._(); + : super._(); /// Name of the image asset. final String name; @@ -447,11 +468,11 @@ class AssetImageBitmap extends BitmapDescriptor { @override Object toJson() => [ - BitmapDescriptor._fromAssetImage, - name, - scale, - if (size != null) [size!.width, size!.height] - ]; + BitmapDescriptor._fromAssetImage, + name, + scale, + if (size != null) [size!.width, size!.height], + ]; } /// Represents a [BitmapDescriptor] base class for map bitmaps. @@ -665,12 +686,12 @@ class AssetMapBitmap extends MapBitmap { double? width, double? height, }) : this._( - assetName: assetName, - bitmapScaling: bitmapScaling, - imagePixelRatio: imagePixelRatio ?? _naturalPixelRatio, - width: width, - height: height, - ); + assetName: assetName, + bitmapScaling: bitmapScaling, + imagePixelRatio: imagePixelRatio ?? _naturalPixelRatio, + width: width, + height: height, + ); /// Internal constructor for creating a [AssetMapBitmap]. AssetMapBitmap._({ @@ -679,14 +700,20 @@ class AssetMapBitmap extends MapBitmap { required super.bitmapScaling, super.width, super.height, - }) : assert(assetName.isNotEmpty, 'The asset name must not be empty.'), - assert(imagePixelRatio > 0.0, - 'The imagePixelRatio must be greater than 0.'), - assert(bitmapScaling != MapBitmapScaling.none || width == null, - 'If bitmapScaling is set to MapBitmapScaling.none, width parameter cannot be used.'), - assert(bitmapScaling != MapBitmapScaling.none || height == null, - 'If bitmapScaling is set to MapBitmapScaling.none, height parameter cannot be used.'), - super._(); + }) : assert(assetName.isNotEmpty, 'The asset name must not be empty.'), + assert( + imagePixelRatio > 0.0, + 'The imagePixelRatio must be greater than 0.', + ), + assert( + bitmapScaling != MapBitmapScaling.none || width == null, + 'If bitmapScaling is set to MapBitmapScaling.none, width parameter cannot be used.', + ), + assert( + bitmapScaling != MapBitmapScaling.none || height == null, + 'If bitmapScaling is set to MapBitmapScaling.none, height parameter cannot be used.', + ), + super._(); /// The type of the [BitmapDescriptor] object, used for the /// JSON serialization. @@ -781,30 +808,35 @@ class AssetMapBitmap extends MapBitmap { MapBitmapScaling bitmapScaling = MapBitmapScaling.auto, }) async { assert(assetName.isNotEmpty, 'The asset name must not be empty.'); - final AssetImage assetImage = - AssetImage(assetName, package: package, bundle: bundle); - final AssetBundleImageKey assetBundleImageKey = - await assetImage.obtainKey(configuration); + final AssetImage assetImage = AssetImage( + assetName, + package: package, + bundle: bundle, + ); + final AssetBundleImageKey assetBundleImageKey = await assetImage.obtainKey( + configuration, + ); return AssetMapBitmap._( - assetName: assetBundleImageKey.name, - imagePixelRatio: imagePixelRatio ?? assetBundleImageKey.scale, - bitmapScaling: bitmapScaling, - width: width ?? configuration.size?.width, - height: height ?? configuration.size?.height); + assetName: assetBundleImageKey.name, + imagePixelRatio: imagePixelRatio ?? assetBundleImageKey.scale, + bitmapScaling: bitmapScaling, + width: width ?? configuration.size?.width, + height: height ?? configuration.size?.height, + ); } @override Object toJson() => [ - type, - { - 'assetName': assetName, - 'bitmapScaling': bitmapScaling.name, - 'imagePixelRatio': imagePixelRatio, - if (width != null) 'width': width, - if (height != null) 'height': height, - } - ]; + type, + { + 'assetName': assetName, + 'bitmapScaling': bitmapScaling.name, + 'imagePixelRatio': imagePixelRatio, + if (width != null) 'width': width, + if (height != null) 'height': height, + }, + ]; } /// Represents a [BitmapDescriptor] that is created from an array of bytes @@ -953,16 +985,23 @@ class BytesMapBitmap extends MapBitmap { super.width, super.height, double? imagePixelRatio, - }) : assert(byteData.isNotEmpty, - 'Cannot create BitmapDescriptor with empty byteData.'), - assert( - bitmapScaling != MapBitmapScaling.none || imagePixelRatio == null, - 'If bitmapScaling is set to MapBitmapScaling.none, imagePixelRatio parameter cannot be used.'), - assert(bitmapScaling != MapBitmapScaling.none || width == null, - 'If bitmapScaling is set to MapBitmapScaling.none, width parameter cannot be used.'), - assert(bitmapScaling != MapBitmapScaling.none || height == null, - 'If bitmapScaling is set to MapBitmapScaling.none, height parameter cannot be used.'), - super._(imagePixelRatio: imagePixelRatio ?? _naturalPixelRatio); + }) : assert( + byteData.isNotEmpty, + 'Cannot create BitmapDescriptor with empty byteData.', + ), + assert( + bitmapScaling != MapBitmapScaling.none || imagePixelRatio == null, + 'If bitmapScaling is set to MapBitmapScaling.none, imagePixelRatio parameter cannot be used.', + ), + assert( + bitmapScaling != MapBitmapScaling.none || width == null, + 'If bitmapScaling is set to MapBitmapScaling.none, width parameter cannot be used.', + ), + assert( + bitmapScaling != MapBitmapScaling.none || height == null, + 'If bitmapScaling is set to MapBitmapScaling.none, height parameter cannot be used.', + ), + super._(imagePixelRatio: imagePixelRatio ?? _naturalPixelRatio); /// The type of the MapBitmap object, used for the JSON serialization. static const String type = 'bytes'; @@ -972,15 +1011,15 @@ class BytesMapBitmap extends MapBitmap { @override Object toJson() => [ - type, - { - 'byteData': byteData, - 'bitmapScaling': bitmapScaling.name, - 'imagePixelRatio': imagePixelRatio, - if (width != null) 'width': width, - if (height != null) 'height': height, - } - ]; + type, + { + 'byteData': byteData, + 'bitmapScaling': bitmapScaling.name, + 'imagePixelRatio': imagePixelRatio, + if (width != null) 'width': width, + if (height != null) 'height': height, + }, + ]; } /// Represents a [BitmapDescriptor] that is created from a pin configuration. @@ -1036,15 +1075,12 @@ class PinConfig extends BitmapDescriptor { /// pin marker. /// /// At least one of the parameters must not be null. - const PinConfig({ - this.backgroundColor, - this.borderColor, - this.glyph, - }) : assert( - backgroundColor != null || borderColor != null || glyph != null, - 'Cannot create PinConfig with all parameters being null.', - ), - super._(); + const PinConfig({this.backgroundColor, this.borderColor, this.glyph}) + : assert( + backgroundColor != null || borderColor != null || glyph != null, + 'Cannot create PinConfig with all parameters being null.', + ), + super._(); /// The type of the MapBitmap object, used for the JSON serialization. static const String type = 'pinConfig'; @@ -1066,14 +1102,13 @@ class PinConfig extends BitmapDescriptor { @override Object toJson() => [ - type, - { - if (backgroundColor != null) - 'backgroundColor': backgroundColor?.value, - if (borderColor != null) 'borderColor': borderColor?.value, - if (glyph != null) 'glyph': glyph?.toJson(), - } - ]; + type, + { + if (backgroundColor != null) 'backgroundColor': backgroundColor?.value, + if (borderColor != null) 'borderColor': borderColor?.value, + if (glyph != null) 'glyph': glyph?.toJson(), + }, + ]; } /// Defines a glyph (the element at the center of an [AdvancedMarker] icon). @@ -1085,20 +1120,16 @@ sealed class AdvancedMarkerGlyph extends BitmapDescriptor { class CircleGlyph extends AdvancedMarkerGlyph { /// Constructs a glyph instance, using the default circle, but with /// a custom color. - const CircleGlyph({ - required this.color, - }) : super._(); + const CircleGlyph({required this.color}) : super._(); /// Color of the circular icon. final Color color; @override Object toJson() => [ - 'circleGlyph', - { - 'color': color.value, - } - ]; + 'circleGlyph', + {'color': color.value}, + ]; } /// Defines a glyph instance with a specified bitmap. @@ -1107,33 +1138,27 @@ class BitmapGlyph extends AdvancedMarkerGlyph { /// /// [bitmap] is the image to be displayed in the center of the glyph. Must not /// be an [AdvancedMarkerGlyph]. - const BitmapGlyph({ - required this.bitmap, - }) : assert( - bitmap is! AdvancedMarkerGlyph, - 'BitmapDescriptor cannot be an AdvancedMarkerGlyph.', - ), - super._(); + const BitmapGlyph({required this.bitmap}) + : assert( + bitmap is! AdvancedMarkerGlyph, + 'BitmapDescriptor cannot be an AdvancedMarkerGlyph.', + ), + super._(); /// Bitmap image to be displayed in the center of the glyph. final BitmapDescriptor bitmap; @override Object toJson() => [ - 'bitmapGlyph', - { - 'bitmap': bitmap.toJson(), - } - ]; + 'bitmapGlyph', + {'bitmap': bitmap.toJson()}, + ]; } /// Defines a glyph instance with a specified text and color. class TextGlyph extends AdvancedMarkerGlyph { /// Constructs a glyph with the specified [text] and [textColor]. - const TextGlyph({ - required this.text, - this.textColor, - }) : super._(); + const TextGlyph({required this.text, this.textColor}) : super._(); /// Text to be displayed in the glyph. final String text; @@ -1148,7 +1173,7 @@ class TextGlyph extends AdvancedMarkerGlyph { { 'text': text, if (textColor != null) 'textColor': textColor!.value, - } + }, ]; } } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/callbacks.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/callbacks.dart index 41f0fe23ef1..e1949f162ae 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/callbacks.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/callbacks.dart @@ -35,8 +35,9 @@ class ArgumentCallbacks { if (length == 1) { _callbacks[0].call(argument); } else if (0 < length) { - for (final ArgumentCallback callback - in List>.from(_callbacks)) { + for (final ArgumentCallback callback in List>.from( + _callbacks, + )) { callback(argument); } } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/camera.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/camera.dart index 7a5afc80a71..4c2fda53ef1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/camera.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/camera.dart @@ -62,11 +62,11 @@ class CameraPosition { /// /// Mainly for internal use when calling [CameraUpdate.newCameraPosition]. Object toMap() => { - 'bearing': bearing, - 'target': target.toJson(), - 'tilt': tilt, - 'zoom': zoom, - }; + 'bearing': bearing, + 'target': target.toJson(), + 'tilt': tilt, + 'zoom': zoom, + }; /// Deserializes [CameraPosition] from a map. /// @@ -219,7 +219,7 @@ abstract class CameraUpdate { class CameraUpdateNewCameraPosition extends CameraUpdate { /// Creates a camera move. const CameraUpdateNewCameraPosition(this.cameraPosition) - : super._(CameraUpdateType.newCameraPosition); + : super._(CameraUpdateType.newCameraPosition); /// The new camera position. final CameraPosition cameraPosition; @@ -231,7 +231,7 @@ class CameraUpdateNewCameraPosition extends CameraUpdate { class CameraUpdateNewLatLng extends CameraUpdate { /// Creates a camera move to latitude and longitude. const CameraUpdateNewLatLng(this.latLng) - : super._(CameraUpdateType.newLatLng); + : super._(CameraUpdateType.newLatLng); /// New latitude and longitude of the camera.. final LatLng latLng; @@ -243,7 +243,7 @@ class CameraUpdateNewLatLng extends CameraUpdate { class CameraUpdateNewLatLngBounds extends CameraUpdate { /// Creates a camera move to a bounding range. const CameraUpdateNewLatLngBounds(this.bounds, this.padding) - : super._(CameraUpdateType.newLatLngBounds); + : super._(CameraUpdateType.newLatLngBounds); /// The northeast and southwest bounding coordinates. final LatLngBounds bounds; @@ -258,7 +258,7 @@ class CameraUpdateNewLatLngBounds extends CameraUpdate { class CameraUpdateNewLatLngZoom extends CameraUpdate { /// Creates a camera move with coordinates and zoom level. const CameraUpdateNewLatLngZoom(this.latLng, this.zoom) - : super._(CameraUpdateType.newLatLngZoom); + : super._(CameraUpdateType.newLatLngZoom); /// New coordinates of the camera. final LatLng latLng; @@ -273,7 +273,7 @@ class CameraUpdateNewLatLngZoom extends CameraUpdate { class CameraUpdateScrollBy extends CameraUpdate { /// Creates a camera scroll. const CameraUpdateScrollBy(this.dx, this.dy) - : super._(CameraUpdateType.scrollBy); + : super._(CameraUpdateType.scrollBy); /// Scroll delta x. final double dx; @@ -288,7 +288,7 @@ class CameraUpdateScrollBy extends CameraUpdate { class CameraUpdateZoomBy extends CameraUpdate { /// Creates a relative camera zoom. const CameraUpdateZoomBy(this.amount, [this.focus]) - : super._(CameraUpdateType.zoomBy); + : super._(CameraUpdateType.zoomBy); /// Change in camera zoom amount. final double amount; @@ -296,13 +296,14 @@ class CameraUpdateZoomBy extends CameraUpdate { /// Optional point around which the zoom is focused. final Offset? focus; @override - Object toJson() => (focus == null) - ? ['zoomBy', amount] - : [ - 'zoomBy', - amount, - [focus!.dx, focus!.dy] - ]; + Object toJson() => + (focus == null) + ? ['zoomBy', amount] + : [ + 'zoomBy', + amount, + [focus!.dx, focus!.dy], + ]; } /// Defines a camera zoom in. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart index c67439e3e31..61acc5616e7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cap.dart @@ -29,11 +29,11 @@ enum CapType { } String _capTypeToJson(CapType capType) => switch (capType) { - CapType.butt => 'buttCap', - CapType.round => 'roundCap', - CapType.square => 'squareCap', - CapType.custom => 'customCap', - }; + CapType.butt => 'buttCap', + CapType.round => 'roundCap', + CapType.square => 'squareCap', + CapType.custom => 'customCap', +}; /// Cap that can be applied at the start or end vertex of a [Polyline]. @immutable @@ -94,7 +94,7 @@ class CustomCap extends Cap { /// the cap bitmap at its native dimension is designed. Must be positive. Default value /// is 10 pixels. const CustomCap(this.bitmapDescriptor, {this.refWidth = 10}) - : super._(CapType.custom); + : super._(CapType.custom); /// Bitmap overlay centered at the start or end vertex of a [Polyline]. final BitmapDescriptor bitmapDescriptor; @@ -104,6 +104,9 @@ class CustomCap extends Cap { final double refWidth; @override - Object toJson() => - [_capTypeToJson(type), bitmapDescriptor.toJson(), refWidth]; + Object toJson() => [ + _capTypeToJson(type), + bitmapDescriptor.toJson(), + refWidth, + ]; } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle_updates.dart index f8fc725c14d..68d47c1b31e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle_updates.dart @@ -11,7 +11,7 @@ import 'types.dart'; class CircleUpdates extends MapsObjectUpdates { /// Computes [CircleUpdates] given previous and current [Circle]s. CircleUpdates.from(super.previous, super.current) - : super.from(objectName: 'circle'); + : super.from(objectName: 'circle'); /// Set of Circles to be added in this update. Set get circlesToAdd => objectsToAdd; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cluster_manager.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cluster_manager.dart index ec3c1f7e435..69b12079fa0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cluster_manager.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cluster_manager.dart @@ -19,10 +19,7 @@ class ClusterManagerId extends MapsObjectId { @immutable class ClusterManager implements MapsObject { /// Creates an immutable object for managing clustering for set of markers. - const ClusterManager({ - required this.clusterManagerId, - this.onClusterTap, - }); + const ClusterManager({required this.clusterManagerId, this.onClusterTap}); /// Uniquely identifies a [ClusterManager]. final ClusterManagerId clusterManagerId; @@ -35,9 +32,7 @@ class ClusterManager implements MapsObject { /// Creates a new [ClusterManager] object whose values are the same as this instance, /// unless overwritten by the specified parameters. - ClusterManager copyWith({ - ArgumentCallback? onClusterTapParam, - }) { + ClusterManager copyWith({ArgumentCallback? onClusterTapParam}) { return ClusterManager( clusterManagerId: clusterManagerId, onClusterTap: onClusterTapParam ?? onClusterTap, diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cluster_manager_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cluster_manager_updates.dart index 167201906dd..c674d73c4f4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cluster_manager_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/cluster_manager_updates.dart @@ -11,7 +11,7 @@ import 'types.dart'; class ClusterManagerUpdates extends MapsObjectUpdates { /// Computes [ClusterManagerUpdates] given previous and current [ClusterManager]s. ClusterManagerUpdates.from(super.previous, super.current) - : super.from(objectName: 'clusterManager'); + : super.from(objectName: 'clusterManager'); /// Set of Clusters to be added in this update. Set get clusterManagersToAdd => objectsToAdd; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay.dart index c9e84a632b1..b87ca3a952b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay.dart @@ -102,16 +102,24 @@ class GroundOverlay implements MapsObject { this.clickable = true, this.onTap, this.zoomLevel, - }) : assert(transparency >= 0.0 && transparency <= 1.0), - assert(bearing >= 0.0 && bearing <= 360.0), - assert((position == null) != (bounds == null), - 'Either position or bounds must be given, but not both'), - assert(position == null || (width == null || width > 0), - 'Width must be null or greater than 0 when position is used'), - assert(position == null || (height == null || height > 0), - 'Height must be null or greater than 0 when position is used'), - assert(image.bitmapScaling == MapBitmapScaling.none, - 'The provided image must have its bitmapScaling property set to MapBitmapScaling.none.'); + }) : assert(transparency >= 0.0 && transparency <= 1.0), + assert(bearing >= 0.0 && bearing <= 360.0), + assert( + (position == null) != (bounds == null), + 'Either position or bounds must be given, but not both', + ), + assert( + position == null || (width == null || width > 0), + 'Width must be null or greater than 0 when position is used', + ), + assert( + position == null || (height == null || height > 0), + 'Height must be null or greater than 0 when position is used', + ), + assert( + image.bitmapScaling == MapBitmapScaling.none, + 'The provided image must have its bitmapScaling property set to MapBitmapScaling.none.', + ); /// Creates a [GroundOverlay] fitted to the specified [bounds] with the /// provided [image]. @@ -317,7 +325,9 @@ class GroundOverlay implements MapsObject { addIfPresent('width', width); addIfPresent('height', height); addIfPresent( - 'anchor', anchor != null ? [anchor!.dx, anchor!.dy] : null); + 'anchor', + anchor != null ? [anchor!.dx, anchor!.dy] : null, + ); addIfPresent('bearing', bearing); addIfPresent('transparency', transparency); addIfPresent('zIndex', zIndex); @@ -382,18 +392,18 @@ class GroundOverlay implements MapsObject { @override int get hashCode => Object.hash( - groundOverlayId, - image, - position, - bounds, - width, - height, - anchor, - bearing, - transparency, - zIndex, - visible, - clickable, - zoomLevel, - ); + groundOverlayId, + image, + position, + bounds, + width, + height, + anchor, + bearing, + transparency, + zIndex, + visible, + clickable, + zoomLevel, + ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay_updates.dart index 152352e78ae..72d55e9789c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ground_overlay_updates.dart @@ -8,7 +8,7 @@ import 'types.dart'; class GroundOverlayUpdates extends MapsObjectUpdates { /// Computes [GroundOverlayUpdates] given previous and current [GroundOverlay]s. GroundOverlayUpdates.from(super.previous, super.current) - : super.from(objectName: 'groundOverlay'); + : super.from(objectName: 'groundOverlay'); /// Set of GroundOverlays to be added in this update. Set get groundOverlaysToAdd => objectsToAdd; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap.dart index 41b4dcb2abc..c356cf9a592 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap.dart @@ -159,9 +159,9 @@ class Heatmap implements MapsObject { /// instance. @override Heatmap clone() => copyWith( - dataParam: List.of(data), - gradientParam: gradient?.clone(), - ); + dataParam: List.of(data), + gradientParam: gradient?.clone(), + ); /// Converts this object to something serializable in JSON. @override @@ -253,10 +253,7 @@ class WeightedLatLng { @immutable class HeatmapGradient { /// Creates a new [HeatmapGradient] object. - const HeatmapGradient( - this.colors, { - this.colorMapSize = 256, - }); + const HeatmapGradient(this.colors, {this.colorMapSize = 256}); /// The gradient colors. /// @@ -281,9 +278,8 @@ class HeatmapGradient { /// Creates a new [HeatmapGradient] object whose values are the same as this /// instance. - HeatmapGradient clone() => copyWith( - colorsParam: List.of(colors), - ); + HeatmapGradient clone() => + copyWith(colorsParam: List.of(colors)); /// Converts this object to something serializable in JSON. Object toJson() { @@ -295,10 +291,14 @@ class HeatmapGradient { } } - addIfPresent('colors', - colors.map((HeatmapGradientColor e) => e.color.value).toList()); - addIfPresent('startPoints', - colors.map((HeatmapGradientColor e) => e.startPoint).toList()); + addIfPresent( + 'colors', + colors.map((HeatmapGradientColor e) => e.color.value).toList(), + ); + addIfPresent( + 'startPoints', + colors.map((HeatmapGradientColor e) => e.startPoint).toList(), + ); addIfPresent('colorMapSize', colorMapSize); return json; @@ -335,10 +335,7 @@ class HeatmapGradientColor { /// Creates a new [HeatmapGradientColor] object whose values are the same as /// this instance, unless overwritten by the specified parameters. - HeatmapGradientColor copyWith({ - Color? colorParam, - double? startPointParam, - }) { + HeatmapGradientColor copyWith({Color? colorParam, double? startPointParam}) { return HeatmapGradientColor( colorParam ?? color, startPointParam ?? startPoint, diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap_updates.dart index bd74c6301fc..6bfa63ad213 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/heatmap_updates.dart @@ -10,10 +10,8 @@ import 'types.dart'; // (Do not re-export) class HeatmapUpdates extends MapsObjectUpdates { /// Computes [HeatmapUpdates] given previous and current [Heatmap]s. - HeatmapUpdates.from( - super.previous, - super.current, - ) : super.from(objectName: 'heatmap'); + HeatmapUpdates.from(super.previous, super.current) + : super.from(objectName: 'heatmap'); /// Set of Heatmaps to be added in this update. Set get heatmapsToAdd => objectsToAdd; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart index b00446a542b..7b65c586a1f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/location.dart @@ -16,12 +16,12 @@ class LatLng { /// The longitude is normalized to the half-open interval from -180.0 /// (inclusive) to +180.0 (exclusive). const LatLng(double latitude, double longitude) - : latitude = - latitude < -90.0 ? -90.0 : (90.0 < latitude ? 90.0 : latitude), - // Avoids normalization if possible to prevent unnecessary loss of precision - longitude = longitude >= -180 && longitude < 180 - ? longitude - : (longitude + 180.0) % 360.0 - 180.0; + : latitude = latitude < -90.0 ? -90.0 : (90.0 < latitude ? 90.0 : latitude), + // Avoids normalization if possible to prevent unnecessary loss of precision + longitude = + longitude >= -180 && longitude < 180 + ? longitude + : (longitude + 180.0) % 360.0 - 180.0; /// The latitude in degrees between -90.0 and 90.0, both inclusive. final double latitude; @@ -74,7 +74,7 @@ class LatLngBounds { /// The latitude of the southwest corner cannot be larger than the /// latitude of the northeast corner. LatLngBounds({required this.southwest, required this.northeast}) - : assert(southwest.latitude <= northeast.latitude); + : assert(southwest.latitude <= northeast.latitude); /// The southwest corner of the rectangle. final LatLng southwest; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart index 5162cd50813..960a4c425b1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/map_configuration.dart @@ -142,21 +142,25 @@ class MapConfiguration { /// that are different from [other]. MapConfiguration diffFrom(MapConfiguration other) { return MapConfiguration( - webGestureHandling: webGestureHandling != other.webGestureHandling - ? webGestureHandling - : null, + webGestureHandling: + webGestureHandling != other.webGestureHandling + ? webGestureHandling + : null, compassEnabled: compassEnabled != other.compassEnabled ? compassEnabled : null, - mapToolbarEnabled: mapToolbarEnabled != other.mapToolbarEnabled - ? mapToolbarEnabled - : null, - cameraTargetBounds: cameraTargetBounds != other.cameraTargetBounds - ? cameraTargetBounds - : null, + mapToolbarEnabled: + mapToolbarEnabled != other.mapToolbarEnabled + ? mapToolbarEnabled + : null, + cameraTargetBounds: + cameraTargetBounds != other.cameraTargetBounds + ? cameraTargetBounds + : null, mapType: mapType != other.mapType ? mapType : null, - minMaxZoomPreference: minMaxZoomPreference != other.minMaxZoomPreference - ? minMaxZoomPreference - : null, + minMaxZoomPreference: + minMaxZoomPreference != other.minMaxZoomPreference + ? minMaxZoomPreference + : null, rotateGesturesEnabled: rotateGesturesEnabled != other.rotateGesturesEnabled ? rotateGesturesEnabled @@ -165,35 +169,41 @@ class MapConfiguration { scrollGesturesEnabled != other.scrollGesturesEnabled ? scrollGesturesEnabled : null, - tiltGesturesEnabled: tiltGesturesEnabled != other.tiltGesturesEnabled - ? tiltGesturesEnabled - : null, + tiltGesturesEnabled: + tiltGesturesEnabled != other.tiltGesturesEnabled + ? tiltGesturesEnabled + : null, fortyFiveDegreeImageryEnabled: fortyFiveDegreeImageryEnabled != other.fortyFiveDegreeImageryEnabled ? fortyFiveDegreeImageryEnabled : null, - trackCameraPosition: trackCameraPosition != other.trackCameraPosition - ? trackCameraPosition - : null, - zoomControlsEnabled: zoomControlsEnabled != other.zoomControlsEnabled - ? zoomControlsEnabled - : null, - zoomGesturesEnabled: zoomGesturesEnabled != other.zoomGesturesEnabled - ? zoomGesturesEnabled - : null, + trackCameraPosition: + trackCameraPosition != other.trackCameraPosition + ? trackCameraPosition + : null, + zoomControlsEnabled: + zoomControlsEnabled != other.zoomControlsEnabled + ? zoomControlsEnabled + : null, + zoomGesturesEnabled: + zoomGesturesEnabled != other.zoomGesturesEnabled + ? zoomGesturesEnabled + : null, liteModeEnabled: liteModeEnabled != other.liteModeEnabled ? liteModeEnabled : null, - myLocationEnabled: myLocationEnabled != other.myLocationEnabled - ? myLocationEnabled - : null, + myLocationEnabled: + myLocationEnabled != other.myLocationEnabled + ? myLocationEnabled + : null, myLocationButtonEnabled: myLocationButtonEnabled != other.myLocationButtonEnabled ? myLocationButtonEnabled : null, padding: padding != other.padding ? padding : null, - indoorViewEnabled: indoorViewEnabled != other.indoorViewEnabled - ? indoorViewEnabled - : null, + indoorViewEnabled: + indoorViewEnabled != other.indoorViewEnabled + ? indoorViewEnabled + : null, trafficEnabled: trafficEnabled != other.trafficEnabled ? trafficEnabled : null, buildingsEnabled: @@ -300,30 +310,30 @@ class MapConfiguration { @override int get hashCode => Object.hashAll([ - webGestureHandling, - compassEnabled, - mapToolbarEnabled, - cameraTargetBounds, - mapType, - minMaxZoomPreference, - rotateGesturesEnabled, - scrollGesturesEnabled, - tiltGesturesEnabled, - fortyFiveDegreeImageryEnabled, - trackCameraPosition, - zoomControlsEnabled, - zoomGesturesEnabled, - liteModeEnabled, - myLocationEnabled, - myLocationButtonEnabled, - padding, - indoorViewEnabled, - trafficEnabled, - buildingsEnabled, - mapId, - style, - markerType, - ]); + webGestureHandling, + compassEnabled, + mapToolbarEnabled, + cameraTargetBounds, + mapType, + minMaxZoomPreference, + rotateGesturesEnabled, + scrollGesturesEnabled, + tiltGesturesEnabled, + fortyFiveDegreeImageryEnabled, + trackCameraPosition, + zoomControlsEnabled, + zoomGesturesEnabled, + liteModeEnabled, + myLocationEnabled, + myLocationButtonEnabled, + padding, + indoorViewEnabled, + trafficEnabled, + buildingsEnabled, + mapId, + style, + markerType, + ]); } /// Indicates the type of marker that the map should use. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/maps_object_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/maps_object_updates.dart index efc319b60ce..889131d3f9e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/maps_object_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/maps_object_updates.dart @@ -37,10 +37,11 @@ class MapsObjectUpdates> { _objectIdsToRemove = previousObjectIds.difference(currentObjectIds); - _objectsToAdd = currentObjectIds - .difference(previousObjectIds) - .map(idToCurrentObject) - .toSet(); + _objectsToAdd = + currentObjectIds + .difference(previousObjectIds) + .map(idToCurrentObject) + .toSet(); // Returns `true` if [current] is not equals to previous one with the // same id. @@ -49,11 +50,12 @@ class MapsObjectUpdates> { return current != previous; } - _objectsToChange = currentObjectIds - .intersection(previousObjectIds) - .map(idToCurrentObject) - .where(hasChanged) - .toSet(); + _objectsToChange = + currentObjectIds + .intersection(previousObjectIds) + .map(idToCurrentObject) + .where(hasChanged) + .toSet(); } /// The name of the objects being updated, for use in serialization. @@ -92,12 +94,13 @@ class MapsObjectUpdates> { addIfNonNull('${objectName}sToAdd', serializeMapsObjectSet(_objectsToAdd)); addIfNonNull( - '${objectName}sToChange', serializeMapsObjectSet(_objectsToChange)); + '${objectName}sToChange', + serializeMapsObjectSet(_objectsToChange), + ); addIfNonNull( - '${objectName}IdsToRemove', - _objectIdsToRemove - .map((MapsObjectId m) => m.value) - .toList()); + '${objectName}IdsToRemove', + _objectIdsToRemove.map((MapsObjectId m) => m.value).toList(), + ); return updateMap; } @@ -114,8 +117,11 @@ class MapsObjectUpdates> { } @override - int get hashCode => Object.hash(Object.hashAll(_objectsToAdd), - Object.hashAll(_objectIdsToRemove), Object.hashAll(_objectsToChange)); + int get hashCode => Object.hash( + Object.hashAll(_objectsToAdd), + Object.hashAll(_objectIdsToRemove), + Object.hashAll(_objectsToChange), + ); @override String toString() { diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart index d0093f3716f..215d0318467 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker.dart @@ -164,10 +164,12 @@ class Marker implements MapsObject { this.onDrag, this.onDragStart, this.onDragEnd, - }) : assert(0.0 <= alpha && alpha <= 1.0), - assert(zIndex == 0.0 || zIndexInt == 0, - 'Only one of zIndex and zIndexInt can be provided'), - _zIndexNum = zIndexInt == 0 ? zIndex : zIndexInt; + }) : assert(0.0 <= alpha && alpha <= 1.0), + assert( + zIndex == 0.0 || zIndexInt == 0, + 'Only one of zIndex and zIndexInt can be provided', + ), + _zIndexNum = zIndexInt == 0 ? zIndex : zIndexInt; /// Uniquely identifies a [Marker]. final MarkerId markerId; @@ -283,8 +285,10 @@ class Marker implements MapsObject { ValueChanged? onDragEndParam, ClusterManagerId? clusterManagerIdParam, }) { - assert(zIndexParam == null || zIndexIntParam == null, - 'Only one of zIndexParam and zIndexIntParam can be provided'); + assert( + zIndexParam == null || zIndexIntParam == null, + 'Only one of zIndexParam and zIndexIntParam can be provided', + ); return Marker( markerId: markerId, alpha: alphaParam ?? alpha, diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker_updates.dart index 4a9ca8df823..fdd2fdbe037 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/marker_updates.dart @@ -11,7 +11,7 @@ import 'types.dart'; class MarkerUpdates extends MapsObjectUpdates { /// Computes [MarkerUpdates] given previous and current [Marker]s. MarkerUpdates.from(super.previous, super.current) - : super.from(objectName: 'marker'); + : super.from(objectName: 'marker'); /// Set of Markers to be added in this update. Set get markersToAdd => objectsToAdd; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/pattern_item.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/pattern_item.dart index 90adfbc84c6..d8d383f2ca7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/pattern_item.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/pattern_item.dart @@ -17,10 +17,10 @@ enum PatternItemType { } String _patternItemTypeToJson(PatternItemType itemType) => switch (itemType) { - PatternItemType.dot => 'dot', - PatternItemType.dash => 'dash', - PatternItemType.gap => 'gap', - }; + PatternItemType.dot => 'dot', + PatternItemType.dash => 'dash', + PatternItemType.gap => 'gap', +}; /// Item used in the stroke pattern for a Polyline. @immutable @@ -36,7 +36,9 @@ class PatternItem { static PatternItem dash(double length) { assert(length >= 0.0); return VariableLengthPatternItem._( - patternItemType: PatternItemType.dash, length: length); + patternItemType: PatternItemType.dash, + length: length, + ); } /// A gap used in the stroke pattern for a [Polyline]. @@ -45,32 +47,30 @@ class PatternItem { static PatternItem gap(double length) { assert(length >= 0.0); return VariableLengthPatternItem._( - patternItemType: PatternItemType.gap, length: length); + patternItemType: PatternItemType.gap, + length: length, + ); } /// The type of rendering used for an item in a pattern. final PatternItemType type; /// Converts this object to something serializable in JSON. - Object toJson() => [ - _patternItemTypeToJson(type), - ]; + Object toJson() => [_patternItemTypeToJson(type)]; } /// A pattern item with a length, i.e. a dash or gap. @immutable class VariableLengthPatternItem extends PatternItem { - const VariableLengthPatternItem._( - {required PatternItemType patternItemType, required this.length}) - : super._(patternItemType); + const VariableLengthPatternItem._({ + required PatternItemType patternItemType, + required this.length, + }) : super._(patternItemType); /// The length in pixels of a dash or gap. final double length; /// Converts this object to something serializable in JSON. @override - Object toJson() => [ - _patternItemTypeToJson(type), - length, - ]; + Object toJson() => [_patternItemTypeToJson(type), length]; } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon_updates.dart index ce73e6d9523..9fd3e6560f9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon_updates.dart @@ -11,7 +11,7 @@ import 'types.dart'; class PolygonUpdates extends MapsObjectUpdates { /// Computes [PolygonUpdates] given previous and current [Polygon]s. PolygonUpdates.from(super.previous, super.current) - : super.from(objectName: 'polygon'); + : super.from(objectName: 'polygon'); /// Set of Polygons to be added in this update. Set get polygonsToAdd => objectsToAdd; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart index 9e2e4bb2872..6afa798d914 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline_updates.dart @@ -11,7 +11,7 @@ import 'types.dart'; class PolylineUpdates extends MapsObjectUpdates { /// Computes [PolylineUpdates] given previous and current [Polyline]s. PolylineUpdates.from(super.previous, super.current) - : super.from(objectName: 'polyline'); + : super.from(objectName: 'polyline'); /// Set of Polylines to be added in this update. Set get polylinesToAdd => objectsToAdd; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart index b1d37dc2c23..61652056ef9 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/screen_coordinate.dart @@ -12,10 +12,7 @@ import 'package:flutter/foundation.dart' show immutable, objectRuntimeType; @immutable class ScreenCoordinate { /// Creates an immutable representation of a point coordinate in the [GoogleMap]'s view. - const ScreenCoordinate({ - required this.x, - required this.y, - }); + const ScreenCoordinate({required this.x, required this.y}); /// Represents the number of pixels from the left of the [GoogleMap]. final int x; @@ -25,10 +22,7 @@ class ScreenCoordinate { /// Converts this object to something serializable in JSON. Object toJson() { - return { - 'x': x, - 'y': y, - }; + return {'x': x, 'y': y}; } @override diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile_overlay.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile_overlay.dart index 43699f82055..757eee16a7a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile_overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile_overlay.dart @@ -146,6 +146,13 @@ class TileOverlay implements MapsObject { } @override - int get hashCode => Object.hash(tileOverlayId, fadeIn, tileProvider, - transparency, zIndex, visible, tileSize); + int get hashCode => Object.hash( + tileOverlayId, + fadeIn, + tileProvider, + transparency, + zIndex, + visible, + tileSize, + ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile_overlay_updates.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile_overlay_updates.dart index c6155c2442b..ea8be0e3bec 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile_overlay_updates.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile_overlay_updates.dart @@ -8,7 +8,7 @@ import 'types.dart'; class TileOverlayUpdates extends MapsObjectUpdates { /// Computes [TileOverlayUpdates] given previous and current [TileOverlay]s. TileOverlayUpdates.from(super.previous, super.current) - : super.from(objectName: 'tileOverlay'); + : super.from(objectName: 'tileOverlay'); /// Set of TileOverlays to be added in this update. Set get tileOverlaysToAdd => objectsToAdd; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ui.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ui.dart index 482f64be8b4..ddce089e538 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ui.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/ui.dart @@ -78,7 +78,7 @@ class MinMaxZoomPreference { /// /// [AssertionError] will be thrown if [minZoom] > [maxZoom]. const MinMaxZoomPreference(this.minZoom, this.maxZoom) - : assert(minZoom == null || maxZoom == null || minZoom <= maxZoom); + : assert(minZoom == null || maxZoom == null || minZoom <= maxZoom); /// The preferred minimum zoom level or null, if unbounded from below. final double? minZoom; @@ -87,8 +87,10 @@ class MinMaxZoomPreference { final double? maxZoom; /// Unbounded zooming. - static const MinMaxZoomPreference unbounded = - MinMaxZoomPreference(null, null); + static const MinMaxZoomPreference unbounded = MinMaxZoomPreference( + null, + null, + ); /// Converts this object to something serializable in JSON. Object toJson() => [minZoom, maxZoom]; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/cluster_manager.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/cluster_manager.dart index c44578c04d0..1a7975249df 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/cluster_manager.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/cluster_manager.dart @@ -7,7 +7,9 @@ import 'maps_object.dart'; /// Converts an [Iterable] of Cluster Managers in a Map of ClusterManagerId -> Cluster. Map keyByClusterManagerId( - Iterable clusterManagers) { - return keyByMapsObjectId(clusterManagers) - .cast(); + Iterable clusterManagers, +) { + return keyByMapsObjectId( + clusterManagers, + ).cast(); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/ground_overlay.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/ground_overlay.dart index 6e92d621138..75b962c49f4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/ground_overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/ground_overlay.dart @@ -7,7 +7,9 @@ import 'maps_object.dart'; /// Converts an [Iterable] of GroundOverlay to a Map of GroundOverlayId -> GroundOverlay. Map keyByGroundOverlayId( - Iterable groundOverlays) { - return keyByMapsObjectId(groundOverlays) - .cast(); + Iterable groundOverlays, +) { + return keyByMapsObjectId( + groundOverlays, + ).cast(); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/heatmap.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/heatmap.dart index ff6e7944601..598b7615f09 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/heatmap.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/heatmap.dart @@ -7,9 +7,7 @@ import 'maps_object.dart'; /// Converts an [Iterable] of Heatmaps in a Map of /// HeatmapId -> Heatmap. -Map keyByHeatmapId( - Iterable heatmaps, -) { +Map keyByHeatmapId(Iterable heatmaps) { return keyByMapsObjectId(heatmaps).cast(); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/maps_object.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/maps_object.dart index d17dbd279df..ea803fa50ae 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/maps_object.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/maps_object.dart @@ -6,9 +6,13 @@ import '../maps_object.dart'; /// Converts an [Iterable] of [MapsObject]s in a Map of [MapObjectId] -> [MapObject]. Map, T> keyByMapsObjectId>( - Iterable objects) { - return Map, T>.fromEntries(objects.map((T object) => - MapEntry, T>(object.mapsId, object.clone()))); + Iterable objects, +) { + return Map, T>.fromEntries( + objects.map( + (T object) => MapEntry, T>(object.mapsId, object.clone()), + ), + ); } /// Converts a Set of [MapsObject]s into something serializable in JSON. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/tile_overlay.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/tile_overlay.dart index fae61a4b443..65afb69cb05 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/tile_overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/utils/tile_overlay.dart @@ -7,9 +7,11 @@ import 'maps_object.dart'; /// Converts an [Iterable] of TileOverlay in a Map of TileOverlayId -> TileOverlay. Map keyTileOverlayId( - Iterable tileOverlays) { - return keyByMapsObjectId(tileOverlays) - .cast(); + Iterable tileOverlays, +) { + return keyByMapsObjectId( + tileOverlays, + ).cast(); } /// Converts a Set of TileOverlays into something serializable in JSON. diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml index 81c20b09a8a..643165f130e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/pubspec.yaml @@ -7,8 +7,8 @@ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+ version: 2.13.0 environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" dependencies: collection: ^1.15.0 diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel/method_channel_google_maps_flutter_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel/method_channel_google_maps_flutter_test.dart index 89f1ba5c3f2..c029fdf95c1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel/method_channel_google_maps_flutter_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/method_channel/method_channel_google_maps_flutter_test.dart @@ -26,22 +26,26 @@ void main() { }) { final MethodChannel channel = maps.ensureChannelInitialized(mapId); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .setMockMethodCallHandler( - channel, - (MethodCall methodCall) { - log.add(methodCall.method); - return handler(methodCall); - }, - ); + .setMockMethodCallHandler(channel, (MethodCall methodCall) { + log.add(methodCall.method); + return handler(methodCall); + }); } Future sendPlatformMessage( - int mapId, String method, Map data) async { - final ByteData byteData = const StandardMethodCodec() - .encodeMethodCall(MethodCall(method, data)); + int mapId, + String method, + Map data, + ) async { + final ByteData byteData = const StandardMethodCodec().encodeMethodCall( + MethodCall(method, data), + ); await TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger - .handlePlatformMessage('plugins.flutter.io/google_maps_$mapId', - byteData, (ByteData? data) {}); + .handlePlatformMessage( + 'plugins.flutter.io/google_maps_$mapId', + byteData, + (ByteData? data) {}, + ); } // Calls each method that uses invokeMethod with a return type other than @@ -53,19 +57,22 @@ void main() { const int mapId = 0; final MethodChannelGoogleMapsFlutter maps = MethodChannelGoogleMapsFlutter(); - configureMockMap(maps, mapId: mapId, - handler: (MethodCall methodCall) async { - switch (methodCall.method) { - case 'map#getLatLng': - return [1.0, 2.0]; - case 'markers#isInfoWindowShown': - return true; - case 'map#getZoomLevel': - return 2.5; - case 'map#takeSnapshot': - return null; - } - }); + configureMockMap( + maps, + mapId: mapId, + handler: (MethodCall methodCall) async { + switch (methodCall.method) { + case 'map#getLatLng': + return [1.0, 2.0]; + case 'markers#isInfoWindowShown': + return true; + case 'map#getZoomLevel': + return 2.5; + case 'map#takeSnapshot': + return null; + } + }, + ); await maps.getLatLng(const ScreenCoordinate(x: 0, y: 0), mapId: mapId); await maps.isMarkerInfoWindowShown(const MarkerId(''), mapId: mapId); @@ -84,17 +91,17 @@ void main() { final Map jsonMarkerDragStartEvent = { 'mapId': mapId, 'markerId': 'drag-start-marker', - 'position': [1.0, 1.0] + 'position': [1.0, 1.0], }; final Map jsonMarkerDragEvent = { 'mapId': mapId, 'markerId': 'drag-marker', - 'position': [1.0, 1.0] + 'position': [1.0, 1.0], }; final Map jsonMarkerDragEndEvent = { 'mapId': mapId, 'markerId': 'drag-end-marker', - 'position': [1.0, 1.0] + 'position': [1.0, 1.0], }; final MethodChannelGoogleMapsFlutter maps = @@ -103,23 +110,34 @@ void main() { final StreamQueue markerDragStartStream = StreamQueue( - maps.onMarkerDragStart(mapId: mapId)); + maps.onMarkerDragStart(mapId: mapId), + ); final StreamQueue markerDragStream = StreamQueue(maps.onMarkerDrag(mapId: mapId)); final StreamQueue markerDragEndStream = StreamQueue(maps.onMarkerDragEnd(mapId: mapId)); await sendPlatformMessage( - mapId, 'marker#onDragStart', jsonMarkerDragStartEvent); + mapId, + 'marker#onDragStart', + jsonMarkerDragStartEvent, + ); await sendPlatformMessage(mapId, 'marker#onDrag', jsonMarkerDragEvent); await sendPlatformMessage( - mapId, 'marker#onDragEnd', jsonMarkerDragEndEvent); + mapId, + 'marker#onDragEnd', + jsonMarkerDragEndEvent, + ); - expect((await markerDragStartStream.next).value.value, - equals('drag-start-marker')); + expect( + (await markerDragStartStream.next).value.value, + equals('drag-start-marker'), + ); expect((await markerDragStream.next).value.value, equals('drag-marker')); - expect((await markerDragEndStream.next).value.value, - equals('drag-end-marker')); + expect( + (await markerDragEndStream.next).value.value, + equals('drag-end-marker'), + ); }); }); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/platform_interface/google_maps_flutter_platform_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/platform_interface/google_maps_flutter_platform_test.dart index 6d8583e82a0..7a1f3c47bbc 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/platform_interface/google_maps_flutter_platform_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/platform_interface/google_maps_flutter_platform_test.dart @@ -56,8 +56,9 @@ void main() { platform.buildViewWithTextDirection( 0, (_) {}, - initialCameraPosition: - const CameraPosition(target: LatLng(0.0, 0.0)), + initialCameraPosition: const CameraPosition( + target: LatLng(0.0, 0.0), + ), textDirection: TextDirection.ltr, ), isA(), @@ -84,43 +85,35 @@ void main() { }, ); - test( - 'updateClusterManagers() throws UnimplementedError', - () { - expect( - () => BuildViewGoogleMapsFlutterPlatform().updateClusterManagers( - ClusterManagerUpdates.from( - { - const ClusterManager( - clusterManagerId: ClusterManagerId('123')) - }, - { - const ClusterManager( - clusterManagerId: ClusterManagerId('456')) - }, - ), - mapId: 0), - throwsUnimplementedError); - }, - ); + test('updateClusterManagers() throws UnimplementedError', () { + expect( + () => BuildViewGoogleMapsFlutterPlatform().updateClusterManagers( + ClusterManagerUpdates.from( + { + const ClusterManager(clusterManagerId: ClusterManagerId('123')), + }, + { + const ClusterManager(clusterManagerId: ClusterManagerId('456')), + }, + ), + mapId: 0, + ), + throwsUnimplementedError, + ); + }); - test( - 'onClusterTap() throws UnimplementedError', - () { - expect( - () => BuildViewGoogleMapsFlutterPlatform().onClusterTap(mapId: 0), - throwsUnimplementedError); - }, - ); + test('onClusterTap() throws UnimplementedError', () { + expect( + () => BuildViewGoogleMapsFlutterPlatform().onClusterTap(mapId: 0), + throwsUnimplementedError, + ); + }); - test( - 'default implementation of `getStyleError` returns null', - () async { - final GoogleMapsFlutterPlatform platform = - BuildViewGoogleMapsFlutterPlatform(); - expect(await platform.getStyleError(mapId: 0), null); - }, - ); + test('default implementation of `getStyleError` returns null', () async { + final GoogleMapsFlutterPlatform platform = + BuildViewGoogleMapsFlutterPlatform(); + expect(await platform.getStyleError(mapId: 0), null); + }); test( 'default implementation of isAdvancedMarkersAvailable returns false', @@ -132,26 +125,34 @@ void main() { ); test( - 'default implementation of `animateCameraWithConfiguration` delegates to `animateCamera`', - () { - final GoogleMapsFlutterPlatform platform = - ExtendsGoogleMapsFlutterPlatform(); - GoogleMapsFlutterPlatform.instance = platform; + 'default implementation of `animateCameraWithConfiguration` delegates to `animateCamera`', + () { + final GoogleMapsFlutterPlatform platform = + ExtendsGoogleMapsFlutterPlatform(); + GoogleMapsFlutterPlatform.instance = platform; - const CameraUpdateAnimationConfiguration animationConfig = - CameraUpdateAnimationConfiguration(duration: Duration(seconds: 2)); - final CameraUpdate cameraUpdate = CameraUpdate.newCameraPosition( - const CameraPosition(target: LatLng(10.0, 15.0)), - ); + const CameraUpdateAnimationConfiguration animationConfig = + CameraUpdateAnimationConfiguration(duration: Duration(seconds: 2)); + final CameraUpdate cameraUpdate = CameraUpdate.newCameraPosition( + const CameraPosition(target: LatLng(10.0, 15.0)), + ); - expect( + expect( () => platform.animateCameraWithConfiguration( - cameraUpdate, animationConfig, mapId: 0), - throwsA(isA().having( + cameraUpdate, + animationConfig, + mapId: 0, + ), + throwsA( + isA().having( (UnimplementedError e) => e.message, 'message', - contains('animateCamera() has not been implemented')))); - }); + contains('animateCamera() has not been implemented'), + ), + ), + ); + }, + ); }); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/advanced_marker_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/advanced_marker_test.dart index 1ddc5c947e6..2f427068c21 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/advanced_marker_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/advanced_marker_test.dart @@ -9,8 +9,9 @@ void main() { group('$AdvancedMarker', () { test('constructor defaults', () { - final AdvancedMarker marker = - AdvancedMarker(markerId: const MarkerId('ABC123')); + final AdvancedMarker marker = AdvancedMarker( + markerId: const MarkerId('ABC123'), + ); expect(marker.alpha, equals(1.0)); expect(marker.anchor, equals(const Offset(0.5, 1.0))); @@ -119,8 +120,9 @@ void main() { const double testRotationParam = 100; final bool testVisibleParam = !marker.visible; const double testZIndexParam = 100; - const ClusterManagerId testClusterManagerIdParam = - ClusterManagerId('DEF123'); + const ClusterManagerId testClusterManagerIdParam = ClusterManagerId( + 'DEF123', + ); final List log = []; const MarkerCollisionBehavior testCollisionBehavior = MarkerCollisionBehavior.requiredAndHidesOptional; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/bitmap_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/bitmap_test.dart index 44e63badbbd..68535f14d26 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/bitmap_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/bitmap_test.dart @@ -12,13 +12,15 @@ void main() { group('$BitmapDescriptor', () { test('toJson / fromJson', () { - final BitmapDescriptor descriptor = - BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueCyan); + final BitmapDescriptor descriptor = BitmapDescriptor.defaultMarkerWithHue( + BitmapDescriptor.hueCyan, + ); final Object json = descriptor.toJson(); // Rehydrate a new bitmap descriptor... - final BitmapDescriptor descriptorFromJson = - BitmapDescriptor.fromJson(json); + final BitmapDescriptor descriptorFromJson = BitmapDescriptor.fromJson( + json, + ); expect(descriptorFromJson, isNot(descriptor)); // New instance expect(descriptorFromJson.toJson(), json); @@ -44,11 +46,12 @@ void main() { ); expect(descriptor, isA()); expect( - descriptor.toJson(), - equals([ - 'fromBytes', - [1, 2, 3], - ])); + descriptor.toJson(), + equals([ + 'fromBytes', + [1, 2, 3], + ]), + ); descriptor as BytesBitmap; expect(descriptor.byteData, Uint8List.fromList([1, 2, 3])); }); @@ -60,11 +63,12 @@ void main() { ); expect( - descriptor.toJson(), - equals([ - 'fromBytes', - [1, 2, 3], - ])); + descriptor.toJson(), + equals([ + 'fromBytes', + [1, 2, 3], + ]), + ); descriptor as BytesBitmap; expect(descriptor.byteData, Uint8List.fromList([1, 2, 3])); expect(descriptor.size, null); @@ -77,12 +81,13 @@ void main() { ); expect( - descriptor.toJson(), - equals([ - 'fromBytes', - [1, 2, 3], - [40, 20], - ])); + descriptor.toJson(), + equals([ + 'fromBytes', + [1, 2, 3], + [40, 20], + ]), + ); descriptor as BytesBitmap; expect(descriptor.byteData, Uint8List.fromList([1, 2, 3])); expect(descriptor.size, const Size(40, 20)); @@ -92,8 +97,10 @@ void main() { group('fromJson validation', () { group('type validation', () { test('correct type', () { - expect(BitmapDescriptor.fromJson(['defaultMarker']), - isA()); + expect( + BitmapDescriptor.fromJson(['defaultMarker']), + isA(), + ); }); test('wrong type', () { @@ -104,13 +111,17 @@ void main() { }); group('defaultMarker', () { test('hue is null', () { - expect(BitmapDescriptor.fromJson(['defaultMarker']), - isA()); + expect( + BitmapDescriptor.fromJson(['defaultMarker']), + isA(), + ); }); test('hue is number', () { - expect(BitmapDescriptor.fromJson(['defaultMarker', 158]), - isA()); + expect( + BitmapDescriptor.fromJson(['defaultMarker', 158]), + isA(), + ); }); test('hue is not number', () { @@ -131,11 +142,12 @@ void main() { group('fromBytes', () { test('with bytes', () { expect( - BitmapDescriptor.fromJson([ - 'fromBytes', - Uint8List.fromList([1, 2, 3]) - ]), - isA()); + BitmapDescriptor.fromJson([ + 'fromBytes', + Uint8List.fromList([1, 2, 3]), + ]), + isA(), + ); }); test('without bytes', () { @@ -150,9 +162,9 @@ void main() { group('fromAsset', () { test('name is passed', () { expect( - BitmapDescriptor.fromJson( - ['fromAsset', 'some/path.png']), - isA()); + BitmapDescriptor.fromJson(['fromAsset', 'some/path.png']), + isA(), + ); }); test('name cannot be null or empty', () { @@ -166,50 +178,68 @@ void main() { test('package is passed', () { expect( - BitmapDescriptor.fromJson( - ['fromAsset', 'some/path.png', 'some_package']), - isA()); + BitmapDescriptor.fromJson([ + 'fromAsset', + 'some/path.png', + 'some_package', + ]), + isA(), + ); }); test('package cannot be null or empty', () { expect(() { - BitmapDescriptor.fromJson( - ['fromAsset', 'some/path.png', null]); + BitmapDescriptor.fromJson([ + 'fromAsset', + 'some/path.png', + null, + ]); }, throwsAssertionError); expect(() { - BitmapDescriptor.fromJson( - ['fromAsset', 'some/path.png', '']); + BitmapDescriptor.fromJson([ + 'fromAsset', + 'some/path.png', + '', + ]); }, throwsAssertionError); }); }); group('fromAssetImage', () { test('name and dpi passed', () { expect( - BitmapDescriptor.fromJson( - ['fromAssetImage', 'some/path.png', 1.0]), - isA()); - }); - - test('mipmaps determines dpi', () async { - const ImageConfiguration imageConfiguration = ImageConfiguration( - devicePixelRatio: 3, + BitmapDescriptor.fromJson([ + 'fromAssetImage', + 'some/path.png', + 1.0, + ]), + isA(), ); + }); - final BitmapDescriptor mip = await BitmapDescriptor.fromAssetImage( - imageConfiguration, - 'red_square.png', - ); - final BitmapDescriptor scaled = await BitmapDescriptor.fromAssetImage( - imageConfiguration, - 'red_square.png', - mipmaps: false, - ); + test( + 'mipmaps determines dpi', + () async { + const ImageConfiguration imageConfiguration = ImageConfiguration( + devicePixelRatio: 3, + ); + + final BitmapDescriptor mip = await BitmapDescriptor.fromAssetImage( + imageConfiguration, + 'red_square.png', + ); + final BitmapDescriptor scaled = + await BitmapDescriptor.fromAssetImage( + imageConfiguration, + 'red_square.png', + mipmaps: false, + ); - expect((mip.toJson() as List)[2], 1); - expect((scaled.toJson() as List)[2], 3); - }, - // TODO(stuartmorgan): Investigate timeout on web. - skip: kIsWeb); + expect((mip.toJson() as List)[2], 1); + expect((scaled.toJson() as List)[2], 3); + }, + // TODO(stuartmorgan): Investigate timeout on web. + skip: kIsWeb, + ); test('name cannot be null or empty', () { expect(() { @@ -222,72 +252,97 @@ void main() { test('dpi must be number', () { expect(() { - BitmapDescriptor.fromJson( - ['fromAssetImage', 'some/path.png', null]); + BitmapDescriptor.fromJson([ + 'fromAssetImage', + 'some/path.png', + null, + ]); }, throwsAssertionError); expect(() { - BitmapDescriptor.fromJson( - ['fromAssetImage', 'some/path.png', 'one']); + BitmapDescriptor.fromJson([ + 'fromAssetImage', + 'some/path.png', + 'one', + ]); }, throwsAssertionError); }); test('with optional [width, height] List', () { expect( - BitmapDescriptor.fromJson([ - 'fromAssetImage', - 'some/path.png', - 1.0, - [640, 480] - ]), - isA()); - }); - - test( - 'optional [width, height] List cannot be null or not contain 2 elements', - () { - expect(() { - BitmapDescriptor.fromJson( - ['fromAssetImage', 'some/path.png', 1.0, null]); - }, throwsAssertionError); - expect(() { - BitmapDescriptor.fromJson( - ['fromAssetImage', 'some/path.png', 1.0, []]); - }, throwsAssertionError); - expect(() { BitmapDescriptor.fromJson([ 'fromAssetImage', 'some/path.png', 1.0, - [640, 480, 1024] - ]); - }, throwsAssertionError); + [640, 480], + ]), + isA(), + ); }); + + test( + 'optional [width, height] List cannot be null or not contain 2 elements', + () { + expect(() { + BitmapDescriptor.fromJson([ + 'fromAssetImage', + 'some/path.png', + 1.0, + null, + ]); + }, throwsAssertionError); + expect(() { + BitmapDescriptor.fromJson([ + 'fromAssetImage', + 'some/path.png', + 1.0, + [], + ]); + }, throwsAssertionError); + expect(() { + BitmapDescriptor.fromJson([ + 'fromAssetImage', + 'some/path.png', + 1.0, + [640, 480, 1024], + ]); + }, throwsAssertionError); + }, + ); }); group('bytes', () { test('with bytes', () { expect( - BitmapDescriptor.fromJson([ - BytesMapBitmap.type, - { - 'byteData': Uint8List.fromList([1, 2, 3]), - 'bitmapScaling': MapBitmapScaling.auto.name, - 'imagePixelRatio': 1.0, - 'width': 1.0, - 'height': 1.0, - } - ]), - isA()); + BitmapDescriptor.fromJson([ + BytesMapBitmap.type, + { + 'byteData': Uint8List.fromList([1, 2, 3]), + 'bitmapScaling': MapBitmapScaling.auto.name, + 'imagePixelRatio': 1.0, + 'width': 1.0, + 'height': 1.0, + }, + ]), + isA(), + ); }); test('without bytes', () { expect(() { - BitmapDescriptor.fromJson( - [BytesMapBitmap.type, null, 'auto', 3.0]); + BitmapDescriptor.fromJson([ + BytesMapBitmap.type, + null, + 'auto', + 3.0, + ]); }, throwsAssertionError); expect(() { - BitmapDescriptor.fromJson( - [BytesMapBitmap.type, [], 'auto', 3.0]); + BitmapDescriptor.fromJson([ + BytesMapBitmap.type, + [], + 'auto', + 3.0, + ]); }, throwsAssertionError); }); }); @@ -295,15 +350,16 @@ void main() { group('asset', () { test('name and dpi passed', () { expect( - BitmapDescriptor.fromJson([ - AssetMapBitmap.type, - { - 'assetName': 'red_square.png', - 'bitmapScaling': MapBitmapScaling.auto.name, - 'imagePixelRatio': 1.0, - } - ]), - isA()); + BitmapDescriptor.fromJson([ + AssetMapBitmap.type, + { + 'assetName': 'red_square.png', + 'bitmapScaling': MapBitmapScaling.auto.name, + 'imagePixelRatio': 1.0, + }, + ]), + isA(), + ); }); test('name cannot be null or empty', () { @@ -333,7 +389,7 @@ void main() { 'assetName': 'red_square.png', 'bitmapScaling': MapBitmapScaling.auto.name, 'imagePixelRatio': 'string', - } + }, ]); }, throwsAssertionError); expect(() { @@ -343,97 +399,100 @@ void main() { 'assetName': 'red_square.png', 'bitmapScaling': MapBitmapScaling.auto.name, 'imagePixelRatio': null, - } + }, ]); }, throwsAssertionError); }); test('with optional [width, height]', () { expect( - BitmapDescriptor.fromJson([ - AssetMapBitmap.type, - { - 'assetName': 'red_square.png', - 'bitmapScaling': MapBitmapScaling.auto.name, - 'imagePixelRatio': 1.0, - 'width': 1.0, - 'height': 1.0, - } - ]), - isA()); - }); - - test('optional width and height parameters must be in proper format', - () { - expect(() { - BitmapDescriptor.fromJson([ - 'fromAssetImage', - 'some/path.png', - 'auto', - 1.0, - null - ]); - }, throwsAssertionError); - expect(() { - BitmapDescriptor.fromJson([ - 'fromAssetImage', - 'some/path.png', - 'auto', - 1.0, - [] - ]); - }, throwsAssertionError); - expect(() { BitmapDescriptor.fromJson([ AssetMapBitmap.type, - 'some/path.png', { 'assetName': 'red_square.png', 'bitmapScaling': MapBitmapScaling.auto.name, - 'imagePixelRatio': null, - 'width': null, - 'height': 1.0, - } - ]); - }, throwsAssertionError); - expect(() { - BitmapDescriptor.fromJson([ - AssetMapBitmap.type, - 'some/path.png', - { - 'assetName': 'red_square.png', - 'bitmapScaling': MapBitmapScaling.auto.name, - 'imagePixelRatio': null, + 'imagePixelRatio': 1.0, 'width': 1.0, - 'height': null, - } - ]); - }, throwsAssertionError); - expect(() { - BitmapDescriptor.fromJson([ - AssetMapBitmap.type, - 'some/path.png', - { - 'assetName': 'red_square.png', - 'bitmapScaling': MapBitmapScaling.auto.name, - 'imagePixelRatio': null, - 'width': '1.0', - } - ]); - }, throwsAssertionError); + 'height': 1.0, + }, + ]), + isA(), + ); }); + + test( + 'optional width and height parameters must be in proper format', + () { + expect(() { + BitmapDescriptor.fromJson([ + 'fromAssetImage', + 'some/path.png', + 'auto', + 1.0, + null, + ]); + }, throwsAssertionError); + expect(() { + BitmapDescriptor.fromJson([ + 'fromAssetImage', + 'some/path.png', + 'auto', + 1.0, + [], + ]); + }, throwsAssertionError); + expect(() { + BitmapDescriptor.fromJson([ + AssetMapBitmap.type, + 'some/path.png', + { + 'assetName': 'red_square.png', + 'bitmapScaling': MapBitmapScaling.auto.name, + 'imagePixelRatio': null, + 'width': null, + 'height': 1.0, + }, + ]); + }, throwsAssertionError); + expect(() { + BitmapDescriptor.fromJson([ + AssetMapBitmap.type, + 'some/path.png', + { + 'assetName': 'red_square.png', + 'bitmapScaling': MapBitmapScaling.auto.name, + 'imagePixelRatio': null, + 'width': 1.0, + 'height': null, + }, + ]); + }, throwsAssertionError); + expect(() { + BitmapDescriptor.fromJson([ + AssetMapBitmap.type, + 'some/path.png', + { + 'assetName': 'red_square.png', + 'bitmapScaling': MapBitmapScaling.auto.name, + 'imagePixelRatio': null, + 'width': '1.0', + }, + ]); + }, throwsAssertionError); + }, + ); }); }); }); - group('AssetMapBitmap', () { - test('construct', () async { - final BitmapDescriptor descriptor = AssetMapBitmap( - 'red_square.png', - ); - expect(descriptor, isA()); - expect(descriptor, isA()); - expect( + group( + 'AssetMapBitmap', + () { + test('construct', () async { + final BitmapDescriptor descriptor = AssetMapBitmap('red_square.png'); + expect(descriptor, isA()); + expect(descriptor, isA()); + expect( descriptor.toJson(), equals([ AssetMapBitmap.type, @@ -441,21 +500,24 @@ void main() { 'assetName': 'red_square.png', 'bitmapScaling': MapBitmapScaling.auto.name, 'imagePixelRatio': 1.0, - } - ])); - descriptor as AssetMapBitmap; - expect(descriptor.assetName, 'red_square.png'); - expect(descriptor.bitmapScaling, MapBitmapScaling.auto); - expect(descriptor.imagePixelRatio, 1.0); - }); + }, + ]), + ); + descriptor as AssetMapBitmap; + expect(descriptor.assetName, 'red_square.png'); + expect(descriptor.bitmapScaling, MapBitmapScaling.auto); + expect(descriptor.imagePixelRatio, 1.0); + }); - test('construct with imagePixelRatio', () async { - final BitmapDescriptor descriptor = - AssetMapBitmap('red_square.png', imagePixelRatio: 1.2345); + test('construct with imagePixelRatio', () async { + final BitmapDescriptor descriptor = AssetMapBitmap( + 'red_square.png', + imagePixelRatio: 1.2345, + ); - expect(descriptor, isA()); - expect(descriptor, isA()); - expect( + expect(descriptor, isA()); + expect(descriptor, isA()); + expect( descriptor.toJson(), equals([ AssetMapBitmap.type, @@ -463,22 +525,25 @@ void main() { 'assetName': 'red_square.png', 'bitmapScaling': MapBitmapScaling.auto.name, 'imagePixelRatio': 1.2345, - } - ])); - descriptor as AssetMapBitmap; - expect(descriptor.assetName, 'red_square.png'); - expect(descriptor.bitmapScaling, MapBitmapScaling.auto); - expect(descriptor.imagePixelRatio, 1.2345); - }); + }, + ]), + ); + descriptor as AssetMapBitmap; + expect(descriptor.assetName, 'red_square.png'); + expect(descriptor.bitmapScaling, MapBitmapScaling.auto); + expect(descriptor.imagePixelRatio, 1.2345); + }); - test('construct with width', () async { - const double width = 100; - final BitmapDescriptor descriptor = - AssetMapBitmap('red_square.png', width: width); + test('construct with width', () async { + const double width = 100; + final BitmapDescriptor descriptor = AssetMapBitmap( + 'red_square.png', + width: width, + ); - expect(descriptor, isA()); - expect(descriptor, isA()); - expect( + expect(descriptor, isA()); + expect(descriptor, isA()); + expect( descriptor.toJson(), equals([ AssetMapBitmap.type, @@ -487,48 +552,58 @@ void main() { 'bitmapScaling': MapBitmapScaling.auto.name, 'imagePixelRatio': 1.0, 'width': width, - } - ])); - descriptor as AssetMapBitmap; - expect(descriptor.assetName, 'red_square.png'); - expect(descriptor.bitmapScaling, MapBitmapScaling.auto); - expect(descriptor.imagePixelRatio, 1.0); - expect(descriptor.width, width); - }); + }, + ]), + ); + descriptor as AssetMapBitmap; + expect(descriptor.assetName, 'red_square.png'); + expect(descriptor.bitmapScaling, MapBitmapScaling.auto); + expect(descriptor.imagePixelRatio, 1.0); + expect(descriptor.width, width); + }); - test('create', () async { - final BitmapDescriptor descriptor = await AssetMapBitmap.create( - ImageConfiguration.empty, 'red_square.png'); - expect(descriptor, isA()); - expect(descriptor, isA()); - expect( - descriptor.toJson(), - equals([ - AssetMapBitmap.type, - { - 'assetName': 'red_square.png', - 'bitmapScaling': MapBitmapScaling.auto.name, - 'imagePixelRatio': 1.0 - } - ])); - descriptor as AssetMapBitmap; - expect(descriptor.assetName, 'red_square.png'); - expect(descriptor.bitmapScaling, MapBitmapScaling.auto); - expect(descriptor.imagePixelRatio, 1.0); - }, + test( + 'create', + () async { + final BitmapDescriptor descriptor = await AssetMapBitmap.create( + ImageConfiguration.empty, + 'red_square.png', + ); + expect(descriptor, isA()); + expect(descriptor, isA()); + expect( + descriptor.toJson(), + equals([ + AssetMapBitmap.type, + { + 'assetName': 'red_square.png', + 'bitmapScaling': MapBitmapScaling.auto.name, + 'imagePixelRatio': 1.0, + }, + ]), + ); + descriptor as AssetMapBitmap; + expect(descriptor.assetName, 'red_square.png'); + expect(descriptor.bitmapScaling, MapBitmapScaling.auto); + expect(descriptor.imagePixelRatio, 1.0); + }, // TODO(stuartmorgan): Investigate timeout on web. - skip: kIsWeb); + skip: kIsWeb, + ); - test('create with size', () async { - const Size size = Size(100, 200); - const ImageConfiguration imageConfiguration = - ImageConfiguration(size: size); - final BitmapDescriptor descriptor = - await AssetMapBitmap.create(imageConfiguration, 'red_square.png'); + test('create with size', () async { + const Size size = Size(100, 200); + const ImageConfiguration imageConfiguration = ImageConfiguration( + size: size, + ); + final BitmapDescriptor descriptor = await AssetMapBitmap.create( + imageConfiguration, + 'red_square.png', + ); - expect(descriptor, isA()); - expect(descriptor, isA()); - expect( + expect(descriptor, isA()); + expect(descriptor, isA()); + expect( descriptor.toJson(), equals([ AssetMapBitmap.type, @@ -537,26 +612,29 @@ void main() { 'bitmapScaling': MapBitmapScaling.auto.name, 'imagePixelRatio': 1.0, 'width': 100.0, - 'height': 200.0 - } - ])); - descriptor as AssetMapBitmap; - expect(descriptor.assetName, 'red_square.png'); - expect(descriptor.bitmapScaling, MapBitmapScaling.auto); - expect(descriptor.imagePixelRatio, 1.0); - expect(descriptor.width, 100.0); - expect(descriptor.height, 200.0); - }); + 'height': 200.0, + }, + ]), + ); + descriptor as AssetMapBitmap; + expect(descriptor.assetName, 'red_square.png'); + expect(descriptor.bitmapScaling, MapBitmapScaling.auto); + expect(descriptor.imagePixelRatio, 1.0); + expect(descriptor.width, 100.0); + expect(descriptor.height, 200.0); + }); - test('create with width', () async { - const ImageConfiguration imageConfiguration = ImageConfiguration.empty; - final BitmapDescriptor descriptor = await AssetMapBitmap.create( - imageConfiguration, 'red_square.png', - width: 100); + test('create with width', () async { + const ImageConfiguration imageConfiguration = ImageConfiguration.empty; + final BitmapDescriptor descriptor = await AssetMapBitmap.create( + imageConfiguration, + 'red_square.png', + width: 100, + ); - expect(descriptor, isA()); - expect(descriptor, isA()); - expect( + expect(descriptor, isA()); + expect(descriptor, isA()); + expect( descriptor.toJson(), equals([ AssetMapBitmap.type, @@ -565,24 +643,27 @@ void main() { 'bitmapScaling': MapBitmapScaling.auto.name, 'imagePixelRatio': 1.0, 'width': 100.0, - } - ])); - descriptor as AssetMapBitmap; - expect(descriptor.assetName, 'red_square.png'); - expect(descriptor.bitmapScaling, MapBitmapScaling.auto); - expect(descriptor.imagePixelRatio, 1.0); - expect(descriptor.width, 100.0); - }); + }, + ]), + ); + descriptor as AssetMapBitmap; + expect(descriptor.assetName, 'red_square.png'); + expect(descriptor.bitmapScaling, MapBitmapScaling.auto); + expect(descriptor.imagePixelRatio, 1.0); + expect(descriptor.width, 100.0); + }); - test('create with height', () async { - const ImageConfiguration imageConfiguration = ImageConfiguration.empty; - final BitmapDescriptor descriptor = await AssetMapBitmap.create( - imageConfiguration, 'red_square.png', - height: 200); + test('create with height', () async { + const ImageConfiguration imageConfiguration = ImageConfiguration.empty; + final BitmapDescriptor descriptor = await AssetMapBitmap.create( + imageConfiguration, + 'red_square.png', + height: 200, + ); - expect(descriptor, isA()); - expect(descriptor, isA()); - expect( + expect(descriptor, isA()); + expect(descriptor, isA()); + expect( descriptor.toJson(), equals([ AssetMapBitmap.type, @@ -590,18 +671,20 @@ void main() { 'assetName': 'red_square.png', 'bitmapScaling': MapBitmapScaling.auto.name, 'imagePixelRatio': 1.0, - 'height': 200.0 - } - ])); - descriptor as AssetMapBitmap; - expect(descriptor.assetName, 'red_square.png'); - expect(descriptor.bitmapScaling, MapBitmapScaling.auto); - expect(descriptor.imagePixelRatio, 1.0); - expect(descriptor.height, 200.0); - }); - }, - // TODO(stuartmorgan): Investigate timeout on web. - skip: kIsWeb); + 'height': 200.0, + }, + ]), + ); + descriptor as AssetMapBitmap; + expect(descriptor.assetName, 'red_square.png'); + expect(descriptor.bitmapScaling, MapBitmapScaling.auto); + expect(descriptor.imagePixelRatio, 1.0); + expect(descriptor.height, 200.0); + }); + }, + // TODO(stuartmorgan): Investigate timeout on web. + skip: kIsWeb, + ); group('BytesMapBitmap', () { test('construct with empty byte array, throws assertion error', () { @@ -617,15 +700,16 @@ void main() { expect(descriptor, isA()); expect(descriptor, isA()); expect( - descriptor.toJson(), - equals([ - BytesMapBitmap.type, - { - 'byteData': [1, 2, 3], - 'bitmapScaling': MapBitmapScaling.auto.name, - 'imagePixelRatio': 1.0, - } - ])); + descriptor.toJson(), + equals([ + BytesMapBitmap.type, + { + 'byteData': [1, 2, 3], + 'bitmapScaling': MapBitmapScaling.auto.name, + 'imagePixelRatio': 1.0, + }, + ]), + ); descriptor as BytesMapBitmap; expect(descriptor.byteData, Uint8List.fromList([1, 2, 3])); expect(descriptor.bitmapScaling, MapBitmapScaling.auto); @@ -641,16 +725,17 @@ void main() { expect(descriptor, isA()); expect( - descriptor.toJson(), - equals([ - BytesMapBitmap.type, - { - 'byteData': [1, 2, 3], - 'bitmapScaling': MapBitmapScaling.auto.name, - 'imagePixelRatio': 1.0, - 'width': 100.0 - } - ])); + descriptor.toJson(), + equals([ + BytesMapBitmap.type, + { + 'byteData': [1, 2, 3], + 'bitmapScaling': MapBitmapScaling.auto.name, + 'imagePixelRatio': 1.0, + 'width': 100.0, + }, + ]), + ); descriptor as BytesMapBitmap; expect(descriptor.byteData, Uint8List.fromList([1, 2, 3])); expect(descriptor.bitmapScaling, MapBitmapScaling.auto); @@ -666,15 +751,16 @@ void main() { expect(descriptor, isA()); expect( - descriptor.toJson(), - equals([ - BytesMapBitmap.type, - { - 'byteData': [1, 2, 3], - 'bitmapScaling': MapBitmapScaling.auto.name, - 'imagePixelRatio': 1.2345 - } - ])); + descriptor.toJson(), + equals([ + BytesMapBitmap.type, + { + 'byteData': [1, 2, 3], + 'bitmapScaling': MapBitmapScaling.auto.name, + 'imagePixelRatio': 1.2345, + }, + ]), + ); descriptor as BytesMapBitmap; expect(descriptor.byteData, Uint8List.fromList([1, 2, 3])); expect(descriptor.bitmapScaling, MapBitmapScaling.auto); @@ -695,16 +781,13 @@ void main() { expect(pinConfig, isA()); expect(pinConfig.backgroundColor, Colors.green); expect(pinConfig.borderColor, Colors.blue); - expect( - pinConfig.toJson(), - [ - PinConfig.type, - { - 'backgroundColor': Colors.green.value, - 'borderColor': Colors.blue.value, - }, - ], - ); + expect(pinConfig.toJson(), [ + PinConfig.type, + { + 'backgroundColor': Colors.green.value, + 'borderColor': Colors.blue.value, + }, + ]); }); test('construct with glyph text', () { @@ -716,23 +799,17 @@ void main() { expect(pinConfig.glyph, isA()); expect((pinConfig.glyph! as TextGlyph).text, 'Hello'); expect((pinConfig.glyph! as TextGlyph).textColor, Colors.red); - expect( - pinConfig.toJson(), - [ - PinConfig.type, - { - 'backgroundColor': Colors.green.value, - 'borderColor': Colors.blue.value, - 'glyph': [ - 'textGlyph', - { - 'text': 'Hello', - 'textColor': Colors.red.value, - } - ], - }, - ], - ); + expect(pinConfig.toJson(), [ + PinConfig.type, + { + 'backgroundColor': Colors.green.value, + 'borderColor': Colors.blue.value, + 'glyph': [ + 'textGlyph', + {'text': 'Hello', 'textColor': Colors.red.value}, + ], + }, + ]); }); test('construct with glyph bitmap', () async { @@ -745,25 +822,19 @@ void main() { expect(pinConfig.backgroundColor, Colors.black); expect(pinConfig.borderColor, Colors.red); - expect( - pinConfig.toJson(), - [ - PinConfig.type, - { - 'glyph': [ - 'bitmapGlyph', - { - 'bitmap': [ - 'fromAsset', - 'red_square.png', - ], - }, - ], - 'backgroundColor': Colors.black.value, - 'borderColor': Colors.red.value, - }, - ], - ); + expect(pinConfig.toJson(), [ + PinConfig.type, + { + 'glyph': [ + 'bitmapGlyph', + { + 'bitmap': ['fromAsset', 'red_square.png'], + }, + ], + 'backgroundColor': Colors.black.value, + 'borderColor': Colors.red.value, + }, + ]); }); }); diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/camera_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/camera_test.dart index 4c4214b2609..9f2451ec6df 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/camera_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/camera_test.dart @@ -10,7 +10,11 @@ void main() { test('toMap / fromMap', () { const CameraPosition cameraPosition = CameraPosition( - target: LatLng(10.0, 15.0), bearing: 0.5, tilt: 30.0, zoom: 1.5); + target: LatLng(10.0, 15.0), + bearing: 0.5, + tilt: 30.0, + zoom: 1.5, + ); // Cast to to ensure that recreating from JSON, where // type information will have likely been lost, still works. final Map json = @@ -23,9 +27,14 @@ void main() { test('CameraUpdate.newCameraPosition', () { const CameraPosition cameraPosition = CameraPosition( - target: LatLng(10.0, 15.0), bearing: 0.5, tilt: 30.0, zoom: 1.5); - final CameraUpdate cameraUpdate = - CameraUpdate.newCameraPosition(cameraPosition); + target: LatLng(10.0, 15.0), + bearing: 0.5, + tilt: 30.0, + zoom: 1.5, + ); + final CameraUpdate cameraUpdate = CameraUpdate.newCameraPosition( + cameraPosition, + ); expect(cameraUpdate.runtimeType, CameraUpdateNewCameraPosition); expect(cameraUpdate.updateType, CameraUpdateType.newCameraPosition); cameraUpdate as CameraUpdateNewCameraPosition; @@ -47,10 +56,14 @@ void main() { test('CameraUpdate.newLatLngBounds', () { final LatLngBounds latLngBounds = LatLngBounds( - northeast: const LatLng(1.0, 2.0), southwest: const LatLng(-2.0, -3.0)); + northeast: const LatLng(1.0, 2.0), + southwest: const LatLng(-2.0, -3.0), + ); const double padding = 1.0; - final CameraUpdate cameraUpdate = - CameraUpdate.newLatLngBounds(latLngBounds, padding); + final CameraUpdate cameraUpdate = CameraUpdate.newLatLngBounds( + latLngBounds, + padding, + ); expect(cameraUpdate.runtimeType, CameraUpdateNewLatLngBounds); expect(cameraUpdate.updateType, CameraUpdateType.newLatLngBounds); cameraUpdate as CameraUpdateNewLatLngBounds; diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cap_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cap_test.dart index bdd94018f9a..9e992586066 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cap_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cap_test.dart @@ -26,23 +26,27 @@ void main() { test('customCap', () { final Cap cap = Cap.customCapFromBitmap(BitmapDescriptor.defaultMarker); expect( - cap.toJson(), - equals([ - 'customCap', - ['defaultMarker'], - 10.0 - ])); + cap.toJson(), + equals([ + 'customCap', + ['defaultMarker'], + 10.0, + ]), + ); }); test('customCapWithWidth', () { - final Cap cap = - Cap.customCapFromBitmap(BitmapDescriptor.defaultMarker, refWidth: 100); + final Cap cap = Cap.customCapFromBitmap( + BitmapDescriptor.defaultMarker, + refWidth: 100, + ); expect( - cap.toJson(), - equals([ - 'customCap', - ['defaultMarker'], - 100.0 - ])); + cap.toJson(), + equals([ + 'customCap', + ['defaultMarker'], + 100.0, + ]), + ); }); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cluster_manager_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cluster_manager_test.dart index 073c6c3dbec..d876d7b0a20 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cluster_manager_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cluster_manager_test.dart @@ -11,33 +11,35 @@ void main() { group('$ClusterManager', () { test('constructor defaults', () { - const ClusterManager manager = - ClusterManager(clusterManagerId: ClusterManagerId('1234')); + const ClusterManager manager = ClusterManager( + clusterManagerId: ClusterManagerId('1234'), + ); expect(manager.clusterManagerId, const ClusterManagerId('1234')); }); test('toJson', () { - const ClusterManager manager = - ClusterManager(clusterManagerId: ClusterManagerId('1234')); + const ClusterManager manager = ClusterManager( + clusterManagerId: ClusterManagerId('1234'), + ); final Map json = manager.toJson() as Map; - expect(json, { - 'clusterManagerId': '1234', - }); + expect(json, {'clusterManagerId': '1234'}); }); test('clone', () { - const ClusterManager manager = - ClusterManager(clusterManagerId: ClusterManagerId('1234')); + const ClusterManager manager = ClusterManager( + clusterManagerId: ClusterManagerId('1234'), + ); final ClusterManager clone = manager.clone(); expect(identical(clone, manager), isFalse); expect(clone, equals(manager)); }); test('copyWith', () { - const ClusterManager manager = - ClusterManager(clusterManagerId: ClusterManagerId('1234')); + const ClusterManager manager = ClusterManager( + clusterManagerId: ClusterManagerId('1234'), + ); final List log = []; final ClusterManager copy = manager.copyWith( @@ -45,12 +47,17 @@ void main() { log.add('onTapParam'); }, ); - copy.onClusterTap!(Cluster( - manager.clusterManagerId, const [MarkerId('5678')], + copy.onClusterTap!( + Cluster( + manager.clusterManagerId, + const [MarkerId('5678')], position: const LatLng(11.0, 22.0), bounds: LatLngBounds( - southwest: const LatLng(22.0, 33.0), - northeast: const LatLng(33.0, 88.0)))); + southwest: const LatLng(22.0, 33.0), + northeast: const LatLng(33.0, 88.0), + ), + ), + ); expect(log, contains('onTapParam')); }); }); diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cluster_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cluster_test.dart index 26a69ed0ee3..c13a3042255 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cluster_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/cluster_test.dart @@ -25,11 +25,12 @@ void main() { expect(cluster.markerIds[0].value, equals('23456')); expect(cluster.position, equals(const LatLng(55.0, 66.0))); expect( - cluster.bounds, - LatLngBounds( - northeast: const LatLng(88.0, 22.0), - southwest: const LatLng(11.0, 99.0), - )); + cluster.bounds, + LatLngBounds( + northeast: const LatLng(88.0, 22.0), + southwest: const LatLng(11.0, 99.0), + ), + ); }); test('constructor markerIds length is > 0', () { @@ -45,8 +46,10 @@ void main() { ); } - expect(() => initWithMarkerIds([const MarkerId('12342323')]), - isNot(throwsAssertionError)); + expect( + () => initWithMarkerIds([const MarkerId('12342323')]), + isNot(throwsAssertionError), + ); expect(() => initWithMarkerIds([]), throwsAssertionError); }); }); diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/heatmap_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/heatmap_test.dart index bc7d779d00a..c8cc93f34f4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/heatmap_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/heatmap_test.dart @@ -255,8 +255,10 @@ void main() { HeatmapGradientColor(Colors.red, 0.0), ]; const int colorMapSize = 512; - const HeatmapGradient gradient = - HeatmapGradient(colors, colorMapSize: colorMapSize); + const HeatmapGradient gradient = HeatmapGradient( + colors, + colorMapSize: colorMapSize, + ); expect(gradient.colors, colors); expect(gradient.colorMapSize, colorMapSize); @@ -281,10 +283,9 @@ void main() { }); test('clone', () { - const HeatmapGradient gradient1 = HeatmapGradient( - [HeatmapGradientColor(Colors.red, 0.0)], - colorMapSize: 512, - ); + const HeatmapGradient gradient1 = HeatmapGradient([ + HeatmapGradientColor(Colors.red, 0.0), + ], colorMapSize: 512); final HeatmapGradient gradient2 = gradient1.clone(); expect(gradient2, gradient1); @@ -295,8 +296,10 @@ void main() { HeatmapGradientColor(Colors.red, 0.0), ]; const int colorMapSize = 512; - const HeatmapGradient gradient = - HeatmapGradient(colors, colorMapSize: colorMapSize); + const HeatmapGradient gradient = HeatmapGradient( + colors, + colorMapSize: colorMapSize, + ); expect(gradient.toJson(), { 'colors': @@ -313,9 +316,9 @@ void main() { ]; const HeatmapGradient gradient1 = HeatmapGradient(colors); const HeatmapGradient gradient2 = HeatmapGradient(colors); - const HeatmapGradient gradient3 = HeatmapGradient( - [HeatmapGradientColor(Colors.blue, 0.0)], - colorMapSize: 512); + const HeatmapGradient gradient3 = HeatmapGradient([ + HeatmapGradientColor(Colors.blue, 0.0), + ], colorMapSize: 512); expect(gradient1, gradient2); expect(gradient1, isNot(gradient3)); @@ -326,8 +329,10 @@ void main() { HeatmapGradientColor(Colors.red, 0.0), ]; const int colorMapSize = 512; - const HeatmapGradient gradient = - HeatmapGradient(colors, colorMapSize: colorMapSize); + const HeatmapGradient gradient = HeatmapGradient( + colors, + colorMapSize: colorMapSize, + ); expect(gradient.hashCode, Object.hash(colors, colorMapSize)); }); @@ -337,16 +342,20 @@ void main() { test('construct with values', () { const Color color = Colors.red; const double startPoint = 0.0; - const HeatmapGradientColor gradientColor = - HeatmapGradientColor(color, startPoint); + const HeatmapGradientColor gradientColor = HeatmapGradientColor( + color, + startPoint, + ); expect(gradientColor.color, color); expect(gradientColor.startPoint, startPoint); }); test('copyWith', () { - const HeatmapGradientColor gradientColor1 = - HeatmapGradientColor(Colors.red, 0.0); + const HeatmapGradientColor gradientColor1 = HeatmapGradientColor( + Colors.red, + 0.0, + ); const Color color = Colors.blue; const double startPoint = 0.5; @@ -360,28 +369,38 @@ void main() { }); test('clone', () { - const HeatmapGradientColor gradientColor1 = - HeatmapGradientColor(Colors.red, 0.0); + const HeatmapGradientColor gradientColor1 = HeatmapGradientColor( + Colors.red, + 0.0, + ); final HeatmapGradientColor gradientColor2 = gradientColor1.clone(); expect(gradientColor2, gradientColor1); }); test('==', () { - const HeatmapGradientColor gradientColor1 = - HeatmapGradientColor(Colors.red, 0.0); - const HeatmapGradientColor gradientColor2 = - HeatmapGradientColor(Colors.red, 0.0); - const HeatmapGradientColor gradientColor3 = - HeatmapGradientColor(Colors.blue, 0.0); + const HeatmapGradientColor gradientColor1 = HeatmapGradientColor( + Colors.red, + 0.0, + ); + const HeatmapGradientColor gradientColor2 = HeatmapGradientColor( + Colors.red, + 0.0, + ); + const HeatmapGradientColor gradientColor3 = HeatmapGradientColor( + Colors.blue, + 0.0, + ); expect(gradientColor1, gradientColor2); expect(gradientColor1, isNot(gradientColor3)); }); test('hashCode', () { - const HeatmapGradientColor gradientColor = - HeatmapGradientColor(Colors.red, 0.0); + const HeatmapGradientColor gradientColor = HeatmapGradientColor( + Colors.red, + 0.0, + ); expect( gradientColor.hashCode, @@ -390,8 +409,10 @@ void main() { }); test('toString', () { - const HeatmapGradientColor gradientColor = - HeatmapGradientColor(Colors.red, 0.0); + const HeatmapGradientColor gradientColor = HeatmapGradientColor( + Colors.red, + 0.0, + ); expect( gradientColor.toString(), diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/map_configuration_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/map_configuration_test.dart index bcd69a0e82f..5ce807556df 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/map_configuration_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/map_configuration_test.dart @@ -15,8 +15,12 @@ void main() { webGestureHandling: WebGestureHandling.auto, compassEnabled: false, mapToolbarEnabled: false, - cameraTargetBounds: CameraTargetBounds(LatLngBounds( - northeast: const LatLng(30, 20), southwest: const LatLng(10, 40))), + cameraTargetBounds: CameraTargetBounds( + LatLngBounds( + northeast: const LatLng(30, 20), + southwest: const LatLng(10, 40), + ), + ), mapType: MapType.normal, minMaxZoomPreference: const MinMaxZoomPreference(1.0, 10.0), rotateGesturesEnabled: false, @@ -62,8 +66,9 @@ void main() { }); test('handle webGestureHandling', () async { - const MapConfiguration diff = - MapConfiguration(webGestureHandling: WebGestureHandling.none); + const MapConfiguration diff = MapConfiguration( + webGestureHandling: WebGestureHandling.none, + ); const MapConfiguration empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); @@ -111,10 +116,15 @@ void main() { }); test('handle cameraTargetBounds', () async { - final CameraTargetBounds newBounds = CameraTargetBounds(LatLngBounds( - northeast: const LatLng(55, 15), southwest: const LatLng(5, 15))); - final MapConfiguration diff = - MapConfiguration(cameraTargetBounds: newBounds); + final CameraTargetBounds newBounds = CameraTargetBounds( + LatLngBounds( + northeast: const LatLng(55, 15), + southwest: const LatLng(5, 15), + ), + ); + final MapConfiguration diff = MapConfiguration( + cameraTargetBounds: newBounds, + ); const MapConfiguration empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); @@ -130,8 +140,9 @@ void main() { }); test('handle mapType', () async { - const MapConfiguration diff = - MapConfiguration(mapType: MapType.satellite); + const MapConfiguration diff = MapConfiguration( + mapType: MapType.satellite, + ); const MapConfiguration empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); @@ -148,8 +159,9 @@ void main() { test('handle minMaxZoomPreference', () async { const MinMaxZoomPreference newZoomPref = MinMaxZoomPreference(3.3, 4.5); - const MapConfiguration diff = - MapConfiguration(minMaxZoomPreference: newZoomPref); + const MapConfiguration diff = MapConfiguration( + minMaxZoomPreference: newZoomPref, + ); const MapConfiguration empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); @@ -165,8 +177,9 @@ void main() { }); test('handle rotateGesturesEnabled', () async { - const MapConfiguration diff = - MapConfiguration(rotateGesturesEnabled: true); + const MapConfiguration diff = MapConfiguration( + rotateGesturesEnabled: true, + ); const MapConfiguration empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); @@ -182,8 +195,9 @@ void main() { }); test('handle scrollGesturesEnabled', () async { - const MapConfiguration diff = - MapConfiguration(scrollGesturesEnabled: true); + const MapConfiguration diff = MapConfiguration( + scrollGesturesEnabled: true, + ); const MapConfiguration empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); @@ -215,8 +229,9 @@ void main() { }); test('handle fortyFiveDegreeImageryEnabled', () async { - const MapConfiguration diff = - MapConfiguration(fortyFiveDegreeImageryEnabled: true); + const MapConfiguration diff = MapConfiguration( + fortyFiveDegreeImageryEnabled: true, + ); const MapConfiguration empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); @@ -312,8 +327,9 @@ void main() { }); test('handle myLocationButtonEnabled', () async { - const MapConfiguration diff = - MapConfiguration(myLocationButtonEnabled: true); + const MapConfiguration diff = MapConfiguration( + myLocationButtonEnabled: true, + ); const MapConfiguration empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); @@ -329,8 +345,10 @@ void main() { }); test('handle padding', () async { - const EdgeInsets newPadding = - EdgeInsets.symmetric(vertical: 1.0, horizontal: 3.0); + const EdgeInsets newPadding = EdgeInsets.symmetric( + vertical: 1.0, + horizontal: 3.0, + ); const MapConfiguration diff = MapConfiguration(padding: newPadding); const MapConfiguration empty = MapConfiguration(); @@ -465,39 +483,48 @@ void main() { }); test('is false with cameraTargetBounds', () async { - final CameraTargetBounds newBounds = CameraTargetBounds(LatLngBounds( - northeast: const LatLng(55, 15), southwest: const LatLng(5, 15))); - final MapConfiguration diff = - MapConfiguration(cameraTargetBounds: newBounds); + final CameraTargetBounds newBounds = CameraTargetBounds( + LatLngBounds( + northeast: const LatLng(55, 15), + southwest: const LatLng(5, 15), + ), + ); + final MapConfiguration diff = MapConfiguration( + cameraTargetBounds: newBounds, + ); expect(diff.isEmpty, false); }); test('is false with mapType', () async { - const MapConfiguration diff = - MapConfiguration(mapType: MapType.satellite); + const MapConfiguration diff = MapConfiguration( + mapType: MapType.satellite, + ); expect(diff.isEmpty, false); }); test('is false with minMaxZoomPreference', () async { const MinMaxZoomPreference newZoomPref = MinMaxZoomPreference(3.3, 4.5); - const MapConfiguration diff = - MapConfiguration(minMaxZoomPreference: newZoomPref); + const MapConfiguration diff = MapConfiguration( + minMaxZoomPreference: newZoomPref, + ); expect(diff.isEmpty, false); }); test('is false with rotateGesturesEnabled', () async { - const MapConfiguration diff = - MapConfiguration(rotateGesturesEnabled: true); + const MapConfiguration diff = MapConfiguration( + rotateGesturesEnabled: true, + ); expect(diff.isEmpty, false); }); test('is false with scrollGesturesEnabled', () async { - const MapConfiguration diff = - MapConfiguration(scrollGesturesEnabled: true); + const MapConfiguration diff = MapConfiguration( + scrollGesturesEnabled: true, + ); expect(diff.isEmpty, false); }); @@ -539,15 +566,18 @@ void main() { }); test('is false with myLocationButtonEnabled', () async { - const MapConfiguration diff = - MapConfiguration(myLocationButtonEnabled: true); + const MapConfiguration diff = MapConfiguration( + myLocationButtonEnabled: true, + ); expect(diff.isEmpty, false); }); test('is false with padding', () async { - const EdgeInsets newPadding = - EdgeInsets.symmetric(vertical: 1.0, horizontal: 3.0); + const EdgeInsets newPadding = EdgeInsets.symmetric( + vertical: 1.0, + horizontal: 3.0, + ); const MapConfiguration diff = MapConfiguration(padding: newPadding); expect(diff.isEmpty, false); diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/maps_object_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/maps_object_test.dart index 7c5106c2317..ced1e9ea82f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/maps_object_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/maps_object_test.dart @@ -19,12 +19,13 @@ void main() { const TestMapsObject object2 = TestMapsObject(id2, data: 2); const TestMapsObject object3 = TestMapsObject(id3); expect( - keyByMapsObjectId({object1, object2, object3}), - , TestMapsObject>{ - id1: object1, - id2: object2, - id3: object3, - }); + keyByMapsObjectId({object1, object2, object3}), + , TestMapsObject>{ + id1: object1, + id2: object2, + id3: object3, + }, + ); }); test('serializeMapsObjectSet', () async { @@ -35,11 +36,12 @@ void main() { const TestMapsObject object2 = TestMapsObject(id2, data: 2); const TestMapsObject object3 = TestMapsObject(id3); expect( - serializeMapsObjectSet({object1, object2, object3}), - >[ - {'id': '1'}, - {'id': '2'}, - {'id': '3'} - ]); + serializeMapsObjectSet({object1, object2, object3}), + >[ + {'id': '1'}, + {'id': '2'}, + {'id': '3'}, + ], + ); }); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/maps_object_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/maps_object_updates_test.dart index 8608873b25b..4f12993b9d1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/maps_object_updates_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/maps_object_updates_test.dart @@ -11,7 +11,7 @@ import 'test_maps_object.dart'; class TestMapsObjectUpdate extends MapsObjectUpdates { TestMapsObjectUpdate.from(super.previous, super.current) - : super.from(objectName: 'testObject'); + : super.from(objectName: 'testObject'); } void main() { @@ -19,29 +19,37 @@ void main() { group('tile overlay updates tests', () { test('Correctly set toRemove, toAdd and toChange', () async { - const TestMapsObject to1 = - TestMapsObject(MapsObjectId('id1')); - const TestMapsObject to2 = - TestMapsObject(MapsObjectId('id2')); - const TestMapsObject to3 = - TestMapsObject(MapsObjectId('id3')); - const TestMapsObject to3Changed = - TestMapsObject(MapsObjectId('id3'), data: 2); - const TestMapsObject to4 = - TestMapsObject(MapsObjectId('id4')); + const TestMapsObject to1 = TestMapsObject( + MapsObjectId('id1'), + ); + const TestMapsObject to2 = TestMapsObject( + MapsObjectId('id2'), + ); + const TestMapsObject to3 = TestMapsObject( + MapsObjectId('id3'), + ); + const TestMapsObject to3Changed = TestMapsObject( + MapsObjectId('id3'), + data: 2, + ); + const TestMapsObject to4 = TestMapsObject( + MapsObjectId('id4'), + ); final Set previous = {to1, to2, to3}; final Set current = { to2, to3Changed, - to4 + to4, }; - final TestMapsObjectUpdate updates = - TestMapsObjectUpdate.from(previous, current); + final TestMapsObjectUpdate updates = TestMapsObjectUpdate.from( + previous, + current, + ); final Set> toRemove = >{ - const MapsObjectId('id1') - }; + const MapsObjectId('id1'), + }; expect(updates.objectIdsToRemove, toRemove); final Set toAdd = {to4}; @@ -52,119 +60,159 @@ void main() { }); test('toJson', () async { - const TestMapsObject to1 = - TestMapsObject(MapsObjectId('id1')); - const TestMapsObject to2 = - TestMapsObject(MapsObjectId('id2')); - const TestMapsObject to3 = - TestMapsObject(MapsObjectId('id3')); - const TestMapsObject to3Changed = - TestMapsObject(MapsObjectId('id3'), data: 2); - const TestMapsObject to4 = - TestMapsObject(MapsObjectId('id4')); + const TestMapsObject to1 = TestMapsObject( + MapsObjectId('id1'), + ); + const TestMapsObject to2 = TestMapsObject( + MapsObjectId('id2'), + ); + const TestMapsObject to3 = TestMapsObject( + MapsObjectId('id3'), + ); + const TestMapsObject to3Changed = TestMapsObject( + MapsObjectId('id3'), + data: 2, + ); + const TestMapsObject to4 = TestMapsObject( + MapsObjectId('id4'), + ); final Set previous = {to1, to2, to3}; final Set current = { to2, to3Changed, - to4 + to4, }; - final TestMapsObjectUpdate updates = - TestMapsObjectUpdate.from(previous, current); + final TestMapsObjectUpdate updates = TestMapsObjectUpdate.from( + previous, + current, + ); final Object json = updates.toJson(); expect(json, { 'testObjectsToAdd': serializeMapsObjectSet(updates.objectsToAdd), 'testObjectsToChange': serializeMapsObjectSet(updates.objectsToChange), - 'testObjectIdsToRemove': updates.objectIdsToRemove - .map((MapsObjectId m) => m.value) - .toList() + 'testObjectIdsToRemove': + updates.objectIdsToRemove + .map((MapsObjectId m) => m.value) + .toList(), }); }); test('equality', () async { - const TestMapsObject to1 = - TestMapsObject(MapsObjectId('id1')); - const TestMapsObject to2 = - TestMapsObject(MapsObjectId('id2')); - const TestMapsObject to3 = - TestMapsObject(MapsObjectId('id3')); - const TestMapsObject to3Changed = - TestMapsObject(MapsObjectId('id3'), data: 2); - const TestMapsObject to4 = - TestMapsObject(MapsObjectId('id4')); + const TestMapsObject to1 = TestMapsObject( + MapsObjectId('id1'), + ); + const TestMapsObject to2 = TestMapsObject( + MapsObjectId('id2'), + ); + const TestMapsObject to3 = TestMapsObject( + MapsObjectId('id3'), + ); + const TestMapsObject to3Changed = TestMapsObject( + MapsObjectId('id3'), + data: 2, + ); + const TestMapsObject to4 = TestMapsObject( + MapsObjectId('id4'), + ); final Set previous = {to1, to2, to3}; final Set current1 = { to2, to3Changed, - to4 + to4, }; final Set current2 = { to2, to3Changed, - to4 + to4, }; final Set current3 = {to2, to4}; - final TestMapsObjectUpdate updates1 = - TestMapsObjectUpdate.from(previous, current1); - final TestMapsObjectUpdate updates2 = - TestMapsObjectUpdate.from(previous, current2); - final TestMapsObjectUpdate updates3 = - TestMapsObjectUpdate.from(previous, current3); + final TestMapsObjectUpdate updates1 = TestMapsObjectUpdate.from( + previous, + current1, + ); + final TestMapsObjectUpdate updates2 = TestMapsObjectUpdate.from( + previous, + current2, + ); + final TestMapsObjectUpdate updates3 = TestMapsObjectUpdate.from( + previous, + current3, + ); expect(updates1, updates2); expect(updates1, isNot(updates3)); }); test('hashCode', () async { - const TestMapsObject to1 = - TestMapsObject(MapsObjectId('id1')); - const TestMapsObject to2 = - TestMapsObject(MapsObjectId('id2')); - const TestMapsObject to3 = - TestMapsObject(MapsObjectId('id3')); - const TestMapsObject to3Changed = - TestMapsObject(MapsObjectId('id3'), data: 2); - const TestMapsObject to4 = - TestMapsObject(MapsObjectId('id4')); + const TestMapsObject to1 = TestMapsObject( + MapsObjectId('id1'), + ); + const TestMapsObject to2 = TestMapsObject( + MapsObjectId('id2'), + ); + const TestMapsObject to3 = TestMapsObject( + MapsObjectId('id3'), + ); + const TestMapsObject to3Changed = TestMapsObject( + MapsObjectId('id3'), + data: 2, + ); + const TestMapsObject to4 = TestMapsObject( + MapsObjectId('id4'), + ); final Set previous = {to1, to2, to3}; final Set current = { to2, to3Changed, - to4 + to4, }; - final TestMapsObjectUpdate updates = - TestMapsObjectUpdate.from(previous, current); + final TestMapsObjectUpdate updates = TestMapsObjectUpdate.from( + previous, + current, + ); expect( - updates.hashCode, - Object.hash( - Object.hashAll(updates.objectsToAdd), - Object.hashAll(updates.objectIdsToRemove), - Object.hashAll(updates.objectsToChange))); + updates.hashCode, + Object.hash( + Object.hashAll(updates.objectsToAdd), + Object.hashAll(updates.objectIdsToRemove), + Object.hashAll(updates.objectsToChange), + ), + ); }); test('toString', () async { - const TestMapsObject to1 = - TestMapsObject(MapsObjectId('id1')); - const TestMapsObject to2 = - TestMapsObject(MapsObjectId('id2')); - const TestMapsObject to3 = - TestMapsObject(MapsObjectId('id3')); - const TestMapsObject to3Changed = - TestMapsObject(MapsObjectId('id3'), data: 2); - const TestMapsObject to4 = - TestMapsObject(MapsObjectId('id4')); + const TestMapsObject to1 = TestMapsObject( + MapsObjectId('id1'), + ); + const TestMapsObject to2 = TestMapsObject( + MapsObjectId('id2'), + ); + const TestMapsObject to3 = TestMapsObject( + MapsObjectId('id3'), + ); + const TestMapsObject to3Changed = TestMapsObject( + MapsObjectId('id3'), + data: 2, + ); + const TestMapsObject to4 = TestMapsObject( + MapsObjectId('id4'), + ); final Set previous = {to1, to2, to3}; final Set current = { to2, to3Changed, - to4 + to4, }; - final TestMapsObjectUpdate updates = - TestMapsObjectUpdate.from(previous, current); + final TestMapsObjectUpdate updates = TestMapsObjectUpdate.from( + previous, + current, + ); expect( - updates.toString(), - 'TestMapsObjectUpdate(add: ${updates.objectsToAdd}, ' - 'remove: ${updates.objectIdsToRemove}, ' - 'change: ${updates.objectsToChange})'); + updates.toString(), + 'TestMapsObjectUpdate(add: ${updates.objectsToAdd}, ' + 'remove: ${updates.objectIdsToRemove}, ' + 'change: ${updates.objectsToChange})', + ); }); }); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/marker_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/marker_test.dart index ea366602999..77a52cb9bcd 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/marker_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/marker_test.dart @@ -113,8 +113,9 @@ void main() { const double testRotationParam = 100; final bool testVisibleParam = !marker.visible; const double testZIndexParam = 100; - const ClusterManagerId testClusterManagerIdParam = - ClusterManagerId('DEF123'); + const ClusterManagerId testClusterManagerIdParam = ClusterManagerId( + 'DEF123', + ); final List log = []; final Marker copy = marker.copyWith( @@ -183,40 +184,28 @@ void main() { }); test('zIndex param', () { - const Marker marker = Marker( - markerId: MarkerId('ABC123'), - zIndex: 5.00, - ); + const Marker marker = Marker(markerId: MarkerId('ABC123'), zIndex: 5.00); expect(marker.zIndexInt, 5); expect(marker.zIndex, 5.00); }); test('zIndexInt param', () { - const Marker marker = Marker( - markerId: MarkerId('ABC123'), - zIndexInt: 5, - ); + const Marker marker = Marker(markerId: MarkerId('ABC123'), zIndexInt: 5); expect(marker.zIndexInt, 5); expect(marker.zIndex, 5.00); }); test('zIndexInt param copyWith', () { - const Marker marker = Marker( - markerId: MarkerId('ABC123'), - zIndexInt: 5, - ); + const Marker marker = Marker(markerId: MarkerId('ABC123'), zIndexInt: 5); final Marker copy = marker.copyWith(zIndexIntParam: 10); expect(copy.zIndexInt, 10); expect(copy.zIndex, 10.0); }); test('zIndex param copyWith', () { - const Marker marker = Marker( - markerId: MarkerId('ABC123'), - zIndexInt: 5, - ); + const Marker marker = Marker(markerId: MarkerId('ABC123'), zIndexInt: 5); final Marker copy = marker.copyWith(zIndexParam: 10.0); expect(copy.zIndexInt, 10); expect(copy.zIndex, 10.0); diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/test_maps_object.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/test_maps_object.dart index 17676a259b2..c4683fb91c0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/test_maps_object.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/test_maps_object.dart @@ -42,5 +42,5 @@ class TestMapsObject implements MapsObject { class TestMapsObjectUpdate extends MapsObjectUpdates { TestMapsObjectUpdate.from(super.previous, super.current) - : super.from(objectName: 'testObject'); + : super.from(objectName: 'testObject'); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_overlay_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_overlay_test.dart index fe5d86335af..d1af30592a7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_overlay_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_overlay_test.dart @@ -33,12 +33,13 @@ void main() { group('tile overlay tests', () { test('toJson returns correct format', () async { const TileOverlay tileOverlay = TileOverlay( - tileOverlayId: TileOverlayId('id'), - fadeIn: false, - transparency: 0.1, - zIndex: 1, - visible: false, - tileSize: 128); + tileOverlayId: TileOverlayId('id'), + fadeIn: false, + transparency: 0.1, + zIndex: 1, + visible: false, + tileSize: 128, + ); final Object json = tileOverlay.toJson(); expect(json, { 'tileOverlayId': 'id', @@ -52,48 +53,58 @@ void main() { test('invalid transparency throws', () async { expect( - () => TileOverlay( - tileOverlayId: const TileOverlayId('id1'), transparency: -0.1), - throwsAssertionError); + () => TileOverlay( + tileOverlayId: const TileOverlayId('id1'), + transparency: -0.1, + ), + throwsAssertionError, + ); expect( - () => TileOverlay( - tileOverlayId: const TileOverlayId('id2'), transparency: 1.2), - throwsAssertionError); + () => TileOverlay( + tileOverlayId: const TileOverlayId('id2'), + transparency: 1.2, + ), + throwsAssertionError, + ); }); test('equality', () async { final TileProvider tileProvider = _TestTileProvider(); final TileOverlay tileOverlay1 = TileOverlay( - tileOverlayId: const TileOverlayId('id1'), - fadeIn: false, - tileProvider: tileProvider, - transparency: 0.1, - zIndex: 1, - visible: false, - tileSize: 128); + tileOverlayId: const TileOverlayId('id1'), + fadeIn: false, + tileProvider: tileProvider, + transparency: 0.1, + zIndex: 1, + visible: false, + tileSize: 128, + ); final TileOverlay tileOverlaySameValues = TileOverlay( - tileOverlayId: const TileOverlayId('id1'), - fadeIn: false, - tileProvider: tileProvider, - transparency: 0.1, - zIndex: 1, - visible: false, - tileSize: 128); + tileOverlayId: const TileOverlayId('id1'), + fadeIn: false, + tileProvider: tileProvider, + transparency: 0.1, + zIndex: 1, + visible: false, + tileSize: 128, + ); final TileOverlay tileOverlayDifferentId = TileOverlay( - tileOverlayId: const TileOverlayId('id2'), - fadeIn: false, - tileProvider: tileProvider, - transparency: 0.1, - zIndex: 1, - visible: false, - tileSize: 128); + tileOverlayId: const TileOverlayId('id2'), + fadeIn: false, + tileProvider: tileProvider, + transparency: 0.1, + zIndex: 1, + visible: false, + tileSize: 128, + ); const TileOverlay tileOverlayDifferentProvider = TileOverlay( - tileOverlayId: TileOverlayId('id1'), - fadeIn: false, - transparency: 0.1, - zIndex: 1, - visible: false, - tileSize: 128); + tileOverlayId: TileOverlayId('id1'), + fadeIn: false, + transparency: 0.1, + zIndex: 1, + visible: false, + tileSize: 128, + ); expect(tileOverlay1, tileOverlaySameValues); expect(tileOverlay1, isNot(tileOverlayDifferentId)); expect(tileOverlay1, isNot(tileOverlayDifferentProvider)); @@ -103,13 +114,14 @@ void main() { final TileProvider tileProvider = _TestTileProvider(); // Set non-default values for every parameter. final TileOverlay tileOverlay = TileOverlay( - tileOverlayId: const TileOverlayId('id1'), - fadeIn: false, - tileProvider: tileProvider, - transparency: 0.1, - zIndex: 1, - visible: false, - tileSize: 128); + tileOverlayId: const TileOverlayId('id1'), + fadeIn: false, + tileProvider: tileProvider, + transparency: 0.1, + zIndex: 1, + visible: false, + tileSize: 128, + ); expect(tileOverlay, tileOverlay.clone()); }); @@ -117,23 +129,26 @@ void main() { final TileProvider tileProvider = _TestTileProvider(); const TileOverlayId id = TileOverlayId('id1'); final TileOverlay tileOverlay = TileOverlay( - tileOverlayId: id, - fadeIn: false, - tileProvider: tileProvider, - transparency: 0.1, - zIndex: 1, - visible: false, - tileSize: 128); + tileOverlayId: id, + fadeIn: false, + tileProvider: tileProvider, + transparency: 0.1, + zIndex: 1, + visible: false, + tileSize: 128, + ); expect( - tileOverlay.hashCode, - Object.hash( - tileOverlay.tileOverlayId, - tileOverlay.fadeIn, - tileOverlay.tileProvider, - tileOverlay.transparency, - tileOverlay.zIndex, - tileOverlay.visible, - tileOverlay.tileSize)); + tileOverlay.hashCode, + Object.hash( + tileOverlay.tileOverlayId, + tileOverlay.fadeIn, + tileOverlay.tileProvider, + tileOverlay.transparency, + tileOverlay.zIndex, + tileOverlay.visible, + tileOverlay.tileSize, + ), + ); }); }); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_overlay_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_overlay_updates_test.dart index b62f7326d83..251cdd12f9d 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_overlay_updates_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_overlay_updates_test.dart @@ -15,16 +15,20 @@ void main() { const TileOverlay to1 = TileOverlay(tileOverlayId: TileOverlayId('id1')); const TileOverlay to2 = TileOverlay(tileOverlayId: TileOverlayId('id2')); const TileOverlay to3 = TileOverlay(tileOverlayId: TileOverlayId('id3')); - const TileOverlay to3Changed = - TileOverlay(tileOverlayId: TileOverlayId('id3'), transparency: 0.5); + const TileOverlay to3Changed = TileOverlay( + tileOverlayId: TileOverlayId('id3'), + transparency: 0.5, + ); const TileOverlay to4 = TileOverlay(tileOverlayId: TileOverlayId('id4')); final Set previous = {to1, to2, to3}; final Set current = {to2, to3Changed, to4}; - final TileOverlayUpdates updates = - TileOverlayUpdates.from(previous, current); + final TileOverlayUpdates updates = TileOverlayUpdates.from( + previous, + current, + ); final Set toRemove = { - const TileOverlayId('id1') + const TileOverlayId('id1'), }; expect(updates.tileOverlayIdsToRemove, toRemove); @@ -39,22 +43,28 @@ void main() { const TileOverlay to1 = TileOverlay(tileOverlayId: TileOverlayId('id1')); const TileOverlay to2 = TileOverlay(tileOverlayId: TileOverlayId('id2')); const TileOverlay to3 = TileOverlay(tileOverlayId: TileOverlayId('id3')); - const TileOverlay to3Changed = - TileOverlay(tileOverlayId: TileOverlayId('id3'), transparency: 0.5); + const TileOverlay to3Changed = TileOverlay( + tileOverlayId: TileOverlayId('id3'), + transparency: 0.5, + ); const TileOverlay to4 = TileOverlay(tileOverlayId: TileOverlayId('id4')); final Set previous = {to1, to2, to3}; final Set current = {to2, to3Changed, to4}; - final TileOverlayUpdates updates = - TileOverlayUpdates.from(previous, current); + final TileOverlayUpdates updates = TileOverlayUpdates.from( + previous, + current, + ); final Object json = updates.toJson(); expect(json, { 'tileOverlaysToAdd': serializeTileOverlaySet(updates.tileOverlaysToAdd), - 'tileOverlaysToChange': - serializeTileOverlaySet(updates.tileOverlaysToChange), - 'tileOverlayIdsToRemove': updates.tileOverlayIdsToRemove - .map((TileOverlayId m) => m.value) - .toList() + 'tileOverlaysToChange': serializeTileOverlaySet( + updates.tileOverlaysToChange, + ), + 'tileOverlayIdsToRemove': + updates.tileOverlayIdsToRemove + .map((TileOverlayId m) => m.value) + .toList(), }); }); @@ -62,19 +72,27 @@ void main() { const TileOverlay to1 = TileOverlay(tileOverlayId: TileOverlayId('id1')); const TileOverlay to2 = TileOverlay(tileOverlayId: TileOverlayId('id2')); const TileOverlay to3 = TileOverlay(tileOverlayId: TileOverlayId('id3')); - const TileOverlay to3Changed = - TileOverlay(tileOverlayId: TileOverlayId('id3'), transparency: 0.5); + const TileOverlay to3Changed = TileOverlay( + tileOverlayId: TileOverlayId('id3'), + transparency: 0.5, + ); const TileOverlay to4 = TileOverlay(tileOverlayId: TileOverlayId('id4')); final Set previous = {to1, to2, to3}; final Set current1 = {to2, to3Changed, to4}; final Set current2 = {to2, to3Changed, to4}; final Set current3 = {to2, to4}; - final TileOverlayUpdates updates1 = - TileOverlayUpdates.from(previous, current1); - final TileOverlayUpdates updates2 = - TileOverlayUpdates.from(previous, current2); - final TileOverlayUpdates updates3 = - TileOverlayUpdates.from(previous, current3); + final TileOverlayUpdates updates1 = TileOverlayUpdates.from( + previous, + current1, + ); + final TileOverlayUpdates updates2 = TileOverlayUpdates.from( + previous, + current2, + ); + final TileOverlayUpdates updates3 = TileOverlayUpdates.from( + previous, + current3, + ); expect(updates1, updates2); expect(updates1, isNot(updates3)); }); @@ -83,37 +101,48 @@ void main() { const TileOverlay to1 = TileOverlay(tileOverlayId: TileOverlayId('id1')); const TileOverlay to2 = TileOverlay(tileOverlayId: TileOverlayId('id2')); const TileOverlay to3 = TileOverlay(tileOverlayId: TileOverlayId('id3')); - const TileOverlay to3Changed = - TileOverlay(tileOverlayId: TileOverlayId('id3'), transparency: 0.5); + const TileOverlay to3Changed = TileOverlay( + tileOverlayId: TileOverlayId('id3'), + transparency: 0.5, + ); const TileOverlay to4 = TileOverlay(tileOverlayId: TileOverlayId('id4')); final Set previous = {to1, to2, to3}; final Set current = {to2, to3Changed, to4}; - final TileOverlayUpdates updates = - TileOverlayUpdates.from(previous, current); + final TileOverlayUpdates updates = TileOverlayUpdates.from( + previous, + current, + ); expect( - updates.hashCode, - Object.hash( - Object.hashAll(updates.tileOverlaysToAdd), - Object.hashAll(updates.tileOverlayIdsToRemove), - Object.hashAll(updates.tileOverlaysToChange))); + updates.hashCode, + Object.hash( + Object.hashAll(updates.tileOverlaysToAdd), + Object.hashAll(updates.tileOverlayIdsToRemove), + Object.hashAll(updates.tileOverlaysToChange), + ), + ); }); test('toString', () async { const TileOverlay to1 = TileOverlay(tileOverlayId: TileOverlayId('id1')); const TileOverlay to2 = TileOverlay(tileOverlayId: TileOverlayId('id2')); const TileOverlay to3 = TileOverlay(tileOverlayId: TileOverlayId('id3')); - const TileOverlay to3Changed = - TileOverlay(tileOverlayId: TileOverlayId('id3'), transparency: 0.5); + const TileOverlay to3Changed = TileOverlay( + tileOverlayId: TileOverlayId('id3'), + transparency: 0.5, + ); const TileOverlay to4 = TileOverlay(tileOverlayId: TileOverlayId('id4')); final Set previous = {to1, to2, to3}; final Set current = {to2, to3Changed, to4}; - final TileOverlayUpdates updates = - TileOverlayUpdates.from(previous, current); + final TileOverlayUpdates updates = TileOverlayUpdates.from( + previous, + current, + ); expect( - updates.toString(), - 'TileOverlayUpdates(add: ${updates.tileOverlaysToAdd}, ' - 'remove: ${updates.tileOverlayIdsToRemove}, ' - 'change: ${updates.tileOverlaysToChange})'); + updates.toString(), + 'TileOverlayUpdates(add: ${updates.tileOverlaysToAdd}, ' + 'remove: ${updates.tileOverlayIdsToRemove}, ' + 'change: ${updates.tileOverlaysToChange})', + ); }); }); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_test.dart index ab49fd1a6c5..e5f9cb752db 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_test.dart @@ -15,20 +15,13 @@ void main() { final Uint8List data = Uint8List.fromList([0, 1]); final Tile tile = Tile(100, 200, data); final Object json = tile.toJson(); - expect(json, { - 'width': 100, - 'height': 200, - 'data': data, - }); + expect(json, {'width': 100, 'height': 200, 'data': data}); }); test('toJson handles null data', () async { const Tile tile = Tile(0, 0, null); final Object json = tile.toJson(); - expect(json, { - 'width': 0, - 'height': 0, - }); + expect(json, {'width': 0, 'height': 0}); }); }); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/utils/map_configuration_serialization_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/utils/map_configuration_serialization_test.dart index 3d00e04495b..5b3d33369ee 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/utils/map_configuration_serialization_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/utils/map_configuration_serialization_test.dart @@ -22,8 +22,12 @@ void main() { final MapConfiguration config = MapConfiguration( compassEnabled: false, mapToolbarEnabled: false, - cameraTargetBounds: CameraTargetBounds(LatLngBounds( - northeast: const LatLng(30, 20), southwest: const LatLng(10, 40))), + cameraTargetBounds: CameraTargetBounds( + LatLngBounds( + northeast: const LatLng(30, 20), + southwest: const LatLng(10, 40), + ), + ), mapType: MapType.normal, minMaxZoomPreference: const MinMaxZoomPreference(1.0, 10.0), rotateGesturesEnabled: false, @@ -56,8 +60,8 @@ void main() { 'cameraTargetBounds': [ [ [10.0, 40.0], - [30.0, 20.0] - ] + [30.0, 20.0], + ], ], 'mapType': 1, 'minMaxZoomPreference': [1.0, 10.0], @@ -85,10 +89,7 @@ void main() { cloudMapId: 'cloud-map-id', ); final Map json = jsonForMapConfiguration(config); - expect(json, { - 'mapId': 'map-id', - 'cloudMapId': 'map-id', - }); + expect(json, {'mapId': 'map-id', 'cloudMapId': 'map-id'}); }); test('mapId falls back to cloudMapId', () { diff --git a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md index 82f2fc94e86..4e53b1a6282 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter_web/CHANGELOG.md @@ -1,3 +1,7 @@ +## NEXT + +* Updates minimum supported SDK version to Flutter 3.29/Dart 3.7. + ## 0.5.12+2 * Fix broken cameraTargetBounds option on web. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart index 0853359835e..32ebfdc5b93 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.dart @@ -45,7 +45,6 @@ gmaps.Map mapShim() => throw UnimplementedError(); fallbackGenerators: {#googleMap: mapShim}, ), ]) - /// Test Google Map Controller void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); @@ -57,8 +56,9 @@ void main() { // Creates a controller with the default mapId and stream controller, and any `options` needed. GoogleMapController createController({ - CameraPosition initialCameraPosition = - const CameraPosition(target: LatLng(0, 0)), + CameraPosition initialCameraPosition = const CameraPosition( + target: LatLng(0, 0), + ), MapObjects mapObjects = const MapObjects(), MapConfiguration mapConfiguration = const MapConfiguration(), }) { @@ -66,8 +66,9 @@ void main() { mapId: mapId, streamController: stream, widgetConfiguration: MapWidgetConfiguration( - initialCameraPosition: initialCameraPosition, - textDirection: TextDirection.ltr), + initialCameraPosition: initialCameraPosition, + textDirection: TextDirection.ltr, + ), mapObjects: mapObjects, mapConfiguration: mapConfiguration, ); @@ -85,8 +86,10 @@ void main() { testWidgets('constructor creates widget', (WidgetTester tester) async { expect(controller.widget, isNotNull); expect(controller.widget, isA()); - expect((controller.widget! as HtmlElementView).viewType, - endsWith('$mapId')); + expect( + (controller.widget! as HtmlElementView).viewType, + endsWith('$mapId'), + ); }); testWidgets('widget is cached when reused', (WidgetTester tester) async { @@ -96,16 +99,18 @@ void main() { }); group('dispose', () { - testWidgets('closes the stream and removes the widget', - (WidgetTester tester) async { + testWidgets('closes the stream and removes the widget', ( + WidgetTester tester, + ) async { controller.dispose(); expect(stream.isClosed, isTrue); expect(controller.widget, isNull); }); - testWidgets('cannot call getVisibleRegion after dispose', - (WidgetTester tester) async { + testWidgets('cannot call getVisibleRegion after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); expect(() async { @@ -113,8 +118,9 @@ void main() { }, throwsAssertionError); }); - testWidgets('cannot call getScreenCoordinate after dispose', - (WidgetTester tester) async { + testWidgets('cannot call getScreenCoordinate after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); expect(() async { @@ -124,19 +130,19 @@ void main() { }, throwsAssertionError); }); - testWidgets('cannot call getLatLng after dispose', - (WidgetTester tester) async { + testWidgets('cannot call getLatLng after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); expect(() async { - await controller.getLatLng( - const ScreenCoordinate(x: 640, y: 480), - ); + await controller.getLatLng(const ScreenCoordinate(x: 640, y: 480)); }, throwsAssertionError); }); - testWidgets('cannot call moveCamera after dispose', - (WidgetTester tester) async { + testWidgets('cannot call moveCamera after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); expect(() async { @@ -144,8 +150,9 @@ void main() { }, throwsAssertionError); }); - testWidgets('cannot call getZoomLevel after dispose', - (WidgetTester tester) async { + testWidgets('cannot call getZoomLevel after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); expect(() async { @@ -153,72 +160,65 @@ void main() { }, throwsAssertionError); }); - testWidgets('cannot updateCircles after dispose', - (WidgetTester tester) async { + testWidgets('cannot updateCircles after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); expect(() { controller.updateCircles( - CircleUpdates.from( - const {}, - const {}, - ), + CircleUpdates.from(const {}, const {}), ); }, throwsAssertionError); }); - testWidgets('cannot updateHeatmaps after dispose', - (WidgetTester tester) async { + testWidgets('cannot updateHeatmaps after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); expect(() { controller.updateHeatmaps( - HeatmapUpdates.from( - const {}, - const {}, - ), + HeatmapUpdates.from(const {}, const {}), ); }, throwsAssertionError); }); - testWidgets('cannot updatePolygons after dispose', - (WidgetTester tester) async { + testWidgets('cannot updatePolygons after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); expect(() { controller.updatePolygons( - PolygonUpdates.from( - const {}, - const {}, - ), + PolygonUpdates.from(const {}, const {}), ); }, throwsAssertionError); }); - testWidgets('cannot updatePolylines after dispose', - (WidgetTester tester) async { + testWidgets('cannot updatePolylines after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); expect(() { controller.updatePolylines( - PolylineUpdates.from( - const {}, - const {}, - ), + PolylineUpdates.from(const {}, const {}), ); }, throwsAssertionError); }); - testWidgets('cannot updateMarkers after dispose', - (WidgetTester tester) async { + testWidgets('cannot updateMarkers after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); await expectLater( - controller.updateMarkers(MarkerUpdates.from( - const {}, - const {}, - )), - throwsAssertionError); + controller.updateMarkers( + MarkerUpdates.from(const {}, const {}), + ), + throwsAssertionError, + ); expect(() { controller.showInfoWindow(const MarkerId('any')); @@ -229,8 +229,9 @@ void main() { }, throwsAssertionError); }); - testWidgets('cannot updateTileOverlays after dispose', - (WidgetTester tester) async { + testWidgets('cannot updateTileOverlays after dispose', ( + WidgetTester tester, + ) async { controller.dispose(); expect(() { @@ -238,8 +239,9 @@ void main() { }, throwsAssertionError); }); - testWidgets('isInfoWindowShown defaults to false', - (WidgetTester tester) async { + testWidgets('isInfoWindowShown defaults to false', ( + WidgetTester tester, + ) async { controller.dispose(); expect(controller.isInfoWindowShown(const MarkerId('any')), false); @@ -269,17 +271,18 @@ void main() { }); testWidgets('listens to map events', (WidgetTester tester) async { - controller = createController() - ..debugSetOverrides( - createMap: (_, __) => map, - circles: circles, - heatmaps: heatmaps, - markers: markers, - polygons: polygons, - polylines: polylines, - groundOverlays: groundOverlays, - ) - ..init(); + controller = + createController() + ..debugSetOverrides( + createMap: (_, __) => map, + circles: circles, + heatmaps: heatmaps, + markers: markers, + polygons: polygons, + polylines: polylines, + groundOverlays: groundOverlays, + ) + ..init(); // Trigger events on the map, and verify they've been broadcast to the stream final Stream> capturedEvents = stream.stream.take(5); @@ -307,20 +310,22 @@ void main() { expect(events[4], isA()); }); - testWidgets("binds geometry controllers to map's", - (WidgetTester tester) async { - controller = createController() - ..debugSetOverrides( - createMap: (_, __) => map, - circles: circles, - heatmaps: heatmaps, - markers: markers, - polygons: polygons, - polylines: polylines, - tileOverlays: tileOverlays, - groundOverlays: groundOverlays, - ) - ..init(); + testWidgets("binds geometry controllers to map's", ( + WidgetTester tester, + ) async { + controller = + createController() + ..debugSetOverrides( + createMap: (_, __) => map, + circles: circles, + heatmaps: heatmaps, + markers: markers, + polygons: polygons, + polylines: polylines, + tileOverlays: tileOverlays, + groundOverlays: groundOverlays, + ) + ..init(); verify(circles.bindToMap(mapId, map)); verify(heatmaps.bindToMap(mapId, map)); @@ -332,91 +337,103 @@ void main() { }); testWidgets('renders initial geometry', (WidgetTester tester) async { - final MapObjects mapObjects = MapObjects(circles: { - const Circle( - circleId: CircleId('circle-1'), - zIndex: 1234, - ), - }, heatmaps: { - const Heatmap( - heatmapId: HeatmapId('heatmap-1'), - data: [ - WeightedLatLng(LatLng(43.355114, -5.851333)), - WeightedLatLng(LatLng(43.354797, -5.851860)), - WeightedLatLng(LatLng(43.354469, -5.851318)), - WeightedLatLng(LatLng(43.354762, -5.850824)), - ], - radius: HeatmapRadius.fromPixels(20), - ), - }, markers: { - const Marker( - markerId: MarkerId('marker-1'), - infoWindow: InfoWindow( - title: 'title for test', - snippet: 'snippet for test', + final MapObjects mapObjects = MapObjects( + circles: { + const Circle(circleId: CircleId('circle-1'), zIndex: 1234), + }, + heatmaps: { + const Heatmap( + heatmapId: HeatmapId('heatmap-1'), + data: [ + WeightedLatLng(LatLng(43.355114, -5.851333)), + WeightedLatLng(LatLng(43.354797, -5.851860)), + WeightedLatLng(LatLng(43.354469, -5.851318)), + WeightedLatLng(LatLng(43.354762, -5.850824)), + ], + radius: HeatmapRadius.fromPixels(20), ), - ), - }, polygons: { - const Polygon(polygonId: PolygonId('polygon-1'), points: [ - LatLng(43.355114, -5.851333), - LatLng(43.354797, -5.851860), - LatLng(43.354469, -5.851318), - LatLng(43.354762, -5.850824), - ]), - const Polygon( - polygonId: PolygonId('polygon-2-with-holes'), - points: [ - LatLng(43.355114, -5.851333), - LatLng(43.354797, -5.851860), - LatLng(43.354469, -5.851318), - LatLng(43.354762, -5.850824), - ], - holes: >[ - [ - LatLng(41.354797, -6.851860), - LatLng(41.354469, -6.851318), - LatLng(41.354762, -6.850824), - ] - ], - ), - }, polylines: { - const Polyline(polylineId: PolylineId('polyline-1'), points: [ - LatLng(43.355114, -5.851333), - LatLng(43.354797, -5.851860), - LatLng(43.354469, -5.851318), - LatLng(43.354762, -5.850824), - ]) - }, tileOverlays: { - const TileOverlay(tileOverlayId: TileOverlayId('overlay-1')) - }, groundOverlays: { - GroundOverlay.fromBounds( - groundOverlayId: const GroundOverlayId('bounds_1'), - bounds: LatLngBounds( - northeast: const LatLng(100, 0), - southwest: const LatLng(0, 100), + }, + markers: { + const Marker( + markerId: MarkerId('marker-1'), + infoWindow: InfoWindow( + title: 'title for test', + snippet: 'snippet for test', + ), ), - image: AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 1.0, - bitmapScaling: MapBitmapScaling.none, + }, + polygons: { + const Polygon( + polygonId: PolygonId('polygon-1'), + points: [ + LatLng(43.355114, -5.851333), + LatLng(43.354797, -5.851860), + LatLng(43.354469, -5.851318), + LatLng(43.354762, -5.850824), + ], ), - transparency: 0.7, - bearing: 10, - zIndex: 10, - ) - }); + const Polygon( + polygonId: PolygonId('polygon-2-with-holes'), + points: [ + LatLng(43.355114, -5.851333), + LatLng(43.354797, -5.851860), + LatLng(43.354469, -5.851318), + LatLng(43.354762, -5.850824), + ], + holes: >[ + [ + LatLng(41.354797, -6.851860), + LatLng(41.354469, -6.851318), + LatLng(41.354762, -6.850824), + ], + ], + ), + }, + polylines: { + const Polyline( + polylineId: PolylineId('polyline-1'), + points: [ + LatLng(43.355114, -5.851333), + LatLng(43.354797, -5.851860), + LatLng(43.354469, -5.851318), + LatLng(43.354762, -5.850824), + ], + ), + }, + tileOverlays: { + const TileOverlay(tileOverlayId: TileOverlayId('overlay-1')), + }, + groundOverlays: { + GroundOverlay.fromBounds( + groundOverlayId: const GroundOverlayId('bounds_1'), + bounds: LatLngBounds( + northeast: const LatLng(100, 0), + southwest: const LatLng(0, 100), + ), + image: AssetMapBitmap( + 'assets/red_square.png', + imagePixelRatio: 1.0, + bitmapScaling: MapBitmapScaling.none, + ), + transparency: 0.7, + bearing: 10, + zIndex: 10, + ), + }, + ); - controller = createController(mapObjects: mapObjects) - ..debugSetOverrides( - circles: circles, - heatmaps: heatmaps, - markers: markers, - polygons: polygons, - polylines: polylines, - tileOverlays: tileOverlays, - groundOverlays: groundOverlays, - ) - ..init(); + controller = + createController(mapObjects: mapObjects) + ..debugSetOverrides( + circles: circles, + heatmaps: heatmaps, + markers: markers, + polygons: polygons, + polylines: polylines, + tileOverlays: tileOverlays, + groundOverlays: groundOverlays, + ) + ..init(); verify(circles.addCircles(mapObjects.circles)); verify(heatmaps.addHeatmaps(mapObjects.heatmaps)); @@ -431,17 +448,19 @@ void main() { testWidgets('translates initial options', (WidgetTester tester) async { gmaps.MapOptions? capturedOptions; controller = createController( - mapConfiguration: const MapConfiguration( - mapType: MapType.satellite, - zoomControlsEnabled: true, - cloudMapId: _kCloudMapId, - fortyFiveDegreeImageryEnabled: false, - )); + mapConfiguration: const MapConfiguration( + mapType: MapType.satellite, + zoomControlsEnabled: true, + cloudMapId: _kCloudMapId, + fortyFiveDegreeImageryEnabled: false, + ), + ); controller.debugSetOverrides( - createMap: (_, gmaps.MapOptions options) { - capturedOptions = options; - return map; - }); + createMap: (_, gmaps.MapOptions options) { + capturedOptions = options; + return map; + }, + ); controller.init(); @@ -449,26 +468,31 @@ void main() { expect(capturedOptions!.mapTypeId, gmaps.MapTypeId.SATELLITE); expect(capturedOptions!.zoomControl, true); expect(capturedOptions!.mapId, _kCloudMapId); - expect(capturedOptions!.gestureHandling, 'auto', - reason: - 'by default the map handles zoom/pan gestures internally'); + expect( + capturedOptions!.gestureHandling, + 'auto', + reason: 'by default the map handles zoom/pan gestures internally', + ); expect(capturedOptions!.rotateControl, false); expect(capturedOptions!.tilt, 0); }); - testWidgets('translates fortyFiveDegreeImageryEnabled option', - (WidgetTester tester) async { + testWidgets('translates fortyFiveDegreeImageryEnabled option', ( + WidgetTester tester, + ) async { gmaps.MapOptions? capturedOptions; controller = createController( - mapConfiguration: const MapConfiguration( - scrollGesturesEnabled: false, - fortyFiveDegreeImageryEnabled: true, - )); + mapConfiguration: const MapConfiguration( + scrollGesturesEnabled: false, + fortyFiveDegreeImageryEnabled: true, + ), + ); controller.debugSetOverrides( - createMap: (_, gmaps.MapOptions options) { - capturedOptions = options; - return map; - }); + createMap: (_, gmaps.MapOptions options) { + capturedOptions = options; + return map; + }, + ); controller.init(); @@ -477,19 +501,22 @@ void main() { expect(capturedOptions!.tilt, isNull); }); - testWidgets('translates webGestureHandling option', - (WidgetTester tester) async { + testWidgets('translates webGestureHandling option', ( + WidgetTester tester, + ) async { gmaps.MapOptions? capturedOptions; controller = createController( - mapConfiguration: const MapConfiguration( - zoomGesturesEnabled: false, - webGestureHandling: WebGestureHandling.greedy, - )); + mapConfiguration: const MapConfiguration( + zoomGesturesEnabled: false, + webGestureHandling: WebGestureHandling.greedy, + ), + ); controller.debugSetOverrides( - createMap: (_, gmaps.MapOptions options) { - capturedOptions = options; - return map; - }); + createMap: (_, gmaps.MapOptions options) { + capturedOptions = options; + return map; + }, + ); controller.init(); @@ -497,22 +524,25 @@ void main() { expect(capturedOptions!.gestureHandling, 'greedy'); }); - testWidgets('translates cameraTargetBounds option', - (WidgetTester tester) async { + testWidgets('translates cameraTargetBounds option', ( + WidgetTester tester, + ) async { final LatLngBounds mockLatLngBounds = LatLngBounds( southwest: const LatLng(20, 30), northeast: const LatLng(25, 35), ); gmaps.MapOptions? capturedOptions; controller = createController( - mapConfiguration: MapConfiguration( - cameraTargetBounds: CameraTargetBounds(mockLatLngBounds), - )); + mapConfiguration: MapConfiguration( + cameraTargetBounds: CameraTargetBounds(mockLatLngBounds), + ), + ); controller.debugSetOverrides( - createMap: (_, gmaps.MapOptions options) { - capturedOptions = options; - return map; - }); + createMap: (_, gmaps.MapOptions options) { + capturedOptions = options; + return map; + }, + ); controller.init(); @@ -527,20 +557,24 @@ void main() { expect(capturedBounds.west, mockLatLngBounds.southwest.longitude); }); - testWidgets('sets initial position when passed', - (WidgetTester tester) async { + testWidgets('sets initial position when passed', ( + WidgetTester tester, + ) async { gmaps.MapOptions? capturedOptions; - controller = createController( - initialCameraPosition: const CameraPosition( - target: LatLng(43.308, -5.6910), - zoom: 12, - ), - ) - ..debugSetOverrides(createMap: (_, gmaps.MapOptions options) { - capturedOptions = options; - return map; - }) - ..init(); + controller = + createController( + initialCameraPosition: const CameraPosition( + target: LatLng(43.308, -5.6910), + zoom: 12, + ), + ) + ..debugSetOverrides( + createMap: (_, gmaps.MapOptions options) { + capturedOptions = options; + return map; + }, + ) + ..init(); expect(capturedOptions, isNotNull); expect(capturedOptions!.zoom, 12); @@ -556,12 +590,14 @@ void main() { "stylers": [{"color": "#6b9a76"}] }]'''; controller = createController( - mapConfiguration: const MapConfiguration(style: style)); + mapConfiguration: const MapConfiguration(style: style), + ); controller.debugSetOverrides( - createMap: (_, gmaps.MapOptions options) { - capturedOptions = options; - return map; - }); + createMap: (_, gmaps.MapOptions options) { + capturedOptions = options; + return map; + }, + ); controller.init(); @@ -569,17 +605,22 @@ void main() { expect(capturedOptions!.styles?.length, 1); }); - testWidgets('stores style errors for later querying', - (WidgetTester tester) async { + testWidgets('stores style errors for later querying', ( + WidgetTester tester, + ) async { gmaps.MapOptions? capturedOptions; controller = createController( - mapConfiguration: const MapConfiguration( - style: '[[invalid style', zoomControlsEnabled: true)); + mapConfiguration: const MapConfiguration( + style: '[[invalid style', + zoomControlsEnabled: true, + ), + ); controller.debugSetOverrides( - createMap: (_, gmaps.MapOptions options) { - capturedOptions = options; - return map; - }); + createMap: (_, gmaps.MapOptions options) { + capturedOptions = options; + return map; + }, + ); controller.init(); @@ -589,8 +630,9 @@ void main() { expect(capturedOptions!.zoomControl, true); }); - testWidgets('setting invalid style leaves previous style', - (WidgetTester tester) async { + testWidgets('setting invalid style leaves previous style', ( + WidgetTester tester, + ) async { gmaps.MapOptions? initialCapturedOptions; gmaps.MapOptions? updatedCapturedOptions; const String style = ''' @@ -600,7 +642,8 @@ void main() { "stylers": [{"color": "#6b9a76"}] }]'''; controller = createController( - mapConfiguration: const MapConfiguration(style: style)); + mapConfiguration: const MapConfiguration(style: style), + ); controller.debugSetOverrides( createMap: (_, gmaps.MapOptions options) { initialCapturedOptions = options; @@ -613,13 +656,16 @@ void main() { controller.init(); controller.updateMapConfiguration( - const MapConfiguration(style: '[[invalid style')); + const MapConfiguration(style: '[[invalid style'), + ); expect(initialCapturedOptions, isNotNull); expect(initialCapturedOptions!.styles?.length, 1); // The styles should not have changed. expect( - updatedCapturedOptions!.styles, initialCapturedOptions!.styles); + updatedCapturedOptions!.styles, + initialCapturedOptions!.styles, + ); }); }); @@ -629,14 +675,17 @@ void main() { expect(controller.trafficLayer, isNull); }); - testWidgets('initializes with traffic layer', - (WidgetTester tester) async { - controller = createController( - mapConfiguration: const MapConfiguration( - trafficEnabled: true, - )) - ..debugSetOverrides(createMap: (_, __) => map) - ..init(); + testWidgets('initializes with traffic layer', ( + WidgetTester tester, + ) async { + controller = + createController( + mapConfiguration: const MapConfiguration( + trafficEnabled: true, + ), + ) + ..debugSetOverrides(createMap: (_, __) => map) + ..init(); expect(controller.trafficLayer, isNotNull); }); }); @@ -653,16 +702,17 @@ void main() { ..zoom = 10 ..center = gmaps.LatLng(0, 0), ); - controller = createController() - ..debugSetOverrides(createMap: (_, __) => map) - ..init(); + controller = + createController() + ..debugSetOverrides(createMap: (_, __) => map) + ..init(); }); group('updateMapConfiguration', () { testWidgets('can update `options`', (WidgetTester tester) async { - controller.updateMapConfiguration(const MapConfiguration( - mapType: MapType.satellite, - )); + controller.updateMapConfiguration( + const MapConfiguration(mapType: MapType.satellite), + ); expect(map.mapTypeId, gmaps.MapTypeId.SATELLITE); }); @@ -670,15 +720,15 @@ void main() { testWidgets('can turn on/off traffic', (WidgetTester tester) async { expect(controller.trafficLayer, isNull); - controller.updateMapConfiguration(const MapConfiguration( - trafficEnabled: true, - )); + controller.updateMapConfiguration( + const MapConfiguration(trafficEnabled: true), + ); expect(controller.trafficLayer, isNotNull); - controller.updateMapConfiguration(const MapConfiguration( - trafficEnabled: false, - )); + controller.updateMapConfiguration( + const MapConfiguration(trafficEnabled: false), + ); expect(controller.trafficLayer, isNull); }); @@ -690,15 +740,17 @@ void main() { "elementType": "labels.text.fill", "stylers": [{"color": "#6b9a76"}] }]'''; - controller - .updateMapConfiguration(const MapConfiguration(style: style)); + controller.updateMapConfiguration( + const MapConfiguration(style: style), + ); expect(controller.styles.length, 1); }); testWidgets('can update style', (WidgetTester tester) async { controller.updateMapConfiguration( - const MapConfiguration(style: '[[[invalid style')); + const MapConfiguration(style: '[[[invalid style'), + ); expect(controller.styles, isEmpty); expect(controller.lastStyleError, isNotNull); @@ -708,14 +760,19 @@ void main() { group('viewport getters', () { testWidgets('getVisibleRegion', (WidgetTester tester) async { final gmaps.LatLng gmCenter = map.center; - final LatLng center = - LatLng(gmCenter.lat.toDouble(), gmCenter.lng.toDouble()); + final LatLng center = LatLng( + gmCenter.lat.toDouble(), + gmCenter.lng.toDouble(), + ); final LatLngBounds bounds = await controller.getVisibleRegion(); - expect(bounds.contains(center), isTrue, - reason: - 'The computed visible region must contain the center of the created map.'); + expect( + bounds.contains(center), + isTrue, + reason: + 'The computed visible region must contain the center of the created map.', + ); }); testWidgets('getZoomLevel', (WidgetTester tester) async { @@ -750,15 +807,17 @@ void main() { controller.updateCircles(CircleUpdates.from(previous, current)); - verify(mock.removeCircles({ - const CircleId('to-be-removed'), - })); - verify(mock.addCircles({ - const Circle(circleId: CircleId('to-be-added')), - })); - verify(mock.changeCircles({ - const Circle(circleId: CircleId('to-be-updated'), visible: false), - })); + verify(mock.removeCircles({const CircleId('to-be-removed')})); + verify( + mock.addCircles({ + const Circle(circleId: CircleId('to-be-added')), + }), + ); + verify( + mock.changeCircles({ + const Circle(circleId: CircleId('to-be-updated'), visible: false), + }), + ); }); testWidgets('updateHeatmaps', (WidgetTester tester) async { @@ -779,7 +838,7 @@ void main() { WeightedLatLng(LatLng(37.785, -122.441)), WeightedLatLng(LatLng(37.785, -122.439)), WeightedLatLng(LatLng(37.785, -122.437)), - WeightedLatLng(LatLng(37.785, -122.435)) + WeightedLatLng(LatLng(37.785, -122.435)), ]; final Set previous = { @@ -811,24 +870,28 @@ void main() { controller.updateHeatmaps(HeatmapUpdates.from(previous, current)); - verify(mock.removeHeatmaps({ - const HeatmapId('to-be-removed'), - })); - verify(mock.addHeatmaps({ - const Heatmap( - heatmapId: HeatmapId('to-be-added'), - data: heatmapPoints, - radius: HeatmapRadius.fromPixels(20), - ), - })); - verify(mock.changeHeatmaps({ - const Heatmap( - heatmapId: HeatmapId('to-be-updated'), - data: heatmapPoints, - dissipating: false, - radius: HeatmapRadius.fromPixels(20), - ), - })); + verify( + mock.removeHeatmaps({const HeatmapId('to-be-removed')}), + ); + verify( + mock.addHeatmaps({ + const Heatmap( + heatmapId: HeatmapId('to-be-added'), + data: heatmapPoints, + radius: HeatmapRadius.fromPixels(20), + ), + }), + ); + verify( + mock.changeHeatmaps({ + const Heatmap( + heatmapId: HeatmapId('to-be-updated'), + data: heatmapPoints, + dissipating: false, + radius: HeatmapRadius.fromPixels(20), + ), + }), + ); }); testWidgets('updateMarkers', (WidgetTester tester) async { @@ -847,15 +910,17 @@ void main() { await controller.updateMarkers(MarkerUpdates.from(previous, current)); - verify(mock.removeMarkers({ - const MarkerId('to-be-removed'), - })); - verify(mock.addMarkers({ - const Marker(markerId: MarkerId('to-be-added')), - })); - verify(mock.changeMarkers({ - const Marker(markerId: MarkerId('to-be-updated'), visible: false), - })); + verify(mock.removeMarkers({const MarkerId('to-be-removed')})); + verify( + mock.addMarkers({ + const Marker(markerId: MarkerId('to-be-added')), + }), + ); + verify( + mock.changeMarkers({ + const Marker(markerId: MarkerId('to-be-updated'), visible: false), + }), + ); }); testWidgets('updatePolygons', (WidgetTester tester) async { @@ -874,15 +939,22 @@ void main() { controller.updatePolygons(PolygonUpdates.from(previous, current)); - verify(mock.removePolygons({ - const PolygonId('to-be-removed'), - })); - verify(mock.addPolygons({ - const Polygon(polygonId: PolygonId('to-be-added')), - })); - verify(mock.changePolygons({ - const Polygon(polygonId: PolygonId('to-be-updated'), visible: false), - })); + verify( + mock.removePolygons({const PolygonId('to-be-removed')}), + ); + verify( + mock.addPolygons({ + const Polygon(polygonId: PolygonId('to-be-added')), + }), + ); + verify( + mock.changePolygons({ + const Polygon( + polygonId: PolygonId('to-be-updated'), + visible: false, + ), + }), + ); }); testWidgets('updatePolylines', (WidgetTester tester) async { @@ -904,52 +976,68 @@ void main() { controller.updatePolylines(PolylineUpdates.from(previous, current)); - verify(mock.removePolylines({ - const PolylineId('to-be-removed'), - })); - verify(mock.addPolylines({ - const Polyline(polylineId: PolylineId('to-be-added')), - })); - verify(mock.changePolylines({ - const Polyline( - polylineId: PolylineId('to-be-updated'), - visible: false, - ), - })); + verify( + mock.removePolylines({const PolylineId('to-be-removed')}), + ); + verify( + mock.addPolylines({ + const Polyline(polylineId: PolylineId('to-be-added')), + }), + ); + verify( + mock.changePolylines({ + const Polyline( + polylineId: PolylineId('to-be-updated'), + visible: false, + ), + }), + ); }); testWidgets('updateTileOverlays', (WidgetTester tester) async { final MockTileOverlaysController mock = MockTileOverlaysController(); controller = createController( - mapObjects: MapObjects(tileOverlays: { - const TileOverlay(tileOverlayId: TileOverlayId('to-be-updated')), - const TileOverlay(tileOverlayId: TileOverlayId('to-be-removed')), - })) - ..debugSetOverrides(tileOverlays: mock); + mapObjects: MapObjects( + tileOverlays: { + const TileOverlay(tileOverlayId: TileOverlayId('to-be-updated')), + const TileOverlay(tileOverlayId: TileOverlayId('to-be-removed')), + }, + ), + )..debugSetOverrides(tileOverlays: mock); controller.updateTileOverlays({ const TileOverlay( - tileOverlayId: TileOverlayId('to-be-updated'), visible: false), + tileOverlayId: TileOverlayId('to-be-updated'), + visible: false, + ), const TileOverlay(tileOverlayId: TileOverlayId('to-be-added')), }); - verify(mock.removeTileOverlays({ - const TileOverlayId('to-be-removed'), - })); - verify(mock.addTileOverlays({ - const TileOverlay(tileOverlayId: TileOverlayId('to-be-added')), - })); - verify(mock.changeTileOverlays({ - const TileOverlay( - tileOverlayId: TileOverlayId('to-be-updated'), visible: false), - })); + verify( + mock.removeTileOverlays({ + const TileOverlayId('to-be-removed'), + }), + ); + verify( + mock.addTileOverlays({ + const TileOverlay(tileOverlayId: TileOverlayId('to-be-added')), + }), + ); + verify( + mock.changeTileOverlays({ + const TileOverlay( + tileOverlayId: TileOverlayId('to-be-updated'), + visible: false, + ), + }), + ); }); testWidgets('updateGroundOverlays', (WidgetTester tester) async { final MockGroundOverlaysController mock = MockGroundOverlaysController(); - controller = createController() - ..debugSetOverrides(groundOverlays: mock); + controller = + createController()..debugSetOverrides(groundOverlays: mock); final LatLngBounds bounds = LatLngBounds( northeast: const LatLng(100, 0), @@ -969,10 +1057,10 @@ void main() { ); final GroundOverlay groundOverlayToBeRemoved = GroundOverlay.fromPosition( - groundOverlayId: const GroundOverlayId('to-be-removed'), - image: image, - position: position, - ); + groundOverlayId: const GroundOverlayId('to-be-removed'), + image: image, + position: position, + ); final GroundOverlay groundOverlayToBeAdded = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('to-be-added'), image: image, @@ -981,24 +1069,29 @@ void main() { final Set previous = { groundOverlayToBeUpdated, - groundOverlayToBeRemoved + groundOverlayToBeRemoved, }; final Set current = { groundOverlayToBeUpdated.copyWith(visibleParam: false), - groundOverlayToBeAdded + groundOverlayToBeAdded, }; - controller - .updateGroundOverlays(GroundOverlayUpdates.from(previous, current)); + controller.updateGroundOverlays( + GroundOverlayUpdates.from(previous, current), + ); - verify(mock.removeGroundOverlays({ - groundOverlayToBeRemoved.groundOverlayId, - })); + verify( + mock.removeGroundOverlays({ + groundOverlayToBeRemoved.groundOverlayId, + }), + ); verify(mock.addGroundOverlays({groundOverlayToBeAdded})); - verify(mock.changeGroundOverlays({ - groundOverlayToBeUpdated.copyWith(visibleParam: false), - })); + verify( + mock.changeGroundOverlays({ + groundOverlayToBeUpdated.copyWith(visibleParam: false), + }), + ); }); testWidgets('infoWindow visibility', (WidgetTester tester) async { diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart index 7904b7352cb..a47b2daad9e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_controller_test.mocks.dart @@ -31,87 +31,68 @@ import 'google_maps_controller_test.dart' as _i5; /// See the documentation for Mockito's code generation for more information. class MockCirclesController extends _i1.Mock implements _i2.CirclesController { @override - Map<_i3.CircleId, _i2.CircleController> get circles => (super.noSuchMethod( - Invocation.getter(#circles), - returnValue: <_i3.CircleId, _i2.CircleController>{}, - returnValueForMissingStub: <_i3.CircleId, _i2.CircleController>{}, - ) as Map<_i3.CircleId, _i2.CircleController>); + Map<_i3.CircleId, _i2.CircleController> get circles => + (super.noSuchMethod( + Invocation.getter(#circles), + returnValue: <_i3.CircleId, _i2.CircleController>{}, + returnValueForMissingStub: <_i3.CircleId, _i2.CircleController>{}, + ) + as Map<_i3.CircleId, _i2.CircleController>); @override - _i4.Map get googleMap => (super.noSuchMethod( - Invocation.getter(#googleMap), - returnValue: _i5.mapShim(), - returnValueForMissingStub: _i5.mapShim(), - ) as _i4.Map); + _i4.Map get googleMap => + (super.noSuchMethod( + Invocation.getter(#googleMap), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), + ) + as _i4.Map); @override set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( - Invocation.setter( - #googleMap, - _googleMap, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#googleMap, _googleMap), + returnValueForMissingStub: null, + ); @override - int get mapId => (super.noSuchMethod( - Invocation.getter(#mapId), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); + int get mapId => + (super.noSuchMethod( + Invocation.getter(#mapId), + returnValue: 0, + returnValueForMissingStub: 0, + ) + as int); @override set mapId(int? _mapId) => super.noSuchMethod( - Invocation.setter( - #mapId, - _mapId, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#mapId, _mapId), + returnValueForMissingStub: null, + ); @override void addCircles(Set<_i3.Circle>? circlesToAdd) => super.noSuchMethod( - Invocation.method( - #addCircles, - [circlesToAdd], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#addCircles, [circlesToAdd]), + returnValueForMissingStub: null, + ); @override void changeCircles(Set<_i3.Circle>? circlesToChange) => super.noSuchMethod( - Invocation.method( - #changeCircles, - [circlesToChange], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#changeCircles, [circlesToChange]), + returnValueForMissingStub: null, + ); @override void removeCircles(Set<_i3.CircleId>? circleIdsToRemove) => super.noSuchMethod( - Invocation.method( - #removeCircles, - [circleIdsToRemove], - ), + Invocation.method(#removeCircles, [circleIdsToRemove]), returnValueForMissingStub: null, ); @override - void bindToMap( - int? mapId, - _i4.Map? googleMap, - ) => - super.noSuchMethod( - Invocation.method( - #bindToMap, - [ - mapId, - googleMap, - ], - ), - returnValueForMissingStub: null, - ); + void bindToMap(int? mapId, _i4.Map? googleMap) => super.noSuchMethod( + Invocation.method(#bindToMap, [mapId, googleMap]), + returnValueForMissingStub: null, + ); } /// A class which mocks [HeatmapsController]. @@ -120,87 +101,68 @@ class MockCirclesController extends _i1.Mock implements _i2.CirclesController { class MockHeatmapsController extends _i1.Mock implements _i2.HeatmapsController { @override - Map<_i3.HeatmapId, _i2.HeatmapController> get heatmaps => (super.noSuchMethod( - Invocation.getter(#heatmaps), - returnValue: <_i3.HeatmapId, _i2.HeatmapController>{}, - returnValueForMissingStub: <_i3.HeatmapId, _i2.HeatmapController>{}, - ) as Map<_i3.HeatmapId, _i2.HeatmapController>); + Map<_i3.HeatmapId, _i2.HeatmapController> get heatmaps => + (super.noSuchMethod( + Invocation.getter(#heatmaps), + returnValue: <_i3.HeatmapId, _i2.HeatmapController>{}, + returnValueForMissingStub: <_i3.HeatmapId, _i2.HeatmapController>{}, + ) + as Map<_i3.HeatmapId, _i2.HeatmapController>); @override - _i4.Map get googleMap => (super.noSuchMethod( - Invocation.getter(#googleMap), - returnValue: _i5.mapShim(), - returnValueForMissingStub: _i5.mapShim(), - ) as _i4.Map); + _i4.Map get googleMap => + (super.noSuchMethod( + Invocation.getter(#googleMap), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), + ) + as _i4.Map); @override set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( - Invocation.setter( - #googleMap, - _googleMap, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#googleMap, _googleMap), + returnValueForMissingStub: null, + ); @override - int get mapId => (super.noSuchMethod( - Invocation.getter(#mapId), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); + int get mapId => + (super.noSuchMethod( + Invocation.getter(#mapId), + returnValue: 0, + returnValueForMissingStub: 0, + ) + as int); @override set mapId(int? _mapId) => super.noSuchMethod( - Invocation.setter( - #mapId, - _mapId, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#mapId, _mapId), + returnValueForMissingStub: null, + ); @override void addHeatmaps(Set<_i3.Heatmap>? heatmapsToAdd) => super.noSuchMethod( - Invocation.method( - #addHeatmaps, - [heatmapsToAdd], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#addHeatmaps, [heatmapsToAdd]), + returnValueForMissingStub: null, + ); @override void changeHeatmaps(Set<_i3.Heatmap>? heatmapsToChange) => super.noSuchMethod( - Invocation.method( - #changeHeatmaps, - [heatmapsToChange], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#changeHeatmaps, [heatmapsToChange]), + returnValueForMissingStub: null, + ); @override void removeHeatmaps(Set<_i3.HeatmapId>? heatmapIdsToRemove) => super.noSuchMethod( - Invocation.method( - #removeHeatmaps, - [heatmapIdsToRemove], - ), + Invocation.method(#removeHeatmaps, [heatmapIdsToRemove]), returnValueForMissingStub: null, ); @override - void bindToMap( - int? mapId, - _i4.Map? googleMap, - ) => - super.noSuchMethod( - Invocation.method( - #bindToMap, - [ - mapId, - googleMap, - ], - ), - returnValueForMissingStub: null, - ); + void bindToMap(int? mapId, _i4.Map? googleMap) => super.noSuchMethod( + Invocation.method(#bindToMap, [mapId, googleMap]), + returnValueForMissingStub: null, + ); } /// A class which mocks [PolygonsController]. @@ -209,87 +171,68 @@ class MockHeatmapsController extends _i1.Mock class MockPolygonsController extends _i1.Mock implements _i2.PolygonsController { @override - Map<_i3.PolygonId, _i2.PolygonController> get polygons => (super.noSuchMethod( - Invocation.getter(#polygons), - returnValue: <_i3.PolygonId, _i2.PolygonController>{}, - returnValueForMissingStub: <_i3.PolygonId, _i2.PolygonController>{}, - ) as Map<_i3.PolygonId, _i2.PolygonController>); + Map<_i3.PolygonId, _i2.PolygonController> get polygons => + (super.noSuchMethod( + Invocation.getter(#polygons), + returnValue: <_i3.PolygonId, _i2.PolygonController>{}, + returnValueForMissingStub: <_i3.PolygonId, _i2.PolygonController>{}, + ) + as Map<_i3.PolygonId, _i2.PolygonController>); @override - _i4.Map get googleMap => (super.noSuchMethod( - Invocation.getter(#googleMap), - returnValue: _i5.mapShim(), - returnValueForMissingStub: _i5.mapShim(), - ) as _i4.Map); + _i4.Map get googleMap => + (super.noSuchMethod( + Invocation.getter(#googleMap), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), + ) + as _i4.Map); @override set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( - Invocation.setter( - #googleMap, - _googleMap, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#googleMap, _googleMap), + returnValueForMissingStub: null, + ); @override - int get mapId => (super.noSuchMethod( - Invocation.getter(#mapId), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); + int get mapId => + (super.noSuchMethod( + Invocation.getter(#mapId), + returnValue: 0, + returnValueForMissingStub: 0, + ) + as int); @override set mapId(int? _mapId) => super.noSuchMethod( - Invocation.setter( - #mapId, - _mapId, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#mapId, _mapId), + returnValueForMissingStub: null, + ); @override void addPolygons(Set<_i3.Polygon>? polygonsToAdd) => super.noSuchMethod( - Invocation.method( - #addPolygons, - [polygonsToAdd], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#addPolygons, [polygonsToAdd]), + returnValueForMissingStub: null, + ); @override void changePolygons(Set<_i3.Polygon>? polygonsToChange) => super.noSuchMethod( - Invocation.method( - #changePolygons, - [polygonsToChange], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#changePolygons, [polygonsToChange]), + returnValueForMissingStub: null, + ); @override void removePolygons(Set<_i3.PolygonId>? polygonIdsToRemove) => super.noSuchMethod( - Invocation.method( - #removePolygons, - [polygonIdsToRemove], - ), + Invocation.method(#removePolygons, [polygonIdsToRemove]), returnValueForMissingStub: null, ); @override - void bindToMap( - int? mapId, - _i4.Map? googleMap, - ) => - super.noSuchMethod( - Invocation.method( - #bindToMap, - [ - mapId, - googleMap, - ], - ), - returnValueForMissingStub: null, - ); + void bindToMap(int? mapId, _i4.Map? googleMap) => super.noSuchMethod( + Invocation.method(#bindToMap, [mapId, googleMap]), + returnValueForMissingStub: null, + ); } /// A class which mocks [PolylinesController]. @@ -298,88 +241,70 @@ class MockPolygonsController extends _i1.Mock class MockPolylinesController extends _i1.Mock implements _i2.PolylinesController { @override - Map<_i3.PolylineId, _i2.PolylineController> get lines => (super.noSuchMethod( - Invocation.getter(#lines), - returnValue: <_i3.PolylineId, _i2.PolylineController>{}, - returnValueForMissingStub: <_i3.PolylineId, _i2.PolylineController>{}, - ) as Map<_i3.PolylineId, _i2.PolylineController>); + Map<_i3.PolylineId, _i2.PolylineController> get lines => + (super.noSuchMethod( + Invocation.getter(#lines), + returnValue: <_i3.PolylineId, _i2.PolylineController>{}, + returnValueForMissingStub: + <_i3.PolylineId, _i2.PolylineController>{}, + ) + as Map<_i3.PolylineId, _i2.PolylineController>); @override - _i4.Map get googleMap => (super.noSuchMethod( - Invocation.getter(#googleMap), - returnValue: _i5.mapShim(), - returnValueForMissingStub: _i5.mapShim(), - ) as _i4.Map); + _i4.Map get googleMap => + (super.noSuchMethod( + Invocation.getter(#googleMap), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), + ) + as _i4.Map); @override set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( - Invocation.setter( - #googleMap, - _googleMap, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#googleMap, _googleMap), + returnValueForMissingStub: null, + ); @override - int get mapId => (super.noSuchMethod( - Invocation.getter(#mapId), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); + int get mapId => + (super.noSuchMethod( + Invocation.getter(#mapId), + returnValue: 0, + returnValueForMissingStub: 0, + ) + as int); @override set mapId(int? _mapId) => super.noSuchMethod( - Invocation.setter( - #mapId, - _mapId, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#mapId, _mapId), + returnValueForMissingStub: null, + ); @override void addPolylines(Set<_i3.Polyline>? polylinesToAdd) => super.noSuchMethod( - Invocation.method( - #addPolylines, - [polylinesToAdd], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#addPolylines, [polylinesToAdd]), + returnValueForMissingStub: null, + ); @override void changePolylines(Set<_i3.Polyline>? polylinesToChange) => super.noSuchMethod( - Invocation.method( - #changePolylines, - [polylinesToChange], - ), + Invocation.method(#changePolylines, [polylinesToChange]), returnValueForMissingStub: null, ); @override void removePolylines(Set<_i3.PolylineId>? polylineIdsToRemove) => super.noSuchMethod( - Invocation.method( - #removePolylines, - [polylineIdsToRemove], - ), + Invocation.method(#removePolylines, [polylineIdsToRemove]), returnValueForMissingStub: null, ); @override - void bindToMap( - int? mapId, - _i4.Map? googleMap, - ) => - super.noSuchMethod( - Invocation.method( - #bindToMap, - [ - mapId, - googleMap, - ], - ), - returnValueForMissingStub: null, - ); + void bindToMap(int? mapId, _i4.Map? googleMap) => super.noSuchMethod( + Invocation.method(#bindToMap, [mapId, googleMap]), + returnValueForMissingStub: null, + ); } /// A class which mocks [MarkersController]. @@ -387,119 +312,95 @@ class MockPolylinesController extends _i1.Mock /// See the documentation for Mockito's code generation for more information. class MockMarkersController extends _i1.Mock implements _i2.MarkersController { @override - Map<_i3.MarkerId, _i2.MarkerController> get markers => (super.noSuchMethod( - Invocation.getter(#markers), - returnValue: <_i3.MarkerId, _i2.MarkerController>{}, - returnValueForMissingStub: <_i3.MarkerId, _i2.MarkerController>{}, - ) as Map<_i3.MarkerId, _i2.MarkerController>); + Map<_i3.MarkerId, _i2.MarkerController> get markers => + (super.noSuchMethod( + Invocation.getter(#markers), + returnValue: <_i3.MarkerId, _i2.MarkerController>{}, + returnValueForMissingStub: <_i3.MarkerId, _i2.MarkerController>{}, + ) + as Map<_i3.MarkerId, _i2.MarkerController>); @override - _i4.Map get googleMap => (super.noSuchMethod( - Invocation.getter(#googleMap), - returnValue: _i5.mapShim(), - returnValueForMissingStub: _i5.mapShim(), - ) as _i4.Map); + _i4.Map get googleMap => + (super.noSuchMethod( + Invocation.getter(#googleMap), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), + ) + as _i4.Map); @override set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( - Invocation.setter( - #googleMap, - _googleMap, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#googleMap, _googleMap), + returnValueForMissingStub: null, + ); @override - int get mapId => (super.noSuchMethod( - Invocation.getter(#mapId), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); + int get mapId => + (super.noSuchMethod( + Invocation.getter(#mapId), + returnValue: 0, + returnValueForMissingStub: 0, + ) + as int); @override set mapId(int? _mapId) => super.noSuchMethod( - Invocation.setter( - #mapId, - _mapId, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#mapId, _mapId), + returnValueForMissingStub: null, + ); @override _i6.Future addMarkers(Set<_i3.Marker>? markersToAdd) => (super.noSuchMethod( - Invocation.method( - #addMarkers, - [markersToAdd], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + Invocation.method(#addMarkers, [markersToAdd]), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) + as _i6.Future); @override _i6.Future changeMarkers(Set<_i3.Marker>? markersToChange) => (super.noSuchMethod( - Invocation.method( - #changeMarkers, - [markersToChange], - ), - returnValue: _i6.Future.value(), - returnValueForMissingStub: _i6.Future.value(), - ) as _i6.Future); + Invocation.method(#changeMarkers, [markersToChange]), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) + as _i6.Future); @override void removeMarkers(Set<_i3.MarkerId>? markerIdsToRemove) => super.noSuchMethod( - Invocation.method( - #removeMarkers, - [markerIdsToRemove], - ), + Invocation.method(#removeMarkers, [markerIdsToRemove]), returnValueForMissingStub: null, ); @override void showMarkerInfoWindow(_i3.MarkerId? markerId) => super.noSuchMethod( - Invocation.method( - #showMarkerInfoWindow, - [markerId], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#showMarkerInfoWindow, [markerId]), + returnValueForMissingStub: null, + ); @override void hideMarkerInfoWindow(_i3.MarkerId? markerId) => super.noSuchMethod( - Invocation.method( - #hideMarkerInfoWindow, - [markerId], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#hideMarkerInfoWindow, [markerId]), + returnValueForMissingStub: null, + ); @override - bool isInfoWindowShown(_i3.MarkerId? markerId) => (super.noSuchMethod( - Invocation.method( - #isInfoWindowShown, - [markerId], - ), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); + bool isInfoWindowShown(_i3.MarkerId? markerId) => + (super.noSuchMethod( + Invocation.method(#isInfoWindowShown, [markerId]), + returnValue: false, + returnValueForMissingStub: false, + ) + as bool); @override - void bindToMap( - int? mapId, - _i4.Map? googleMap, - ) => - super.noSuchMethod( - Invocation.method( - #bindToMap, - [ - mapId, - googleMap, - ], - ), - returnValueForMissingStub: null, - ); + void bindToMap(int? mapId, _i4.Map? googleMap) => super.noSuchMethod( + Invocation.method(#bindToMap, [mapId, googleMap]), + returnValueForMissingStub: null, + ); } /// A class which mocks [TileOverlaysController]. @@ -508,91 +409,67 @@ class MockMarkersController extends _i1.Mock implements _i2.MarkersController { class MockTileOverlaysController extends _i1.Mock implements _i2.TileOverlaysController { @override - _i4.Map get googleMap => (super.noSuchMethod( - Invocation.getter(#googleMap), - returnValue: _i5.mapShim(), - returnValueForMissingStub: _i5.mapShim(), - ) as _i4.Map); + _i4.Map get googleMap => + (super.noSuchMethod( + Invocation.getter(#googleMap), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), + ) + as _i4.Map); @override set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( - Invocation.setter( - #googleMap, - _googleMap, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#googleMap, _googleMap), + returnValueForMissingStub: null, + ); @override - int get mapId => (super.noSuchMethod( - Invocation.getter(#mapId), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); + int get mapId => + (super.noSuchMethod( + Invocation.getter(#mapId), + returnValue: 0, + returnValueForMissingStub: 0, + ) + as int); @override set mapId(int? _mapId) => super.noSuchMethod( - Invocation.setter( - #mapId, - _mapId, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#mapId, _mapId), + returnValueForMissingStub: null, + ); @override void addTileOverlays(Set<_i3.TileOverlay>? tileOverlaysToAdd) => super.noSuchMethod( - Invocation.method( - #addTileOverlays, - [tileOverlaysToAdd], - ), + Invocation.method(#addTileOverlays, [tileOverlaysToAdd]), returnValueForMissingStub: null, ); @override void changeTileOverlays(Set<_i3.TileOverlay>? tileOverlays) => super.noSuchMethod( - Invocation.method( - #changeTileOverlays, - [tileOverlays], - ), + Invocation.method(#changeTileOverlays, [tileOverlays]), returnValueForMissingStub: null, ); @override void removeTileOverlays(Set<_i3.TileOverlayId>? tileOverlayIds) => super.noSuchMethod( - Invocation.method( - #removeTileOverlays, - [tileOverlayIds], - ), + Invocation.method(#removeTileOverlays, [tileOverlayIds]), returnValueForMissingStub: null, ); @override void clearTileCache(_i3.TileOverlayId? tileOverlayId) => super.noSuchMethod( - Invocation.method( - #clearTileCache, - [tileOverlayId], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#clearTileCache, [tileOverlayId]), + returnValueForMissingStub: null, + ); @override - void bindToMap( - int? mapId, - _i4.Map? googleMap, - ) => - super.noSuchMethod( - Invocation.method( - #bindToMap, - [ - mapId, - googleMap, - ], - ), - returnValueForMissingStub: null, - ); + void bindToMap(int? mapId, _i4.Map? googleMap) => super.noSuchMethod( + Invocation.method(#bindToMap, [mapId, googleMap]), + returnValueForMissingStub: null, + ); } /// A class which mocks [GroundOverlaysController]. @@ -601,80 +478,59 @@ class MockTileOverlaysController extends _i1.Mock class MockGroundOverlaysController extends _i1.Mock implements _i2.GroundOverlaysController { @override - _i4.Map get googleMap => (super.noSuchMethod( - Invocation.getter(#googleMap), - returnValue: _i5.mapShim(), - returnValueForMissingStub: _i5.mapShim(), - ) as _i4.Map); + _i4.Map get googleMap => + (super.noSuchMethod( + Invocation.getter(#googleMap), + returnValue: _i5.mapShim(), + returnValueForMissingStub: _i5.mapShim(), + ) + as _i4.Map); @override set googleMap(_i4.Map? _googleMap) => super.noSuchMethod( - Invocation.setter( - #googleMap, - _googleMap, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#googleMap, _googleMap), + returnValueForMissingStub: null, + ); @override - int get mapId => (super.noSuchMethod( - Invocation.getter(#mapId), - returnValue: 0, - returnValueForMissingStub: 0, - ) as int); + int get mapId => + (super.noSuchMethod( + Invocation.getter(#mapId), + returnValue: 0, + returnValueForMissingStub: 0, + ) + as int); @override set mapId(int? _mapId) => super.noSuchMethod( - Invocation.setter( - #mapId, - _mapId, - ), - returnValueForMissingStub: null, - ); + Invocation.setter(#mapId, _mapId), + returnValueForMissingStub: null, + ); @override void addGroundOverlays(Set<_i3.GroundOverlay>? groundOverlaysToAdd) => super.noSuchMethod( - Invocation.method( - #addGroundOverlays, - [groundOverlaysToAdd], - ), + Invocation.method(#addGroundOverlays, [groundOverlaysToAdd]), returnValueForMissingStub: null, ); @override void changeGroundOverlays(Set<_i3.GroundOverlay>? groundOverlays) => super.noSuchMethod( - Invocation.method( - #changeGroundOverlays, - [groundOverlays], - ), + Invocation.method(#changeGroundOverlays, [groundOverlays]), returnValueForMissingStub: null, ); @override void removeGroundOverlays(Set<_i3.GroundOverlayId>? groundOverlayIds) => super.noSuchMethod( - Invocation.method( - #removeGroundOverlays, - [groundOverlayIds], - ), + Invocation.method(#removeGroundOverlays, [groundOverlayIds]), returnValueForMissingStub: null, ); @override - void bindToMap( - int? mapId, - _i4.Map? googleMap, - ) => - super.noSuchMethod( - Invocation.method( - #bindToMap, - [ - mapId, - googleMap, - ], - ), - returnValueForMissingStub: null, - ); + void bindToMap(int? mapId, _i4.Map? googleMap) => super.noSuchMethod( + Invocation.method(#bindToMap, [mapId, googleMap]), + returnValueForMissingStub: null, + ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart index 1e02f576a08..4160ffcd041 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.dart @@ -51,8 +51,9 @@ void main() { plugin.debugSetMapById({0: controller}); }); - testWidgets('cannot call methods after dispose', - (WidgetTester tester) async { + testWidgets('cannot call methods after dispose', ( + WidgetTester tester, + ) async { plugin.dispose(mapId: 0); verify(controller.dispose()); @@ -67,49 +68,53 @@ void main() { group('buildView', () { const int testMapId = 33930; - const CameraPosition initialCameraPosition = - CameraPosition(target: LatLng(0, 0)); + const CameraPosition initialCameraPosition = CameraPosition( + target: LatLng(0, 0), + ); testWidgets( - 'returns an HtmlElementView and caches the controller for later', - (WidgetTester tester) async { - final Map cache = - {}; - plugin.debugSetMapById(cache); - - final Widget widget = plugin.buildViewWithConfiguration( - testMapId, - onPlatformViewCreated, - widgetConfiguration: const MapWidgetConfiguration( - initialCameraPosition: initialCameraPosition, - textDirection: TextDirection.ltr, - ), - ); + 'returns an HtmlElementView and caches the controller for later', + (WidgetTester tester) async { + final Map cache = + {}; + plugin.debugSetMapById(cache); + + final Widget widget = plugin.buildViewWithConfiguration( + testMapId, + onPlatformViewCreated, + widgetConfiguration: const MapWidgetConfiguration( + initialCameraPosition: initialCameraPosition, + textDirection: TextDirection.ltr, + ), + ); - expect(widget, isA()); - expect( - (widget as HtmlElementView).viewType, - contains('$testMapId'), - reason: - 'view type should contain the mapId passed when creating the map.', - ); - expect(cache, contains(testMapId)); - expect( - cache[testMapId], - isNotNull, - reason: 'cached controller cannot be null.', - ); - expect( - cache[testMapId]!.isInitialized, - isTrue, - reason: 'buildView calls init on the controller', + expect(widget, isA()); + expect( + (widget as HtmlElementView).viewType, + contains('$testMapId'), + reason: + 'view type should contain the mapId passed when creating the map.', + ); + expect(cache, contains(testMapId)); + expect( + cache[testMapId], + isNotNull, + reason: 'cached controller cannot be null.', + ); + expect( + cache[testMapId]!.isInitialized, + isTrue, + reason: 'buildView calls init on the controller', + ); + }, + ); + + testWidgets('returns cached instance if it already exists', ( + WidgetTester tester, + ) async { + const HtmlElementView expected = HtmlElementView( + viewType: 'only-for-testing', ); - }); - - testWidgets('returns cached instance if it already exists', - (WidgetTester tester) async { - const HtmlElementView expected = - HtmlElementView(viewType: 'only-for-testing'); when(controller.widget).thenReturn(expected); plugin.debugSetMapById({ testMapId: controller, @@ -128,44 +133,45 @@ void main() { }); testWidgets( - 'asynchronously reports onPlatformViewCreated the first time it happens', - (WidgetTester tester) async { - final Map cache = - {}; - plugin.debugSetMapById(cache); - - plugin.buildViewWithConfiguration( - testMapId, - onPlatformViewCreated, - widgetConfiguration: const MapWidgetConfiguration( - initialCameraPosition: initialCameraPosition, - textDirection: TextDirection.ltr, - ), - ); + 'asynchronously reports onPlatformViewCreated the first time it happens', + (WidgetTester tester) async { + final Map cache = + {}; + plugin.debugSetMapById(cache); + + plugin.buildViewWithConfiguration( + testMapId, + onPlatformViewCreated, + widgetConfiguration: const MapWidgetConfiguration( + initialCameraPosition: initialCameraPosition, + textDirection: TextDirection.ltr, + ), + ); - // Simulate Google Maps JS SDK being "ready" - cache[testMapId]!.stream.add(WebMapReadyEvent(testMapId)); + // Simulate Google Maps JS SDK being "ready" + cache[testMapId]!.stream.add(WebMapReadyEvent(testMapId)); - expect( - cache[testMapId]!.isInitialized, - isTrue, - reason: 'buildView calls init on the controller', - ); - expect( - await reportedMapIdCompleter.future, - testMapId, - reason: 'Should call onPlatformViewCreated with the mapId', - ); + expect( + cache[testMapId]!.isInitialized, + isTrue, + reason: 'buildView calls init on the controller', + ); + expect( + await reportedMapIdCompleter.future, + testMapId, + reason: 'Should call onPlatformViewCreated with the mapId', + ); - // Fire repeated event again... - cache[testMapId]!.stream.add(WebMapReadyEvent(testMapId)); - expect( - numberOnPlatformViewCreatedCalls, - equals(1), - reason: - 'Should not call onPlatformViewCreated for the same controller multiple times', - ); - }); + // Fire repeated event again... + cache[testMapId]!.stream.add(WebMapReadyEvent(testMapId)); + expect( + numberOnPlatformViewCreatedCalls, + equals(1), + reason: + 'Should not call onPlatformViewCreated for the same controller multiple times', + ); + }, + ); }); group('setMapStyles', () { @@ -176,8 +182,9 @@ void main() { "stylers": [{"color": "#6b9a76"}] }]'''; - testWidgets('translates styles for controller', - (WidgetTester tester) async { + testWidgets('translates styles for controller', ( + WidgetTester tester, + ) async { plugin.debugSetMapById({0: controller}); await plugin.setMapStyle(mapStyle, mapId: 0); @@ -196,8 +203,9 @@ void main() { expect((style.stylers[0]['color']! as JSString).toDart, '#6b9a76'); }); - testWidgets('throws MapStyleException for invalid styles', - (WidgetTester tester) async { + testWidgets('throws MapStyleException for invalid styles', ( + WidgetTester tester, + ) async { plugin.debugSetMapById({0: controller}); expect(() async { @@ -215,8 +223,9 @@ void main() { }); // Options testWidgets('updateMapConfiguration', (WidgetTester tester) async { - const MapConfiguration configuration = - MapConfiguration(mapType: MapType.satellite); + const MapConfiguration configuration = MapConfiguration( + mapType: MapType.satellite, + ); await plugin.updateMapConfiguration(configuration, mapId: mapId); @@ -276,11 +285,13 @@ void main() { // Tile Overlays testWidgets('updateTileOverlays', (WidgetTester tester) async { final Set expectedOverlays = { - const TileOverlay(tileOverlayId: TileOverlayId('overlay')) + const TileOverlay(tileOverlayId: TileOverlayId('overlay')), }; await plugin.updateTileOverlays( - newTileOverlays: expectedOverlays, mapId: mapId); + newTileOverlays: expectedOverlays, + mapId: mapId, + ); verify(controller.updateTileOverlays(expectedOverlays)); }); @@ -313,11 +324,12 @@ void main() { // Viewport testWidgets('getVisibleRegion', (WidgetTester tester) async { - when(controller.getVisibleRegion()) - .thenAnswer((_) async => LatLngBounds( - northeast: const LatLng(47.2359634, -68.0192019), - southwest: const LatLng(34.5019594, -120.4974629), - )); + when(controller.getVisibleRegion()).thenAnswer( + (_) async => LatLngBounds( + northeast: const LatLng(47.2359634, -68.0192019), + southwest: const LatLng(34.5019594, -120.4974629), + ), + ); await plugin.getVisibleRegion(mapId: mapId); verify(controller.getVisibleRegion()); @@ -332,8 +344,8 @@ void main() { testWidgets('getScreenCoordinate', (WidgetTester tester) async { when(controller.getScreenCoordinate(any)).thenAnswer( - (_) async => const ScreenCoordinate(x: 320, y: 240) // fake return - ); + (_) async => const ScreenCoordinate(x: 320, y: 240), // fake return + ); const LatLng latLng = LatLng(43.3613, -5.8499); @@ -344,8 +356,8 @@ void main() { testWidgets('getLatLng', (WidgetTester tester) async { when(controller.getLatLng(any)).thenAnswer( - (_) async => const LatLng(43.3613, -5.8499) // fake return - ); + (_) async => const LatLng(43.3613, -5.8499), // fake return + ); const ScreenCoordinate coordinates = ScreenCoordinate(x: 19, y: 26); @@ -388,14 +400,17 @@ void main() { late StreamController> streamController; setUp(() { streamController = StreamController>.broadcast(); - when(controller.events) - .thenAnswer((Invocation realInvocation) => streamController.stream); + when( + controller.events, + ).thenAnswer((Invocation realInvocation) => streamController.stream); plugin.debugSetMapById({mapId: controller}); }); // Dispatches a few events in the global streamController, and expects *only* the passed event to be there. Future testStreamFiltering( - Stream> stream, MapEvent event) async { + Stream> stream, + MapEvent event, + ) async { Timer.run(() { streamController.add(_OtherMapEvent(mapId)); streamController.add(event); @@ -413,29 +428,29 @@ void main() { testWidgets('onCameraMoveStarted', (WidgetTester tester) async { final CameraMoveStartedEvent event = CameraMoveStartedEvent(mapId); - final Stream stream = - plugin.onCameraMoveStarted(mapId: mapId); + final Stream stream = plugin + .onCameraMoveStarted(mapId: mapId); await testStreamFiltering(stream, event); }); testWidgets('onCameraMoveStarted', (WidgetTester tester) async { final CameraMoveEvent event = CameraMoveEvent( mapId, - const CameraPosition( - target: LatLng(43.3790, -5.8660), - ), + const CameraPosition(target: LatLng(43.3790, -5.8660)), ); - final Stream stream = - plugin.onCameraMove(mapId: mapId); + final Stream stream = plugin.onCameraMove( + mapId: mapId, + ); await testStreamFiltering(stream, event); }); testWidgets('onCameraIdle', (WidgetTester tester) async { final CameraIdleEvent event = CameraIdleEvent(mapId); - final Stream stream = - plugin.onCameraIdle(mapId: mapId); + final Stream stream = plugin.onCameraIdle( + mapId: mapId, + ); await testStreamFiltering(stream, event); }); @@ -456,8 +471,9 @@ void main() { const MarkerId('test-123'), ); - final Stream stream = - plugin.onInfoWindowTap(mapId: mapId); + final Stream stream = plugin.onInfoWindowTap( + mapId: mapId, + ); await testStreamFiltering(stream, event); }); @@ -468,8 +484,9 @@ void main() { const MarkerId('test-123'), ); - final Stream stream = - plugin.onMarkerDragStart(mapId: mapId); + final Stream stream = plugin.onMarkerDragStart( + mapId: mapId, + ); await testStreamFiltering(stream, event); }); @@ -480,8 +497,9 @@ void main() { const MarkerId('test-123'), ); - final Stream stream = - plugin.onMarkerDrag(mapId: mapId); + final Stream stream = plugin.onMarkerDrag( + mapId: mapId, + ); await testStreamFiltering(stream, event); }); @@ -492,8 +510,9 @@ void main() { const MarkerId('test-123'), ); - final Stream stream = - plugin.onMarkerDragEnd(mapId: mapId); + final Stream stream = plugin.onMarkerDragEnd( + mapId: mapId, + ); await testStreamFiltering(stream, event); }); @@ -504,8 +523,9 @@ void main() { const PolygonId('test-123'), ); - final Stream stream = - plugin.onPolygonTap(mapId: mapId); + final Stream stream = plugin.onPolygonTap( + mapId: mapId, + ); await testStreamFiltering(stream, event); }); @@ -515,8 +535,9 @@ void main() { const PolylineId('test-123'), ); - final Stream stream = - plugin.onPolylineTap(mapId: mapId); + final Stream stream = plugin.onPolylineTap( + mapId: mapId, + ); await testStreamFiltering(stream, event); }); @@ -547,8 +568,9 @@ void main() { const LatLng(43.3608, -5.8425), ); - final Stream stream = - plugin.onLongPress(mapId: mapId); + final Stream stream = plugin.onLongPress( + mapId: mapId, + ); await testStreamFiltering(stream, event); }); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.mocks.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.mocks.dart index 54825075821..0d38efbf4f8 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.mocks.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/google_maps_plugin_test.mocks.dart @@ -27,55 +27,30 @@ import 'package:mockito/mockito.dart' as _i1; class _FakeMapConfiguration_0 extends _i1.SmartFake implements _i2.MapConfiguration { - _FakeMapConfiguration_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakeMapConfiguration_0(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakeStreamController_1 extends _i1.SmartFake implements _i3.StreamController { - _FakeStreamController_1( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakeStreamController_1(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakeLatLngBounds_2 extends _i1.SmartFake implements _i2.LatLngBounds { - _FakeLatLngBounds_2( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakeLatLngBounds_2(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakeScreenCoordinate_3 extends _i1.SmartFake implements _i2.ScreenCoordinate { - _FakeScreenCoordinate_3( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakeScreenCoordinate_3(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } class _FakeLatLng_4 extends _i1.SmartFake implements _i2.LatLng { - _FakeLatLng_4( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakeLatLng_4(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } /// A class which mocks [GoogleMapController]. @@ -84,52 +59,63 @@ class _FakeLatLng_4 extends _i1.SmartFake implements _i2.LatLng { class MockGoogleMapController extends _i1.Mock implements _i4.GoogleMapController { @override - _i2.MapConfiguration get configuration => (super.noSuchMethod( - Invocation.getter(#configuration), - returnValue: _FakeMapConfiguration_0( - this, - Invocation.getter(#configuration), - ), - returnValueForMissingStub: _FakeMapConfiguration_0( - this, - Invocation.getter(#configuration), - ), - ) as _i2.MapConfiguration); + _i2.MapConfiguration get configuration => + (super.noSuchMethod( + Invocation.getter(#configuration), + returnValue: _FakeMapConfiguration_0( + this, + Invocation.getter(#configuration), + ), + returnValueForMissingStub: _FakeMapConfiguration_0( + this, + Invocation.getter(#configuration), + ), + ) + as _i2.MapConfiguration); @override - _i3.StreamController<_i2.MapEvent> get stream => (super.noSuchMethod( - Invocation.getter(#stream), - returnValue: _FakeStreamController_1<_i2.MapEvent>( - this, - Invocation.getter(#stream), - ), - returnValueForMissingStub: - _FakeStreamController_1<_i2.MapEvent>( - this, - Invocation.getter(#stream), - ), - ) as _i3.StreamController<_i2.MapEvent>); + _i3.StreamController<_i2.MapEvent> get stream => + (super.noSuchMethod( + Invocation.getter(#stream), + returnValue: _FakeStreamController_1<_i2.MapEvent>( + this, + Invocation.getter(#stream), + ), + returnValueForMissingStub: + _FakeStreamController_1<_i2.MapEvent>( + this, + Invocation.getter(#stream), + ), + ) + as _i3.StreamController<_i2.MapEvent>); @override - _i3.Stream<_i2.MapEvent> get events => (super.noSuchMethod( - Invocation.getter(#events), - returnValue: _i3.Stream<_i2.MapEvent>.empty(), - returnValueForMissingStub: _i3.Stream<_i2.MapEvent>.empty(), - ) as _i3.Stream<_i2.MapEvent>); + _i3.Stream<_i2.MapEvent> get events => + (super.noSuchMethod( + Invocation.getter(#events), + returnValue: _i3.Stream<_i2.MapEvent>.empty(), + returnValueForMissingStub: + _i3.Stream<_i2.MapEvent>.empty(), + ) + as _i3.Stream<_i2.MapEvent>); @override - bool get isInitialized => (super.noSuchMethod( - Invocation.getter(#isInitialized), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); + bool get isInitialized => + (super.noSuchMethod( + Invocation.getter(#isInitialized), + returnValue: false, + returnValueForMissingStub: false, + ) + as bool); @override - List<_i5.MapTypeStyle> get styles => (super.noSuchMethod( - Invocation.getter(#styles), - returnValue: <_i5.MapTypeStyle>[], - returnValueForMissingStub: <_i5.MapTypeStyle>[], - ) as List<_i5.MapTypeStyle>); + List<_i5.MapTypeStyle> get styles => + (super.noSuchMethod( + Invocation.getter(#styles), + returnValue: <_i5.MapTypeStyle>[], + returnValueForMissingStub: <_i5.MapTypeStyle>[], + ) + as List<_i5.MapTypeStyle>); @override void debugSetOverrides({ @@ -143,267 +129,200 @@ class MockGoogleMapController extends _i1.Mock _i6.ClusterManagersController? clusterManagers, _i4.TileOverlaysController? tileOverlays, _i4.GroundOverlaysController? groundOverlays, - }) => - super.noSuchMethod( - Invocation.method( - #debugSetOverrides, - [], - { - #createMap: createMap, - #setOptions: setOptions, - #markers: markers, - #circles: circles, - #heatmaps: heatmaps, - #polygons: polygons, - #polylines: polylines, - #clusterManagers: clusterManagers, - #tileOverlays: tileOverlays, - #groundOverlays: groundOverlays, - }, - ), - returnValueForMissingStub: null, - ); + }) => super.noSuchMethod( + Invocation.method(#debugSetOverrides, [], { + #createMap: createMap, + #setOptions: setOptions, + #markers: markers, + #circles: circles, + #heatmaps: heatmaps, + #polygons: polygons, + #polylines: polylines, + #clusterManagers: clusterManagers, + #tileOverlays: tileOverlays, + #groundOverlays: groundOverlays, + }), + returnValueForMissingStub: null, + ); @override void init() => super.noSuchMethod( - Invocation.method( - #init, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#init, []), + returnValueForMissingStub: null, + ); @override void updateMapConfiguration(_i2.MapConfiguration? update) => super.noSuchMethod( - Invocation.method( - #updateMapConfiguration, - [update], - ), + Invocation.method(#updateMapConfiguration, [update]), returnValueForMissingStub: null, ); @override void updateStyles(List<_i5.MapTypeStyle>? styles) => super.noSuchMethod( - Invocation.method( - #updateStyles, - [styles], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#updateStyles, [styles]), + returnValueForMissingStub: null, + ); @override - _i3.Future<_i2.LatLngBounds> getVisibleRegion() => (super.noSuchMethod( - Invocation.method( - #getVisibleRegion, - [], - ), - returnValue: _i3.Future<_i2.LatLngBounds>.value(_FakeLatLngBounds_2( - this, - Invocation.method( - #getVisibleRegion, - [], - ), - )), - returnValueForMissingStub: - _i3.Future<_i2.LatLngBounds>.value(_FakeLatLngBounds_2( - this, - Invocation.method( - #getVisibleRegion, - [], - ), - )), - ) as _i3.Future<_i2.LatLngBounds>); + _i3.Future<_i2.LatLngBounds> getVisibleRegion() => + (super.noSuchMethod( + Invocation.method(#getVisibleRegion, []), + returnValue: _i3.Future<_i2.LatLngBounds>.value( + _FakeLatLngBounds_2( + this, + Invocation.method(#getVisibleRegion, []), + ), + ), + returnValueForMissingStub: _i3.Future<_i2.LatLngBounds>.value( + _FakeLatLngBounds_2( + this, + Invocation.method(#getVisibleRegion, []), + ), + ), + ) + as _i3.Future<_i2.LatLngBounds>); @override _i3.Future<_i2.ScreenCoordinate> getScreenCoordinate(_i2.LatLng? latLng) => (super.noSuchMethod( - Invocation.method( - #getScreenCoordinate, - [latLng], - ), - returnValue: - _i3.Future<_i2.ScreenCoordinate>.value(_FakeScreenCoordinate_3( - this, - Invocation.method( - #getScreenCoordinate, - [latLng], - ), - )), - returnValueForMissingStub: - _i3.Future<_i2.ScreenCoordinate>.value(_FakeScreenCoordinate_3( - this, - Invocation.method( - #getScreenCoordinate, - [latLng], - ), - )), - ) as _i3.Future<_i2.ScreenCoordinate>); + Invocation.method(#getScreenCoordinate, [latLng]), + returnValue: _i3.Future<_i2.ScreenCoordinate>.value( + _FakeScreenCoordinate_3( + this, + Invocation.method(#getScreenCoordinate, [latLng]), + ), + ), + returnValueForMissingStub: _i3.Future<_i2.ScreenCoordinate>.value( + _FakeScreenCoordinate_3( + this, + Invocation.method(#getScreenCoordinate, [latLng]), + ), + ), + ) + as _i3.Future<_i2.ScreenCoordinate>); @override _i3.Future<_i2.LatLng> getLatLng(_i2.ScreenCoordinate? screenCoordinate) => (super.noSuchMethod( - Invocation.method( - #getLatLng, - [screenCoordinate], - ), - returnValue: _i3.Future<_i2.LatLng>.value(_FakeLatLng_4( - this, - Invocation.method( - #getLatLng, - [screenCoordinate], - ), - )), - returnValueForMissingStub: _i3.Future<_i2.LatLng>.value(_FakeLatLng_4( - this, - Invocation.method( - #getLatLng, - [screenCoordinate], - ), - )), - ) as _i3.Future<_i2.LatLng>); + Invocation.method(#getLatLng, [screenCoordinate]), + returnValue: _i3.Future<_i2.LatLng>.value( + _FakeLatLng_4( + this, + Invocation.method(#getLatLng, [screenCoordinate]), + ), + ), + returnValueForMissingStub: _i3.Future<_i2.LatLng>.value( + _FakeLatLng_4( + this, + Invocation.method(#getLatLng, [screenCoordinate]), + ), + ), + ) + as _i3.Future<_i2.LatLng>); @override _i3.Future moveCamera(_i2.CameraUpdate? cameraUpdate) => (super.noSuchMethod( - Invocation.method( - #moveCamera, - [cameraUpdate], - ), - returnValue: _i3.Future.value(), - returnValueForMissingStub: _i3.Future.value(), - ) as _i3.Future); + Invocation.method(#moveCamera, [cameraUpdate]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); @override - _i3.Future getZoomLevel() => (super.noSuchMethod( - Invocation.method( - #getZoomLevel, - [], - ), - returnValue: _i3.Future.value(0.0), - returnValueForMissingStub: _i3.Future.value(0.0), - ) as _i3.Future); + _i3.Future getZoomLevel() => + (super.noSuchMethod( + Invocation.method(#getZoomLevel, []), + returnValue: _i3.Future.value(0.0), + returnValueForMissingStub: _i3.Future.value(0.0), + ) + as _i3.Future); @override void updateCircles(_i2.CircleUpdates? updates) => super.noSuchMethod( - Invocation.method( - #updateCircles, - [updates], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#updateCircles, [updates]), + returnValueForMissingStub: null, + ); @override void updateHeatmaps(_i2.HeatmapUpdates? updates) => super.noSuchMethod( - Invocation.method( - #updateHeatmaps, - [updates], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#updateHeatmaps, [updates]), + returnValueForMissingStub: null, + ); @override void updatePolygons(_i2.PolygonUpdates? updates) => super.noSuchMethod( - Invocation.method( - #updatePolygons, - [updates], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#updatePolygons, [updates]), + returnValueForMissingStub: null, + ); @override void updatePolylines(_i2.PolylineUpdates? updates) => super.noSuchMethod( - Invocation.method( - #updatePolylines, - [updates], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#updatePolylines, [updates]), + returnValueForMissingStub: null, + ); @override _i3.Future updateMarkers(_i2.MarkerUpdates? updates) => (super.noSuchMethod( - Invocation.method( - #updateMarkers, - [updates], - ), - returnValue: _i3.Future.value(), - returnValueForMissingStub: _i3.Future.value(), - ) as _i3.Future); + Invocation.method(#updateMarkers, [updates]), + returnValue: _i3.Future.value(), + returnValueForMissingStub: _i3.Future.value(), + ) + as _i3.Future); @override void updateClusterManagers(_i2.ClusterManagerUpdates? updates) => super.noSuchMethod( - Invocation.method( - #updateClusterManagers, - [updates], - ), + Invocation.method(#updateClusterManagers, [updates]), returnValueForMissingStub: null, ); @override void updateGroundOverlays(_i2.GroundOverlayUpdates? updates) => super.noSuchMethod( - Invocation.method( - #updateGroundOverlays, - [updates], - ), + Invocation.method(#updateGroundOverlays, [updates]), returnValueForMissingStub: null, ); @override void updateTileOverlays(Set<_i2.TileOverlay>? newOverlays) => super.noSuchMethod( - Invocation.method( - #updateTileOverlays, - [newOverlays], - ), + Invocation.method(#updateTileOverlays, [newOverlays]), returnValueForMissingStub: null, ); @override void clearTileCache(_i2.TileOverlayId? id) => super.noSuchMethod( - Invocation.method( - #clearTileCache, - [id], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#clearTileCache, [id]), + returnValueForMissingStub: null, + ); @override void showInfoWindow(_i2.MarkerId? markerId) => super.noSuchMethod( - Invocation.method( - #showInfoWindow, - [markerId], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#showInfoWindow, [markerId]), + returnValueForMissingStub: null, + ); @override void hideInfoWindow(_i2.MarkerId? markerId) => super.noSuchMethod( - Invocation.method( - #hideInfoWindow, - [markerId], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#hideInfoWindow, [markerId]), + returnValueForMissingStub: null, + ); @override - bool isInfoWindowShown(_i2.MarkerId? markerId) => (super.noSuchMethod( - Invocation.method( - #isInfoWindowShown, - [markerId], - ), - returnValue: false, - returnValueForMissingStub: false, - ) as bool); + bool isInfoWindowShown(_i2.MarkerId? markerId) => + (super.noSuchMethod( + Invocation.method(#isInfoWindowShown, [markerId]), + returnValue: false, + returnValueForMissingStub: false, + ) + as bool); @override void dispose() => super.noSuchMethod( - Invocation.method( - #dispose, - [], - ), - returnValueForMissingStub: null, - ); + Invocation.method(#dispose, []), + returnValueForMissingStub: null, + ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_clustering_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_clustering_test.dart index fbdcbf94946..4bcf6c5e276 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_clustering_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_clustering_test.dart @@ -20,8 +20,9 @@ void main() { GoogleMapsInspectorPlatform.instance!; const LatLng mapCenter = LatLng(20, 20); - const CameraPosition initialCameraPosition = - CameraPosition(target: mapCenter); + const CameraPosition initialCameraPosition = CameraPosition( + target: mapCenter, + ); group('MarkersController', () { const int testMapId = 33930; @@ -36,27 +37,34 @@ void main() { // Create the marker with clusterManagerId. final Set initialMarkers = { const Marker( - markerId: MarkerId('1'), - position: mapCenter, - clusterManagerId: clusterManagerId), + markerId: MarkerId('1'), + position: mapCenter, + clusterManagerId: clusterManagerId, + ), const Marker( - markerId: MarkerId('2'), - position: mapCenter, - clusterManagerId: clusterManagerId), + markerId: MarkerId('2'), + position: mapCenter, + clusterManagerId: clusterManagerId, + ), }; final Completer mapIdCompleter = Completer(); await _pumpMap( - tester, - plugin.buildViewWithConfiguration( - testMapId, (int id) => mapIdCompleter.complete(id), - widgetConfiguration: const MapWidgetConfiguration( - initialCameraPosition: initialCameraPosition, - textDirection: TextDirection.ltr, - ), - mapObjects: MapObjects( - clusterManagers: clusterManagers, markers: initialMarkers))); + tester, + plugin.buildViewWithConfiguration( + testMapId, + (int id) => mapIdCompleter.complete(id), + widgetConfiguration: const MapWidgetConfiguration( + initialCameraPosition: initialCameraPosition, + textDirection: TextDirection.ltr, + ), + mapObjects: MapObjects( + clusterManagers: clusterManagers, + markers: initialMarkers, + ), + ), + ); final int mapId = await mapIdCompleter.future; expect(mapId, equals(testMapId)); @@ -65,11 +73,14 @@ void main() { final List clusters = await waitForValueMatchingPredicate>( - tester, - () async => inspector.getClusters( - mapId: mapId, clusterManagerId: clusterManagerId), - (List clusters) => clusters.isNotEmpty) ?? - []; + tester, + () async => inspector.getClusters( + mapId: mapId, + clusterManagerId: clusterManagerId, + ), + (List clusters) => clusters.isNotEmpty, + ) ?? + []; expect(clusters.length, 1); expect(clusters[0].markerIds.length, 2); @@ -77,20 +88,25 @@ void main() { // Copy only the first marker with null clusterManagerId. // This means that both markers should be removed from the cluster. final Set updatedMarkers = { - _copyMarkerWithClusterManagerId(initialMarkers.first, null) + _copyMarkerWithClusterManagerId(initialMarkers.first, null), }; - final MarkerUpdates markerUpdates = - MarkerUpdates.from(initialMarkers, updatedMarkers); + final MarkerUpdates markerUpdates = MarkerUpdates.from( + initialMarkers, + updatedMarkers, + ); await plugin.updateMarkers(markerUpdates, mapId: mapId); final List updatedClusters = await waitForValueMatchingPredicate>( - tester, - () async => inspector.getClusters( - mapId: mapId, clusterManagerId: clusterManagerId), - (List clusters) => clusters.isNotEmpty) ?? - []; + tester, + () async => inspector.getClusters( + mapId: mapId, + clusterManagerId: clusterManagerId, + ), + (List clusters) => clusters.isNotEmpty, + ) ?? + []; expect(updatedClusters.length, 0); }); @@ -106,9 +122,12 @@ void main() { // This is useful for cases where the Maps SDK has some internally // asynchronous operation that we don't have visibility into (e.g., native UI // animations). -Future waitForValueMatchingPredicate(WidgetTester tester, - Future Function() getValue, bool Function(T) predicate, - {int maxTries = 100}) async { +Future waitForValueMatchingPredicate( + WidgetTester tester, + Future Function() getValue, + bool Function(T) predicate, { + int maxTries = 100, +}) async { for (int i = 0; i < maxTries; i++) { final T value = await getValue(); if (predicate(value)) { @@ -120,7 +139,9 @@ Future waitForValueMatchingPredicate(WidgetTester tester, } Marker _copyMarkerWithClusterManagerId( - Marker marker, ClusterManagerId? clusterManagerId) { + Marker marker, + ClusterManagerId? clusterManagerId, +) { return Marker( markerId: marker.markerId, alpha: marker.alpha, @@ -144,8 +165,11 @@ Marker _copyMarkerWithClusterManagerId( } /// Pumps a [map] widget in [tester] of a certain [size], then waits until it settles. -Future _pumpMap(WidgetTester tester, Widget map, - [Size size = const Size.square(200)]) async { +Future _pumpMap( + WidgetTester tester, + Widget map, [ + Size size = const Size.square(200), +]) async { await tester.pumpWidget(_wrapMap(map, size)); await tester.pumpAndSettle(); } @@ -156,12 +180,7 @@ Future _pumpMap(WidgetTester tester, Widget map, Widget _wrapMap(Widget map, [Size size = const Size.square(200)]) { return MaterialApp( home: Scaffold( - body: Center( - child: SizedBox.fromSize( - size: size, - child: map, - ), - ), + body: Center(child: SizedBox.fromSize(size: size, child: map)), ), ); } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart index 2859d082b78..0295a0e3310 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/marker_test.dart @@ -56,11 +56,7 @@ void main() { MarkerController(marker: marker, onTap: onTap); // Trigger a click event... - gmaps.event.trigger( - marker, - 'click', - gmaps.MapMouseEvent(), - ); + gmaps.event.trigger(marker, 'click', gmaps.MapMouseEvent()); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); @@ -107,9 +103,10 @@ void main() { testWidgets('update', (WidgetTester tester) async { final MarkerController controller = MarkerController(marker: marker); - final gmaps.MarkerOptions options = gmaps.MarkerOptions() - ..draggable = true - ..position = gmaps.LatLng(42, 54); + final gmaps.MarkerOptions options = + gmaps.MarkerOptions() + ..draggable = true + ..position = gmaps.LatLng(42, 54); expect(marker.isDraggableDefined(), isFalse); @@ -120,8 +117,9 @@ void main() { expect(marker.position?.lng, equals(54)); }); - testWidgets('infoWindow null, showInfoWindow.', - (WidgetTester tester) async { + testWidgets('infoWindow null, showInfoWindow.', ( + WidgetTester tester, + ) async { final MarkerController controller = MarkerController(marker: marker); controller.showInfoWindow(); @@ -175,10 +173,11 @@ void main() { expect(controller.marker, isNull); }); - testWidgets('cannot call update after remove', - (WidgetTester tester) async { - final gmaps.MarkerOptions options = gmaps.MarkerOptions() - ..draggable = true; + testWidgets('cannot call update after remove', ( + WidgetTester tester, + ) async { + final gmaps.MarkerOptions options = + gmaps.MarkerOptions()..draggable = true; controller.remove(); @@ -187,8 +186,9 @@ void main() { }, throwsAssertionError); }); - testWidgets('cannot call showInfoWindow after remove', - (WidgetTester tester) async { + testWidgets('cannot call showInfoWindow after remove', ( + WidgetTester tester, + ) async { controller.remove(); expect(() { @@ -196,8 +196,9 @@ void main() { }, throwsAssertionError); }); - testWidgets('cannot call hideInfoWindow after remove', - (WidgetTester tester) async { + testWidgets('cannot call hideInfoWindow after remove', ( + WidgetTester tester, + ) async { controller.remove(); expect(() { diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart index 39e28509de7..2c8c8013a01 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/markers_test.dart @@ -34,7 +34,9 @@ void main() { clusterManagersController = ClusterManagersController(stream: events); controller = MarkersController( - stream: events, clusterManagersController: clusterManagersController); + stream: events, + clusterManagersController: clusterManagersController, + ); map = gmaps.Map(createDivElement()); clusterManagersController.bindToMap(123, map); controller.bindToMap(123, map); @@ -95,47 +97,42 @@ void main() { }); testWidgets( - 'changeMarkers resets marker position if not passed when updating!', - (WidgetTester tester) async { - gmaps.Marker? marker; - gmaps.LatLng? position; - - final Set markers = { - const Marker( - markerId: MarkerId('1'), - position: LatLng(42, 54), - ), - }; - await controller.addMarkers(markers); - - marker = controller.markers[const MarkerId('1')]?.marker; - expect(marker, isNotNull); - expect(marker!.draggable, isFalse); - - position = marker.position; - expect(position, isNotNull); - expect(position!.lat, equals(42)); - expect(position.lng, equals(54)); - - // Update the marker without position - final Set updatedMarkers = { - const Marker( - markerId: MarkerId('1'), - draggable: true, - ), - }; - await controller.changeMarkers(updatedMarkers); - expect(controller.markers.length, 1); - - marker = controller.markers[const MarkerId('1')]?.marker; - expect(marker, isNotNull); - expect(marker!.draggable, isTrue); - - position = marker.position; - expect(position, isNotNull); - expect(position!.lat, equals(0)); - expect(position.lng, equals(0)); - }); + 'changeMarkers resets marker position if not passed when updating!', + (WidgetTester tester) async { + gmaps.Marker? marker; + gmaps.LatLng? position; + + final Set markers = { + const Marker(markerId: MarkerId('1'), position: LatLng(42, 54)), + }; + await controller.addMarkers(markers); + + marker = controller.markers[const MarkerId('1')]?.marker; + expect(marker, isNotNull); + expect(marker!.draggable, isFalse); + + position = marker.position; + expect(position, isNotNull); + expect(position!.lat, equals(42)); + expect(position.lng, equals(54)); + + // Update the marker without position + final Set updatedMarkers = { + const Marker(markerId: MarkerId('1'), draggable: true), + }; + await controller.changeMarkers(updatedMarkers); + expect(controller.markers.length, 1); + + marker = controller.markers[const MarkerId('1')]?.marker; + expect(marker, isNotNull); + expect(marker!.draggable, isTrue); + + position = marker.position; + expect(position, isNotNull); + expect(position!.lat, equals(0)); + expect(position.lng, equals(0)); + }, + ); testWidgets('removeMarkers', (WidgetTester tester) async { final Set markers = { @@ -184,8 +181,9 @@ void main() { }); // https://github.com/flutter/flutter/issues/67380 - testWidgets('only single InfoWindow is visible', - (WidgetTester tester) async { + testWidgets('only single InfoWindow is visible', ( + WidgetTester tester, + ) async { final Set markers = { const Marker( markerId: MarkerId('1'), @@ -212,15 +210,14 @@ void main() { expect(controller.markers[const MarkerId('2')]?.infoWindowShown, isTrue); }); - testWidgets('markers with custom asset icon work', - (WidgetTester tester) async { + testWidgets('markers with custom asset icon work', ( + WidgetTester tester, + ) async { final Set markers = { Marker( - markerId: const MarkerId('1'), - icon: AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 1.0, - )), + markerId: const MarkerId('1'), + icon: AssetMapBitmap('assets/red_square.png', imagePixelRatio: 1.0), + ), }; await controller.addMarkers(markers); @@ -243,15 +240,14 @@ void main() { expect(scaledSize.height, 48); }); - testWidgets('markers with custom asset icon and pixelratio work', - (WidgetTester tester) async { + testWidgets('markers with custom asset icon and pixelratio work', ( + WidgetTester tester, + ) async { final Set markers = { Marker( - markerId: const MarkerId('1'), - icon: AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 2.0, - )), + markerId: const MarkerId('1'), + icon: AssetMapBitmap('assets/red_square.png', imagePixelRatio: 2.0), + ), }; await controller.addMarkers(markers); @@ -274,17 +270,19 @@ void main() { expect(scaledSize.width, 24); expect(scaledSize.height, 24); }); - testWidgets('markers with custom asset icon with width and height work', - (WidgetTester tester) async { + testWidgets('markers with custom asset icon with width and height work', ( + WidgetTester tester, + ) async { final Set markers = { Marker( - markerId: const MarkerId('1'), - icon: AssetMapBitmap( - 'assets/red_square.png', - imagePixelRatio: 2.0, - width: 64, - height: 64, - )), + markerId: const MarkerId('1'), + icon: AssetMapBitmap( + 'assets/red_square.png', + imagePixelRatio: 2.0, + width: 64, + height: 64, + ), + ), }; await controller.addMarkers(markers); @@ -308,15 +306,17 @@ void main() { expect(scaledSize.height, 64); }); - testWidgets('markers with missing asset icon should not set size', - (WidgetTester tester) async { + testWidgets('markers with missing asset icon should not set size', ( + WidgetTester tester, + ) async { final Set markers = { Marker( - markerId: const MarkerId('1'), - icon: AssetMapBitmap( - 'assets/broken_asset_name.png', - imagePixelRatio: 2.0, - )), + markerId: const MarkerId('1'), + icon: AssetMapBitmap( + 'assets/broken_asset_name.png', + imagePixelRatio: 2.0, + ), + ), }; await controller.addMarkers(markers); @@ -335,8 +335,9 @@ void main() { }); // https://github.com/flutter/flutter/issues/66622 - testWidgets('markers with custom bitmap icon work', - (WidgetTester tester) async { + testWidgets('markers with custom bitmap icon work', ( + WidgetTester tester, + ) async { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); final Set markers = { Marker( @@ -359,9 +360,12 @@ void main() { expect(blobUrl, startsWith('blob:')); final http.Response response = await http.get(Uri.parse(blobUrl)); - expect(response.bodyBytes, bytes, - reason: - 'Bytes from the Icon blob must match bytes used to create Marker'); + expect( + response.bodyBytes, + bytes, + reason: + 'Bytes from the Icon blob must match bytes used to create Marker', + ); final gmaps.Size size = icon.size!; final gmaps.Size scaledSize = icon.scaledSize!; @@ -376,16 +380,14 @@ void main() { expect(scaledSize.height, expectedSize); }); - testWidgets('markers with custom bitmap icon and pixelratio work', - (WidgetTester tester) async { + testWidgets('markers with custom bitmap icon and pixelratio work', ( + WidgetTester tester, + ) async { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); final Set markers = { Marker( markerId: const MarkerId('1'), - icon: BytesMapBitmap( - bytes, - imagePixelRatio: 1, - ), + icon: BytesMapBitmap(bytes, imagePixelRatio: 1), ), }; @@ -409,17 +411,14 @@ void main() { }); // https://github.com/flutter/flutter/issues/73789 - testWidgets('markers with custom bitmap icon pass size to sdk', - (WidgetTester tester) async { + testWidgets('markers with custom bitmap icon pass size to sdk', ( + WidgetTester tester, + ) async { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); final Set markers = { Marker( markerId: const MarkerId('1'), - icon: BytesMapBitmap( - bytes, - width: 20, - height: 30, - ), + icon: BytesMapBitmap(bytes, width: 20, height: 30), ), }; @@ -440,8 +439,9 @@ void main() { }); // https://github.com/flutter/flutter/issues/67854 - testWidgets('InfoWindow snippet can have links', - (WidgetTester tester) async { + testWidgets('InfoWindow snippet can have links', ( + WidgetTester tester, + ) async { final Set markers = { const Marker( markerId: MarkerId('1'), @@ -455,17 +455,19 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final HTMLElement? content = controller - .markers[const MarkerId('1')]?.infoWindow?.content as HTMLElement?; + final HTMLElement? content = + controller.markers[const MarkerId('1')]?.infoWindow?.content + as HTMLElement?; expect(content, isNotNull); final String innerHtml = (content!.innerHTML as JSString).toDart; expect(innerHtml, contains('title for test')); expect( - innerHtml, - contains( - 'Go to Google >>>', - )); + innerHtml, + contains( + 'Go to Google >>>', + ), + ); }); // https://github.com/flutter/flutter/issues/67289 @@ -483,8 +485,9 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final HTMLElement? content = controller - .markers[const MarkerId('1')]?.infoWindow?.content as HTMLElement?; + final HTMLElement? content = + controller.markers[const MarkerId('1')]?.infoWindow?.content + as HTMLElement?; content?.click(); @@ -502,19 +505,11 @@ void main() { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); final Marker marker1 = Marker( markerId: const MarkerId('1'), - icon: BytesMapBitmap( - bytes, - width: width, - height: height, - ), + icon: BytesMapBitmap(bytes, width: width, height: height), ); final Marker marker2 = Marker( markerId: const MarkerId('2'), - icon: BytesMapBitmap( - bytes, - width: width, - height: height, - ), + icon: BytesMapBitmap(bytes, width: width, height: height), anchor: anchorOffset, ); final Set markers = {marker1, marker2}; @@ -537,8 +532,9 @@ void main() { expect(icon2.anchor!.y, height * anchorOffset.dy); }); - testWidgets('interpret correct zIndex in convertsion', - (WidgetTester tester) async { + testWidgets('interpret correct zIndex in convertsion', ( + WidgetTester tester, + ) async { const MarkerId markerId = MarkerId('1'); final Set markers = { diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart index 8d192e18306..2cb0668d41b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlay_test.dart @@ -58,8 +58,9 @@ void main() { ), ); - final HTMLImageElement img = controller.gmMapType - .getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; + final HTMLImageElement img = + controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! + as HTMLImageElement; expect(img.naturalWidth, 0); expect(img.naturalHeight, 0); expect((img.hidden! as JSBoolean).toDart, true); @@ -81,8 +82,9 @@ void main() { ), ); { - final HTMLImageElement img = controller.gmMapType - .getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; + final HTMLImageElement img = + controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! + as HTMLImageElement; await null; // let `getTile` `then` complete expect( img.src, @@ -91,13 +93,13 @@ void main() { ); } - controller.update(const TileOverlay( - tileOverlayId: id, - tileProvider: TestTileProvider(), - )); + controller.update( + const TileOverlay(tileOverlayId: id, tileProvider: TestTileProvider()), + ); { - final HTMLImageElement img = controller.gmMapType - .getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; + final HTMLImageElement img = + controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! + as HTMLImageElement; await img.onLoad.first; diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart index 1b5b8af5f02..c5d47dacf12 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.dart @@ -23,8 +23,9 @@ import 'overlays_test.mocks.dart'; MockTileProvider neverTileProvider() { final MockTileProvider tileProvider = MockTileProvider(); - when(tileProvider.getTile(any, any, any)) - .thenAnswer((_) => Completer().future); + when( + tileProvider.getTile(any, any, any), + ).thenAnswer((_) => Completer().future); return tileProvider; } @@ -51,15 +52,16 @@ void main() { controller.googleMap = map; tileProviders = [ - for (int i = 0; i < 3; ++i) neverTileProvider() + for (int i = 0; i < 3; ++i) neverTileProvider(), ]; tileOverlays = [ for (int i = 0; i < 3; ++i) TileOverlay( - tileOverlayId: TileOverlayId('$i'), - tileProvider: tileProviders[i], - zIndex: i) + tileOverlayId: TileOverlayId('$i'), + tileProvider: tileProviders[i], + zIndex: i, + ), ]; }); @@ -97,8 +99,9 @@ void main() { verifyNoMoreInteractions(tileProviders[2]); // Re-enable overlay 0. - controller.changeTileOverlays( - {tileOverlays[0].copyWith(visibleParam: true)}); + controller.changeTileOverlays({ + tileOverlays[0].copyWith(visibleParam: true), + }); probeTiles(); @@ -113,17 +116,18 @@ void main() { }); testWidgets( - 'updating the z index of a hidden layer does not make it visible', - (WidgetTester tester) async { - controller.addTileOverlays({...tileOverlays}); + 'updating the z index of a hidden layer does not make it visible', + (WidgetTester tester) async { + controller.addTileOverlays({...tileOverlays}); - controller.changeTileOverlays({ - tileOverlays[0].copyWith(zIndexParam: -1, visibleParam: false), - }); + controller.changeTileOverlays({ + tileOverlays[0].copyWith(zIndexParam: -1, visibleParam: false), + }); - probeTiles(); - verifyZeroInteractions(tileProviders[0]); - }); + probeTiles(); + verifyZeroInteractions(tileProviders[0]); + }, + ); testWidgets('removeTileOverlays', (WidgetTester tester) async { controller.addTileOverlays({...tileOverlays}); @@ -143,19 +147,23 @@ void main() { testWidgets('clearTileCache', (WidgetTester tester) async { final Completer controllerCompleter = Completer(); - await tester.pumpWidget(MaterialApp( + await tester.pumpWidget( + MaterialApp( home: Scaffold( - body: GoogleMap( - initialCameraPosition: const CameraPosition( - target: LatLng(43.3078, -5.6958), - zoom: 14, + body: GoogleMap( + initialCameraPosition: const CameraPosition( + target: LatLng(43.3078, -5.6958), + zoom: 14, + ), + tileOverlays: {...tileOverlays.take(2)}, + onMapCreated: (GoogleMapController value) { + controllerCompleter.complete(value); + addTearDown(() => value.dispose()); + }, + ), + ), ), - tileOverlays: {...tileOverlays.take(2)}, - onMapCreated: (GoogleMapController value) { - controllerCompleter.complete(value); - addTearDown(() => value.dispose()); - }, - )))); + ); // This is needed to kick-off the rendering of the JS Map flutter widget await tester.pump(); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.mocks.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.mocks.dart index 0480e644fe1..8a13b88eb10 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.mocks.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/overlays_test.mocks.dart @@ -23,13 +23,8 @@ import 'package:mockito/mockito.dart' as _i1; // ignore_for_file: subtype_of_sealed_class class _FakeTile_0 extends _i1.SmartFake implements _i2.Tile { - _FakeTile_0( - Object parent, - Invocation parentInvocation, - ) : super( - parent, - parentInvocation, - ); + _FakeTile_0(Object parent, Invocation parentInvocation) + : super(parent, parentInvocation); } /// A class which mocks [TileProvider]. @@ -37,41 +32,15 @@ class _FakeTile_0 extends _i1.SmartFake implements _i2.Tile { /// See the documentation for Mockito's code generation for more information. class MockTileProvider extends _i1.Mock implements _i2.TileProvider { @override - _i3.Future<_i2.Tile> getTile( - int? x, - int? y, - int? zoom, - ) => + _i3.Future<_i2.Tile> getTile(int? x, int? y, int? zoom) => (super.noSuchMethod( - Invocation.method( - #getTile, - [ - x, - y, - zoom, - ], - ), - returnValue: _i3.Future<_i2.Tile>.value(_FakeTile_0( - this, - Invocation.method( - #getTile, - [ - x, - y, - zoom, - ], - ), - )), - returnValueForMissingStub: _i3.Future<_i2.Tile>.value(_FakeTile_0( - this, - Invocation.method( - #getTile, - [ - x, - y, - zoom, - ], - ), - )), - ) as _i3.Future<_i2.Tile>); + Invocation.method(#getTile, [x, y, zoom]), + returnValue: _i3.Future<_i2.Tile>.value( + _FakeTile_0(this, Invocation.method(#getTile, [x, y, zoom])), + ), + returnValueForMissingStub: _i3.Future<_i2.Tile>.value( + _FakeTile_0(this, Invocation.method(#getTile, [x, y, zoom])), + ), + ) + as _i3.Future<_i2.Tile>); } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/projection_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/projection_test.dart index c5d2ff7aba2..f59441a4d6b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/projection_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/projection_test.dart @@ -46,43 +46,47 @@ void main() { }); group('moveCamera', () { - testWidgets('center can be moved with newLatLngZoom', - (WidgetTester tester) async { - await pumpCenteredMap( - tester, - initialCamera: initialCamera, - size: size, - onMapCreated: onMapCreated, - ); + testWidgets( + 'center can be moved with newLatLngZoom', + (WidgetTester tester) async { + await pumpCenteredMap( + tester, + initialCamera: initialCamera, + size: size, + onMapCreated: onMapCreated, + ); - final GoogleMapController controller = await controllerCompleter.future; + final GoogleMapController controller = + await controllerCompleter.future; - await controller.moveCamera( - CameraUpdate.newLatLngZoom( - const LatLng(19, 26), - 12, - ), - ); + await controller.moveCamera( + CameraUpdate.newLatLngZoom(const LatLng(19, 26), 12), + ); - final LatLng coords = await controller.getLatLng( - ScreenCoordinate(x: size.width ~/ 2, y: size.height ~/ 2), - ); + final LatLng coords = await controller.getLatLng( + ScreenCoordinate(x: size.width ~/ 2, y: size.height ~/ 2), + ); - expect(await controller.getZoomLevel(), 12); - expect(coords.latitude, closeTo(19, _acceptableLatLngDelta)); - expect(coords.longitude, closeTo(26, _acceptableLatLngDelta)); - }, - // TODO(bparrishMines): This is failing due to an error being thrown after - // completion. See https://github.com/flutter/flutter/issues/145149 - skip: true); + expect(await controller.getZoomLevel(), 12); + expect(coords.latitude, closeTo(19, _acceptableLatLngDelta)); + expect(coords.longitude, closeTo(26, _acceptableLatLngDelta)); + }, + // TODO(bparrishMines): This is failing due to an error being thrown after + // completion. See https://github.com/flutter/flutter/issues/145149 + skip: true, + ); testWidgets('addPadding', (WidgetTester tester) async { const LatLng initialMapCenter = LatLng(0, 0); const double initialZoomLevel = 5; - const CameraPosition initialCameraPosition = - CameraPosition(target: initialMapCenter, zoom: initialZoomLevel); + const CameraPosition initialCameraPosition = CameraPosition( + target: initialMapCenter, + zoom: initialZoomLevel, + ); final LatLngBounds zeroLatLngBounds = LatLngBounds( - southwest: const LatLng(0, 0), northeast: const LatLng(0, 0)); + southwest: const LatLng(0, 0), + northeast: const LatLng(0, 0), + ); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -107,7 +111,8 @@ void main() { const double padding = 0.1; await controller.moveCamera( - CameraUpdate.newLatLngBounds(firstVisibleRegion, padding)); + CameraUpdate.newLatLngBounds(firstVisibleRegion, padding), + ); await tester.pumpAndSettle(const Duration(seconds: 3)); final LatLngBounds secondVisibleRegion = @@ -115,10 +120,7 @@ void main() { expect(secondVisibleRegion, isNotNull); expect(secondVisibleRegion, isNot(zeroLatLngBounds)); - expect( - secondVisibleRegion, - isNot(firstVisibleRegion), - ); + expect(secondVisibleRegion, isNot(firstVisibleRegion)); expect(secondVisibleRegion.contains(initialMapCenter), isTrue); expect( secondVisibleRegion.contains(firstVisibleRegion.northeast), @@ -132,8 +134,9 @@ void main() { }); group('getScreenCoordinate', () { - testWidgets('target of map is in center of widget', - (WidgetTester tester) async { + testWidgets('target of map is in center of widget', ( + WidgetTester tester, + ) async { await pumpCenteredMap( tester, initialCamera: initialCamera, @@ -143,8 +146,8 @@ void main() { final GoogleMapController controller = await controllerCompleter.future; - final ScreenCoordinate screenPosition = - await controller.getScreenCoordinate(center); + final ScreenCoordinate screenPosition = await controller + .getScreenCoordinate(center); expect( screenPosition.x, @@ -156,8 +159,9 @@ void main() { ); }); - testWidgets('NorthWest of visible region corresponds to x:0, y:0', - (WidgetTester tester) async { + testWidgets('NorthWest of visible region corresponds to x:0, y:0', ( + WidgetTester tester, + ) async { await pumpCenteredMap( tester, initialCamera: initialCamera, @@ -172,41 +176,44 @@ void main() { bounds.southwest.longitude, ); - final ScreenCoordinate screenPosition = - await controller.getScreenCoordinate(northWest); + final ScreenCoordinate screenPosition = await controller + .getScreenCoordinate(northWest); expect(screenPosition.x, closeTo(0, _acceptablePixelDelta)); expect(screenPosition.y, closeTo(0, _acceptablePixelDelta)); }); testWidgets( - 'SouthEast of visible region corresponds to x:size.width, y:size.height', - (WidgetTester tester) async { - await pumpCenteredMap( - tester, - initialCamera: initialCamera, - size: size, - onMapCreated: onMapCreated, - ); - final GoogleMapController controller = await controllerCompleter.future; - - final LatLngBounds bounds = await controller.getVisibleRegion(); - final LatLng southEast = LatLng( - bounds.southwest.latitude, - bounds.northeast.longitude, - ); - - final ScreenCoordinate screenPosition = - await controller.getScreenCoordinate(southEast); - - expect(screenPosition.x, closeTo(size.width, _acceptablePixelDelta)); - expect(screenPosition.y, closeTo(size.height, _acceptablePixelDelta)); - }); + 'SouthEast of visible region corresponds to x:size.width, y:size.height', + (WidgetTester tester) async { + await pumpCenteredMap( + tester, + initialCamera: initialCamera, + size: size, + onMapCreated: onMapCreated, + ); + final GoogleMapController controller = + await controllerCompleter.future; + + final LatLngBounds bounds = await controller.getVisibleRegion(); + final LatLng southEast = LatLng( + bounds.southwest.latitude, + bounds.northeast.longitude, + ); + + final ScreenCoordinate screenPosition = await controller + .getScreenCoordinate(southEast); + + expect(screenPosition.x, closeTo(size.width, _acceptablePixelDelta)); + expect(screenPosition.y, closeTo(size.height, _acceptablePixelDelta)); + }, + ); }); group('getLatLng', () { - testWidgets('Center of widget is the target of map', - (WidgetTester tester) async { + testWidgets('Center of widget is the target of map', ( + WidgetTester tester, + ) async { await pumpCenteredMap( tester, initialCamera: initialCamera, @@ -230,8 +237,9 @@ void main() { ); }); - testWidgets('Top-left of widget is NorthWest bound of map', - (WidgetTester tester) async { + testWidgets('Top-left of widget is NorthWest bound of map', ( + WidgetTester tester, + ) async { await pumpCenteredMap( tester, initialCamera: initialCamera, @@ -260,8 +268,9 @@ void main() { ); }); - testWidgets('Bottom-right of widget is SouthWest bound of map', - (WidgetTester tester) async { + testWidgets('Bottom-right of widget is SouthWest bound of map', ( + WidgetTester tester, + ) async { await pumpCenteredMap( tester, initialCamera: initialCamera, diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart index 725e8e38edb..1f7cc176871 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shape_test.dart @@ -44,11 +44,7 @@ void main() { CircleController(circle: circle, consumeTapEvents: true, onTap: onTap); // Trigger a click event... - gmaps.event.trigger( - circle, - 'click', - gmaps.MapMouseEvent(), - ); + gmaps.event.trigger(circle, 'click', gmaps.MapMouseEvent()); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); @@ -56,8 +52,8 @@ void main() { testWidgets('update', (WidgetTester tester) async { final CircleController controller = CircleController(circle: circle); - final gmaps.CircleOptions options = gmaps.CircleOptions() - ..draggable = true; + final gmaps.CircleOptions options = + gmaps.CircleOptions()..draggable = true; expect(circle.isDraggableDefined(), isFalse); @@ -79,10 +75,11 @@ void main() { expect(controller.circle, isNull); }); - testWidgets('cannot call update after remove', - (WidgetTester tester) async { - final gmaps.CircleOptions options = gmaps.CircleOptions() - ..draggable = true; + testWidgets('cannot call update after remove', ( + WidgetTester tester, + ) async { + final gmaps.CircleOptions options = + gmaps.CircleOptions()..draggable = true; controller.remove(); @@ -104,11 +101,7 @@ void main() { PolygonController(polygon: polygon, consumeTapEvents: true, onTap: onTap); // Trigger a click event... - gmaps.event.trigger( - polygon, - 'click', - gmaps.MapMouseEvent(), - ); + gmaps.event.trigger(polygon, 'click', gmaps.MapMouseEvent()); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); @@ -116,8 +109,8 @@ void main() { testWidgets('update', (WidgetTester tester) async { final PolygonController controller = PolygonController(polygon: polygon); - final gmaps.PolygonOptions options = gmaps.PolygonOptions() - ..draggable = true; + final gmaps.PolygonOptions options = + gmaps.PolygonOptions()..draggable = true; expect(polygon.isDraggableDefined(), isFalse); @@ -139,10 +132,11 @@ void main() { expect(controller.polygon, isNull); }); - testWidgets('cannot call update after remove', - (WidgetTester tester) async { - final gmaps.PolygonOptions options = gmaps.PolygonOptions() - ..draggable = true; + testWidgets('cannot call update after remove', ( + WidgetTester tester, + ) async { + final gmaps.PolygonOptions options = + gmaps.PolygonOptions()..draggable = true; controller.remove(); @@ -168,11 +162,7 @@ void main() { ); // Trigger a click event... - gmaps.event.trigger( - polyline, - 'click', - gmaps.MapMouseEvent(), - ); + gmaps.event.trigger(polyline, 'click', gmaps.MapMouseEvent()); // The event handling is now truly async. Wait for it... expect(await methodCalled, isTrue); @@ -182,8 +172,8 @@ void main() { final PolylineController controller = PolylineController( polyline: polyline, ); - final gmaps.PolylineOptions options = gmaps.PolylineOptions() - ..draggable = true; + final gmaps.PolylineOptions options = + gmaps.PolylineOptions()..draggable = true; expect(polyline.isDraggableDefined(), isFalse); @@ -205,10 +195,11 @@ void main() { expect(controller.line, isNull); }); - testWidgets('cannot call update after remove', - (WidgetTester tester) async { - final gmaps.PolylineOptions options = gmaps.PolylineOptions() - ..draggable = true; + testWidgets('cannot call update after remove', ( + WidgetTester tester, + ) async { + final gmaps.PolylineOptions options = + gmaps.PolylineOptions()..draggable = true; controller.remove(); @@ -252,8 +243,9 @@ void main() { expect(controller.heatmap, isNull); }); - testWidgets('cannot call update after remove', - (WidgetTester tester) async { + testWidgets('cannot call update after remove', ( + WidgetTester tester, + ) async { final visualization.HeatmapLayerOptions options = visualization.HeatmapLayerOptions()..dissipating = true; diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart index 6b712eeb7af..602e039b011 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/shapes_test.dart @@ -111,11 +111,15 @@ void main() { final gmaps.Circle circle = controller.circles.values.first.circle!; expect((circle.get('fillColor')! as JSString).toDart, '#fabada'); - expect((circle.get('fillOpacity')! as JSNumber).toDartDouble, - closeTo(0.5, _acceptableDelta)); + expect( + (circle.get('fillOpacity')! as JSNumber).toDartDouble, + closeTo(0.5, _acceptableDelta), + ); expect((circle.get('strokeColor')! as JSString).toDart, '#c0ffee'); - expect((circle.get('strokeOpacity')! as JSNumber).toDartDouble, - closeTo(1, _acceptableDelta)); + expect( + (circle.get('strokeOpacity')! as JSNumber).toDartDouble, + closeTo(1, _acceptableDelta), + ); }); }); @@ -150,7 +154,9 @@ void main() { controller.addPolygons(polygons); expect( - controller.polygons[const PolygonId('1')]?.polygon?.visible, isTrue); + controller.polygons[const PolygonId('1')]?.polygon?.visible, + isTrue, + ); // Update the polygon final Set updatedPolygons = { @@ -160,7 +166,9 @@ void main() { expect(controller.polygons.length, 1); expect( - controller.polygons[const PolygonId('1')]?.polygon?.visible, isFalse); + controller.polygons[const PolygonId('1')]?.polygon?.visible, + isFalse, + ); }); testWidgets('removePolygons', (WidgetTester tester) async { @@ -202,11 +210,15 @@ void main() { final gmaps.Polygon polygon = controller.polygons.values.first.polygon!; expect((polygon.get('fillColor')! as JSString).toDart, '#fabada'); - expect((polygon.get('fillOpacity')! as JSNumber).toDartDouble, - closeTo(0.5, _acceptableDelta)); + expect( + (polygon.get('fillOpacity')! as JSNumber).toDartDouble, + closeTo(0.5, _acceptableDelta), + ); expect((polygon.get('strokeColor')! as JSString).toDart, '#c0ffee'); - expect((polygon.get('strokeOpacity')! as JSNumber).toDartDouble, - closeTo(1, _acceptableDelta)); + expect( + (polygon.get('strokeOpacity')! as JSNumber).toDartDouble, + closeTo(1, _acceptableDelta), + ); }); testWidgets('Handle Polygons with holes', (WidgetTester tester) async { @@ -262,8 +274,9 @@ void main() { expect(geometry.poly.containsLocation(pointInHole, polygon!), false); }); - testWidgets('Hole Path gets reversed to display correctly', - (WidgetTester tester) async { + testWidgets('Hole Path gets reversed to display correctly', ( + WidgetTester tester, + ) async { final Set polygons = { const Polygon( polygonId: PolygonId('BermudaTriangle'), @@ -361,10 +374,7 @@ void main() { testWidgets('Converts colors to CSS', (WidgetTester tester) async { final Set lines = { - const Polyline( - polylineId: PolylineId('1'), - color: Color(0x7FFABADA), - ), + const Polyline(polylineId: PolylineId('1'), color: Color(0x7FFABADA)), }; controller.addPolylines(lines); @@ -372,8 +382,10 @@ void main() { final gmaps.Polyline line = controller.lines.values.first.line!; expect((line.get('strokeColor')! as JSString).toDart, '#fabada'); - expect((line.get('strokeOpacity')! as JSNumber).toDartDouble, - closeTo(0.5, _acceptableDelta)); + expect( + (line.get('strokeOpacity')! as JSNumber).toDartDouble, + closeTo(0.5, _acceptableDelta), + ); }); }); @@ -394,7 +406,7 @@ void main() { WeightedLatLng(LatLng(37.785, -122.441)), WeightedLatLng(LatLng(37.785, -122.439)), WeightedLatLng(LatLng(37.785, -122.437)), - WeightedLatLng(LatLng(37.785, -122.435)) + WeightedLatLng(LatLng(37.785, -122.435)), ]; setUp(() { @@ -497,9 +509,9 @@ void main() { const Heatmap( heatmapId: HeatmapId('1'), data: heatmapPoints, - gradient: HeatmapGradient( - [HeatmapGradientColor(Color(0xFFFABADA), 0)], - ), + gradient: HeatmapGradient([ + HeatmapGradientColor(Color(0xFFFABADA), 0), + ]), radius: HeatmapRadius.fromPixels(20), ), }; @@ -510,9 +522,9 @@ void main() { controller.heatmaps.values.first.heatmap!; expect( - (heatmap.get('gradient')! as JSArray) - .toDart - .map((JSString? value) => value!.toDart), + (heatmap.get('gradient')! as JSArray).toDart.map( + (JSString? value) => value!.toDart, + ), ['rgba(250, 186, 218, 0.00)', 'rgba(250, 186, 218, 1.00)'], ); }); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml index 6d404825bc7..b87b2a4cc48 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/pubspec.yaml @@ -2,8 +2,8 @@ name: google_maps_flutter_web_integration_tests publish_to: none environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" dependencies: flutter: diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circle.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circle.dart index 8776bef9fd1..e46dc4c8c7f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circle.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circle.dart @@ -11,8 +11,8 @@ class CircleController { required gmaps.Circle circle, bool consumeTapEvents = false, VoidCallback? onTap, - }) : _circle = circle, - _consumeTapEvents = consumeTapEvents { + }) : _circle = circle, + _consumeTapEvents = consumeTapEvents { if (onTap != null) { circle.onClick.listen((_) { onTap.call(); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circles.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circles.dart index 4bc0fd385a2..e30ea51a186 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circles.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/circles.dart @@ -7,10 +7,9 @@ part of '../google_maps_flutter_web.dart'; /// This class manages all the [CircleController]s associated to a [GoogleMapController]. class CirclesController extends GeometryController { /// Initialize the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers. - CirclesController({ - required StreamController> stream, - }) : _streamController = stream, - _circleIdToController = {}; + CirclesController({required StreamController> stream}) + : _streamController = stream, + _circleIdToController = {}; // A cache of [CircleController]s indexed by their [CircleId]. final Map _circleIdToController; @@ -33,11 +32,12 @@ class CirclesController extends GeometryController { final gmaps.CircleOptions circleOptions = _circleOptionsFromCircle(circle); final gmaps.Circle gmCircle = gmaps.Circle(circleOptions)..map = googleMap; final CircleController controller = CircleController( - circle: gmCircle, - consumeTapEvents: circle.consumeTapEvents, - onTap: () { - _onCircleTap(circle.circleId); - }); + circle: gmCircle, + consumeTapEvents: circle.consumeTapEvents, + onTap: () { + _onCircleTap(circle.circleId); + }, + ); _circleIdToController[circle.circleId] = controller; } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart index ee62cad2733..51b2c9cb8e8 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/convert.dart @@ -6,8 +6,10 @@ part of '../google_maps_flutter_web.dart'; // Default values for when the gmaps objects return null/undefined values. final gmaps.LatLng _nullGmapsLatLng = gmaps.LatLng(0, 0); -final gmaps.LatLngBounds _nullGmapsLatLngBounds = - gmaps.LatLngBounds(_nullGmapsLatLng, _nullGmapsLatLng); +final gmaps.LatLngBounds _nullGmapsLatLngBounds = gmaps.LatLngBounds( + _nullGmapsLatLng, + _nullGmapsLatLng, +); // The TrustedType Policy used by this plugin. Used to sanitize InfoWindow contents. TrustedTypePolicy? _gmapsTrustedTypePolicy; @@ -54,7 +56,9 @@ String _getCssColorWithAlpha(Color color) { // buildingsEnabled seems to not have an equivalent in web // padding seems to behave differently in web than mobile. You can't move UI elements in web. gmaps.MapOptions _configurationAndStyleToGmapsOptions( - MapConfiguration configuration, List styles) { + MapConfiguration configuration, + List styles, +) { final gmaps.MapOptions options = gmaps.MapOptions(); if (configuration.mapType != null) { @@ -137,7 +141,9 @@ gmaps.MapOptions _applyInitialPosition( // Adjust the initial position, if passed... options.zoom = initialPosition.zoom; options.center = gmaps.LatLng( - initialPosition.target.latitude, initialPosition.target.longitude); + initialPosition.target.latitude, + initialPosition.target.longitude, + ); return options; } @@ -159,22 +165,28 @@ List _mapStyles(String? mapStyleJson) { if (mapStyleJson != null) { try { styles = - (json.decode(mapStyleJson, reviver: (Object? key, Object? value) { - if (value is Map && _isJsonMapStyle(value as Map)) { - List stylers = []; - if (value['stylers'] != null) { - stylers = (value['stylers']! as List) - .whereType>() - .map(MapStyler.fromJson) - .toList(); - } - return gmaps.MapTypeStyle() - ..elementType = value['elementType'] as String? - ..featureType = value['featureType'] as String? - ..stylers = stylers; - } - return value; - }) as List) + (json.decode( + mapStyleJson, + reviver: (Object? key, Object? value) { + if (value is Map && + _isJsonMapStyle(value as Map)) { + List stylers = []; + if (value['stylers'] != null) { + stylers = + (value['stylers']! as List) + .whereType>() + .map(MapStyler.fromJson) + .toList(); + } + return gmaps.MapTypeStyle() + ..elementType = value['elementType'] as String? + ..featureType = value['featureType'] as String? + ..stylers = stylers; + } + return value; + }, + ) + as List) .where((Object? element) => element != null) .cast() .toList(); @@ -205,14 +217,17 @@ LatLngBounds gmLatLngBoundsTolatLngBounds(gmaps.LatLngBounds latLngBounds) { /// Converts a [LatLngBounds] into a [gmaps.LatLngBounds]. gmaps.LatLngBounds latLngBoundsToGmlatLngBounds(LatLngBounds latLngBounds) { - return gmaps.LatLngBounds(_latLngToGmLatLng(latLngBounds.southwest), - _latLngToGmLatLng(latLngBounds.northeast)); + return gmaps.LatLngBounds( + _latLngToGmLatLng(latLngBounds.southwest), + _latLngToGmLatLng(latLngBounds.northeast), + ); } CameraPosition _gmViewportToCameraPosition(gmaps.Map map) { return CameraPosition( - target: - gmLatLngToLatLng(map.isCenterDefined() ? map.center : _nullGmapsLatLng), + target: gmLatLngToLatLng( + map.isCenterDefined() ? map.center : _nullGmapsLatLng, + ), bearing: map.isHeadingDefined() ? map.heading.toDouble() : 0, tilt: map.isTiltDefined() ? map.tilt.toDouble() : 0, zoom: map.isZoomDefined() ? map.zoom.toDouble() : 0, @@ -234,8 +249,9 @@ gmaps.InfoWindowOptions? _infoWindowOptionsFromMarker(Marker marker) { // Add an outer wrapper to the contents of the infowindow, we need it to listen // to click events... - final HTMLElement container = createDivElement() - ..id = 'gmaps-marker-${marker.markerId.value}-infowindow'; + final HTMLElement container = + createDivElement() + ..id = 'gmaps-marker-${marker.markerId.value}-infowindow'; if (markerTitle.isNotEmpty) { final HTMLHeadingElement title = @@ -245,8 +261,8 @@ gmaps.InfoWindowOptions? _infoWindowOptionsFromMarker(Marker marker) { container.appendChild(title); } if (markerSnippet.isNotEmpty) { - final HTMLElement snippet = createDivElement() - ..className = 'infowindow-snippet'; + final HTMLElement snippet = + createDivElement()..className = 'infowindow-snippet'; // Firefox and Safari don't support Trusted Types yet. // See https://developer.mozilla.org/en-US/docs/Web/API/TrustedTypePolicyFactory#browser_compatibility @@ -254,14 +270,16 @@ gmaps.InfoWindowOptions? _infoWindowOptionsFromMarker(Marker marker) { _gmapsTrustedTypePolicy ??= window.trustedTypes.createPolicy( 'google_maps_flutter_sanitize', TrustedTypePolicyOptions( - createHTML: (String html) { - return sanitizeHtml(html).toJS; - }.toJS, + createHTML: + (String html) { + return sanitizeHtml(html).toJS; + }.toJS, ), ); - snippet.trustedInnerHTML = - _gmapsTrustedTypePolicy!.createHTMLNoArgs(markerSnippet); + snippet.trustedInnerHTML = _gmapsTrustedTypePolicy!.createHTMLNoArgs( + markerSnippet, + ); } else { // `sanitizeHtml` is used to clean the (potential) user input from (potential) // XSS attacks through the contents of the marker InfoWindow. @@ -288,20 +306,14 @@ gmaps.Size? _gmSizeFromIconConfig(List iconConfig, int sizeIndex) { if (iconConfig.length >= sizeIndex + 1) { final List? rawIconSize = iconConfig[sizeIndex] as List?; if (rawIconSize != null) { - size = gmaps.Size( - rawIconSize[0]! as double, - rawIconSize[1]! as double, - ); + size = gmaps.Size(rawIconSize[0]! as double, rawIconSize[1]! as double); } } return size; } /// Sets the size of the Google Maps icon. -void _setIconSize({ - required Size size, - required gmaps.Icon icon, -}) { +void _setIconSize({required Size size, required gmaps.Icon icon}) { final gmaps.Size gmapsSize = gmaps.Size(size.width, size.height); icon.size = gmapsSize; icon.scaledSize = gmapsSize; @@ -334,7 +346,9 @@ Future _getBitmapSize(MapBitmap mapBitmap, String url) async { return Size(width, height); } else { assert( - url.isNotEmpty, 'URL must not be empty when calculating dimensions.'); + url.isNotEmpty, + 'URL must not be empty when calculating dimensions.', + ); final Size? bitmapSize = await _bitmapSizeFutureCache.putIfAbsent(url, () { return _fetchBitmapSize(url); @@ -394,7 +408,9 @@ void _cleanUpBitmapConversionCaches() { // Converts a [BitmapDescriptor] into a [gmaps.Icon] that can be used in Markers. Future _gmIconFromBitmapDescriptor( - BitmapDescriptor bitmapDescriptor, Offset anchor) async { + BitmapDescriptor bitmapDescriptor, + Offset anchor, +) async { gmaps.Icon? icon; if (bitmapDescriptor is MapBitmap) { @@ -422,8 +438,9 @@ Future _gmIconFromBitmapDescriptor( assert(iconConfig.length >= 2); // iconConfig[2] contains the DPIs of the screen, but that information is // already encoded in the iconConfig[1] - icon = gmaps.Icon() - ..url = ui_web.assetManager.getAssetUrl(iconConfig[1]! as String); + icon = + gmaps.Icon() + ..url = ui_web.assetManager.getAssetUrl(iconConfig[1]! as String); final gmaps.Size? size = _gmSizeFromIconConfig(iconConfig, 3); if (size != null) { @@ -482,40 +499,48 @@ Future _markerOptionsFromMarker( } gmaps.CircleOptions _circleOptionsFromCircle(Circle circle) { - final gmaps.CircleOptions circleOptions = gmaps.CircleOptions() - ..strokeColor = _getCssColor(circle.strokeColor) - ..strokeOpacity = _getCssOpacity(circle.strokeColor) - ..strokeWeight = circle.strokeWidth - ..fillColor = _getCssColor(circle.fillColor) - ..fillOpacity = _getCssOpacity(circle.fillColor) - ..center = gmaps.LatLng(circle.center.latitude, circle.center.longitude) - ..radius = circle.radius - ..visible = circle.visible - ..zIndex = circle.zIndex; + final gmaps.CircleOptions circleOptions = + gmaps.CircleOptions() + ..strokeColor = _getCssColor(circle.strokeColor) + ..strokeOpacity = _getCssOpacity(circle.strokeColor) + ..strokeWeight = circle.strokeWidth + ..fillColor = _getCssColor(circle.fillColor) + ..fillOpacity = _getCssOpacity(circle.fillColor) + ..center = gmaps.LatLng(circle.center.latitude, circle.center.longitude) + ..radius = circle.radius + ..visible = circle.visible + ..zIndex = circle.zIndex; return circleOptions; } visualization.HeatmapLayerOptions _heatmapOptionsFromHeatmap(Heatmap heatmap) { - final Iterable? gradientColors = - heatmap.gradient?.colors.map((HeatmapGradientColor e) => e.color); + final Iterable? gradientColors = heatmap.gradient?.colors.map( + (HeatmapGradientColor e) => e.color, + ); final visualization.HeatmapLayerOptions heatmapOptions = visualization.HeatmapLayerOptions() - ..data = heatmap.data - .map( - (WeightedLatLng e) => visualization.WeightedLocation() - ..location = gmaps.LatLng(e.point.latitude, e.point.longitude) - ..weight = e.weight, - ) - .toList() - .toJS + ..data = + heatmap.data + .map( + (WeightedLatLng e) => + visualization.WeightedLocation() + ..location = gmaps.LatLng( + e.point.latitude, + e.point.longitude, + ) + ..weight = e.weight, + ) + .toList() + .toJS ..dissipating = heatmap.dissipating - ..gradient = gradientColors == null - ? null - : [ - // Web needs a first color with 0 alpha - gradientColors.first.withAlpha(0), - ...gradientColors, - ].map(_getCssColorWithAlpha).toList() + ..gradient = + gradientColors == null + ? null + : [ + // Web needs a first color with 0 alpha + gradientColors.first.withAlpha(0), + ...gradientColors, + ].map(_getCssColorWithAlpha).toList() ..maxIntensity = heatmap.maxIntensity ..opacity = heatmap.opacity ..radius = heatmap.radius.radius; @@ -523,7 +548,9 @@ visualization.HeatmapLayerOptions _heatmapOptionsFromHeatmap(Heatmap heatmap) { } gmaps.PolygonOptions _polygonOptionsFromPolygon( - gmaps.Map googleMap, Polygon polygon) { + gmaps.Map googleMap, + Polygon polygon, +) { // Convert all points to GmLatLng final List path = polygon.points.map(_latLngToGmLatLng).toList(); @@ -567,9 +594,11 @@ List _ensureHoleHasReverseWinding( if (holeIsClockwise == polyIsClockwise) { holePath = holePath.reversed.toList(); if (kDebugMode) { - print('Hole [$holeId] in Polygon [${polygonId.value}] has been reversed.' - ' Ensure holes in polygons are "wound in the opposite direction to the outer path."' - ' More info: https://github.com/flutter/flutter/issues/74096'); + print( + 'Hole [$holeId] in Polygon [${polygonId.value}] has been reversed.' + ' Ensure holes in polygons are "wound in the opposite direction to the outer path."' + ' More info: https://github.com/flutter/flutter/issues/74096', + ); } } @@ -590,7 +619,8 @@ List _ensureHoleHasReverseWinding( bool _isPolygonClockwise(List path) { double direction = 0.0; for (int i = 0; i < path.length; i++) { - direction = direction + + direction = + direction + ((path[(i + 1) % path.length].lat - path[i].lat) * (path[(i + 1) % path.length].lng + path[i].lng)); } @@ -598,7 +628,9 @@ bool _isPolygonClockwise(List path) { } gmaps.PolylineOptions _polylineOptionsFromPolyline( - gmaps.Map googleMap, Polyline polyline) { + gmaps.Map googleMap, + Polyline polyline, +) { final List paths = polyline.points.map(_latLngToGmLatLng).toList(); @@ -610,11 +642,11 @@ gmaps.PolylineOptions _polylineOptionsFromPolyline( ..visible = polyline.visible ..zIndex = polyline.zIndex ..geodesic = polyline.geodesic; -// this.endCap = Cap.buttCap, -// this.jointType = JointType.mitered, -// this.patterns = const [], -// this.startCap = Cap.buttCap, -// this.width = 10, + // this.endCap = Cap.buttCap, + // this.jointType = JointType.mitered, + // this.patterns = const [], + // this.startCap = Cap.buttCap, + // this.width = 10, } // Translates a [CameraUpdate] into operations on a [gmaps.Map]. @@ -637,9 +669,7 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { final List latLng = asJsonList(position['target']); map.heading = position['bearing']! as num; map.zoom = position['zoom']! as num; - map.panTo( - gmaps.LatLng(latLng[0]! as num, latLng[1]! as num), - ); + map.panTo(gmaps.LatLng(latLng[0]! as num, latLng[1]! as num)); map.tilt = position['tilt']! as num; case 'newLatLng': final List latLng = asJsonList(json[1]); @@ -672,8 +702,11 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { final List latLng = asJsonList(json[2]); // With focus try { - focusLatLng = - _pixelToLatLng(map, latLng[0]! as int, latLng[1]! as int); + focusLatLng = _pixelToLatLng( + map, + latLng[0]! as int, + latLng[1]! as int, + ); } catch (e) { // https://github.com/a14n/dart-google-maps/issues/87 // print('Error computing new focus LatLng. JS Error: ' + e.toString()); @@ -697,16 +730,22 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { /// Converts a [MapBitmap] into a URL. String urlFromMapBitmap(MapBitmap mapBitmap) { return switch (mapBitmap) { - (final BytesMapBitmap bytesMapBitmap) => - _bitmapBlobUrlCache.putIfAbsent(bytesMapBitmap.byteData.hashCode, () { - final Blob blob = - Blob([bytesMapBitmap.byteData.toJS].toJS); + (final BytesMapBitmap bytesMapBitmap) => _bitmapBlobUrlCache.putIfAbsent( + bytesMapBitmap.byteData.hashCode, + () { + final Blob blob = Blob( + [bytesMapBitmap.byteData.toJS].toJS, + ); return URL.createObjectURL(blob as JSObject); - }), - (final AssetMapBitmap assetMapBitmap) => - ui_web.assetManager.getAssetUrl(assetMapBitmap.assetName), - _ => throw UnimplementedError( - 'Only BytesMapBitmap and AssetMapBitmap are supported.'), + }, + ), + (final AssetMapBitmap assetMapBitmap) => ui_web.assetManager.getAssetUrl( + assetMapBitmap.assetName, + ), + _ => + throw UnimplementedError( + 'Only BytesMapBitmap and AssetMapBitmap are supported.', + ), }; } @@ -716,11 +755,17 @@ gmaps.LatLng _pixelToLatLng(gmaps.Map map, int x, int y) { final gmaps.Projection? projection = map.projection; assert( - bounds != null, 'Map Bounds required to compute LatLng of screen x/y.'); - assert(projection != null, - 'Map Projection required to compute LatLng of screen x/y'); - assert(map.isZoomDefined(), - 'Current map zoom level required to compute LatLng of screen x/y'); + bounds != null, + 'Map Bounds required to compute LatLng of screen x/y.', + ); + assert( + projection != null, + 'Map Projection required to compute LatLng of screen x/y', + ); + assert( + map.isZoomDefined(), + 'Current map zoom level required to compute LatLng of screen x/y', + ); final num zoom = map.zoom; @@ -732,8 +777,10 @@ gmaps.LatLng _pixelToLatLng(gmaps.Map map, int x, int y) { final int scale = 1 << (zoom.toInt()); // 2 ^ zoom - final gmaps.Point point = - gmaps.Point((x / scale) + bottomLeft.x, (y / scale) + topRight.y); + final gmaps.Point point = gmaps.Point( + (x / scale) + bottomLeft.x, + (y / scale) + topRight.y, + ); return projection.fromPointToLatLng(point)!; } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/dom_window_extension.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/dom_window_extension.dart index 87aa8304174..10a2b0d84f5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/dom_window_extension.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/dom_window_extension.dart @@ -42,7 +42,5 @@ extension InnerHTMLString on web.HTMLElement { extension CreateHTMLNoArgs on web.TrustedTypePolicy { /// Allows calling `createHTML` with only the `input` argument. @JS('createHTML') - external web.TrustedHTML createHTMLNoArgs( - String input, - ); + external web.TrustedHTML createHTMLNoArgs(String input); } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart index 4588c4717ba..f93bbbe770a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_controller.dart @@ -6,8 +6,8 @@ part of '../google_maps_flutter_web.dart'; /// Type used when passing an override to the _createMap function. @visibleForTesting -typedef DebugCreateMapFunction = gmaps.Map Function( - HTMLElement div, gmaps.MapOptions options); +typedef DebugCreateMapFunction = + gmaps.Map Function(HTMLElement div, gmaps.MapOptions options); /// Type used when passing an override to the _setOptions function. @visibleForTesting @@ -22,39 +22,43 @@ class GoogleMapController { required MapWidgetConfiguration widgetConfiguration, MapObjects mapObjects = const MapObjects(), MapConfiguration mapConfiguration = const MapConfiguration(), - }) : _mapId = mapId, - _streamController = streamController, - _initialCameraPosition = widgetConfiguration.initialCameraPosition, - _markers = mapObjects.markers, - _polygons = mapObjects.polygons, - _polylines = mapObjects.polylines, - _circles = mapObjects.circles, - _clusterManagers = mapObjects.clusterManagers, - _heatmaps = mapObjects.heatmaps, - _groundOverlays = mapObjects.groundOverlays, - _tileOverlays = mapObjects.tileOverlays, - _lastMapConfiguration = mapConfiguration { + }) : _mapId = mapId, + _streamController = streamController, + _initialCameraPosition = widgetConfiguration.initialCameraPosition, + _markers = mapObjects.markers, + _polygons = mapObjects.polygons, + _polylines = mapObjects.polylines, + _circles = mapObjects.circles, + _clusterManagers = mapObjects.clusterManagers, + _heatmaps = mapObjects.heatmaps, + _groundOverlays = mapObjects.groundOverlays, + _tileOverlays = mapObjects.tileOverlays, + _lastMapConfiguration = mapConfiguration { _circlesController = CirclesController(stream: _streamController); _heatmapsController = HeatmapsController(); _polygonsController = PolygonsController(stream: _streamController); _polylinesController = PolylinesController(stream: _streamController); - _clusterManagersController = - ClusterManagersController(stream: _streamController); + _clusterManagersController = ClusterManagersController( + stream: _streamController, + ); _markersController = MarkersController( - stream: _streamController, - clusterManagersController: _clusterManagersController!); + stream: _streamController, + clusterManagersController: _clusterManagersController!, + ); _tileOverlaysController = TileOverlaysController(); - _groundOverlaysController = - GroundOverlaysController(stream: _streamController); + _groundOverlaysController = GroundOverlaysController( + stream: _streamController, + ); _updateStylesFromConfiguration(mapConfiguration); // Register the view factory that will hold the `_div` that holds the map in the DOM. // The `_div` needs to be created outside of the ViewFactory (and cached!) so we can // use it to create the [gmaps.Map] in the `init()` method of this class. - _div = createDivElement() - ..id = _getViewType(mapId) - ..style.width = '100%' - ..style.height = '100%'; + _div = + createDivElement() + ..id = _getViewType(mapId) + ..style.width = '100%' + ..style.height = '100%'; ui_web.platformViewRegistry.registerViewFactory( _getViewType(mapId), @@ -100,9 +104,7 @@ class GoogleMapController { /// The Flutter widget that will contain the rendered Map. Used for caching. Widget? get widget { if (_widget == null && !_streamController.isClosed) { - _widget = HtmlElementView( - viewType: _getViewType(_mapId), - ); + _widget = HtmlElementView(viewType: _getViewType(_mapId)); } return _widget; } @@ -216,7 +218,9 @@ class GoogleMapController { /// and most of the public methods on this class no-op'ing. void init() { gmaps.MapOptions options = _configurationAndStyleToGmapsOptions( - _lastMapConfiguration, _lastStyles); + _lastMapConfiguration, + _lastStyles, + ); // Initial position can only to be set here! options = _applyInitialPosition(_initialCameraPosition, options); @@ -280,22 +284,38 @@ class GoogleMapController { // These controllers are either created in the constructor of this class, or // overriden (for testing) by the [debugSetOverrides] method. They can't be // null. - assert(_circlesController != null, - 'Cannot attach a map to a null CirclesController instance.'); - assert(_heatmapsController != null, - 'Cannot attach a map to a null HeatmapsController instance.'); - assert(_polygonsController != null, - 'Cannot attach a map to a null PolygonsController instance.'); - assert(_polylinesController != null, - 'Cannot attach a map to a null PolylinesController instance.'); - assert(_markersController != null, - 'Cannot attach a map to a null MarkersController instance.'); - assert(_clusterManagersController != null, - 'Cannot attach a map to a null ClusterManagersController instance.'); - assert(_tileOverlaysController != null, - 'Cannot attach a map to a null TileOverlaysController instance.'); - assert(_groundOverlaysController != null, - 'Cannot attach a map to a null GroundOverlaysController instance.'); + assert( + _circlesController != null, + 'Cannot attach a map to a null CirclesController instance.', + ); + assert( + _heatmapsController != null, + 'Cannot attach a map to a null HeatmapsController instance.', + ); + assert( + _polygonsController != null, + 'Cannot attach a map to a null PolygonsController instance.', + ); + assert( + _polylinesController != null, + 'Cannot attach a map to a null PolylinesController instance.', + ); + assert( + _markersController != null, + 'Cannot attach a map to a null MarkersController instance.', + ); + assert( + _clusterManagersController != null, + 'Cannot attach a map to a null ClusterManagersController instance.', + ); + assert( + _tileOverlaysController != null, + 'Cannot attach a map to a null TileOverlaysController instance.', + ); + assert( + _groundOverlaysController != null, + 'Cannot attach a map to a null GroundOverlaysController instance.', + ); _circlesController!.bindToMap(_mapId, map); _heatmapsController!.bindToMap(_mapId, map); @@ -316,9 +336,10 @@ class GoogleMapController { // Renders the initial sets of geometry. void _renderInitialGeometry() { assert( - _controllersBoundToMap, - 'Geometry controllers must be bound to a map before any geometry can ' - 'be added to them. Ensure _attachGeometryControllers is called first.'); + _controllersBoundToMap, + 'Geometry controllers must be bound to a map before any geometry can ' + 'be added to them. Ensure _attachGeometryControllers is called first.', + ); // The above assert will only succeed if the controllers have been bound to a map // in the [_attachGeometryControllers] method, which ensures that all these @@ -345,7 +366,8 @@ class GoogleMapController { // source of truth for style info. Currently it's tracked and handled // separately since style didn't used to be part of the configuration. List _updateStylesFromConfiguration( - MapConfiguration update) { + MapConfiguration update, + ) { if (update.style != null) { // Provide async access to the error rather than throwing, to match the // behavior of other platforms where there's no mechanism to return errors @@ -366,11 +388,14 @@ class GoogleMapController { void updateMapConfiguration(MapConfiguration update) { assert(_googleMap != null, 'Cannot update options on a null map.'); - final List styles = - _updateStylesFromConfiguration(update); + final List styles = _updateStylesFromConfiguration( + update, + ); final MapConfiguration newConfiguration = _mergeConfigurations(update); - final gmaps.MapOptions newOptions = - _configurationAndStyleToGmapsOptions(newConfiguration, styles); + final gmaps.MapOptions newOptions = _configurationAndStyleToGmapsOptions( + newConfiguration, + styles, + ); _setOptions(newOptions); _setTrafficLayer(_googleMap!, newConfiguration.trafficEnabled ?? false); @@ -380,7 +405,8 @@ class GoogleMapController { void updateStyles(List styles) { _lastStyles = styles; _setOptions( - _configurationAndStyleToGmapsOptions(_lastMapConfiguration, styles)); + _configurationAndStyleToGmapsOptions(_lastMapConfiguration, styles), + ); } /// A getter for the current styles. Only for tests. @@ -419,29 +445,38 @@ class GoogleMapController { final gmaps.LatLngBounds bounds = await Future.value(_googleMap!.bounds) ?? - _nullGmapsLatLngBounds; + _nullGmapsLatLngBounds; return gmLatLngBoundsTolatLngBounds(bounds); } /// Returns the [ScreenCoordinate] for a given viewport [LatLng]. Future getScreenCoordinate(LatLng latLng) async { - assert(_googleMap != null, - 'Cannot get the screen coordinates with a null map.'); + assert( + _googleMap != null, + 'Cannot get the screen coordinates with a null map.', + ); - final gmaps.Point point = - toScreenLocation(_googleMap!, _latLngToGmLatLng(latLng)); + final gmaps.Point point = toScreenLocation( + _googleMap!, + _latLngToGmLatLng(latLng), + ); return ScreenCoordinate(x: point.x.toInt(), y: point.y.toInt()); } /// Returns the [LatLng] for a `screenCoordinate` (in pixels) of the viewport. Future getLatLng(ScreenCoordinate screenCoordinate) async { - assert(_googleMap != null, - 'Cannot get the lat, lng of a screen coordinate with a null map.'); + assert( + _googleMap != null, + 'Cannot get the lat, lng of a screen coordinate with a null map.', + ); - final gmaps.LatLng latLng = - _pixelToLatLng(_googleMap!, screenCoordinate.x, screenCoordinate.y); + final gmaps.LatLng latLng = _pixelToLatLng( + _googleMap!, + screenCoordinate.x, + screenCoordinate.y, + ); return gmLatLngToLatLng(latLng); } @@ -455,8 +490,10 @@ class GoogleMapController { /// Returns the zoom level of the current viewport. Future getZoomLevel() async { assert(_googleMap != null, 'Cannot get zoom level of a null map.'); - assert(_googleMap!.isZoomDefined(), - 'Zoom level should not be null. Is the map correctly initialized?'); + assert( + _googleMap!.isZoomDefined(), + 'Zoom level should not be null. Is the map correctly initialized?', + ); return _googleMap!.zoom.toDouble(); } @@ -488,7 +525,9 @@ class GoogleMapController { /// Applies [PolygonUpdates] to the currently managed polygons. void updatePolygons(PolygonUpdates updates) { assert( - _polygonsController != null, 'Cannot update polygons after dispose().'); + _polygonsController != null, + 'Cannot update polygons after dispose().', + ); _polygonsController?.addPolygons(updates.polygonsToAdd); _polygonsController?.changePolygons(updates.polygonsToChange); _polygonsController?.removePolygons(updates.polygonIdsToRemove); @@ -496,8 +535,10 @@ class GoogleMapController { /// Applies [PolylineUpdates] to the currently managed lines. void updatePolylines(PolylineUpdates updates) { - assert(_polylinesController != null, - 'Cannot update polylines after dispose().'); + assert( + _polylinesController != null, + 'Cannot update polylines after dispose().', + ); _polylinesController?.addPolylines(updates.polylinesToAdd); _polylinesController?.changePolylines(updates.polylinesToChange); _polylinesController?.removePolylines(updates.polylineIdsToRemove); @@ -506,7 +547,9 @@ class GoogleMapController { /// Applies [MarkerUpdates] to the currently managed markers. Future updateMarkers(MarkerUpdates updates) async { assert( - _markersController != null, 'Cannot update markers after dispose().'); + _markersController != null, + 'Cannot update markers after dispose().', + ); await _markersController?.addMarkers(updates.markersToAdd); await _markersController?.changeMarkers(updates.markersToChange); _markersController?.removeMarkers(updates.markerIdsToRemove); @@ -515,35 +558,48 @@ class GoogleMapController { /// Applies [ClusterManagerUpdates] to the currently managed cluster managers. void updateClusterManagers(ClusterManagerUpdates updates) { - assert(_clusterManagersController != null, - 'Cannot update markers after dispose().'); - _clusterManagersController - ?.addClusterManagers(updates.clusterManagersToAdd); - _clusterManagersController - ?.removeClusterManagers(updates.clusterManagerIdsToRemove); + assert( + _clusterManagersController != null, + 'Cannot update markers after dispose().', + ); + _clusterManagersController?.addClusterManagers( + updates.clusterManagersToAdd, + ); + _clusterManagersController?.removeClusterManagers( + updates.clusterManagerIdsToRemove, + ); } /// Updates the set of [GroundOverlay]s. void updateGroundOverlays(GroundOverlayUpdates updates) { - assert(_groundOverlaysController != null, - 'Cannot update tile overlays after dispose().'); + assert( + _groundOverlaysController != null, + 'Cannot update tile overlays after dispose().', + ); _groundOverlaysController?.addGroundOverlays(updates.objectsToAdd); _groundOverlaysController?.changeGroundOverlays(updates.objectsToChange); _groundOverlaysController?.removeGroundOverlays( - updates.objectIdsToRemove.cast()); + updates.objectIdsToRemove.cast(), + ); } /// Updates the set of [TileOverlay]s. void updateTileOverlays(Set newOverlays) { final MapsObjectUpdates updates = - MapsObjectUpdates.from(_tileOverlays, newOverlays, - objectName: 'tileOverlay'); - assert(_tileOverlaysController != null, - 'Cannot update tile overlays after dispose().'); + MapsObjectUpdates.from( + _tileOverlays, + newOverlays, + objectName: 'tileOverlay', + ); + assert( + _tileOverlaysController != null, + 'Cannot update tile overlays after dispose().', + ); _tileOverlaysController?.addTileOverlays(updates.objectsToAdd); _tileOverlaysController?.changeTileOverlays(updates.objectsToChange); - _tileOverlaysController - ?.removeTileOverlays(updates.objectIdsToRemove.cast()); + _tileOverlaysController?.removeTileOverlays( + updates.objectIdsToRemove.cast(), + ); _tileOverlays = newOverlays; } @@ -554,15 +610,19 @@ class GoogleMapController { /// Shows the [InfoWindow] of the marker identified by its [MarkerId]. void showInfoWindow(MarkerId markerId) { - assert(_markersController != null, - 'Cannot show infowindow of marker [${markerId.value}] after dispose().'); + assert( + _markersController != null, + 'Cannot show infowindow of marker [${markerId.value}] after dispose().', + ); _markersController?.showMarkerInfoWindow(markerId); } /// Hides the [InfoWindow] of the marker identified by its [MarkerId]. void hideInfoWindow(MarkerId markerId) { - assert(_markersController != null, - 'Cannot hide infowindow of marker [${markerId.value}] after dispose().'); + assert( + _markersController != null, + 'Cannot hide infowindow of marker [${markerId.value}] after dispose().', + ); _markersController?.hideMarkerInfoWindow(markerId); } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_flutter_web.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_flutter_web.dart index d205a747690..373135b180e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_flutter_web.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_flutter_web.dart @@ -29,8 +29,10 @@ class GoogleMapsPlugin extends GoogleMapsFlutterPlatform { /// Retrieve a map controller by its mapId. GoogleMapController _map(int mapId) { final GoogleMapController? controller = _mapById[mapId]; - assert(controller != null, - 'Maps cannot be retrieved before calling buildView!'); + assert( + controller != null, + 'Maps cannot be retrieved before calling buildView!', + ); return controller!; } @@ -156,18 +158,13 @@ class GoogleMapsPlugin extends GoogleMapsFlutterPlatform { /// Subsequent calls to this method override previous calls, you need to /// pass full styles. @override - Future setMapStyle( - String? mapStyle, { - required int mapId, - }) async { + Future setMapStyle(String? mapStyle, {required int mapId}) async { _map(mapId).updateStyles(_mapStyles(mapStyle)); } /// Returns the bounds of the current viewport. @override - Future getVisibleRegion({ - required int mapId, - }) { + Future getVisibleRegion({required int mapId}) { return _map(mapId).getVisibleRegion(); } @@ -230,9 +227,7 @@ class GoogleMapsPlugin extends GoogleMapsFlutterPlatform { /// Returns the zoom level of the `mapId`. @override - Future getZoomLevel({ - required int mapId, - }) { + Future getZoomLevel({required int mapId}) { return _map(mapId).getZoomLevel(); } @@ -352,18 +347,21 @@ class GoogleMapsPlugin extends GoogleMapsFlutterPlatform { _mapById[creationId] = mapController; - mapController.events - .whereType() - .first - .then((WebMapReadyEvent event) { - assert(creationId == event.mapId, - 'Received WebMapReadyEvent for the wrong map'); + mapController.events.whereType().first.then(( + WebMapReadyEvent event, + ) { + assert( + creationId == event.mapId, + 'Received WebMapReadyEvent for the wrong map', + ); // Notify the plugin now that there's a fully initialized controller. onPlatformViewCreated.call(event.mapId); }); - assert(mapController.widget != null, - 'The widget of a GoogleMapController cannot be null before calling dispose on it.'); + assert( + mapController.widget != null, + 'The widget of a GoogleMapController cannot be null before calling dispose on it.', + ); return mapController.widget!; } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_inspector_web.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_inspector_web.dart index d5a23c434a2..8adcbdf2419 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_inspector_web.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/google_maps_inspector_web.dart @@ -15,12 +15,12 @@ import 'marker_clustering.dart'; typedef ConfigurationProvider = MapConfiguration Function(int mapId); /// Function that gets the [ClusterManagersController] for a given `mapId`. -typedef ClusterManagersControllerProvider = ClusterManagersController? Function( - int mapId); +typedef ClusterManagersControllerProvider = + ClusterManagersController? Function(int mapId); /// Function that gets the [GroundOverlaysController] for a given `mapId`. -typedef GroundOverlaysControllerProvider = GroundOverlaysController? Function( - int mapId); +typedef GroundOverlaysControllerProvider = + GroundOverlaysController? Function(int mapId); /// This platform implementation allows inspecting the running maps. class GoogleMapsInspectorWeb extends GoogleMapsInspectorPlatform { @@ -29,9 +29,9 @@ class GoogleMapsInspectorWeb extends GoogleMapsInspectorPlatform { ConfigurationProvider configurationProvider, ClusterManagersControllerProvider clusterManagersControllerProvider, GroundOverlaysControllerProvider groundOverlaysControllerProvider, - ) : _configurationProvider = configurationProvider, - _clusterManagersControllerProvider = clusterManagersControllerProvider, - _groundOverlaysControllerProvider = groundOverlaysControllerProvider; + ) : _configurationProvider = configurationProvider, + _clusterManagersControllerProvider = clusterManagersControllerProvider, + _groundOverlaysControllerProvider = groundOverlaysControllerProvider; final ConfigurationProvider _configurationProvider; final ClusterManagersControllerProvider _clusterManagersControllerProvider; @@ -87,11 +87,14 @@ class GoogleMapsInspectorWeb extends GoogleMapsInspectorPlatform { bool supportsGettingGroundOverlayInfo() => true; @override - Future getGroundOverlayInfo(GroundOverlayId groundOverlayId, - {required int mapId}) async { + Future getGroundOverlayInfo( + GroundOverlayId groundOverlayId, { + required int mapId, + }) async { final gmaps.GroundOverlay? groundOverlay = - _groundOverlaysControllerProvider(mapId)! - .getGroundOverlay(groundOverlayId); + _groundOverlaysControllerProvider( + mapId, + )!.getGroundOverlay(groundOverlayId); if (groundOverlay == null) { return null; @@ -100,15 +103,16 @@ class GoogleMapsInspectorWeb extends GoogleMapsInspectorPlatform { final JSAny? clickable = groundOverlay.get('clickable'); return GroundOverlay.fromBounds( - groundOverlayId: groundOverlayId, - image: BytesMapBitmap( - Uint8List.fromList([0]), - bitmapScaling: MapBitmapScaling.none, - ), - bounds: gmLatLngBoundsTolatLngBounds(groundOverlay.bounds), - transparency: 1.0 - groundOverlay.opacity, - visible: groundOverlay.map != null, - clickable: clickable != null && (clickable as JSBoolean).toDart); + groundOverlayId: groundOverlayId, + image: BytesMapBitmap( + Uint8List.fromList([0]), + bitmapScaling: MapBitmapScaling.none, + ), + bounds: gmLatLngBoundsTolatLngBounds(groundOverlay.bounds), + transparency: 1.0 - groundOverlay.opacity, + visible: groundOverlay.map != null, + clickable: clickable != null && (clickable as JSBoolean).toDart, + ); } @override @@ -141,8 +145,9 @@ class GoogleMapsInspectorWeb extends GoogleMapsInspectorPlatform { required int mapId, required ClusterManagerId clusterManagerId, }) async { - return _clusterManagersControllerProvider(mapId) - ?.getClusters(clusterManagerId) ?? + return _clusterManagersControllerProvider( + mapId, + )?.getClusters(clusterManagerId) ?? []; } } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/ground_overlays.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/ground_overlays.dart index 4e780166333..cb9dced691e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/ground_overlays.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/ground_overlays.dart @@ -12,12 +12,12 @@ class GroundOverlaysController extends GeometryController { /// emitting ground overlay tap events. GroundOverlaysController({ required StreamController> stream, - }) : _streamController = stream, - _groundOverlayIdToController = - {}; + }) : _streamController = stream, + _groundOverlayIdToController = + {}; final Map - _groundOverlayIdToController; + _groundOverlayIdToController; // The stream over which ground overlays broadcast their events final StreamController> _streamController; @@ -30,11 +30,14 @@ class GroundOverlaysController extends GeometryController { } void _addGroundOverlay(GroundOverlay groundOverlay) { - assert(groundOverlay.bounds != null, - 'On Web platform, bounds must be provided for GroundOverlay'); + assert( + groundOverlay.bounds != null, + 'On Web platform, bounds must be provided for GroundOverlay', + ); - final gmaps.LatLngBounds bounds = - latLngBoundsToGmlatLngBounds(groundOverlay.bounds!); + final gmaps.LatLngBounds bounds = latLngBoundsToGmlatLngBounds( + groundOverlay.bounds!, + ); final gmaps.GroundOverlayOptions groundOverlayOptions = gmaps.GroundOverlayOptions() @@ -43,7 +46,10 @@ class GroundOverlaysController extends GeometryController { ..map = groundOverlay.visible ? googleMap : null; final gmaps.GroundOverlay overlay = gmaps.GroundOverlay( - urlFromMapBitmap(groundOverlay.image), bounds, groundOverlayOptions); + urlFromMapBitmap(groundOverlay.image), + bounds, + groundOverlayOptions, + ); final GroundOverlayController controller = GroundOverlayController( groundOverlay: overlay, @@ -68,8 +74,10 @@ class GroundOverlaysController extends GeometryController { return; } - assert(groundOverlay.bounds != null, - 'On Web platform, bounds must be provided for GroundOverlay'); + assert( + groundOverlay.bounds != null, + 'On Web platform, bounds must be provided for GroundOverlay', + ); controller.groundOverlay!.set('clickable', groundOverlay.clickable.toJS); controller.groundOverlay!.map = groundOverlay.visible ? googleMap : null; @@ -82,8 +90,8 @@ class GroundOverlaysController extends GeometryController { } void _removeGroundOverlay(GroundOverlayId groundOverlayId) { - final GroundOverlayController? controller = - _groundOverlayIdToController.remove(groundOverlayId); + final GroundOverlayController? controller = _groundOverlayIdToController + .remove(groundOverlayId); if (controller != null) { controller.remove(); } @@ -96,8 +104,8 @@ class GroundOverlaysController extends GeometryController { /// Returns the [GroundOverlay] with the given [GroundOverlayId]. /// Only used for testing. gmaps.GroundOverlay? getGroundOverlay(GroundOverlayId groundOverlayId) { - final GroundOverlayController? controller = - _groundOverlayIdToController.remove(groundOverlayId); + final GroundOverlayController? controller = _groundOverlayIdToController + .remove(groundOverlayId); return controller?.groundOverlay; } } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/heatmap.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/heatmap.dart index 1e792f44ca1..fa00e044f98 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/heatmap.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/heatmap.dart @@ -8,7 +8,7 @@ part of '../google_maps_flutter_web.dart'; class HeatmapController { /// Creates a `HeatmapController`, which wraps a [visualization.HeatmapLayer] object and its `onTap` behavior. HeatmapController({required visualization.HeatmapLayer heatmap}) - : _heatmap = heatmap; + : _heatmap = heatmap; visualization.HeatmapLayer? _heatmap; diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/heatmaps.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/heatmaps.dart index 2d235515a29..eea429a9084 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/heatmaps.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/heatmaps.dart @@ -8,7 +8,7 @@ part of '../google_maps_flutter_web.dart'; class HeatmapsController extends GeometryController { /// Initialize the cache HeatmapsController() - : _heatmapIdToController = {}; + : _heatmapIdToController = {}; // A cache of [HeatmapController]s indexed by their [HeatmapId]. final Map _heatmapIdToController; @@ -27,8 +27,9 @@ class HeatmapsController extends GeometryController { void _addHeatmap(Heatmap heatmap) { final visualization.HeatmapLayerOptions heatmapOptions = _heatmapOptionsFromHeatmap(heatmap); - final visualization.HeatmapLayer gmHeatmap = - visualization.HeatmapLayer(heatmapOptions); + final visualization.HeatmapLayer gmHeatmap = visualization.HeatmapLayer( + heatmapOptions, + ); gmHeatmap.map = googleMap; final HeatmapController controller = HeatmapController(heatmap: gmHeatmap); _heatmapIdToController[heatmap.heatmapId] = controller; diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker.dart index 518dce6de77..90638e88af0 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker.dart @@ -16,10 +16,10 @@ class MarkerController { LatLngCallback? onDragEnd, VoidCallback? onTap, ClusterManagerId? clusterManagerId, - }) : _marker = marker, - _infoWindow = infoWindow, - _consumeTapEvents = consumeTapEvents, - _clusterManagerId = clusterManagerId { + }) : _marker = marker, + _infoWindow = infoWindow, + _consumeTapEvents = consumeTapEvents, + _clusterManagerId = clusterManagerId { if (onTap != null) { marker.onClick.listen((gmaps.MapMouseEvent event) { onTap.call(); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart index 8dbb4308ba6..b19142a9c16 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering.dart @@ -22,18 +22,18 @@ class ClusterManagersController extends GeometryController { /// /// The [stream] parameter is a required [StreamController] used for /// emitting map events. - ClusterManagersController( - {required StreamController> stream}) - : _streamController = stream, - _clusterManagerIdToMarkerClusterer = - {}; + ClusterManagersController({ + required StreamController> stream, + }) : _streamController = stream, + _clusterManagerIdToMarkerClusterer = + {}; // The stream over which cluster managers broadcast their events final StreamController> _streamController; // A cache of [MarkerClusterer]s indexed by their [ClusterManagerId]. final Map - _clusterManagerIdToMarkerClusterer; + _clusterManagerIdToMarkerClusterer; /// Adds a set of [ClusterManager] objects to the cache. void addClusterManagers(Set clusterManagersToAdd) { @@ -42,11 +42,14 @@ class ClusterManagersController extends GeometryController { void _addClusterManager(ClusterManager clusterManager) { final MarkerClusterer markerClusterer = createMarkerClusterer( - googleMap, - (gmaps.MapMouseEvent event, MarkerClustererCluster cluster, - gmaps.Map map) => - _clusterClicked( - clusterManager.clusterManagerId, event, cluster, map)); + googleMap, + ( + gmaps.MapMouseEvent event, + MarkerClustererCluster cluster, + gmaps.Map map, + ) => + _clusterClicked(clusterManager.clusterManagerId, event, cluster, map), + ); _clusterManagerIdToMarkerClusterer[clusterManager.clusterManagerId] = markerClusterer; @@ -99,37 +102,48 @@ class ClusterManagersController extends GeometryController { _clusterManagerIdToMarkerClusterer[clusterManagerId]; if (markerClusterer != null) { return markerClusterer.clusters - .map((MarkerClustererCluster cluster) => - _convertCluster(clusterManagerId, cluster)) + .map( + (MarkerClustererCluster cluster) => + _convertCluster(clusterManagerId, cluster), + ) .toList(); } return []; } void _clusterClicked( - ClusterManagerId clusterManagerId, - gmaps.MapMouseEvent event, - MarkerClustererCluster markerClustererCluster, - gmaps.Map map) { + ClusterManagerId clusterManagerId, + gmaps.MapMouseEvent event, + MarkerClustererCluster markerClustererCluster, + gmaps.Map map, + ) { if (markerClustererCluster.count > 0 && markerClustererCluster.bounds != null) { - final Cluster cluster = - _convertCluster(clusterManagerId, markerClustererCluster); + final Cluster cluster = _convertCluster( + clusterManagerId, + markerClustererCluster, + ); _streamController.add(ClusterTapEvent(mapId, cluster)); } } /// Converts [MarkerClustererCluster] to [Cluster]. - Cluster _convertCluster(ClusterManagerId clusterManagerId, - MarkerClustererCluster markerClustererCluster) { + Cluster _convertCluster( + ClusterManagerId clusterManagerId, + MarkerClustererCluster markerClustererCluster, + ) { final LatLng position = gmLatLngToLatLng(markerClustererCluster.position); - final LatLngBounds bounds = - gmLatLngBoundsTolatLngBounds(markerClustererCluster.bounds!); + final LatLngBounds bounds = gmLatLngBoundsTolatLngBounds( + markerClustererCluster.bounds!, + ); - final List markerIds = markerClustererCluster.markers - .map((gmaps.Marker marker) => - MarkerId((marker.get('markerId')! as JSString).toDart)) - .toList(); + final List markerIds = + markerClustererCluster.markers + .map( + (gmaps.Marker marker) => + MarkerId((marker.get('markerId')! as JSString).toDart), + ) + .toList(); return Cluster( clusterManagerId, markerIds, diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering_js_interop.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering_js_interop.dart index 80e7e5fc1c1..19fca0d71e4 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering_js_interop.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/marker_clustering_js_interop.dart @@ -13,11 +13,8 @@ import 'dart:js_interop'; import 'package:google_maps/google_maps.dart' as gmaps; /// A typedef representing a callback function for handling cluster tap events. -typedef ClusterClickHandler = void Function( - gmaps.MapMouseEvent, - MarkerClustererCluster, - gmaps.Map, -); +typedef ClusterClickHandler = + void Function(gmaps.MapMouseEvent, MarkerClustererCluster, gmaps.Map); /// The [MarkerClustererOptions] object used to initialize [MarkerClusterer]. /// @@ -30,16 +27,20 @@ extension type MarkerClustererOptions._(JSObject _) implements JSObject { gmaps.Map? map, List? markers, ClusterClickHandler? onClusterClick, - }) => - MarkerClustererOptions._js( - map: map as JSAny?, - markers: markers?.cast().toJS ?? JSArray(), - onClusterClick: onClusterClick != null + }) => MarkerClustererOptions._js( + map: map as JSAny?, + markers: markers?.cast().toJS ?? JSArray(), + onClusterClick: + onClusterClick != null ? ((JSAny event, MarkerClustererCluster cluster, JSAny map) => - onClusterClick(event as gmaps.MapMouseEvent, cluster, - map as gmaps.Map)).toJS + onClusterClick( + event as gmaps.MapMouseEvent, + cluster, + map as gmaps.Map, + )) + .toJS : null, - ); + ); external factory MarkerClustererOptions._js({ JSAny? map, @@ -155,7 +156,9 @@ extension type MarkerClusterer._(JSObject _) implements JSObject { /// Creates [MarkerClusterer] object with given [gmaps.Map] and /// [ClusterClickHandler]. MarkerClusterer createMarkerClusterer( - gmaps.Map map, ClusterClickHandler onClusterClickHandler) { + gmaps.Map map, + ClusterClickHandler onClusterClickHandler, +) { final MarkerClustererOptions options = MarkerClustererOptions( map: map, onClusterClick: onClusterClickHandler, diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart index f5204403528..e528426fe06 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/markers.dart @@ -10,9 +10,9 @@ class MarkersController extends GeometryController { MarkersController({ required StreamController> stream, required ClusterManagersController clusterManagersController, - }) : _streamController = stream, - _clusterManagersController = clusterManagersController, - _markerIdToController = {}; + }) : _streamController = stream, + _clusterManagersController = clusterManagersController, + _markerIdToController = {}; // A cache of [MarkerController]s indexed by their [MarkerId]. final Map _markerIdToController; @@ -46,17 +46,20 @@ class MarkersController extends GeometryController { infoWindowOptions.content is HTMLElement) { final HTMLElement content = infoWindowOptions.content! as HTMLElement; - content.onclick = (JSAny? _) { - _onInfoWindowTap(marker.markerId); - }.toJS; + content.onclick = + (JSAny? _) { + _onInfoWindowTap(marker.markerId); + }.toJS; } } final gmaps.Marker? currentMarker = _markerIdToController[marker.markerId]?.marker; - final gmaps.MarkerOptions markerOptions = - await _markerOptionsFromMarker(marker, currentMarker); + final gmaps.MarkerOptions markerOptions = await _markerOptionsFromMarker( + marker, + currentMarker, + ); final gmaps.Marker gmMarker = gmaps.Marker(markerOptions); @@ -109,10 +112,7 @@ class MarkersController extends GeometryController { await _addMarker(marker); } else { final gmaps.MarkerOptions markerOptions = - await _markerOptionsFromMarker( - marker, - markerController.marker, - ); + await _markerOptionsFromMarker(marker, markerController.marker); final gmaps.InfoWindowOptions? infoWindow = _infoWindowOptionsFromMarker(marker); markerController.update( @@ -132,7 +132,9 @@ class MarkersController extends GeometryController { final MarkerController? markerController = _markerIdToController[markerId]; if (markerController?.clusterManagerId != null) { _clusterManagersController.removeItem( - markerController!.clusterManagerId!, markerController.marker); + markerController!.clusterManagerId!, + markerController.marker, + ); } markerController?.remove(); _markerIdToController.remove(markerId); @@ -179,35 +181,31 @@ class MarkersController extends GeometryController { } void _onMarkerDragStart(MarkerId markerId, gmaps.LatLng latLng) { - _streamController.add(MarkerDragStartEvent( - mapId, - gmLatLngToLatLng(latLng), - markerId, - )); + _streamController.add( + MarkerDragStartEvent(mapId, gmLatLngToLatLng(latLng), markerId), + ); } void _onMarkerDrag(MarkerId markerId, gmaps.LatLng latLng) { - _streamController.add(MarkerDragEvent( - mapId, - gmLatLngToLatLng(latLng), - markerId, - )); + _streamController.add( + MarkerDragEvent(mapId, gmLatLngToLatLng(latLng), markerId), + ); } void _onMarkerDragEnd(MarkerId markerId, gmaps.LatLng latLng) { - _streamController.add(MarkerDragEndEvent( - mapId, - gmLatLngToLatLng(latLng), - markerId, - )); + _streamController.add( + MarkerDragEndEvent(mapId, gmLatLngToLatLng(latLng), markerId), + ); } void _hideAllMarkerInfoWindow() { _markerIdToController.values - .where((MarkerController? controller) => - controller?.infoWindowShown ?? false) + .where( + (MarkerController? controller) => + controller?.infoWindowShown ?? false, + ) .forEach((MarkerController controller) { - controller.hideInfoWindow(); - }); + controller.hideInfoWindow(); + }); } } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlay.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlay.dart index 1b4de3e9f4c..8400ed26f64 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlay.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlay.dart @@ -7,9 +7,7 @@ part of '../google_maps_flutter_web.dart'; /// This wraps a [TileOverlay] in a [gmaps.MapType]. class TileOverlayController { /// Creates a `TileOverlayController` that wraps a [TileOverlay] object and its corresponding [gmaps.MapType]. - TileOverlayController({ - required TileOverlay tileOverlay, - }) { + TileOverlayController({required TileOverlay tileOverlay}) { update(tileOverlay); } @@ -27,9 +25,10 @@ class TileOverlayController { /// [TileOverlay]. void update(TileOverlay tileOverlay) { _tileOverlay = tileOverlay; - _gmMapType = gmaps.MapType() - ..tileSize = gmaps.Size(logicalTileSize, logicalTileSize) - ..getTile = _getTile; + _gmMapType = + gmaps.MapType() + ..tileSize = gmaps.Size(logicalTileSize, logicalTileSize) + ..getTile = _getTile; } /// Renders a Tile for gmaps; delegating to the configured [TileProvider]. @@ -51,19 +50,20 @@ class TileOverlayController { _tileOverlay.tileProvider! .getTile(tileCoord!.x.toInt(), tileCoord.y.toInt(), zoom?.toInt()) .then((Tile tile) { - if (tile.data == null) { - return; - } - // Using img lets us take advantage of native decoding. - final String src = URL.createObjectURL( - Blob([tile.data!.toJS].toJS) as JSObject, - ); - img.src = src; - img.onload = (JSAny? _) { - img.hidden = false.toJS; - URL.revokeObjectURL(src); - }.toJS; - }); + if (tile.data == null) { + return; + } + // Using img lets us take advantage of native decoding. + final String src = URL.createObjectURL( + Blob([tile.data!.toJS].toJS) as JSObject, + ); + img.src = src; + img.onload = + (JSAny? _) { + img.hidden = false.toJS; + URL.revokeObjectURL(src); + }.toJS; + }); return img; } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlays.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlays.dart index 59015a4e4b9..4651e70e950 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlays.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/overlays.dart @@ -16,8 +16,9 @@ class TileOverlaysController extends GeometryController { // After insertion, the arrays stay sorted by ascending z-index. void _insertZSorted(TileOverlayController tileOverlayController) { final int index = _visibleTileOverlays.lowerBoundBy( - tileOverlayController, - (TileOverlayController c) => c.tileOverlay.zIndex); + tileOverlayController, + (TileOverlayController c) => c.tileOverlay.zIndex, + ); googleMap.overlayMapTypes.insertAt(index, tileOverlayController.gmMapType); _visibleTileOverlays.insert(index, tileOverlayController); @@ -80,8 +81,9 @@ class TileOverlaysController extends GeometryController { } void _removeTileOverlay(TileOverlayId tileOverlayId) { - final TileOverlayController? controller = - _tileOverlays.remove(tileOverlayId); + final TileOverlayController? controller = _tileOverlays.remove( + tileOverlayId, + ); if (controller != null) { _remove(controller); } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygon.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygon.dart index e2147752d79..c38c264a269 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygon.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygon.dart @@ -11,8 +11,8 @@ class PolygonController { required gmaps.Polygon polygon, bool consumeTapEvents = false, VoidCallback? onTap, - }) : _polygon = polygon, - _consumeTapEvents = consumeTapEvents { + }) : _polygon = polygon, + _consumeTapEvents = consumeTapEvents { if (onTap != null) { polygon.onClick.listen((gmaps.PolyMouseEvent event) { onTap.call(); diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygons.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygons.dart index 708182af86f..92e8d08197a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygons.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polygons.dart @@ -7,10 +7,9 @@ part of '../google_maps_flutter_web.dart'; /// This class manages a set of [PolygonController]s associated to a [GoogleMapController]. class PolygonsController extends GeometryController { /// Initializes the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers. - PolygonsController({ - required StreamController> stream, - }) : _streamController = stream, - _polygonIdToController = {}; + PolygonsController({required StreamController> stream}) + : _streamController = stream, + _polygonIdToController = {}; // A cache of [PolygonController]s indexed by their [PolygonId]. final Map _polygonIdToController; @@ -30,16 +29,19 @@ class PolygonsController extends GeometryController { } void _addPolygon(Polygon polygon) { - final gmaps.PolygonOptions polygonOptions = - _polygonOptionsFromPolygon(googleMap, polygon); + final gmaps.PolygonOptions polygonOptions = _polygonOptionsFromPolygon( + googleMap, + polygon, + ); final gmaps.Polygon gmPolygon = gmaps.Polygon(polygonOptions) ..map = googleMap; final PolygonController controller = PolygonController( - polygon: gmPolygon, - consumeTapEvents: polygon.consumeTapEvents, - onTap: () { - _onPolygonTap(polygon.polygonId); - }); + polygon: gmPolygon, + consumeTapEvents: polygon.consumeTapEvents, + onTap: () { + _onPolygonTap(polygon.polygonId); + }, + ); _polygonIdToController[polygon.polygonId] = controller; } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polyline.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polyline.dart index 04c20d85c6f..bc51f67592a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polyline.dart @@ -11,8 +11,8 @@ class PolylineController { required gmaps.Polyline polyline, bool consumeTapEvents = false, VoidCallback? onTap, - }) : _polyline = polyline, - _consumeTapEvents = consumeTapEvents { + }) : _polyline = polyline, + _consumeTapEvents = consumeTapEvents { if (onTap != null) { polyline.onClick.listen((gmaps.PolyMouseEvent event) { onTap.call(); @@ -36,7 +36,9 @@ class PolylineController { /// This cannot be called after [remove]. void update(gmaps.PolylineOptions options) { assert( - _polyline != null, 'Cannot `update` Polyline after calling `remove`.'); + _polyline != null, + 'Cannot `update` Polyline after calling `remove`.', + ); _polyline!.options = options; } diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polylines.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polylines.dart index 52c8c79a6b4..d1d83361609 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polylines.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/polylines.dart @@ -7,10 +7,9 @@ part of '../google_maps_flutter_web.dart'; /// This class manages a set of [PolylinesController]s associated to a [GoogleMapController]. class PolylinesController extends GeometryController { /// Initializes the cache. The [StreamController] comes from the [GoogleMapController], and is shared with other controllers. - PolylinesController({ - required StreamController> stream, - }) : _streamController = stream, - _polylineIdToController = {}; + PolylinesController({required StreamController> stream}) + : _streamController = stream, + _polylineIdToController = {}; // A cache of [PolylineController]s indexed by their [PolylineId]. final Map _polylineIdToController; @@ -30,16 +29,19 @@ class PolylinesController extends GeometryController { } void _addPolyline(Polyline polyline) { - final gmaps.PolylineOptions polylineOptions = - _polylineOptionsFromPolyline(googleMap, polyline); + final gmaps.PolylineOptions polylineOptions = _polylineOptionsFromPolyline( + googleMap, + polyline, + ); final gmaps.Polyline gmPolyline = gmaps.Polyline(polylineOptions) ..map = googleMap; final PolylineController controller = PolylineController( - polyline: gmPolyline, - consumeTapEvents: polyline.consumeTapEvents, - onTap: () { - _onPolylineTap(polyline.polylineId); - }); + polyline: gmPolyline, + consumeTapEvents: polyline.consumeTapEvents, + onTap: () { + _onPolylineTap(polyline.polylineId); + }, + ); _polylineIdToController[polyline.polylineId] = controller; } @@ -51,8 +53,9 @@ class PolylinesController extends GeometryController { void _changePolyline(Polyline polyline) { final PolylineController? polylineController = _polylineIdToController[polyline.polylineId]; - polylineController - ?.update(_polylineOptionsFromPolyline(googleMap, polyline)); + polylineController?.update( + _polylineOptionsFromPolyline(googleMap, polyline), + ); } /// Removes a set of [PolylineId]s from the cache. diff --git a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart index fc206eb6f91..da923e79215 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/lib/src/third_party/to_screen_location/to_screen_location.dart @@ -29,12 +29,18 @@ import 'package:google_maps/google_maps.dart' as gmaps; /// /// See: https://developers.google.com/maps/documentation/android-sdk/reference/com/google/android/libraries/maps/Projection#public-point-toscreenlocation-latlng-location gmaps.Point toScreenLocation(gmaps.Map map, gmaps.LatLng coords) { - assert(map.bounds != null, - 'Map Bounds required to compute screen x/y of LatLng.'); - assert(map.projection != null, - 'Map Projection required to compute screen x/y of LatLng.'); - assert(map.isZoomDefined(), - 'Current map zoom level required to compute screen x/y of LatLng.'); + assert( + map.bounds != null, + 'Map Bounds required to compute screen x/y of LatLng.', + ); + assert( + map.projection != null, + 'Map Projection required to compute screen x/y of LatLng.', + ); + assert( + map.isZoomDefined(), + 'Current map zoom level required to compute screen x/y of LatLng.', + ); final gmaps.LatLngBounds bounds = map.bounds!; final gmaps.Projection projection = map.projection!; diff --git a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml index 195cce79784..c6a25ab308a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_web/pubspec.yaml @@ -5,8 +5,8 @@ issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+ version: 0.5.12+2 environment: - sdk: ^3.6.0 - flutter: ">=3.27.0" + sdk: ^3.7.0 + flutter: ">=3.29.0" flutter: plugin: