From 5b85941af6a7c020fd2af672350b35777050622d Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 19 Nov 2025 16:17:03 -0500 Subject: [PATCH 1/5] [google_maps_flutter] Replace deprecated APIs This fixes two sets of API deprecations: - Within the package, cloudMapId was deprecated in the platform interface, and replaced with mapId. This updates everything that's not client-facing to use the mapId name instead (except for local variables in native code, where it ensure there's no potential confusion with the plugin-level map ID that tracks map instances in the plugin). - `Color.value` is deprecated. Rather than just replace it with `toARGB()`, this adds structured data to the Pigeon interface, so that it's not relying on magic knowledge on both sides of the interface that the ints are ARGB: - On Android, where the native SDK color representation is just a 32-bit ARGB, this adds a wrapper class to make that explicit in the Pigeon API surface. - On iOS, where `UIColor` uses four doubles, this passes the underlying `Color` doubles directly via the wrapper class, so that it's not lossy. - For legacy JSON representations, it continues to use the equivalent `toARGB()` directly, since it must remain compatible. This also annotates a couple of intentional internal uses of the deprecated `legacy` renderer type so that it won't show up in future repository deprecation audits. Also pays down some tech debt by renaming the now-very-poorly-named FLTGoogleMapJSONConversions.* file to FGMConversionUtils, since it is now mostly Pigeon type conversions. It also renames the legacy FLTGoogleMapJSONConversions bag-of-class-methods class to reflect that it is now only used for heatmaps, the last type that still uses JSON serialization in the Pigeon interface (https://github.com/flutter/flutter/issues/117907). Part of https://github.com/flutter/flutter/issues/159739 --- .../google_maps_flutter/CHANGELOG.md | 3 +- .../example/lib/map_map_id.dart | 1 + .../lib/src/google_map.dart | 2 +- .../google_maps_flutter/pubspec.yaml | 2 +- .../google_maps_flutter_android/CHANGELOG.md | 4 + .../flutter/plugins/googlemaps/Convert.java | 10 +- .../plugins/googlemaps/GoogleMapFactory.java | 2 +- .../flutter/plugins/googlemaps/Messages.java | 268 +++++++++++------- .../googlemaps/CirclesControllerTest.java | 4 +- .../integration_test/google_maps_test.dart | 5 +- .../example/lib/example_google_map.dart | 6 +- .../example/lib/map_map_id.dart | 3 +- .../lib/src/google_maps_flutter_android.dart | 17 +- .../lib/src/messages.g.dart | 177 +++++++----- .../lib/src/serialization.dart | 4 +- .../pigeons/messages.dart | 27 +- .../google_maps_flutter_android/pubspec.yaml | 2 +- .../google_maps_flutter_android_test.dart | 31 +- .../google_maps_flutter_ios/CHANGELOG.md | 4 + .../integration_test/google_maps_test.dart | 2 +- .../ios14/ios/Flutter/AppFrameworkInfo.plist | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 10 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 + ...sionTests.m => FGMConversionsUtilsTests.m} | 21 +- .../GoogleMapsCircleControllerTests.m | 10 +- .../GoogleMapsPolygonControllerTests.m | 27 +- .../GoogleMapsPolylineControllerTests.m | 32 ++- .../lib/example_google_map.dart | 6 +- .../maps_example_dart/lib/map_map_id.dart | 2 +- .../Classes/FGMClusterManagersController.m | 2 +- ...JSONConversions.h => FGMConversionUtils.h} | 7 +- ...JSONConversions.m => FGMConversionUtils.m} | 30 +- .../ios/Classes/FGMGroundOverlayController.m | 2 +- .../Classes/FLTGoogleMapHeatmapController.m | 11 +- .../FLTGoogleMapTileOverlayController.m | 2 +- .../ios/Classes/GoogleMapCircleController.m | 6 +- .../ios/Classes/GoogleMapController.m | 4 +- .../ios/Classes/GoogleMapMarkerController.m | 2 +- .../ios/Classes/GoogleMapPolygonController.m | 6 +- .../ios/Classes/GoogleMapPolylineController.m | 4 +- .../google_maps_flutter_ios-umbrella.h | 2 +- .../ios/Classes/messages.g.h | 36 ++- .../ios/Classes/messages.g.m | 113 +++++--- .../lib/src/google_maps_flutter_ios.dart | 42 ++- .../lib/src/messages.g.dart | 123 +++++--- .../lib/src/serialization.dart | 6 +- .../pigeons/messages.dart | 33 ++- .../google_maps_flutter_ios/pubspec.yaml | 2 +- .../test/google_maps_flutter_ios_test.dart | 29 +- .../lib/src/method_channel/serialization.dart | 4 +- .../lib/src/types/bitmap.dart | 9 +- .../lib/src/types/circle.dart | 4 +- .../lib/src/types/heatmap.dart | 2 +- .../lib/src/types/polygon.dart | 4 +- .../lib/src/types/polyline.dart | 2 +- .../test/types/bitmap_test.dart | 17 +- .../test/types/heatmap_test.dart | 2 +- 57 files changed, 761 insertions(+), 431 deletions(-) rename packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/{FLTGoogleMapJSONConversionsConversionTests.m => FGMConversionsUtilsTests.m} (95%) rename packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/{FLTGoogleMapJSONConversions.h => FGMConversionUtils.h} (94%) rename packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/{FLTGoogleMapJSONConversions.m => FGMConversionUtils.m} (95%) diff --git a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md index 64bc5dc7a8b2..2386feeee9d1 100644 --- a/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md +++ b/packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md @@ -1,5 +1,6 @@ -## NEXT +## 2.14.1 +* Replaces internal use of deprecated methods. * Updates minimum supported SDK version to Flutter 3.32/Dart 3.8. ## 2.14.0 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 d9befb15a880..362cbea31de1 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 @@ -54,6 +54,7 @@ class MapIdBodyState extends State { switch (_initializedRenderer) { case AndroidMapRenderer.latest: return 'latest'; + // ignore: deprecated_member_use case AndroidMapRenderer.legacy: return 'legacy'; case AndroidMapRenderer.platformDefault: 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 44f6dd5d8129..627efae290de 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 @@ -723,7 +723,7 @@ MapConfiguration _configurationFromMapWidget(GoogleMap map) { indoorViewEnabled: map.indoorViewEnabled, trafficEnabled: map.trafficEnabled, buildingsEnabled: map.buildingsEnabled, - cloudMapId: map.cloudMapId, + mapId: map.cloudMapId, // A null style in the widget means no style, which is expressed as '' in // the configuration to distinguish from no change (null). style: map.style ?? '', diff --git a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml index 7f16bf9fb631..d928fb3b21f5 100644 --- a/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter description: A Flutter plugin for integrating Google Maps in iOS and Android applications. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.14.0 +version: 2.14.1 environment: sdk: ^3.8.0 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 d7d88983c3e9..6c42bdb8a51a 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 @@ +## 2.18.6 + +* Replaces internal use of deprecated methods. + ## 2.18.5 * Updates to Pigeon 26. diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java index 871f1eb24d73..44765122a1fb 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java @@ -627,8 +627,8 @@ static String interpretPolygonOptions(Messages.PlatformPolygon polygon, PolygonO sink.setConsumeTapEvents(polygon.getConsumesTapEvents()); sink.setGeodesic(polygon.getGeodesic()); sink.setVisible(polygon.getVisible()); - sink.setFillColor(polygon.getFillColor().intValue()); - sink.setStrokeColor(polygon.getStrokeColor().intValue()); + sink.setFillColor(polygon.getFillColor().getArgbValue().intValue()); + sink.setStrokeColor(polygon.getStrokeColor().getArgbValue().intValue()); sink.setStrokeWidth(polygon.getStrokeWidth()); sink.setZIndex(polygon.getZIndex()); sink.setPoints(pointsFromPigeon(polygon.getPoints())); @@ -654,7 +654,7 @@ static String interpretPolylineOptions( AssetManager assetManager, float density) { sink.setConsumeTapEvents(polyline.getConsumesTapEvents()); - sink.setColor(polyline.getColor().intValue()); + sink.setColor(polyline.getColor().getArgbValue().intValue()); sink.setEndCap(capFromPigeon(polyline.getEndCap(), assetManager, density)); sink.setStartCap(capFromPigeon(polyline.getStartCap(), assetManager, density)); sink.setGeodesic(polyline.getGeodesic()); @@ -669,8 +669,8 @@ static String interpretPolylineOptions( static String interpretCircleOptions(Messages.PlatformCircle circle, CircleOptionsSink sink) { sink.setConsumeTapEvents(circle.getConsumeTapEvents()); - sink.setFillColor(circle.getFillColor().intValue()); - sink.setStrokeColor(circle.getStrokeColor().intValue()); + sink.setFillColor(circle.getFillColor().getArgbValue().intValue()); + sink.setStrokeColor(circle.getStrokeColor().getArgbValue().intValue()); sink.setStrokeWidth(circle.getStrokeWidth()); sink.setZIndex(circle.getZIndex().floatValue()); sink.setCenter(toLatLng(circle.getCenter().toList())); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java index a0a25948efd8..0cd2c6920f2c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java @@ -48,7 +48,7 @@ public PlatformView create(@NonNull Context context, int id, @Nullable Object ar builder.setInitialTileOverlays(params.getInitialTileOverlays()); builder.setInitialGroundOverlays(params.getInitialGroundOverlays()); - final String cloudMapId = mapConfig.getCloudMapId(); + final String cloudMapId = mapConfig.getMapId(); if (cloudMapId != null) { builder.setMapId(cloudMapId); } diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java index 8507c6de157a..d37e4854fbab 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Messages.java @@ -1074,26 +1074,26 @@ public void setConsumeTapEvents(@NonNull Boolean setterArg) { this.consumeTapEvents = setterArg; } - private @NonNull Long fillColor; + private @NonNull PlatformColor fillColor; - public @NonNull Long getFillColor() { + public @NonNull PlatformColor getFillColor() { return fillColor; } - public void setFillColor(@NonNull Long setterArg) { + public void setFillColor(@NonNull PlatformColor setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"fillColor\" is null."); } this.fillColor = setterArg; } - private @NonNull Long strokeColor; + private @NonNull PlatformColor strokeColor; - public @NonNull Long getStrokeColor() { + public @NonNull PlatformColor getStrokeColor() { return strokeColor; } - public void setStrokeColor(@NonNull Long setterArg) { + public void setStrokeColor(@NonNull PlatformColor setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"strokeColor\" is null."); } @@ -1225,18 +1225,18 @@ public static final class Builder { return this; } - private @Nullable Long fillColor; + private @Nullable PlatformColor fillColor; @CanIgnoreReturnValue - public @NonNull Builder setFillColor(@NonNull Long setterArg) { + public @NonNull Builder setFillColor(@NonNull PlatformColor setterArg) { this.fillColor = setterArg; return this; } - private @Nullable Long strokeColor; + private @Nullable PlatformColor strokeColor; @CanIgnoreReturnValue - public @NonNull Builder setStrokeColor(@NonNull Long setterArg) { + public @NonNull Builder setStrokeColor(@NonNull PlatformColor setterArg) { this.strokeColor = setterArg; return this; } @@ -1324,9 +1324,9 @@ ArrayList toList() { Object consumeTapEvents = pigeonVar_list.get(0); pigeonResult.setConsumeTapEvents((Boolean) consumeTapEvents); Object fillColor = pigeonVar_list.get(1); - pigeonResult.setFillColor((Long) fillColor); + pigeonResult.setFillColor((PlatformColor) fillColor); Object strokeColor = pigeonVar_list.get(2); - pigeonResult.setStrokeColor((Long) strokeColor); + pigeonResult.setStrokeColor((PlatformColor) strokeColor); Object visible = pigeonVar_list.get(3); pigeonResult.setVisible((Boolean) visible); Object strokeWidth = pigeonVar_list.get(4); @@ -1585,6 +1585,79 @@ ArrayList toList() { } } + /** + * Pigeon equivalent of the Color class. + * + *

See https://developer.android.com/reference/android/graphics/Color.html. + * + *

Generated class from Pigeon that represents data sent in messages. + */ + public static final class PlatformColor { + private @NonNull Long argbValue; + + public @NonNull Long getArgbValue() { + return argbValue; + } + + public void setArgbValue(@NonNull Long setterArg) { + if (setterArg == null) { + throw new IllegalStateException("Nonnull field \"argbValue\" is null."); + } + this.argbValue = setterArg; + } + + /** Constructor is non-public to enforce null safety; use Builder. */ + PlatformColor() {} + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + PlatformColor that = (PlatformColor) o; + return argbValue.equals(that.argbValue); + } + + @Override + public int hashCode() { + return Objects.hash(argbValue); + } + + public static final class Builder { + + private @Nullable Long argbValue; + + @CanIgnoreReturnValue + public @NonNull Builder setArgbValue(@NonNull Long setterArg) { + this.argbValue = setterArg; + return this; + } + + public @NonNull PlatformColor build() { + PlatformColor pigeonReturn = new PlatformColor(); + pigeonReturn.setArgbValue(argbValue); + return pigeonReturn; + } + } + + @NonNull + ArrayList toList() { + ArrayList toListResult = new ArrayList<>(1); + toListResult.add(argbValue); + return toListResult; + } + + static @NonNull PlatformColor fromList(@NonNull ArrayList pigeonVar_list) { + PlatformColor pigeonResult = new PlatformColor(); + Object argbValue = pigeonVar_list.get(0); + pigeonResult.setArgbValue((Long) argbValue); + return pigeonResult; + } + } + /** * Pigeon equivalent of the InfoWindow class. * @@ -2127,13 +2200,13 @@ public void setConsumesTapEvents(@NonNull Boolean setterArg) { this.consumesTapEvents = setterArg; } - private @NonNull Long fillColor; + private @NonNull PlatformColor fillColor; - public @NonNull Long getFillColor() { + public @NonNull PlatformColor getFillColor() { return fillColor; } - public void setFillColor(@NonNull Long setterArg) { + public void setFillColor(@NonNull PlatformColor setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"fillColor\" is null."); } @@ -2192,13 +2265,13 @@ public void setVisible(@NonNull Boolean setterArg) { this.visible = setterArg; } - private @NonNull Long strokeColor; + private @NonNull PlatformColor strokeColor; - public @NonNull Long getStrokeColor() { + public @NonNull PlatformColor getStrokeColor() { return strokeColor; } - public void setStrokeColor(@NonNull Long setterArg) { + public void setStrokeColor(@NonNull PlatformColor setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"strokeColor\" is null."); } @@ -2288,10 +2361,10 @@ public static final class Builder { return this; } - private @Nullable Long fillColor; + private @Nullable PlatformColor fillColor; @CanIgnoreReturnValue - public @NonNull Builder setFillColor(@NonNull Long setterArg) { + public @NonNull Builder setFillColor(@NonNull PlatformColor setterArg) { this.fillColor = setterArg; return this; } @@ -2328,10 +2401,10 @@ public static final class Builder { return this; } - private @Nullable Long strokeColor; + private @Nullable PlatformColor strokeColor; @CanIgnoreReturnValue - public @NonNull Builder setStrokeColor(@NonNull Long setterArg) { + public @NonNull Builder setStrokeColor(@NonNull PlatformColor setterArg) { this.strokeColor = setterArg; return this; } @@ -2391,7 +2464,7 @@ ArrayList toList() { Object consumesTapEvents = pigeonVar_list.get(1); pigeonResult.setConsumesTapEvents((Boolean) consumesTapEvents); Object fillColor = pigeonVar_list.get(2); - pigeonResult.setFillColor((Long) fillColor); + pigeonResult.setFillColor((PlatformColor) fillColor); Object geodesic = pigeonVar_list.get(3); pigeonResult.setGeodesic((Boolean) geodesic); Object points = pigeonVar_list.get(4); @@ -2401,7 +2474,7 @@ ArrayList toList() { Object visible = pigeonVar_list.get(6); pigeonResult.setVisible((Boolean) visible); Object strokeColor = pigeonVar_list.get(7); - pigeonResult.setStrokeColor((Long) strokeColor); + pigeonResult.setStrokeColor((PlatformColor) strokeColor); Object strokeWidth = pigeonVar_list.get(8); pigeonResult.setStrokeWidth((Long) strokeWidth); Object zIndex = pigeonVar_list.get(9); @@ -2442,13 +2515,13 @@ public void setConsumesTapEvents(@NonNull Boolean setterArg) { this.consumesTapEvents = setterArg; } - private @NonNull Long color; + private @NonNull PlatformColor color; - public @NonNull Long getColor() { + public @NonNull PlatformColor getColor() { return color; } - public void setColor(@NonNull Long setterArg) { + public void setColor(@NonNull PlatformColor setterArg) { if (setterArg == null) { throw new IllegalStateException("Nonnull field \"color\" is null."); } @@ -2639,10 +2712,10 @@ public static final class Builder { return this; } - private @Nullable Long color; + private @Nullable PlatformColor color; @CanIgnoreReturnValue - public @NonNull Builder setColor(@NonNull Long setterArg) { + public @NonNull Builder setColor(@NonNull PlatformColor setterArg) { this.color = setterArg; return this; } @@ -2762,7 +2835,7 @@ ArrayList toList() { Object consumesTapEvents = pigeonVar_list.get(1); pigeonResult.setConsumesTapEvents((Boolean) consumesTapEvents); Object color = pigeonVar_list.get(2); - pigeonResult.setColor((Long) color); + pigeonResult.setColor((PlatformColor) color); Object geodesic = pigeonVar_list.get(3); pigeonResult.setGeodesic((Boolean) geodesic); Object jointType = pigeonVar_list.get(4); @@ -4735,14 +4808,14 @@ public void setLiteModeEnabled(@Nullable Boolean setterArg) { this.liteModeEnabled = setterArg; } - private @Nullable String cloudMapId; + private @Nullable String mapId; - public @Nullable String getCloudMapId() { - return cloudMapId; + public @Nullable String getMapId() { + return mapId; } - public void setCloudMapId(@Nullable String setterArg) { - this.cloudMapId = setterArg; + public void setMapId(@Nullable String setterArg) { + this.mapId = setterArg; } private @Nullable String style; @@ -4782,7 +4855,7 @@ public boolean equals(Object o) { && Objects.equals(trafficEnabled, that.trafficEnabled) && Objects.equals(buildingsEnabled, that.buildingsEnabled) && Objects.equals(liteModeEnabled, that.liteModeEnabled) - && Objects.equals(cloudMapId, that.cloudMapId) + && Objects.equals(mapId, that.mapId) && Objects.equals(style, that.style); } @@ -4807,7 +4880,7 @@ public int hashCode() { trafficEnabled, buildingsEnabled, liteModeEnabled, - cloudMapId, + mapId, style); } @@ -4958,11 +5031,11 @@ public static final class Builder { return this; } - private @Nullable String cloudMapId; + private @Nullable String mapId; @CanIgnoreReturnValue - public @NonNull Builder setCloudMapId(@Nullable String setterArg) { - this.cloudMapId = setterArg; + public @NonNull Builder setMapId(@Nullable String setterArg) { + this.mapId = setterArg; return this; } @@ -4994,7 +5067,7 @@ public static final class Builder { pigeonReturn.setTrafficEnabled(trafficEnabled); pigeonReturn.setBuildingsEnabled(buildingsEnabled); pigeonReturn.setLiteModeEnabled(liteModeEnabled); - pigeonReturn.setCloudMapId(cloudMapId); + pigeonReturn.setMapId(mapId); pigeonReturn.setStyle(style); return pigeonReturn; } @@ -5021,7 +5094,7 @@ ArrayList toList() { toListResult.add(trafficEnabled); toListResult.add(buildingsEnabled); toListResult.add(liteModeEnabled); - toListResult.add(cloudMapId); + toListResult.add(mapId); toListResult.add(style); return toListResult; } @@ -5064,8 +5137,8 @@ ArrayList toList() { pigeonResult.setBuildingsEnabled((Boolean) buildingsEnabled); Object liteModeEnabled = pigeonVar_list.get(17); pigeonResult.setLiteModeEnabled((Boolean) liteModeEnabled); - Object cloudMapId = pigeonVar_list.get(18); - pigeonResult.setCloudMapId((String) cloudMapId); + Object mapId = pigeonVar_list.get(18); + pigeonResult.setMapId((String) mapId); Object style = pigeonVar_list.get(19); pigeonResult.setStyle((String) style); return pigeonResult; @@ -6275,56 +6348,58 @@ protected Object readValueOfType(byte type, @NonNull ByteBuffer buffer) { case (byte) 148: return PlatformDoublePair.fromList((ArrayList) readValue(buffer)); case (byte) 149: - return PlatformInfoWindow.fromList((ArrayList) readValue(buffer)); + return PlatformColor.fromList((ArrayList) readValue(buffer)); case (byte) 150: - return PlatformMarker.fromList((ArrayList) readValue(buffer)); + return PlatformInfoWindow.fromList((ArrayList) readValue(buffer)); case (byte) 151: - return PlatformPolygon.fromList((ArrayList) readValue(buffer)); + return PlatformMarker.fromList((ArrayList) readValue(buffer)); case (byte) 152: - return PlatformPolyline.fromList((ArrayList) readValue(buffer)); + return PlatformPolygon.fromList((ArrayList) readValue(buffer)); case (byte) 153: - return PlatformCap.fromList((ArrayList) readValue(buffer)); + return PlatformPolyline.fromList((ArrayList) readValue(buffer)); case (byte) 154: - return PlatformPatternItem.fromList((ArrayList) readValue(buffer)); + return PlatformCap.fromList((ArrayList) readValue(buffer)); case (byte) 155: - return PlatformTile.fromList((ArrayList) readValue(buffer)); + return PlatformPatternItem.fromList((ArrayList) readValue(buffer)); case (byte) 156: - return PlatformTileOverlay.fromList((ArrayList) readValue(buffer)); + return PlatformTile.fromList((ArrayList) readValue(buffer)); case (byte) 157: - return PlatformEdgeInsets.fromList((ArrayList) readValue(buffer)); + return PlatformTileOverlay.fromList((ArrayList) readValue(buffer)); case (byte) 158: - return PlatformLatLng.fromList((ArrayList) readValue(buffer)); + return PlatformEdgeInsets.fromList((ArrayList) readValue(buffer)); case (byte) 159: - return PlatformLatLngBounds.fromList((ArrayList) readValue(buffer)); + return PlatformLatLng.fromList((ArrayList) readValue(buffer)); case (byte) 160: - return PlatformCluster.fromList((ArrayList) readValue(buffer)); + return PlatformLatLngBounds.fromList((ArrayList) readValue(buffer)); case (byte) 161: - return PlatformGroundOverlay.fromList((ArrayList) readValue(buffer)); + return PlatformCluster.fromList((ArrayList) readValue(buffer)); case (byte) 162: - return PlatformCameraTargetBounds.fromList((ArrayList) readValue(buffer)); + return PlatformGroundOverlay.fromList((ArrayList) readValue(buffer)); case (byte) 163: - return PlatformMapViewCreationParams.fromList((ArrayList) readValue(buffer)); + return PlatformCameraTargetBounds.fromList((ArrayList) readValue(buffer)); case (byte) 164: - return PlatformMapConfiguration.fromList((ArrayList) readValue(buffer)); + return PlatformMapViewCreationParams.fromList((ArrayList) readValue(buffer)); case (byte) 165: - return PlatformPoint.fromList((ArrayList) readValue(buffer)); + return PlatformMapConfiguration.fromList((ArrayList) readValue(buffer)); case (byte) 166: - return PlatformTileLayer.fromList((ArrayList) readValue(buffer)); + return PlatformPoint.fromList((ArrayList) readValue(buffer)); case (byte) 167: - return PlatformZoomRange.fromList((ArrayList) readValue(buffer)); + return PlatformTileLayer.fromList((ArrayList) readValue(buffer)); case (byte) 168: - return PlatformBitmap.fromList((ArrayList) readValue(buffer)); + return PlatformZoomRange.fromList((ArrayList) readValue(buffer)); case (byte) 169: - return PlatformBitmapDefaultMarker.fromList((ArrayList) readValue(buffer)); + return PlatformBitmap.fromList((ArrayList) readValue(buffer)); case (byte) 170: - return PlatformBitmapBytes.fromList((ArrayList) readValue(buffer)); + return PlatformBitmapDefaultMarker.fromList((ArrayList) readValue(buffer)); case (byte) 171: - return PlatformBitmapAsset.fromList((ArrayList) readValue(buffer)); + return PlatformBitmapBytes.fromList((ArrayList) readValue(buffer)); case (byte) 172: - return PlatformBitmapAssetImage.fromList((ArrayList) readValue(buffer)); + return PlatformBitmapAsset.fromList((ArrayList) readValue(buffer)); case (byte) 173: - return PlatformBitmapAssetMap.fromList((ArrayList) readValue(buffer)); + return PlatformBitmapAssetImage.fromList((ArrayList) readValue(buffer)); case (byte) 174: + return PlatformBitmapAssetMap.fromList((ArrayList) readValue(buffer)); + case (byte) 175: return PlatformBitmapBytesMap.fromList((ArrayList) readValue(buffer)); default: return super.readValueOfType(type, buffer); @@ -6393,83 +6468,86 @@ protected void writeValue(@NonNull ByteArrayOutputStream stream, Object value) { } else if (value instanceof PlatformDoublePair) { stream.write(148); writeValue(stream, ((PlatformDoublePair) value).toList()); - } else if (value instanceof PlatformInfoWindow) { + } else if (value instanceof PlatformColor) { stream.write(149); + writeValue(stream, ((PlatformColor) value).toList()); + } else if (value instanceof PlatformInfoWindow) { + stream.write(150); writeValue(stream, ((PlatformInfoWindow) value).toList()); } else if (value instanceof PlatformMarker) { - stream.write(150); + stream.write(151); writeValue(stream, ((PlatformMarker) value).toList()); } else if (value instanceof PlatformPolygon) { - stream.write(151); + stream.write(152); writeValue(stream, ((PlatformPolygon) value).toList()); } else if (value instanceof PlatformPolyline) { - stream.write(152); + stream.write(153); writeValue(stream, ((PlatformPolyline) value).toList()); } else if (value instanceof PlatformCap) { - stream.write(153); + stream.write(154); writeValue(stream, ((PlatformCap) value).toList()); } else if (value instanceof PlatformPatternItem) { - stream.write(154); + stream.write(155); writeValue(stream, ((PlatformPatternItem) value).toList()); } else if (value instanceof PlatformTile) { - stream.write(155); + stream.write(156); writeValue(stream, ((PlatformTile) value).toList()); } else if (value instanceof PlatformTileOverlay) { - stream.write(156); + stream.write(157); writeValue(stream, ((PlatformTileOverlay) value).toList()); } else if (value instanceof PlatformEdgeInsets) { - stream.write(157); + stream.write(158); writeValue(stream, ((PlatformEdgeInsets) value).toList()); } else if (value instanceof PlatformLatLng) { - stream.write(158); + stream.write(159); writeValue(stream, ((PlatformLatLng) value).toList()); } else if (value instanceof PlatformLatLngBounds) { - stream.write(159); + stream.write(160); writeValue(stream, ((PlatformLatLngBounds) value).toList()); } else if (value instanceof PlatformCluster) { - stream.write(160); + stream.write(161); writeValue(stream, ((PlatformCluster) value).toList()); } else if (value instanceof PlatformGroundOverlay) { - stream.write(161); + stream.write(162); writeValue(stream, ((PlatformGroundOverlay) value).toList()); } else if (value instanceof PlatformCameraTargetBounds) { - stream.write(162); + stream.write(163); writeValue(stream, ((PlatformCameraTargetBounds) value).toList()); } else if (value instanceof PlatformMapViewCreationParams) { - stream.write(163); + stream.write(164); writeValue(stream, ((PlatformMapViewCreationParams) value).toList()); } else if (value instanceof PlatformMapConfiguration) { - stream.write(164); + stream.write(165); writeValue(stream, ((PlatformMapConfiguration) value).toList()); } else if (value instanceof PlatformPoint) { - stream.write(165); + stream.write(166); writeValue(stream, ((PlatformPoint) value).toList()); } else if (value instanceof PlatformTileLayer) { - stream.write(166); + stream.write(167); writeValue(stream, ((PlatformTileLayer) value).toList()); } else if (value instanceof PlatformZoomRange) { - stream.write(167); + stream.write(168); writeValue(stream, ((PlatformZoomRange) value).toList()); } else if (value instanceof PlatformBitmap) { - stream.write(168); + stream.write(169); writeValue(stream, ((PlatformBitmap) value).toList()); } else if (value instanceof PlatformBitmapDefaultMarker) { - stream.write(169); + stream.write(170); writeValue(stream, ((PlatformBitmapDefaultMarker) value).toList()); } else if (value instanceof PlatformBitmapBytes) { - stream.write(170); + stream.write(171); writeValue(stream, ((PlatformBitmapBytes) value).toList()); } else if (value instanceof PlatformBitmapAsset) { - stream.write(171); + stream.write(172); writeValue(stream, ((PlatformBitmapAsset) value).toList()); } else if (value instanceof PlatformBitmapAssetImage) { - stream.write(172); + stream.write(173); writeValue(stream, ((PlatformBitmapAssetImage) value).toList()); } else if (value instanceof PlatformBitmapAssetMap) { - stream.write(173); + stream.write(174); writeValue(stream, ((PlatformBitmapAssetMap) value).toList()); } else if (value instanceof PlatformBitmapBytesMap) { - stream.write(174); + stream.write(175); writeValue(stream, ((PlatformBitmapBytesMap) value).toList()); } else { super.writeValue(stream, value); diff --git a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/CirclesControllerTest.java b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/CirclesControllerTest.java index 8ca208c7ba10..dcd07ecd6c75 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/CirclesControllerTest.java +++ b/packages/google_maps_flutter/google_maps_flutter_android/android/src/test/java/io/flutter/plugins/googlemaps/CirclesControllerTest.java @@ -52,10 +52,10 @@ public void controller_changeCircles_updatesExistingCircle() { builder .setCircleId(id) .setConsumeTapEvents(false) - .setFillColor(0L) + .setFillColor(new Messages.PlatformColor.Builder().setArgbValue(0L).build()) .setCenter(new Messages.PlatformLatLng.Builder().setLatitude(0.0).setLongitude(0.0).build()) .setRadius(1.0) - .setStrokeColor(0L) + .setStrokeColor(new Messages.PlatformColor.Builder().setArgbValue(0L).build()) .setStrokeWidth(1L) .setVisible(true) .setZIndex(0.0); 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 d421bcf97189..89dcced09183 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 @@ -65,6 +65,7 @@ void main() { // value. expect( initializedRenderer == AndroidMapRenderer.latest || + // ignore: deprecated_member_use initializedRenderer == AndroidMapRenderer.legacy, true, ); @@ -1468,7 +1469,7 @@ void main() { } }); - testWidgets('testCloudMapId', (WidgetTester tester) async { + testWidgets('testMapId', (WidgetTester tester) async { final Completer mapIdCompleter = Completer(); final Key key = GlobalKey(); @@ -1481,7 +1482,7 @@ void main() { onMapCreated: (ExampleGoogleMapController controller) { mapIdCompleter.complete(controller.mapId); }, - cloudMapId: _kCloudMapId, + mapId: _kCloudMapId, ), ), ); 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 bee30555b2ee..518304c93fd9 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 @@ -316,7 +316,7 @@ class ExampleGoogleMap extends StatefulWidget { this.onCameraIdle, this.onTap, this.onLongPress, - this.cloudMapId, + this.mapId, this.style, }); @@ -430,7 +430,7 @@ class ExampleGoogleMap extends StatefulWidget { /// /// See https://developers.google.com/maps/documentation/get-map-id /// for more details. - final String? cloudMapId; + final String? mapId; /// The locally configured style for the map. final String? style; @@ -680,7 +680,7 @@ MapConfiguration _configurationFromMapWidget(ExampleGoogleMap map) { indoorViewEnabled: map.indoorViewEnabled, trafficEnabled: map.trafficEnabled, buildingsEnabled: map.buildingsEnabled, - cloudMapId: map.cloudMapId, + mapId: map.mapId, style: map.style, ); } 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 039966595ba1..fb33ce4ab9b2 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 @@ -53,6 +53,7 @@ class MapIdBodyState extends State { switch (_initializedRenderer) { case AndroidMapRenderer.latest: return 'latest'; + // ignore: deprecated_member_use case AndroidMapRenderer.legacy: return 'legacy'; case AndroidMapRenderer.platformDefault: @@ -80,7 +81,7 @@ class MapIdBodyState extends State { zoom: 7.0, ), key: _key, - cloudMapId: _mapId, + mapId: _mapId, ); final List columnChildren = [ 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 34d05ca6f8f7..7996c8c7967f 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 @@ -16,9 +16,6 @@ import 'google_map_inspector_android.dart'; import 'messages.g.dart'; import 'serialization.dart'; -// TODO(stuartmorgan): Remove the dependency on platform interface toJson -// methods. Channel serialization details should all be package-internal. - /// The non-test implementation of `_apiProvider`. MapsApi _productionApiProvider(int mapId) { return MapsApi(messageChannelSuffix: mapId.toString()); @@ -774,8 +771,8 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { static PlatformCircle _platformCircleFromCircle(Circle circle) { return PlatformCircle( consumeTapEvents: circle.consumeTapEvents, - fillColor: circle.fillColor.value, - strokeColor: circle.strokeColor.value, + fillColor: PlatformColor(argbValue: circle.fillColor.toARGB32()), + strokeColor: PlatformColor(argbValue: circle.strokeColor.toARGB32()), visible: circle.visible, strokeWidth: circle.strokeWidth, zIndex: circle.zIndex.toDouble(), @@ -862,12 +859,12 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { }).toList(); return PlatformPolygon( polygonId: polygon.polygonId.value, - fillColor: polygon.fillColor.value, + fillColor: PlatformColor(argbValue: polygon.fillColor.toARGB32()), geodesic: polygon.geodesic, consumesTapEvents: polygon.consumeTapEvents, points: points, holes: holes, - strokeColor: polygon.strokeColor.value, + strokeColor: PlatformColor(argbValue: polygon.strokeColor.toARGB32()), strokeWidth: polygon.strokeWidth, zIndex: polygon.zIndex, visible: polygon.visible, @@ -884,7 +881,7 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { return PlatformPolyline( polylineId: polyline.polylineId.value, consumesTapEvents: polyline.consumeTapEvents, - color: polyline.color.value, + color: PlatformColor(argbValue: polyline.color.toARGB32()), startCap: platformCapFromCap(polyline.startCap), endCap: platformCapFromCap(polyline.endCap), geodesic: polyline.geodesic, @@ -1372,7 +1369,7 @@ PlatformMapConfiguration _platformMapConfigurationFromMapConfiguration( trafficEnabled: config.trafficEnabled, buildingsEnabled: config.buildingsEnabled, liteModeEnabled: config.liteModeEnabled, - cloudMapId: config.cloudMapId, + mapId: config.mapId, style: config.style, ); } @@ -1417,7 +1414,7 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( trafficEnabled: options['trafficEnabled'] as bool?, buildingsEnabled: options['buildingsEnabled'] as bool?, liteModeEnabled: options['liteModeEnabled'] as bool?, - cloudMapId: options['cloudMapId'] as String?, + mapId: options['cloudMapId'] as String?, style: options['style'] as String?, ); } 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 0b1342f448d3..09f5bef55d6e 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 @@ -488,8 +488,8 @@ class PlatformCameraUpdateZoomTo { class PlatformCircle { PlatformCircle({ this.consumeTapEvents = false, - this.fillColor = 0x00000000, - this.strokeColor = 0xFF000000, + required this.fillColor, + required this.strokeColor, this.visible = true, this.strokeWidth = 10, this.zIndex = 0.0, @@ -500,9 +500,9 @@ class PlatformCircle { bool consumeTapEvents; - int fillColor; + PlatformColor fillColor; - int strokeColor; + PlatformColor strokeColor; bool visible; @@ -538,8 +538,8 @@ class PlatformCircle { result as List; return PlatformCircle( consumeTapEvents: result[0]! as bool, - fillColor: result[1]! as int, - strokeColor: result[2]! as int, + fillColor: result[1]! as PlatformColor, + strokeColor: result[2]! as PlatformColor, visible: result[3]! as bool, strokeWidth: result[4]! as int, zIndex: result[5]! as double, @@ -681,6 +681,44 @@ class PlatformDoublePair { int get hashCode => Object.hashAll(_toList()); } +/// Pigeon equivalent of the Color class. +/// +/// See https://developer.android.com/reference/android/graphics/Color.html. +class PlatformColor { + PlatformColor({required this.argbValue}); + + int argbValue; + + List _toList() { + return [argbValue]; + } + + Object encode() { + return _toList(); + } + + static PlatformColor decode(Object result) { + result as List; + return PlatformColor(argbValue: result[0]! as int); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! PlatformColor || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()); +} + /// Pigeon equivalent of the InfoWindow class. class PlatformInfoWindow { PlatformInfoWindow({this.title, this.snippet, required this.anchor}); @@ -846,7 +884,7 @@ class PlatformPolygon { bool consumesTapEvents; - int fillColor; + PlatformColor fillColor; bool geodesic; @@ -856,7 +894,7 @@ class PlatformPolygon { bool visible; - int strokeColor; + PlatformColor strokeColor; int strokeWidth; @@ -886,12 +924,12 @@ class PlatformPolygon { return PlatformPolygon( polygonId: result[0]! as String, consumesTapEvents: result[1]! as bool, - fillColor: result[2]! as int, + fillColor: result[2]! as PlatformColor, geodesic: result[3]! as bool, points: (result[4] as List?)!.cast(), holes: (result[5] as List?)!.cast>(), visible: result[6]! as bool, - strokeColor: result[7]! as int, + strokeColor: result[7]! as PlatformColor, strokeWidth: result[8]! as int, zIndex: result[9]! as int, ); @@ -935,7 +973,7 @@ class PlatformPolyline { bool consumesTapEvents; - int color; + PlatformColor color; bool geodesic; @@ -985,7 +1023,7 @@ class PlatformPolyline { return PlatformPolyline( polylineId: result[0]! as String, consumesTapEvents: result[1]! as bool, - color: result[2]! as int, + color: result[2]! as PlatformColor, geodesic: result[3]! as bool, jointType: result[4]! as PlatformJointType, patterns: (result[5] as List?)!.cast(), @@ -1649,7 +1687,7 @@ class PlatformMapConfiguration { this.trafficEnabled, this.buildingsEnabled, this.liteModeEnabled, - this.cloudMapId, + this.mapId, this.style, }); @@ -1689,7 +1727,7 @@ class PlatformMapConfiguration { bool? liteModeEnabled; - String? cloudMapId; + String? mapId; String? style; @@ -1713,7 +1751,7 @@ class PlatformMapConfiguration { trafficEnabled, buildingsEnabled, liteModeEnabled, - cloudMapId, + mapId, style, ]; } @@ -1743,7 +1781,7 @@ class PlatformMapConfiguration { trafficEnabled: result[15] as bool?, buildingsEnabled: result[16] as bool?, liteModeEnabled: result[17] as bool?, - cloudMapId: result[18] as String?, + mapId: result[18] as String?, style: result[19] as String?, ); } @@ -2295,84 +2333,87 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is PlatformDoublePair) { buffer.putUint8(148); writeValue(buffer, value.encode()); - } else if (value is PlatformInfoWindow) { + } else if (value is PlatformColor) { buffer.putUint8(149); writeValue(buffer, value.encode()); - } else if (value is PlatformMarker) { + } else if (value is PlatformInfoWindow) { buffer.putUint8(150); writeValue(buffer, value.encode()); - } else if (value is PlatformPolygon) { + } else if (value is PlatformMarker) { buffer.putUint8(151); writeValue(buffer, value.encode()); - } else if (value is PlatformPolyline) { + } else if (value is PlatformPolygon) { buffer.putUint8(152); writeValue(buffer, value.encode()); - } else if (value is PlatformCap) { + } else if (value is PlatformPolyline) { buffer.putUint8(153); writeValue(buffer, value.encode()); - } else if (value is PlatformPatternItem) { + } else if (value is PlatformCap) { buffer.putUint8(154); writeValue(buffer, value.encode()); - } else if (value is PlatformTile) { + } else if (value is PlatformPatternItem) { buffer.putUint8(155); writeValue(buffer, value.encode()); - } else if (value is PlatformTileOverlay) { + } else if (value is PlatformTile) { buffer.putUint8(156); writeValue(buffer, value.encode()); - } else if (value is PlatformEdgeInsets) { + } else if (value is PlatformTileOverlay) { buffer.putUint8(157); writeValue(buffer, value.encode()); - } else if (value is PlatformLatLng) { + } else if (value is PlatformEdgeInsets) { buffer.putUint8(158); writeValue(buffer, value.encode()); - } else if (value is PlatformLatLngBounds) { + } else if (value is PlatformLatLng) { buffer.putUint8(159); writeValue(buffer, value.encode()); - } else if (value is PlatformCluster) { + } else if (value is PlatformLatLngBounds) { buffer.putUint8(160); writeValue(buffer, value.encode()); - } else if (value is PlatformGroundOverlay) { + } else if (value is PlatformCluster) { buffer.putUint8(161); writeValue(buffer, value.encode()); - } else if (value is PlatformCameraTargetBounds) { + } else if (value is PlatformGroundOverlay) { buffer.putUint8(162); writeValue(buffer, value.encode()); - } else if (value is PlatformMapViewCreationParams) { + } else if (value is PlatformCameraTargetBounds) { buffer.putUint8(163); writeValue(buffer, value.encode()); - } else if (value is PlatformMapConfiguration) { + } else if (value is PlatformMapViewCreationParams) { buffer.putUint8(164); writeValue(buffer, value.encode()); - } else if (value is PlatformPoint) { + } else if (value is PlatformMapConfiguration) { buffer.putUint8(165); writeValue(buffer, value.encode()); - } else if (value is PlatformTileLayer) { + } else if (value is PlatformPoint) { buffer.putUint8(166); writeValue(buffer, value.encode()); - } else if (value is PlatformZoomRange) { + } else if (value is PlatformTileLayer) { buffer.putUint8(167); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmap) { + } else if (value is PlatformZoomRange) { buffer.putUint8(168); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapDefaultMarker) { + } else if (value is PlatformBitmap) { buffer.putUint8(169); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapBytes) { + } else if (value is PlatformBitmapDefaultMarker) { buffer.putUint8(170); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapAsset) { + } else if (value is PlatformBitmapBytes) { buffer.putUint8(171); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapAssetImage) { + } else if (value is PlatformBitmapAsset) { buffer.putUint8(172); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapAssetMap) { + } else if (value is PlatformBitmapAssetImage) { buffer.putUint8(173); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapBytesMap) { + } else if (value is PlatformBitmapAssetMap) { buffer.putUint8(174); writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapBytesMap) { + buffer.putUint8(175); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -2428,56 +2469,58 @@ class _PigeonCodec extends StandardMessageCodec { case 148: return PlatformDoublePair.decode(readValue(buffer)!); case 149: - return PlatformInfoWindow.decode(readValue(buffer)!); + return PlatformColor.decode(readValue(buffer)!); case 150: - return PlatformMarker.decode(readValue(buffer)!); + return PlatformInfoWindow.decode(readValue(buffer)!); case 151: - return PlatformPolygon.decode(readValue(buffer)!); + return PlatformMarker.decode(readValue(buffer)!); case 152: - return PlatformPolyline.decode(readValue(buffer)!); + return PlatformPolygon.decode(readValue(buffer)!); case 153: - return PlatformCap.decode(readValue(buffer)!); + return PlatformPolyline.decode(readValue(buffer)!); case 154: - return PlatformPatternItem.decode(readValue(buffer)!); + return PlatformCap.decode(readValue(buffer)!); case 155: - return PlatformTile.decode(readValue(buffer)!); + return PlatformPatternItem.decode(readValue(buffer)!); case 156: - return PlatformTileOverlay.decode(readValue(buffer)!); + return PlatformTile.decode(readValue(buffer)!); case 157: - return PlatformEdgeInsets.decode(readValue(buffer)!); + return PlatformTileOverlay.decode(readValue(buffer)!); case 158: - return PlatformLatLng.decode(readValue(buffer)!); + return PlatformEdgeInsets.decode(readValue(buffer)!); case 159: - return PlatformLatLngBounds.decode(readValue(buffer)!); + return PlatformLatLng.decode(readValue(buffer)!); case 160: - return PlatformCluster.decode(readValue(buffer)!); + return PlatformLatLngBounds.decode(readValue(buffer)!); case 161: - return PlatformGroundOverlay.decode(readValue(buffer)!); + return PlatformCluster.decode(readValue(buffer)!); case 162: - return PlatformCameraTargetBounds.decode(readValue(buffer)!); + return PlatformGroundOverlay.decode(readValue(buffer)!); case 163: - return PlatformMapViewCreationParams.decode(readValue(buffer)!); + return PlatformCameraTargetBounds.decode(readValue(buffer)!); case 164: - return PlatformMapConfiguration.decode(readValue(buffer)!); + return PlatformMapViewCreationParams.decode(readValue(buffer)!); case 165: - return PlatformPoint.decode(readValue(buffer)!); + return PlatformMapConfiguration.decode(readValue(buffer)!); case 166: - return PlatformTileLayer.decode(readValue(buffer)!); + return PlatformPoint.decode(readValue(buffer)!); case 167: - return PlatformZoomRange.decode(readValue(buffer)!); + return PlatformTileLayer.decode(readValue(buffer)!); case 168: - return PlatformBitmap.decode(readValue(buffer)!); + return PlatformZoomRange.decode(readValue(buffer)!); case 169: - return PlatformBitmapDefaultMarker.decode(readValue(buffer)!); + return PlatformBitmap.decode(readValue(buffer)!); case 170: - return PlatformBitmapBytes.decode(readValue(buffer)!); + return PlatformBitmapDefaultMarker.decode(readValue(buffer)!); case 171: - return PlatformBitmapAsset.decode(readValue(buffer)!); + return PlatformBitmapBytes.decode(readValue(buffer)!); case 172: - return PlatformBitmapAssetImage.decode(readValue(buffer)!); + return PlatformBitmapAsset.decode(readValue(buffer)!); case 173: - return PlatformBitmapAssetMap.decode(readValue(buffer)!); + return PlatformBitmapAssetImage.decode(readValue(buffer)!); case 174: + return PlatformBitmapAssetMap.decode(readValue(buffer)!); + case 175: return PlatformBitmapBytesMap.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); 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 7a9aca87b9aa..4e744a9af532 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 @@ -86,7 +86,9 @@ Object serializeHeatmapGradient(HeatmapGradient gradient) { _addIfNonNull( json, _heatmapGradientColorsKey, - gradient.colors.map((HeatmapGradientColor e) => e.color.value).toList(), + gradient.colors + .map((HeatmapGradientColor e) => e.color.toARGB32()) + .toList(), ); _addIfNonNull( json, 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 bcb3e418c024..1a31450f1889 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 @@ -104,9 +104,9 @@ class PlatformCircle { PlatformCircle({ required this.circleId, required this.center, + required this.fillColor, + required this.strokeColor, this.consumeTapEvents = false, - this.fillColor = 0x00000000, - this.strokeColor = 0xFF000000, this.visible = true, this.strokeWidth = 10, this.zIndex = 0.0, @@ -114,8 +114,8 @@ class PlatformCircle { }); final bool consumeTapEvents; - final int fillColor; - final int strokeColor; + final PlatformColor fillColor; + final PlatformColor strokeColor; final bool visible; final int strokeWidth; final double zIndex; @@ -151,6 +151,15 @@ class PlatformDoublePair { final double y; } +/// Pigeon equivalent of the Color class. +/// +/// See https://developer.android.com/reference/android/graphics/Color.html. +class PlatformColor { + const PlatformColor(this.argbValue); + + final int argbValue; +} + /// Pigeon equivalent of the InfoWindow class. class PlatformInfoWindow { PlatformInfoWindow({required this.anchor, this.title, this.snippet}); @@ -211,12 +220,12 @@ class PlatformPolygon { final String polygonId; final bool consumesTapEvents; - final int fillColor; + final PlatformColor fillColor; final bool geodesic; final List points; final List> holes; final bool visible; - final int strokeColor; + final PlatformColor strokeColor; final int strokeWidth; final int zIndex; } @@ -243,7 +252,7 @@ class PlatformPolyline { final String polylineId; final bool consumesTapEvents; - final int color; + final PlatformColor color; final bool geodesic; /// The joint type. @@ -453,7 +462,7 @@ class PlatformMapConfiguration { required this.trafficEnabled, required this.buildingsEnabled, required this.liteModeEnabled, - required this.cloudMapId, + required this.mapId, required this.style, }); @@ -475,7 +484,7 @@ class PlatformMapConfiguration { final bool? trafficEnabled; final bool? buildingsEnabled; final bool? liteModeEnabled; - final String? cloudMapId; + final String? mapId; final String? style; } 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 4c272074a70e..bb75e4469ea5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_android description: Android implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.18.5 +version: 2.18.6 environment: sdk: ^3.9.0 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 3569b0098c34..55d1ba2eec1f 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 @@ -457,8 +457,11 @@ void main() { expect(toChange.length, 1); final PlatformCircle firstChanged = toChange.first; expect(firstChanged.consumeTapEvents, object2new.consumeTapEvents); - expect(firstChanged.fillColor, object2new.fillColor.value); - expect(firstChanged.strokeColor, object2new.strokeColor.value); + expect(firstChanged.fillColor.argbValue, object2new.fillColor.toARGB32()); + expect( + firstChanged.strokeColor.argbValue, + object2new.strokeColor.toARGB32(), + ); expect(firstChanged.visible, object2new.visible); expect(firstChanged.strokeWidth, object2new.strokeWidth); expect(firstChanged.zIndex, object2new.zIndex.toDouble()); @@ -472,8 +475,8 @@ void main() { expect(toAdd.length, 1); final PlatformCircle firstAdded = toAdd.first; expect(firstAdded.consumeTapEvents, object3.consumeTapEvents); - expect(firstAdded.fillColor, object3.fillColor.value); - expect(firstAdded.strokeColor, object3.strokeColor.value); + expect(firstAdded.fillColor.argbValue, object3.fillColor.toARGB32()); + expect(firstAdded.strokeColor.argbValue, object3.strokeColor.toARGB32()); expect(firstAdded.visible, object3.visible); expect(firstAdded.strokeWidth, object3.strokeWidth); expect(firstAdded.zIndex, object3.zIndex.toDouble()); @@ -641,7 +644,7 @@ void main() { void expectPolygon(PlatformPolygon actual, Polygon expected) { expect(actual.polygonId, expected.polygonId.value); expect(actual.consumesTapEvents, expected.consumeTapEvents); - expect(actual.fillColor, expected.fillColor.value); + expect(actual.fillColor.argbValue, expected.fillColor.toARGB32()); expect(actual.geodesic, expected.geodesic); expect(actual.points.length, expected.points.length); for (final (int i, PlatformLatLng? point) in actual.points.indexed) { @@ -657,7 +660,7 @@ void main() { } } expect(actual.visible, expected.visible); - expect(actual.strokeColor, expected.strokeColor.value); + expect(actual.strokeColor.argbValue, expected.strokeColor.toARGB32()); expect(actual.strokeWidth, expected.strokeWidth); expect(actual.zIndex, expected.zIndex); } @@ -711,7 +714,7 @@ void main() { void expectPolyline(PlatformPolyline actual, Polyline expected) { expect(actual.polylineId, expected.polylineId.value); expect(actual.consumesTapEvents, expected.consumeTapEvents); - expect(actual.color, expected.color.value); + expect(actual.color.argbValue, expected.color.toARGB32()); expect(actual.geodesic, expected.geodesic); expect( actual.jointType, @@ -1497,9 +1500,9 @@ void main() { expect(widget, isA()); }); - testWidgets('cloudMapId is passed', (WidgetTester tester) async { + testWidgets('mapId is passed', (WidgetTester tester) async { const String cloudMapId = '000000000000000'; // Dummy map ID. - final Completer passedCloudMapIdCompleter = Completer(); + final Completer passedMapIdCompleter = Completer(); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler(SystemChannels.platform_views, ( @@ -1517,9 +1520,9 @@ void main() { as PlatformMapViewCreationParams?; if (creationParams != null) { final String? passedMapId = - creationParams.mapConfiguration.cloudMapId; + creationParams.mapConfiguration.mapId; if (passedMapId != null) { - passedCloudMapIdCompleter.complete(passedMapId); + passedMapIdCompleter.complete(passedMapId); } } } @@ -1537,14 +1540,14 @@ void main() { initialCameraPosition: CameraPosition(target: LatLng(0, 0), zoom: 1), textDirection: TextDirection.ltr, ), - mapConfiguration: const MapConfiguration(cloudMapId: cloudMapId), + mapConfiguration: const MapConfiguration(mapId: cloudMapId), ), ); expect( - await passedCloudMapIdCompleter.future, + await passedMapIdCompleter.future, cloudMapId, - reason: 'Should pass cloudMapId on PlatformView creation message', + reason: 'Should pass mapId in PlatformView creation message', ); }); } 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 2cfb1ae67baa..b2b80b419e85 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 @@ +## 2.15.8 + +* Replaces internal use of deprecated methods. + ## 2.15.7 * Updates to Pigeon 26. 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 5eb14dbdd0e1..46c0442b9677 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 @@ -1397,7 +1397,7 @@ void main() { child: ExampleGoogleMap( key: key, initialCameraPosition: _kInitialCameraPosition, - cloudMapId: _kCloudMapId, + mapId: _kCloudMapId, ), ), ); diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Flutter/AppFrameworkInfo.plist b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Flutter/AppFrameworkInfo.plist index b3aaa733dfbb..1f6b98f117b2 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Flutter/AppFrameworkInfo.plist +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Flutter/AppFrameworkInfo.plist @@ -25,6 +25,6 @@ arm64 MinimumOSVersion - 12.0 + 13.0 diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj index dd2afe770706..b394dabbb69f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 60; + objectVersion = 54; objects = { /* Begin PBXBuildFile section */ @@ -19,7 +19,7 @@ 478116522BEF8F47002F593E /* GoogleMapsPolylineControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 478116512BEF8F47002F593E /* GoogleMapsPolylineControllerTests.m */; }; 528F16832C62941000148160 /* FGMClusterManagersControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 528F16822C62941000148160 /* FGMClusterManagersControllerTests.m */; }; 528F16872C62952700148160 /* ExtractIconFromDataTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 528F16862C62952700148160 /* ExtractIconFromDataTests.m */; }; - 6851F3562835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */; }; + 6851F3562835BC180032B7C8 /* FGMConversionsUtilsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6851F3552835BC180032B7C8 /* FGMConversionsUtilsTests.m */; }; 78A318202AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage in Frameworks */ = {isa = PBXBuildFile; productRef = 78A3181F2AECB46A00862997 /* FlutterGeneratedPluginSwiftPackage */; }; 978B8F6F1D3862AE00F588F7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 7AFFD8EE1D35381100E5BB4D /* AppDelegate.m */; }; 97C146F31CF9000F007C117D /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 97C146F21CF9000F007C117D /* main.m */; }; @@ -79,7 +79,7 @@ 528F16822C62941000148160 /* FGMClusterManagersControllerTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FGMClusterManagersControllerTests.m; sourceTree = ""; }; 528F16862C62952700148160 /* ExtractIconFromDataTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ExtractIconFromDataTests.m; sourceTree = ""; }; 61A9A8623F5CA9BBC813DC6B /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLTGoogleMapJSONConversionsConversionTests.m; sourceTree = ""; }; + 6851F3552835BC180032B7C8 /* FGMConversionsUtilsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FGMConversionsUtilsTests.m; sourceTree = ""; }; 733AFAB37683A9DA7512F09C /* Pods-RunnerTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RunnerTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-RunnerTests/Pods-RunnerTests.release.xcconfig"; sourceTree = ""; }; 78E0A7A72DC9AD7400C4905E /* FlutterGeneratedPluginSwiftPackage */ = {isa = PBXFileReference; lastKnownFileType = wrapper; name = FlutterGeneratedPluginSwiftPackage; path = Flutter/ephemeral/Packages/FlutterGeneratedPluginSwiftPackage; sourceTree = ""; }; 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; @@ -221,7 +221,7 @@ 528F16862C62952700148160 /* ExtractIconFromDataTests.m */, 528F16822C62941000148160 /* FGMClusterManagersControllerTests.m */, 339355BE2EB5359B00EBF864 /* FLTGoogleMapHeatmapControllerTests.m */, - 6851F3552835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m */, + 6851F3552835BC180032B7C8 /* FGMConversionsUtilsTests.m */, 0DD7B6C22B744EEF00E857FD /* FLTTileProviderControllerTests.m */, F7151F12265D7ED70028CB91 /* GoogleMapsTests.m */, 339355B92EB3E4F900EBF864 /* GoogleMapsCircleControllerTests.m */, @@ -520,7 +520,7 @@ 339355BF2EB535A600EBF864 /* FLTGoogleMapHeatmapControllerTests.m in Sources */, 339355BD2EB3E56300EBF864 /* GoogleMapsTileOverlayControllerTests.m in Sources */, F7151F13265D7ED70028CB91 /* GoogleMapsTests.m in Sources */, - 6851F3562835BC180032B7C8 /* FLTGoogleMapJSONConversionsConversionTests.m in Sources */, + 6851F3562835BC180032B7C8 /* FGMConversionsUtilsTests.m in Sources */, 982F2A6C27BADE17003C81F4 /* PartiallyMockedMapView.m in Sources */, 330909FF2D99B7A60077A751 /* GoogleMapsMarkerControllerTests.m in Sources */, 478116522BEF8F47002F593E /* GoogleMapsPolylineControllerTests.m in Sources */, diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index cab978a8e3b6..3ea203b77e3b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -44,6 +44,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" shouldUseLaunchSchemeArgsEnv = "YES"> #import "PartiallyMockedMapView.h" -@interface FLTGoogleMapJSONConversionsTests : XCTestCase +@interface FGMConversionUtilsTests : XCTestCase @end -@implementation FLTGoogleMapJSONConversionsTests +@implementation FGMConversionUtilsTests - (void)testGetValueOrNilWithValue { NSString *key = @"key"; @@ -39,28 +39,28 @@ - (void)testGetValueOrNilWithNSNull { - (void)testLocationFromLatLong { NSArray *latlong = @[ @1, @2 ]; - CLLocationCoordinate2D location = [FLTGoogleMapJSONConversions locationFromLatLong:latlong]; + CLLocationCoordinate2D location = [FGMHeatmapConversions locationFromLatLong:latlong]; XCTAssertEqual(location.latitude, 1); XCTAssertEqual(location.longitude, 2); } - (void)testPointFromArray { NSArray *array = @[ @1, @2 ]; - CGPoint point = [FLTGoogleMapJSONConversions pointFromArray:array]; + CGPoint point = [FGMHeatmapConversions pointFromArray:array]; XCTAssertEqual(point.x, 1); XCTAssertEqual(point.y, 2); } - (void)testArrayFromLocation { CLLocationCoordinate2D location = CLLocationCoordinate2DMake(1, 2); - NSArray *array = [FLTGoogleMapJSONConversions arrayFromLocation:location]; + NSArray *array = [FGMHeatmapConversions arrayFromLocation:location]; XCTAssertEqual([array[0] integerValue], 1); XCTAssertEqual([array[1] integerValue], 2); } - (void)testColorFromRGBA { NSNumber *rgba = @(0x01020304); - UIColor *color = [FLTGoogleMapJSONConversions colorFromRGBA:rgba]; + UIColor *color = [FGMHeatmapConversions colorFromRGBA:rgba]; CGFloat red, green, blue, alpha; BOOL success = [color getRed:&red green:&green blue:&blue alpha:&alpha]; XCTAssertTrue(success); @@ -390,7 +390,7 @@ - (void)testWeightedLatLngFromArray { NSArray *weightedLatLng = @[ @[ @1, @2 ], @3 ]; GMUWeightedLatLng *weightedLocation = - [FLTGoogleMapJSONConversions weightedLatLngFromArray:weightedLatLng]; + [FGMHeatmapConversions weightedLatLngFromArray:weightedLatLng]; // The location gets projected to different values XCTAssertEqual([weightedLocation intensity], 3); @@ -399,7 +399,7 @@ - (void)testWeightedLatLngFromArray { - (void)testWeightedLatLngFromArrayThrowsForInvalidInput { NSArray *weightedLatLng = @[]; - XCTAssertThrows([FLTGoogleMapJSONConversions weightedLatLngFromArray:weightedLatLng]); + XCTAssertThrows([FGMHeatmapConversions weightedLatLngFromArray:weightedLatLng]); } - (void)testWeightedDataFromArray { @@ -407,8 +407,7 @@ - (void)testWeightedDataFromArray { NSNumber *intensity2 = @6; NSArray *data = @[ @[ @[ @1, @2 ], intensity1 ], @[ @[ @4, @5 ], intensity2 ] ]; - NSArray *weightedData = - [FLTGoogleMapJSONConversions weightedDataFromArray:data]; + NSArray *weightedData = [FGMHeatmapConversions weightedDataFromArray:data]; XCTAssertEqual([weightedData[0] intensity], [intensity1 floatValue]); XCTAssertEqual([weightedData[1] intensity], [intensity2 floatValue]); } @@ -425,7 +424,7 @@ - (void)testGradientFromDictionary { @"colorMapSize" : colorMapSize, }; - GMUGradient *gradient = [FLTGoogleMapJSONConversions gradientFromDictionary:gradientData]; + GMUGradient *gradient = [FGMHeatmapConversions gradientFromDictionary:gradientData]; CGFloat red, green, blue, alpha; [[gradient colors][0] getRed:&red green:&green blue:&blue alpha:&alpha]; XCTAssertEqual(red, 0); diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsCircleControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsCircleControllerTests.m index 44785692f285..b6da47435aaa 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsCircleControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsCircleControllerTests.m @@ -26,8 +26,14 @@ - (void)testUpdateCircleSetsVisibilityLast { updateCircle:circle fromPlatformCircle:[FGMPlatformCircle makeWithConsumeTapEvents:NO - fillColor:0 - strokeColor:0 + fillColor:[FGMPlatformColor makeWithRed:0 + green:0 + blue:0 + alpha:0] + strokeColor:[FGMPlatformColor makeWithRed:0 + green:0 + blue:0 + alpha:0] visible:YES strokeWidth:0 zIndex:0 diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolygonControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolygonControllerTests.m index 778b1d44112c..77c5a9629672 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolygonControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolygonControllerTests.m @@ -22,16 +22,23 @@ - (void)testUpdatePolygonSetsVisibilityLast { PropertyOrderValidatingPolygon *polygon = [[PropertyOrderValidatingPolygon alloc] init]; [FLTGoogleMapPolygonController updatePolygon:polygon - fromPlatformPolygon:[FGMPlatformPolygon makeWithConsumeTapEvents:NO - fillColor:0 - geodesic:NO - holes:@[] - strokeColor:0 - strokeWidth:0 - visible:YES - zIndex:0 - points:@[] - polygonId:@"polygon"] + fromPlatformPolygon:[FGMPlatformPolygon + makeWithConsumeTapEvents:NO + fillColor:[FGMPlatformColor makeWithRed:0 + green:0 + blue:0 + alpha:0] + geodesic:NO + holes:@[] + strokeColor:[FGMPlatformColor makeWithRed:0 + green:0 + blue:0 + alpha:0] + strokeWidth:0 + visible:YES + zIndex:0 + points:@[] + polygonId:@"polygon"] withMapView:[GoogleMapsPolygonControllerTests mapView]]; XCTAssertTrue(polygon.hasSetMap); } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylineControllerTests.m b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylineControllerTests.m index 6dbe1b93a0e6..848c9c71f41a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylineControllerTests.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/example/ios14/ios/RunnerTests/GoogleMapsPolylineControllerTests.m @@ -27,17 +27,17 @@ @implementation GoogleMapsPolylineControllerTests /// /// @return An object of FLTGoogleMapPolylineController - (FLTGoogleMapPolylineController *)polylineControllerWithMockedMap { - FGMPlatformPolyline *polyline = - [FGMPlatformPolyline makeWithPolylineId:@"polyline_id_0" - consumesTapEvents:NO - color:0 - geodesic:NO - jointType:FGMPlatformJointTypeRound - patterns:@[] - points:[GoogleMapsPolylineControllerTests polylinePoints] - visible:NO - width:1 - zIndex:0]; + FGMPlatformPolyline *polyline = [FGMPlatformPolyline + makeWithPolylineId:@"polyline_id_0" + consumesTapEvents:NO + color:[FGMPlatformColor makeWithRed:0 green:0 blue:0 alpha:0] + geodesic:NO + jointType:FGMPlatformJointTypeRound + patterns:@[] + points:[GoogleMapsPolylineControllerTests polylinePoints] + visible:NO + width:1 + zIndex:0]; CGRect frame = CGRectMake(0, 0, 100, 100); GMSCameraPosition *camera = [[GMSCameraPosition alloc] initWithLatitude:0 longitude:0 zoom:0]; @@ -67,7 +67,10 @@ - (void)testPatternsSetSpans { updateFromPlatformPolyline:[FGMPlatformPolyline makeWithPolylineId:@"polyline_id_0" consumesTapEvents:NO - color:0 + color:[FGMPlatformColor makeWithRed:0 + green:0 + blue:0 + alpha:0] geodesic:NO jointType:FGMPlatformJointTypeRound patterns:@[ @@ -95,7 +98,10 @@ - (void)testUpdatePolylineSetsVisibilityLast { fromPlatformPolyline:[FGMPlatformPolyline makeWithPolylineId:@"polyline" consumesTapEvents:NO - color:0 + color:[FGMPlatformColor makeWithRed:0 + green:0 + blue:0 + alpha:0] geodesic:NO jointType:FGMPlatformJointTypeRound patterns:@[] 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 2fcd42602bf8..152f83c16f38 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 @@ -314,7 +314,7 @@ class ExampleGoogleMap extends StatefulWidget { this.onCameraIdle, this.onTap, this.onLongPress, - this.cloudMapId, + this.mapId, this.style, }); @@ -422,7 +422,7 @@ class ExampleGoogleMap extends StatefulWidget { /// /// See https://developers.google.com/maps/documentation/get-map-id /// for more details. - final String? cloudMapId; + final String? mapId; /// The locally configured style for the map. final String? style; @@ -670,7 +670,7 @@ MapConfiguration _configurationFromMapWidget(ExampleGoogleMap map) { indoorViewEnabled: map.indoorViewEnabled, trafficEnabled: map.trafficEnabled, buildingsEnabled: map.buildingsEnabled, - cloudMapId: map.cloudMapId, + mapId: map.mapId, style: map.style, ); } 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 79e983d8a21b..cca097752fdb 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 @@ -54,7 +54,7 @@ class MapIdBodyState extends State { zoom: 7.0, ), key: _key, - cloudMapId: _mapId, + mapId: _mapId, ); final List columnChildren = [ diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMClusterManagersController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMClusterManagersController.m index 76352bfb8630..04c3f04c9285 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMClusterManagersController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMClusterManagersController.m @@ -4,8 +4,8 @@ #import "FGMClusterManagersController.h" +#import "FGMConversionUtils.h" #import "FGMMarkerUserData.h" -#import "FLTGoogleMapJSONConversions.h" @interface FGMClusterManagersController () diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMConversionUtils.h similarity index 94% rename from packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h rename to packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMConversionUtils.h index 61241fb62468..2cc43fc538f6 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMConversionUtils.h @@ -69,7 +69,7 @@ extern GMSCameraUpdate *_Nullable FGMGetCameraUpdateForPigeonCameraUpdate( FGMPlatformCameraUpdate *update); /// Creates a UIColor from its RGBA components, expressed as an integer. -extern UIColor *FGMGetColorForRGBA(NSInteger rgba); +extern UIColor *FGMGetColorForPigeonColor(FGMPlatformColor *color); /// Creates an array of GMSStrokeStyles using the given patterns and stroke color. extern NSArray *FGMGetStrokeStylesFromPatterns( @@ -79,7 +79,10 @@ extern NSArray *FGMGetStrokeStylesFromPatterns( extern NSArray *FGMGetSpanLengthsFromPatterns( NSArray *patterns); -@interface FLTGoogleMapJSONConversions : NSObject +/// Legacy conversion utils for heatmaps, which are still using a JSON +/// representation instead of structured Pigeon data. +// TODO(stuartmorgan): Remove this once heatmaps are migrated to Pigeon. +@interface FGMHeatmapConversions : NSObject extern NSString *const kHeatmapsToAddKey; extern NSString *const kHeatmapIdKey; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMConversionUtils.m similarity index 95% rename from packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m rename to packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMConversionUtils.m index 479be7101768..bce17ba10af8 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapJSONConversions.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMConversionUtils.m @@ -2,7 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#import "FLTGoogleMapJSONConversions.h" +#import "FGMConversionUtils.h" + #import "FGMMarkerUserData.h" /// Returns dict[key], or nil if dict[key] is NSNull. @@ -212,11 +213,8 @@ GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type) { return nil; } -UIColor *FGMGetColorForRGBA(NSInteger rgba) { - return [UIColor colorWithRed:((CGFloat)((rgba & 0xFF0000) >> 16)) / 255.0 - green:((CGFloat)((rgba & 0xFF00) >> 8)) / 255.0 - blue:((CGFloat)(rgba & 0xFF)) / 255.0 - alpha:((CGFloat)((rgba & 0xFF000000) >> 24)) / 255.0]; +UIColor *FGMGetColorForPigeonColor(FGMPlatformColor *color) { + return [UIColor colorWithRed:color.red green:color.green blue:color.blue alpha:color.alpha]; } NSArray *FGMGetStrokeStylesFromPatterns( @@ -239,7 +237,7 @@ GMSMapViewType FGMGetMapViewTypeForPigeonMapType(FGMPlatformMapType type) { return lengths; } -@implementation FLTGoogleMapJSONConversions +@implementation FGMHeatmapConversions // These constants must match the corresponding constants in serialization.dart NSString *const kHeatmapsToAddKey = @"heatmapsToAdd"; @@ -267,7 +265,11 @@ + (NSArray *)arrayFromLocation:(CLLocationCoordinate2D)location { } + (UIColor *)colorFromRGBA:(NSNumber *)numberColor { - return FGMGetColorForRGBA(numberColor.unsignedLongValue); + NSInteger rgba = numberColor.unsignedLongValue; + return [UIColor colorWithRed:((CGFloat)((rgba & 0xFF0000) >> 16)) / 255.0 + green:((CGFloat)((rgba & 0xFF00) >> 8)) / 255.0 + blue:((CGFloat)(rgba & 0xFF)) / 255.0 + alpha:((CGFloat)((rgba & 0xFF000000) >> 24)) / 255.0]; } + (NSNumber *)RGBAFromColor:(UIColor *)color { @@ -284,14 +286,14 @@ + (GMUWeightedLatLng *)weightedLatLngFromArray:(NSArray *)data { return nil; } return [[GMUWeightedLatLng alloc] - initWithCoordinate:[FLTGoogleMapJSONConversions locationFromLatLong:data[0]] + initWithCoordinate:[FGMHeatmapConversions locationFromLatLong:data[0]] intensity:[data[1] doubleValue]]; } + (NSArray *)arrayFromWeightedLatLng:(GMUWeightedLatLng *)weightedLatLng { GMSMapPoint point = {weightedLatLng.point.x, weightedLatLng.point.y}; return @[ - [FLTGoogleMapJSONConversions arrayFromLocation:GMSUnproject(point)], @(weightedLatLng.intensity) + [FGMHeatmapConversions arrayFromLocation:GMSUnproject(point)], @(weightedLatLng.intensity) ]; } @@ -299,7 +301,7 @@ + (GMUWeightedLatLng *)weightedLatLngFromArray:(NSArray *)data { NSMutableArray *weightedData = [[NSMutableArray alloc] initWithCapacity:data.count]; for (NSArray *item in data) { - GMUWeightedLatLng *weightedLatLng = [FLTGoogleMapJSONConversions weightedLatLngFromArray:item]; + GMUWeightedLatLng *weightedLatLng = [FGMHeatmapConversions weightedLatLngFromArray:item]; if (weightedLatLng == nil) continue; [weightedData addObject:weightedLatLng]; } @@ -310,7 +312,7 @@ + (GMUWeightedLatLng *)weightedLatLngFromArray:(NSArray *)data { + (NSArray *> *)arrayFromWeightedData:(NSArray *)weightedData { NSMutableArray *data = [[NSMutableArray alloc] initWithCapacity:weightedData.count]; for (GMUWeightedLatLng *weightedLatLng in weightedData) { - [data addObject:[FLTGoogleMapJSONConversions arrayFromWeightedLatLng:weightedLatLng]]; + [data addObject:[FGMHeatmapConversions arrayFromWeightedLatLng:weightedLatLng]]; } return data; @@ -320,7 +322,7 @@ + (GMUGradient *)gradientFromDictionary:(NSDictionary *)data { NSArray *colorData = data[kHeatmapGradientColorsKey]; NSMutableArray *colors = [[NSMutableArray alloc] initWithCapacity:colorData.count]; for (NSNumber *colorCode in colorData) { - [colors addObject:[FLTGoogleMapJSONConversions colorFromRGBA:colorCode]]; + [colors addObject:[FGMHeatmapConversions colorFromRGBA:colorCode]]; } return [[GMUGradient alloc] initWithColors:colors @@ -332,7 +334,7 @@ + (GMUGradient *)gradientFromDictionary:(NSDictionary *)data { NSMutableArray *colorCodes = [[NSMutableArray alloc] initWithCapacity:gradient.colors.count]; for (UIColor *color in gradient.colors) { - [colorCodes addObject:[FLTGoogleMapJSONConversions RGBAFromColor:color]]; + [colorCodes addObject:[FGMHeatmapConversions RGBAFromColor:color]]; } return @{ diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.m index 2260dfb9e710..624f43032c53 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FGMGroundOverlayController.m @@ -5,8 +5,8 @@ #import "FGMGroundOverlayController.h" #import "FGMGroundOverlayController_Test.h" +#import "FGMConversionUtils.h" #import "FGMImageUtils.h" -#import "FLTGoogleMapJSONConversions.h" @interface FGMGroundOverlayController () diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapHeatmapController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapHeatmapController.m index aa51fb93c63b..808c5848768e 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapHeatmapController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapHeatmapController.m @@ -7,7 +7,7 @@ @import GoogleMapsUtils; -#import "FLTGoogleMapJSONConversions.h" +#import "FGMConversionUtils.h" @interface FLTGoogleMapHeatmapController () @@ -56,13 +56,12 @@ + (void)updateHeatmap:(GMUHeatmapTileLayer *)heatmapTileLayer // https://github.com/flutter/flutter/issues/117907 id weightedData = options[kHeatmapDataKey]; if ([weightedData isKindOfClass:[NSArray class]]) { - heatmapTileLayer.weightedData = - [FLTGoogleMapJSONConversions weightedDataFromArray:weightedData]; + heatmapTileLayer.weightedData = [FGMHeatmapConversions weightedDataFromArray:weightedData]; } id gradient = options[kHeatmapGradientKey]; if ([gradient isKindOfClass:[NSDictionary class]]) { - heatmapTileLayer.gradient = [FLTGoogleMapJSONConversions gradientFromDictionary:gradient]; + heatmapTileLayer.gradient = [FGMHeatmapConversions gradientFromDictionary:gradient]; } id opacity = options[kHeatmapOpacityKey]; @@ -153,9 +152,9 @@ - (BOOL)hasHeatmapWithIdentifier:(NSString *)identifier { FLTGoogleMapHeatmapController *heatmapController = self.heatmapIdToController[identifier]; if (heatmapController) { return @{ - kHeatmapDataKey : [FLTGoogleMapJSONConversions + kHeatmapDataKey : [FGMHeatmapConversions arrayFromWeightedData:heatmapController.heatmapTileLayer.weightedData], - kHeatmapGradientKey : [FLTGoogleMapJSONConversions + kHeatmapGradientKey : [FGMHeatmapConversions dictionaryFromGradient:heatmapController.heatmapTileLayer.gradient], kHeatmapOpacityKey : @(heatmapController.heatmapTileLayer.opacity), kHeatmapRadiusKey : @(heatmapController.heatmapTileLayer.radius), diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.m index 8132ffbdf280..c4cce14ed247 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/FLTGoogleMapTileOverlayController.m @@ -5,7 +5,7 @@ #import "FLTGoogleMapTileOverlayController.h" #import "FLTGoogleMapTileOverlayController_Test.h" -#import "FLTGoogleMapJSONConversions.h" +#import "FGMConversionUtils.h" @interface FLTGoogleMapTileOverlayController () diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.m index 81c5549bd32b..d2d0130dc64a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapCircleController.m @@ -5,7 +5,7 @@ #import "GoogleMapCircleController.h" #import "GoogleMapCircleController_Test.h" -#import "FLTGoogleMapJSONConversions.h" +#import "FGMConversionUtils.h" @interface FLTGoogleMapCircleController () @@ -48,9 +48,9 @@ + (void)updateCircle:(GMSCircle *)circle circle.zIndex = platformCircle.zIndex; circle.position = FGMGetCoordinateForPigeonLatLng(platformCircle.center); circle.radius = platformCircle.radius; - circle.strokeColor = FGMGetColorForRGBA(platformCircle.strokeColor); + circle.strokeColor = FGMGetColorForPigeonColor(platformCircle.strokeColor); circle.strokeWidth = platformCircle.strokeWidth; - circle.fillColor = FGMGetColorForRGBA(platformCircle.fillColor); + circle.fillColor = FGMGetColorForPigeonColor(platformCircle.fillColor); // This must be done last, to avoid visual flickers of default property values. circle.map = platformCircle.visible ? mapView : nil; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m index 2d62fe9dad66..dc8d6fa6db2b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m @@ -7,10 +7,10 @@ #import "GoogleMapController.h" #import "GoogleMapController_Test.h" +#import "FGMConversionUtils.h" #import "FGMGroundOverlayController.h" #import "FGMMarkerUserData.h" #import "FLTGoogleMapHeatmapController.h" -#import "FLTGoogleMapJSONConversions.h" #import "FLTGoogleMapTileOverlayController.h" #import "messages.g.h" @@ -135,7 +135,7 @@ - (instancetype)initWithFrame:(CGRect)frame GMSMapViewOptions *options = [[GMSMapViewOptions alloc] init]; options.frame = frame; options.camera = camera; - NSString *cloudMapId = creationParameters.mapConfiguration.cloudMapId; + NSString *cloudMapId = creationParameters.mapConfiguration.mapId; if (cloudMapId) { options.mapID = [GMSMapID mapIDWithIdentifier:cloudMapId]; } diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController.m index de9e0f99ac4a..ed3aabd7fc10 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapMarkerController.m @@ -5,9 +5,9 @@ #import "GoogleMapMarkerController.h" #import "GoogleMapMarkerController_Test.h" +#import "FGMConversionUtils.h" #import "FGMImageUtils.h" #import "FGMMarkerUserData.h" -#import "FLTGoogleMapJSONConversions.h" @interface FLTGoogleMapMarkerController () diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolygonController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolygonController.m index aedbf1b90db8..12cbfeefecd7 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolygonController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolygonController.m @@ -5,7 +5,7 @@ #import "GoogleMapPolygonController.h" #import "GoogleMapPolygonController_Test.h" -#import "FLTGoogleMapJSONConversions.h" +#import "FGMConversionUtils.h" /// Converts a list of holes represented as CLLocation lists to GMSMutablePath lists. static NSArray *FMGPathHolesFromLocationHoles( @@ -57,8 +57,8 @@ + (void)updatePolygon:(GMSPolygon *)polygon polygon.path = FGMGetPathFromPoints(FGMGetPointsForPigeonLatLngs(platformPolygon.points)); polygon.holes = FMGPathHolesFromLocationHoles(FGMGetHolesForPigeonLatLngArrays(platformPolygon.holes)); - polygon.fillColor = FGMGetColorForRGBA(platformPolygon.fillColor); - polygon.strokeColor = FGMGetColorForRGBA(platformPolygon.strokeColor); + polygon.fillColor = FGMGetColorForPigeonColor(platformPolygon.fillColor); + polygon.strokeColor = FGMGetColorForPigeonColor(platformPolygon.strokeColor); polygon.strokeWidth = platformPolygon.strokeWidth; // This must be done last, to avoid visual flickers of default property values. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m index cf5277790589..63a7f7b7b0fc 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapPolylineController.m @@ -5,7 +5,7 @@ #import "GoogleMapPolylineController.h" #import "GoogleMapPolylineController_Test.h" -#import "FLTGoogleMapJSONConversions.h" +#import "FGMConversionUtils.h" @interface FLTGoogleMapPolylineController () @@ -46,7 +46,7 @@ + (void)updatePolyline:(GMSPolyline *)polyline GMSMutablePath *path = FGMGetPathFromPoints(FGMGetPointsForPigeonLatLngs(platformPolyline.points)); polyline.path = path; - UIColor *strokeColor = FGMGetColorForRGBA(platformPolyline.color); + UIColor *strokeColor = FGMGetColorForPigeonColor(platformPolyline.color); polyline.strokeColor = strokeColor; polyline.strokeWidth = platformPolyline.width; polyline.geodesic = platformPolyline.geodesic; diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h index 29ef04589aa7..e35e8c3aa70c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/google_maps_flutter_ios-umbrella.h @@ -3,12 +3,12 @@ // found in the LICENSE file. #import +#import #import #import #import #import #import -#import #import #import #import diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.h b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.h index a814fb02f247..fc8146dd0b41 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.h +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.h @@ -96,6 +96,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { @class FGMPlatformMapConfiguration; @class FGMPlatformPoint; @class FGMPlatformSize; +@class FGMPlatformColor; @class FGMPlatformTileLayer; @class FGMPlatformZoomRange; @class FGMPlatformBitmap; @@ -205,8 +206,8 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { /// `init` unavailable to enforce nonnull fields, see the `make` class method. - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithConsumeTapEvents:(BOOL)consumeTapEvents - fillColor:(NSInteger)fillColor - strokeColor:(NSInteger)strokeColor + fillColor:(FGMPlatformColor *)fillColor + strokeColor:(FGMPlatformColor *)strokeColor visible:(BOOL)visible strokeWidth:(NSInteger)strokeWidth zIndex:(double)zIndex @@ -214,8 +215,8 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { radius:(double)radius circleId:(NSString *)circleId; @property(nonatomic, assign) BOOL consumeTapEvents; -@property(nonatomic, assign) NSInteger fillColor; -@property(nonatomic, assign) NSInteger strokeColor; +@property(nonatomic, strong) FGMPlatformColor *fillColor; +@property(nonatomic, strong) FGMPlatformColor *strokeColor; @property(nonatomic, assign) BOOL visible; @property(nonatomic, assign) NSInteger strokeWidth; @property(nonatomic, assign) double zIndex; @@ -307,22 +308,22 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithPolygonId:(NSString *)polygonId consumesTapEvents:(BOOL)consumesTapEvents - fillColor:(NSInteger)fillColor + fillColor:(FGMPlatformColor *)fillColor geodesic:(BOOL)geodesic points:(NSArray *)points holes:(NSArray *> *)holes visible:(BOOL)visible - strokeColor:(NSInteger)strokeColor + strokeColor:(FGMPlatformColor *)strokeColor strokeWidth:(NSInteger)strokeWidth zIndex:(NSInteger)zIndex; @property(nonatomic, copy) NSString *polygonId; @property(nonatomic, assign) BOOL consumesTapEvents; -@property(nonatomic, assign) NSInteger fillColor; +@property(nonatomic, strong) FGMPlatformColor *fillColor; @property(nonatomic, assign) BOOL geodesic; @property(nonatomic, copy) NSArray *points; @property(nonatomic, copy) NSArray *> *holes; @property(nonatomic, assign) BOOL visible; -@property(nonatomic, assign) NSInteger strokeColor; +@property(nonatomic, strong) FGMPlatformColor *strokeColor; @property(nonatomic, assign) NSInteger strokeWidth; @property(nonatomic, assign) NSInteger zIndex; @end @@ -333,7 +334,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { - (instancetype)init NS_UNAVAILABLE; + (instancetype)makeWithPolylineId:(NSString *)polylineId consumesTapEvents:(BOOL)consumesTapEvents - color:(NSInteger)color + color:(FGMPlatformColor *)color geodesic:(BOOL)geodesic jointType:(FGMPlatformJointType)jointType patterns:(NSArray *)patterns @@ -343,7 +344,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { zIndex:(NSInteger)zIndex; @property(nonatomic, copy) NSString *polylineId; @property(nonatomic, assign) BOOL consumesTapEvents; -@property(nonatomic, assign) NSInteger color; +@property(nonatomic, strong) FGMPlatformColor *color; @property(nonatomic, assign) BOOL geodesic; /// The joint type. @property(nonatomic, assign) FGMPlatformJointType jointType; @@ -505,7 +506,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { indoorViewEnabled:(nullable NSNumber *)indoorViewEnabled trafficEnabled:(nullable NSNumber *)trafficEnabled buildingsEnabled:(nullable NSNumber *)buildingsEnabled - cloudMapId:(nullable NSString *)cloudMapId + mapId:(nullable NSString *)mapId style:(nullable NSString *)style; @property(nonatomic, strong, nullable) NSNumber *compassEnabled; @property(nonatomic, strong, nullable) FGMPlatformCameraTargetBounds *cameraTargetBounds; @@ -522,7 +523,7 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { @property(nonatomic, strong, nullable) NSNumber *indoorViewEnabled; @property(nonatomic, strong, nullable) NSNumber *trafficEnabled; @property(nonatomic, strong, nullable) NSNumber *buildingsEnabled; -@property(nonatomic, copy, nullable) NSString *cloudMapId; +@property(nonatomic, copy, nullable) NSString *mapId; @property(nonatomic, copy, nullable) NSString *style; @end @@ -544,6 +545,17 @@ typedef NS_ENUM(NSUInteger, FGMPlatformMapBitmapScaling) { @property(nonatomic, assign) double height; @end +/// Pigeon representation of a color. +@interface FGMPlatformColor : NSObject +/// `init` unavailable to enforce nonnull fields, see the `make` class method. +- (instancetype)init NS_UNAVAILABLE; ++ (instancetype)makeWithRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha; +@property(nonatomic, assign) double red; +@property(nonatomic, assign) double green; +@property(nonatomic, assign) double blue; +@property(nonatomic, assign) double alpha; +@end + /// Pigeon equivalent of GMSTileLayer properties. @interface FGMPlatformTileLayer : NSObject /// `init` unavailable to enforce nonnull fields, see the `make` class method. diff --git a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.m b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.m index dc44ed382b58..86a485af865a 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.m +++ b/packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/messages.g.m @@ -263,6 +263,12 @@ + (nullable FGMPlatformSize *)nullableFromList:(NSArray *)list; - (NSArray *)toList; @end +@interface FGMPlatformColor () ++ (FGMPlatformColor *)fromList:(NSArray *)list; ++ (nullable FGMPlatformColor *)nullableFromList:(NSArray *)list; +- (NSArray *)toList; +@end + @interface FGMPlatformTileLayer () + (FGMPlatformTileLayer *)fromList:(NSArray *)list; + (nullable FGMPlatformTileLayer *)nullableFromList:(NSArray *)list; @@ -559,8 +565,8 @@ + (nullable FGMPlatformCameraUpdateZoomTo *)nullableFromList:(NSArray *)list @implementation FGMPlatformCircle + (instancetype)makeWithConsumeTapEvents:(BOOL)consumeTapEvents - fillColor:(NSInteger)fillColor - strokeColor:(NSInteger)strokeColor + fillColor:(FGMPlatformColor *)fillColor + strokeColor:(FGMPlatformColor *)strokeColor visible:(BOOL)visible strokeWidth:(NSInteger)strokeWidth zIndex:(double)zIndex @@ -582,8 +588,8 @@ + (instancetype)makeWithConsumeTapEvents:(BOOL)consumeTapEvents + (FGMPlatformCircle *)fromList:(NSArray *)list { FGMPlatformCircle *pigeonResult = [[FGMPlatformCircle alloc] init]; pigeonResult.consumeTapEvents = [GetNullableObjectAtIndex(list, 0) boolValue]; - pigeonResult.fillColor = [GetNullableObjectAtIndex(list, 1) integerValue]; - pigeonResult.strokeColor = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.fillColor = GetNullableObjectAtIndex(list, 1); + pigeonResult.strokeColor = GetNullableObjectAtIndex(list, 2); pigeonResult.visible = [GetNullableObjectAtIndex(list, 3) boolValue]; pigeonResult.strokeWidth = [GetNullableObjectAtIndex(list, 4) integerValue]; pigeonResult.zIndex = [GetNullableObjectAtIndex(list, 5) doubleValue]; @@ -598,8 +604,8 @@ + (nullable FGMPlatformCircle *)nullableFromList:(NSArray *)list { - (NSArray *)toList { return @[ @(self.consumeTapEvents), - @(self.fillColor), - @(self.strokeColor), + self.fillColor ?: [NSNull null], + self.strokeColor ?: [NSNull null], @(self.visible), @(self.strokeWidth), @(self.zIndex), @@ -786,12 +792,12 @@ + (nullable FGMPlatformMarker *)nullableFromList:(NSArray *)list { @implementation FGMPlatformPolygon + (instancetype)makeWithPolygonId:(NSString *)polygonId consumesTapEvents:(BOOL)consumesTapEvents - fillColor:(NSInteger)fillColor + fillColor:(FGMPlatformColor *)fillColor geodesic:(BOOL)geodesic points:(NSArray *)points holes:(NSArray *> *)holes visible:(BOOL)visible - strokeColor:(NSInteger)strokeColor + strokeColor:(FGMPlatformColor *)strokeColor strokeWidth:(NSInteger)strokeWidth zIndex:(NSInteger)zIndex { FGMPlatformPolygon *pigeonResult = [[FGMPlatformPolygon alloc] init]; @@ -811,12 +817,12 @@ + (FGMPlatformPolygon *)fromList:(NSArray *)list { FGMPlatformPolygon *pigeonResult = [[FGMPlatformPolygon alloc] init]; pigeonResult.polygonId = GetNullableObjectAtIndex(list, 0); pigeonResult.consumesTapEvents = [GetNullableObjectAtIndex(list, 1) boolValue]; - pigeonResult.fillColor = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.fillColor = GetNullableObjectAtIndex(list, 2); pigeonResult.geodesic = [GetNullableObjectAtIndex(list, 3) boolValue]; pigeonResult.points = GetNullableObjectAtIndex(list, 4); pigeonResult.holes = GetNullableObjectAtIndex(list, 5); pigeonResult.visible = [GetNullableObjectAtIndex(list, 6) boolValue]; - pigeonResult.strokeColor = [GetNullableObjectAtIndex(list, 7) integerValue]; + pigeonResult.strokeColor = GetNullableObjectAtIndex(list, 7); pigeonResult.strokeWidth = [GetNullableObjectAtIndex(list, 8) integerValue]; pigeonResult.zIndex = [GetNullableObjectAtIndex(list, 9) integerValue]; return pigeonResult; @@ -828,12 +834,12 @@ + (nullable FGMPlatformPolygon *)nullableFromList:(NSArray *)list { return @[ self.polygonId ?: [NSNull null], @(self.consumesTapEvents), - @(self.fillColor), + self.fillColor ?: [NSNull null], @(self.geodesic), self.points ?: [NSNull null], self.holes ?: [NSNull null], @(self.visible), - @(self.strokeColor), + self.strokeColor ?: [NSNull null], @(self.strokeWidth), @(self.zIndex), ]; @@ -843,7 +849,7 @@ + (nullable FGMPlatformPolygon *)nullableFromList:(NSArray *)list { @implementation FGMPlatformPolyline + (instancetype)makeWithPolylineId:(NSString *)polylineId consumesTapEvents:(BOOL)consumesTapEvents - color:(NSInteger)color + color:(FGMPlatformColor *)color geodesic:(BOOL)geodesic jointType:(FGMPlatformJointType)jointType patterns:(NSArray *)patterns @@ -868,7 +874,7 @@ + (FGMPlatformPolyline *)fromList:(NSArray *)list { FGMPlatformPolyline *pigeonResult = [[FGMPlatformPolyline alloc] init]; pigeonResult.polylineId = GetNullableObjectAtIndex(list, 0); pigeonResult.consumesTapEvents = [GetNullableObjectAtIndex(list, 1) boolValue]; - pigeonResult.color = [GetNullableObjectAtIndex(list, 2) integerValue]; + pigeonResult.color = GetNullableObjectAtIndex(list, 2); pigeonResult.geodesic = [GetNullableObjectAtIndex(list, 3) boolValue]; FGMPlatformJointTypeBox *boxedFGMPlatformJointType = GetNullableObjectAtIndex(list, 4); pigeonResult.jointType = boxedFGMPlatformJointType.value; @@ -886,7 +892,7 @@ + (nullable FGMPlatformPolyline *)nullableFromList:(NSArray *)list { return @[ self.polylineId ?: [NSNull null], @(self.consumesTapEvents), - @(self.color), + self.color ?: [NSNull null], @(self.geodesic), [[FGMPlatformJointTypeBox alloc] initWithValue:self.jointType], self.patterns ?: [NSNull null], @@ -1232,7 +1238,7 @@ + (instancetype)makeWithCompassEnabled:(nullable NSNumber *)compassEnabled indoorViewEnabled:(nullable NSNumber *)indoorViewEnabled trafficEnabled:(nullable NSNumber *)trafficEnabled buildingsEnabled:(nullable NSNumber *)buildingsEnabled - cloudMapId:(nullable NSString *)cloudMapId + mapId:(nullable NSString *)mapId style:(nullable NSString *)style { FGMPlatformMapConfiguration *pigeonResult = [[FGMPlatformMapConfiguration alloc] init]; pigeonResult.compassEnabled = compassEnabled; @@ -1250,7 +1256,7 @@ + (instancetype)makeWithCompassEnabled:(nullable NSNumber *)compassEnabled pigeonResult.indoorViewEnabled = indoorViewEnabled; pigeonResult.trafficEnabled = trafficEnabled; pigeonResult.buildingsEnabled = buildingsEnabled; - pigeonResult.cloudMapId = cloudMapId; + pigeonResult.mapId = mapId; pigeonResult.style = style; return pigeonResult; } @@ -1271,7 +1277,7 @@ + (FGMPlatformMapConfiguration *)fromList:(NSArray *)list { pigeonResult.indoorViewEnabled = GetNullableObjectAtIndex(list, 12); pigeonResult.trafficEnabled = GetNullableObjectAtIndex(list, 13); pigeonResult.buildingsEnabled = GetNullableObjectAtIndex(list, 14); - pigeonResult.cloudMapId = GetNullableObjectAtIndex(list, 15); + pigeonResult.mapId = GetNullableObjectAtIndex(list, 15); pigeonResult.style = GetNullableObjectAtIndex(list, 16); return pigeonResult; } @@ -1295,7 +1301,7 @@ + (nullable FGMPlatformMapConfiguration *)nullableFromList:(NSArray *)list { self.indoorViewEnabled ?: [NSNull null], self.trafficEnabled ?: [NSNull null], self.buildingsEnabled ?: [NSNull null], - self.cloudMapId ?: [NSNull null], + self.mapId ?: [NSNull null], self.style ?: [NSNull null], ]; } @@ -1349,6 +1355,36 @@ + (nullable FGMPlatformSize *)nullableFromList:(NSArray *)list { } @end +@implementation FGMPlatformColor ++ (instancetype)makeWithRed:(double)red green:(double)green blue:(double)blue alpha:(double)alpha { + FGMPlatformColor *pigeonResult = [[FGMPlatformColor alloc] init]; + pigeonResult.red = red; + pigeonResult.green = green; + pigeonResult.blue = blue; + pigeonResult.alpha = alpha; + return pigeonResult; +} ++ (FGMPlatformColor *)fromList:(NSArray *)list { + FGMPlatformColor *pigeonResult = [[FGMPlatformColor alloc] init]; + pigeonResult.red = [GetNullableObjectAtIndex(list, 0) doubleValue]; + pigeonResult.green = [GetNullableObjectAtIndex(list, 1) doubleValue]; + pigeonResult.blue = [GetNullableObjectAtIndex(list, 2) doubleValue]; + pigeonResult.alpha = [GetNullableObjectAtIndex(list, 3) doubleValue]; + return pigeonResult; +} ++ (nullable FGMPlatformColor *)nullableFromList:(NSArray *)list { + return (list) ? [FGMPlatformColor fromList:list] : nil; +} +- (NSArray *)toList { + return @[ + @(self.red), + @(self.green), + @(self.blue), + @(self.alpha), + ]; +} +@end + @implementation FGMPlatformTileLayer + (instancetype)makeWithVisible:(BOOL)visible fadeIn:(BOOL)fadeIn @@ -1694,22 +1730,24 @@ - (nullable id)readValueOfType:(UInt8)type { case 162: return [FGMPlatformSize fromList:[self readValue]]; case 163: - return [FGMPlatformTileLayer fromList:[self readValue]]; + return [FGMPlatformColor fromList:[self readValue]]; case 164: - return [FGMPlatformZoomRange fromList:[self readValue]]; + return [FGMPlatformTileLayer fromList:[self readValue]]; case 165: - return [FGMPlatformBitmap fromList:[self readValue]]; + return [FGMPlatformZoomRange fromList:[self readValue]]; case 166: - return [FGMPlatformBitmapDefaultMarker fromList:[self readValue]]; + return [FGMPlatformBitmap fromList:[self readValue]]; case 167: - return [FGMPlatformBitmapBytes fromList:[self readValue]]; + return [FGMPlatformBitmapDefaultMarker fromList:[self readValue]]; case 168: - return [FGMPlatformBitmapAsset fromList:[self readValue]]; + return [FGMPlatformBitmapBytes fromList:[self readValue]]; case 169: - return [FGMPlatformBitmapAssetImage fromList:[self readValue]]; + return [FGMPlatformBitmapAsset fromList:[self readValue]]; case 170: - return [FGMPlatformBitmapAssetMap fromList:[self readValue]]; + return [FGMPlatformBitmapAssetImage fromList:[self readValue]]; case 171: + return [FGMPlatformBitmapAssetMap fromList:[self readValue]]; + case 172: return [FGMPlatformBitmapBytesMap fromList:[self readValue]]; default: return [super readValueOfType:type]; @@ -1827,33 +1865,36 @@ - (void)writeValue:(id)value { } else if ([value isKindOfClass:[FGMPlatformSize class]]) { [self writeByte:162]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FGMPlatformTileLayer class]]) { + } else if ([value isKindOfClass:[FGMPlatformColor class]]) { [self writeByte:163]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FGMPlatformZoomRange class]]) { + } else if ([value isKindOfClass:[FGMPlatformTileLayer class]]) { [self writeByte:164]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FGMPlatformBitmap class]]) { + } else if ([value isKindOfClass:[FGMPlatformZoomRange class]]) { [self writeByte:165]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FGMPlatformBitmapDefaultMarker class]]) { + } else if ([value isKindOfClass:[FGMPlatformBitmap class]]) { [self writeByte:166]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FGMPlatformBitmapBytes class]]) { + } else if ([value isKindOfClass:[FGMPlatformBitmapDefaultMarker class]]) { [self writeByte:167]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FGMPlatformBitmapAsset class]]) { + } else if ([value isKindOfClass:[FGMPlatformBitmapBytes class]]) { [self writeByte:168]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FGMPlatformBitmapAssetImage class]]) { + } else if ([value isKindOfClass:[FGMPlatformBitmapAsset class]]) { [self writeByte:169]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FGMPlatformBitmapAssetMap class]]) { + } else if ([value isKindOfClass:[FGMPlatformBitmapAssetImage class]]) { [self writeByte:170]; [self writeValue:[value toList]]; - } else if ([value isKindOfClass:[FGMPlatformBitmapBytesMap class]]) { + } else if ([value isKindOfClass:[FGMPlatformBitmapAssetMap class]]) { [self writeByte:171]; [self writeValue:[value toList]]; + } else if ([value isKindOfClass:[FGMPlatformBitmapBytesMap class]]) { + [self writeByte:172]; + [self writeValue:[value toList]]; } else { [super writeValue:value]; } 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 1794c914855c..51a7d1afd473 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 @@ -15,9 +15,6 @@ import 'google_map_inspector_ios.dart'; import 'messages.g.dart'; import 'serialization.dart'; -// TODO(stuartmorgan): Remove the dependency on platform interface toJson -// methods. Channel serialization details should all be package-internal. - /// The non-test implementation of `_apiProvider`. MapsApi _productionApiProvider(int mapId) { return MapsApi(messageChannelSuffix: mapId.toString()); @@ -658,8 +655,18 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { static PlatformCircle _platformCircleFromCircle(Circle circle) { return PlatformCircle( consumeTapEvents: circle.consumeTapEvents, - fillColor: circle.fillColor.value, - strokeColor: circle.strokeColor.value, + fillColor: PlatformColor( + red: circle.fillColor.r, + green: circle.fillColor.g, + blue: circle.fillColor.b, + alpha: circle.fillColor.a, + ), + strokeColor: PlatformColor( + red: circle.strokeColor.r, + green: circle.strokeColor.g, + blue: circle.strokeColor.b, + alpha: circle.strokeColor.a, + ), visible: circle.visible, strokeWidth: circle.strokeWidth, zIndex: circle.zIndex.toDouble(), @@ -734,12 +741,22 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { }).toList(); return PlatformPolygon( polygonId: polygon.polygonId.value, - fillColor: polygon.fillColor.value, + fillColor: PlatformColor( + red: polygon.fillColor.r, + green: polygon.fillColor.g, + blue: polygon.fillColor.b, + alpha: polygon.fillColor.a, + ), geodesic: polygon.geodesic, consumesTapEvents: polygon.consumeTapEvents, points: points, holes: holes, - strokeColor: polygon.strokeColor.value, + strokeColor: PlatformColor( + red: polygon.strokeColor.r, + green: polygon.strokeColor.g, + blue: polygon.strokeColor.b, + alpha: polygon.strokeColor.a, + ), strokeWidth: polygon.strokeWidth, zIndex: polygon.zIndex, visible: polygon.visible, @@ -756,7 +773,12 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { return PlatformPolyline( polylineId: polyline.polylineId.value, consumesTapEvents: polyline.consumeTapEvents, - color: polyline.color.value, + color: PlatformColor( + red: polyline.color.r, + green: polyline.color.g, + blue: polyline.color.b, + alpha: polyline.color.a, + ), geodesic: polyline.geodesic, visible: polyline.visible, width: polyline.width, @@ -1220,7 +1242,7 @@ PlatformMapConfiguration _platformMapConfigurationFromMapConfiguration( indoorViewEnabled: config.indoorViewEnabled, trafficEnabled: config.trafficEnabled, buildingsEnabled: config.buildingsEnabled, - cloudMapId: config.cloudMapId, + mapId: config.mapId, style: config.style, ); } @@ -1262,7 +1284,7 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( indoorViewEnabled: options['indoorEnabled'] as bool?, trafficEnabled: options['trafficEnabled'] as bool?, buildingsEnabled: options['buildingsEnabled'] as bool?, - cloudMapId: options['cloudMapId'] as String?, + mapId: options['cloudMapId'] as String?, style: options['style'] as String?, ); } 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 09197a6bf21d..2bb8b3fb42d6 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 @@ -479,8 +479,8 @@ class PlatformCameraUpdateZoomTo { class PlatformCircle { PlatformCircle({ this.consumeTapEvents = false, - this.fillColor = 0x00000000, - this.strokeColor = 0xFF000000, + required this.fillColor, + required this.strokeColor, this.visible = true, this.strokeWidth = 10, this.zIndex = 0.0, @@ -491,9 +491,9 @@ class PlatformCircle { bool consumeTapEvents; - int fillColor; + PlatformColor fillColor; - int strokeColor; + PlatformColor strokeColor; bool visible; @@ -529,8 +529,8 @@ class PlatformCircle { result as List; return PlatformCircle( consumeTapEvents: result[0]! as bool, - fillColor: result[1]! as int, - strokeColor: result[2]! as int, + fillColor: result[1]! as PlatformColor, + strokeColor: result[2]! as PlatformColor, visible: result[3]! as bool, strokeWidth: result[4]! as int, zIndex: result[5]! as double, @@ -849,7 +849,7 @@ class PlatformPolygon { bool consumesTapEvents; - int fillColor; + PlatformColor fillColor; bool geodesic; @@ -859,7 +859,7 @@ class PlatformPolygon { bool visible; - int strokeColor; + PlatformColor strokeColor; int strokeWidth; @@ -889,12 +889,12 @@ class PlatformPolygon { return PlatformPolygon( polygonId: result[0]! as String, consumesTapEvents: result[1]! as bool, - fillColor: result[2]! as int, + fillColor: result[2]! as PlatformColor, geodesic: result[3]! as bool, points: (result[4] as List?)!.cast(), holes: (result[5] as List?)!.cast>(), visible: result[6]! as bool, - strokeColor: result[7]! as int, + strokeColor: result[7]! as PlatformColor, strokeWidth: result[8]! as int, zIndex: result[9]! as int, ); @@ -936,7 +936,7 @@ class PlatformPolyline { bool consumesTapEvents; - int color; + PlatformColor color; bool geodesic; @@ -978,7 +978,7 @@ class PlatformPolyline { return PlatformPolyline( polylineId: result[0]! as String, consumesTapEvents: result[1]! as bool, - color: result[2]! as int, + color: result[2]! as PlatformColor, geodesic: result[3]! as bool, jointType: result[4]! as PlatformJointType, patterns: (result[5] as List?)!.cast(), @@ -1535,7 +1535,7 @@ class PlatformMapConfiguration { this.indoorViewEnabled, this.trafficEnabled, this.buildingsEnabled, - this.cloudMapId, + this.mapId, this.style, }); @@ -1569,7 +1569,7 @@ class PlatformMapConfiguration { bool? buildingsEnabled; - String? cloudMapId; + String? mapId; String? style; @@ -1590,7 +1590,7 @@ class PlatformMapConfiguration { indoorViewEnabled, trafficEnabled, buildingsEnabled, - cloudMapId, + mapId, style, ]; } @@ -1617,7 +1617,7 @@ class PlatformMapConfiguration { indoorViewEnabled: result[12] as bool?, trafficEnabled: result[13] as bool?, buildingsEnabled: result[14] as bool?, - cloudMapId: result[15] as String?, + mapId: result[15] as String?, style: result[16] as String?, ); } @@ -1719,6 +1719,58 @@ class PlatformSize { int get hashCode => Object.hashAll(_toList()); } +/// Pigeon representation of a color. +class PlatformColor { + PlatformColor({ + required this.red, + required this.green, + required this.blue, + required this.alpha, + }); + + double red; + + double green; + + double blue; + + double alpha; + + List _toList() { + return [red, green, blue, alpha]; + } + + Object encode() { + return _toList(); + } + + static PlatformColor decode(Object result) { + result as List; + return PlatformColor( + red: result[0]! as double, + green: result[1]! as double, + blue: result[2]! as double, + alpha: result[3]! as double, + ); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + bool operator ==(Object other) { + if (other is! PlatformColor || other.runtimeType != runtimeType) { + return false; + } + if (identical(this, other)) { + return true; + } + return _deepEquals(encode(), other.encode()); + } + + @override + // ignore: avoid_equals_and_hash_code_on_mutable_classes + int get hashCode => Object.hashAll(_toList()); +} + /// Pigeon equivalent of GMSTileLayer properties. class PlatformTileLayer { PlatformTileLayer({ @@ -2246,33 +2298,36 @@ class _PigeonCodec extends StandardMessageCodec { } else if (value is PlatformSize) { buffer.putUint8(162); writeValue(buffer, value.encode()); - } else if (value is PlatformTileLayer) { + } else if (value is PlatformColor) { buffer.putUint8(163); writeValue(buffer, value.encode()); - } else if (value is PlatformZoomRange) { + } else if (value is PlatformTileLayer) { buffer.putUint8(164); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmap) { + } else if (value is PlatformZoomRange) { buffer.putUint8(165); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapDefaultMarker) { + } else if (value is PlatformBitmap) { buffer.putUint8(166); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapBytes) { + } else if (value is PlatformBitmapDefaultMarker) { buffer.putUint8(167); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapAsset) { + } else if (value is PlatformBitmapBytes) { buffer.putUint8(168); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapAssetImage) { + } else if (value is PlatformBitmapAsset) { buffer.putUint8(169); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapAssetMap) { + } else if (value is PlatformBitmapAssetImage) { buffer.putUint8(170); writeValue(buffer, value.encode()); - } else if (value is PlatformBitmapBytesMap) { + } else if (value is PlatformBitmapAssetMap) { buffer.putUint8(171); writeValue(buffer, value.encode()); + } else if (value is PlatformBitmapBytesMap) { + buffer.putUint8(172); + writeValue(buffer, value.encode()); } else { super.writeValue(buffer, value); } @@ -2354,22 +2409,24 @@ class _PigeonCodec extends StandardMessageCodec { case 162: return PlatformSize.decode(readValue(buffer)!); case 163: - return PlatformTileLayer.decode(readValue(buffer)!); + return PlatformColor.decode(readValue(buffer)!); case 164: - return PlatformZoomRange.decode(readValue(buffer)!); + return PlatformTileLayer.decode(readValue(buffer)!); case 165: - return PlatformBitmap.decode(readValue(buffer)!); + return PlatformZoomRange.decode(readValue(buffer)!); case 166: - return PlatformBitmapDefaultMarker.decode(readValue(buffer)!); + return PlatformBitmap.decode(readValue(buffer)!); case 167: - return PlatformBitmapBytes.decode(readValue(buffer)!); + return PlatformBitmapDefaultMarker.decode(readValue(buffer)!); case 168: - return PlatformBitmapAsset.decode(readValue(buffer)!); + return PlatformBitmapBytes.decode(readValue(buffer)!); case 169: - return PlatformBitmapAssetImage.decode(readValue(buffer)!); + return PlatformBitmapAsset.decode(readValue(buffer)!); case 170: - return PlatformBitmapAssetMap.decode(readValue(buffer)!); + return PlatformBitmapAssetImage.decode(readValue(buffer)!); case 171: + return PlatformBitmapAssetMap.decode(readValue(buffer)!); + case 172: return PlatformBitmapBytesMap.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); 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 aa94f6c12b26..f31f9f760cd9 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 @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; import 'package:google_maps_flutter_platform_interface/google_maps_flutter_platform_interface.dart'; -// These constants must match the corresponding constants in FLTGoogleMapJSONConversions.m +// These constants must match the corresponding constants in FGMConversionUtils.m const String _heatmapIdKey = 'heatmapId'; const String _heatmapDataKey = 'data'; const String _heatmapGradientKey = 'gradient'; @@ -96,7 +96,9 @@ Object serializeHeatmapGradient(HeatmapGradient gradient) { _addIfNonNull( json, _heatmapGradientColorsKey, - gradient.colors.map((HeatmapGradientColor e) => e.color.value).toList(), + gradient.colors + .map((HeatmapGradientColor e) => e.color.toARGB32()) + .toList(), ); _addIfNonNull( json, 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 14f270076719..98af369be23a 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 @@ -101,9 +101,9 @@ class PlatformCircle { PlatformCircle({ required this.circleId, required this.center, + required this.fillColor, + required this.strokeColor, this.consumeTapEvents = false, - this.fillColor = 0x00000000, - this.strokeColor = 0xFF000000, this.visible = true, this.strokeWidth = 10, this.zIndex = 0.0, @@ -111,8 +111,8 @@ class PlatformCircle { }); final bool consumeTapEvents; - final int fillColor; - final int strokeColor; + final PlatformColor fillColor; + final PlatformColor strokeColor; final bool visible; final int strokeWidth; final double zIndex; @@ -215,12 +215,12 @@ class PlatformPolygon { final String polygonId; final bool consumesTapEvents; - final int fillColor; + final PlatformColor fillColor; final bool geodesic; final List points; final List> holes; final bool visible; - final int strokeColor; + final PlatformColor strokeColor; final int strokeWidth; final int zIndex; } @@ -245,7 +245,7 @@ class PlatformPolyline { final String polylineId; final bool consumesTapEvents; - final int color; + final PlatformColor color; final bool geodesic; /// The joint type. @@ -414,7 +414,7 @@ class PlatformMapConfiguration { required this.indoorViewEnabled, required this.trafficEnabled, required this.buildingsEnabled, - required this.cloudMapId, + required this.mapId, required this.style, }); @@ -433,7 +433,7 @@ class PlatformMapConfiguration { final bool? indoorViewEnabled; final bool? trafficEnabled; final bool? buildingsEnabled; - final String? cloudMapId; + final String? mapId; final String? style; } @@ -453,6 +453,21 @@ class PlatformSize { final double height; } +/// Pigeon representation of a color. +class PlatformColor { + PlatformColor({ + required this.red, + required this.green, + required this.blue, + required this.alpha, + }); + + final double red; + final double green; + final double blue; + final double alpha; +} + /// Pigeon equivalent of GMSTileLayer properties. class PlatformTileLayer { PlatformTileLayer({ 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 2dfd81cc2c1b..3dd84d3a71db 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml @@ -2,7 +2,7 @@ name: google_maps_flutter_ios description: iOS implementation of the google_maps_flutter plugin. repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter_ios issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 -version: 2.15.7 +version: 2.15.8 environment: sdk: ^3.8.0 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 84890f6f8838..1b91f2a4a89a 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 @@ -411,8 +411,8 @@ void main() { expect(toChange.length, 1); final PlatformCircle firstChanged = toChange.first; expect(firstChanged.consumeTapEvents, object2new.consumeTapEvents); - expect(firstChanged.fillColor, object2new.fillColor.value); - expect(firstChanged.strokeColor, object2new.strokeColor.value); + _expectColorsEqual(firstChanged.fillColor, object2new.fillColor); + _expectColorsEqual(firstChanged.strokeColor, object2new.strokeColor); expect(firstChanged.visible, object2new.visible); expect(firstChanged.strokeWidth, object2new.strokeWidth); expect(firstChanged.zIndex, object2new.zIndex.toDouble()); @@ -426,8 +426,8 @@ void main() { expect(toAdd.length, 1); final PlatformCircle firstAdded = toAdd.first; expect(firstAdded.consumeTapEvents, object3.consumeTapEvents); - expect(firstAdded.fillColor, object3.fillColor.value); - expect(firstAdded.strokeColor, object3.strokeColor.value); + _expectColorsEqual(firstAdded.fillColor, object3.fillColor); + _expectColorsEqual(firstAdded.strokeColor, object3.strokeColor); expect(firstAdded.visible, object3.visible); expect(firstAdded.strokeWidth, object3.strokeWidth); expect(firstAdded.zIndex, object3.zIndex.toDouble()); @@ -593,7 +593,7 @@ void main() { void expectPolygon(PlatformPolygon actual, Polygon expected) { expect(actual.polygonId, expected.polygonId.value); expect(actual.consumesTapEvents, expected.consumeTapEvents); - expect(actual.fillColor, expected.fillColor.value); + _expectColorsEqual(actual.fillColor, expected.fillColor); expect(actual.geodesic, expected.geodesic); expect(actual.points.length, expected.points.length); for (final (int i, PlatformLatLng? point) in actual.points.indexed) { @@ -609,7 +609,7 @@ void main() { } } expect(actual.visible, expected.visible); - expect(actual.strokeColor, expected.strokeColor.value); + _expectColorsEqual(actual.strokeColor, expected.strokeColor); expect(actual.strokeWidth, expected.strokeWidth); expect(actual.zIndex, expected.zIndex); } @@ -663,7 +663,7 @@ void main() { void expectPolyline(PlatformPolyline actual, Polyline expected) { expect(actual.polylineId, expected.polylineId.value); expect(actual.consumesTapEvents, expected.consumeTapEvents); - expect(actual.color, expected.color.value); + _expectColorsEqual(actual.color, expected.color); expect(actual.geodesic, expected.geodesic); expect( actual.jointType, @@ -1346,7 +1346,7 @@ void main() { expect(typedBitmap.height, 200.0); }); - testWidgets('cloudMapId is passed', (WidgetTester tester) async { + testWidgets('mapId is passed', (WidgetTester tester) async { const String cloudMapId = '000000000000000'; // Dummy map ID. final Completer passedCloudMapIdCompleter = Completer(); @@ -1366,7 +1366,7 @@ void main() { as PlatformMapViewCreationParams?; if (creationParams != null) { final String? passedMapId = - creationParams.mapConfiguration.cloudMapId; + creationParams.mapConfiguration.mapId; if (passedMapId != null) { passedCloudMapIdCompleter.complete(passedMapId); } @@ -1391,7 +1391,7 @@ void main() { ), textDirection: TextDirection.ltr, ), - mapConfiguration: const MapConfiguration(cloudMapId: cloudMapId), + mapConfiguration: const MapConfiguration(mapId: cloudMapId), ), ), ); @@ -1399,7 +1399,14 @@ void main() { expect( await passedCloudMapIdCompleter.future, cloudMapId, - reason: 'Should pass cloudMapId on PlatformView creation message', + reason: 'Should pass mapId on PlatformView creation message', ); }); } + +void _expectColorsEqual(PlatformColor actual, Color expected) { + expect(actual.red, expected.r); + expect(actual.green, expected.g); + expect(actual.blue, expected.b); + expect(actual.alpha, expected.a); +} 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 66d5d24c6e41..5c3cf395141b 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 @@ -130,7 +130,9 @@ Object serializeHeatmapGradient(HeatmapGradient gradient) { _addIfNonNull( json, _heatmapGradientColorsKey, - gradient.colors.map((HeatmapGradientColor e) => e.color.value).toList(), + gradient.colors + .map((HeatmapGradientColor e) => e.color.toARGB32()) + .toList(), ); _addIfNonNull( json, 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 ef40f0ef7512..8ad4752685f9 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 @@ -1107,8 +1107,9 @@ class PinConfig extends BitmapDescriptor { Object toJson() => [ type, { - if (backgroundColor != null) 'backgroundColor': backgroundColor?.value, - if (borderColor != null) 'borderColor': borderColor?.value, + if (backgroundColor != null) + 'backgroundColor': backgroundColor?.toARGB32(), + if (borderColor != null) 'borderColor': borderColor?.toARGB32(), if (glyph != null) 'glyph': glyph?.toJson(), }, ]; @@ -1131,7 +1132,7 @@ class CircleGlyph extends AdvancedMarkerGlyph { @override Object toJson() => [ 'circleGlyph', - {'color': color.value}, + {'color': color.toARGB32()}, ]; } @@ -1175,7 +1176,7 @@ class TextGlyph extends AdvancedMarkerGlyph { 'textGlyph', { 'text': text, - if (textColor != null) 'textColor': textColor!.value, + if (textColor != null) 'textColor': textColor!.toARGB32(), }, ]; } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart index c81e2184cbf1..3dc0161d9536 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart @@ -121,10 +121,10 @@ class Circle implements MapsObject { addIfPresent('circleId', circleId.value); addIfPresent('consumeTapEvents', consumeTapEvents); - addIfPresent('fillColor', fillColor.value); + addIfPresent('fillColor', fillColor.toARGB32()); addIfPresent('center', center.toJson()); addIfPresent('radius', radius); - addIfPresent('strokeColor', strokeColor.value); + addIfPresent('strokeColor', strokeColor.toARGB32()); addIfPresent('strokeWidth', strokeWidth); addIfPresent('visible', visible); addIfPresent('zIndex', zIndex); 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 950711868ea4..1eb10292aa8a 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 @@ -293,7 +293,7 @@ class HeatmapGradient { addIfPresent( 'colors', - colors.map((HeatmapGradientColor e) => e.color.value).toList(), + colors.map((HeatmapGradientColor e) => e.color.toARGB32()).toList(), ); addIfPresent( 'startPoints', diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart index 1cf820f08497..fed4a2c9e48f 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart @@ -141,9 +141,9 @@ class Polygon implements MapsObject { addIfPresent('polygonId', polygonId.value); addIfPresent('consumeTapEvents', consumeTapEvents); - addIfPresent('fillColor', fillColor.value); + addIfPresent('fillColor', fillColor.toARGB32()); addIfPresent('geodesic', geodesic); - addIfPresent('strokeColor', strokeColor.value); + addIfPresent('strokeColor', strokeColor.toARGB32()); addIfPresent('strokeWidth', strokeWidth); addIfPresent('visible', visible); addIfPresent('zIndex', zIndex); diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart index 6dcee15fd63b..085ed9e34be5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart @@ -171,7 +171,7 @@ class Polyline implements MapsObject { addIfPresent('polylineId', polylineId.value); addIfPresent('consumeTapEvents', consumeTapEvents); - addIfPresent('color', color.value); + addIfPresent('color', color.toARGB32()); addIfPresent('endCap', endCap.toJson()); addIfPresent('geodesic', geodesic); addIfPresent('jointType', jointType.value); 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 13ccb726840b..16aa10d28eeb 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 @@ -784,8 +784,8 @@ void main() { expect(pinConfig.toJson(), [ PinConfig.type, { - 'backgroundColor': Colors.green.value, - 'borderColor': Colors.blue.value, + 'backgroundColor': Colors.green.toARGB32(), + 'borderColor': Colors.blue.toARGB32(), }, ]); }); @@ -802,11 +802,14 @@ void main() { expect(pinConfig.toJson(), [ PinConfig.type, { - 'backgroundColor': Colors.green.value, - 'borderColor': Colors.blue.value, + 'backgroundColor': Colors.green.toARGB32(), + 'borderColor': Colors.blue.toARGB32(), 'glyph': [ 'textGlyph', - {'text': 'Hello', 'textColor': Colors.red.value}, + { + 'text': 'Hello', + 'textColor': Colors.red.toARGB32(), + }, ], }, ]); @@ -831,8 +834,8 @@ void main() { 'bitmap': ['fromAsset', 'red_square.png'], }, ], - 'backgroundColor': Colors.black.value, - 'borderColor': Colors.red.value, + 'backgroundColor': Colors.black.toARGB32(), + 'borderColor': Colors.red.toARGB32(), }, ]); }); 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 44f3a135b4f9..93329adbdf3b 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 @@ -303,7 +303,7 @@ void main() { expect(gradient.toJson(), { 'colors': colors - .map((HeatmapGradientColor e) => e.color.value) + .map((HeatmapGradientColor e) => e.color.toARGB32()) .toList(), 'startPoints': colors .map((HeatmapGradientColor e) => e.startPoint) From 575320e3622f0c60b28bd68f00df4f855ad67f05 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 19 Nov 2025 16:45:49 -0500 Subject: [PATCH 2/5] Fix min platform interface versions --- .../google_maps_flutter_android/example/pubspec.yaml | 2 +- .../google_maps_flutter_android/pubspec.yaml | 2 +- .../google_maps_flutter_ios/example/ios14/pubspec.yaml | 2 +- .../google_maps_flutter_ios/example/ios15/pubspec.yaml | 2 +- .../example/shared/maps_example_dart/pubspec.yaml | 2 +- .../google_maps_flutter/google_maps_flutter_ios/pubspec.yaml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) 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 e556fa6acf9c..58cec3dcf1a5 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 @@ -18,7 +18,7 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../ - google_maps_flutter_platform_interface: ^2.11.0 + google_maps_flutter_platform_interface: ^2.13.0 dev_dependencies: build_runner: ^2.1.10 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 bb75e4469ea5..af4932a0ad2c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_android/pubspec.yaml @@ -21,7 +21,7 @@ dependencies: flutter: sdk: flutter flutter_plugin_android_lifecycle: ^2.0.1 - google_maps_flutter_platform_interface: ^2.11.0 + google_maps_flutter_platform_interface: ^2.13.0 stream_transform: ^2.0.0 dev_dependencies: 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 d4192ad9642d..125a5a2ac4d2 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 @@ -18,7 +18,7 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../../ - google_maps_flutter_platform_interface: ^2.12.1 + google_maps_flutter_platform_interface: ^2.13.0 maps_example_dart: path: ../shared/maps_example_dart/ 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 d4192ad9642d..125a5a2ac4d2 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 @@ -18,7 +18,7 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../../ - google_maps_flutter_platform_interface: ^2.12.1 + google_maps_flutter_platform_interface: ^2.13.0 maps_example_dart: path: ../shared/maps_example_dart/ 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 a0c48d88f369..c29432c7f7aa 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 @@ -18,7 +18,7 @@ dependencies: # The example app is bundled with the plugin so we use a path dependency on # the parent directory to use the current plugin's version. path: ../../../ - google_maps_flutter_platform_interface: ^2.12.1 + google_maps_flutter_platform_interface: ^2.13.0 dev_dependencies: flutter_test: 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 3dd84d3a71db..eb4fe6d3a4eb 100644 --- a/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml +++ b/packages/google_maps_flutter/google_maps_flutter_ios/pubspec.yaml @@ -19,7 +19,7 @@ flutter: dependencies: flutter: sdk: flutter - google_maps_flutter_platform_interface: ^2.12.1 + google_maps_flutter_platform_interface: ^2.13.0 stream_transform: ^2.0.0 dev_dependencies: From b5443636e7fc476c49e6a4cfbc943c17995cae9a Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Wed, 19 Nov 2025 16:47:27 -0500 Subject: [PATCH 3/5] Missing version/changelog --- .../google_maps_flutter_platform_interface/CHANGELOG.md | 3 ++- .../google_maps_flutter_platform_interface/pubspec.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) 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 7183bed62b73..163cb160043b 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,5 +1,6 @@ -## NEXT +## 2.14.1 +* Replaces internal use of deprecated methods. * Updates minimum supported SDK version to Flutter 3.32/Dart 3.8. ## 2.14.0 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 9f98762bd09a..9aa5ed828406 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 @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/google_maps_f issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.14.0 +version: 2.14.1 environment: sdk: ^3.8.0 From 837196fd373fb651ced42e3ae301814a243bb0b5 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Thu, 20 Nov 2025 09:32:19 -0500 Subject: [PATCH 4/5] Revert platform interface, to split it out --- .../CHANGELOG.md | 3 +-- .../lib/src/method_channel/serialization.dart | 4 +--- .../lib/src/types/bitmap.dart | 9 ++++----- .../lib/src/types/circle.dart | 4 ++-- .../lib/src/types/heatmap.dart | 2 +- .../lib/src/types/polygon.dart | 4 ++-- .../lib/src/types/polyline.dart | 2 +- .../pubspec.yaml | 2 +- .../test/types/bitmap_test.dart | 17 +++++++---------- .../test/types/heatmap_test.dart | 2 +- 10 files changed, 21 insertions(+), 28 deletions(-) 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 163cb160043b..7183bed62b73 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,6 +1,5 @@ -## 2.14.1 +## NEXT -* Replaces internal use of deprecated methods. * Updates minimum supported SDK version to Flutter 3.32/Dart 3.8. ## 2.14.0 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 5c3cf395141b..66d5d24c6e41 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 @@ -130,9 +130,7 @@ Object serializeHeatmapGradient(HeatmapGradient gradient) { _addIfNonNull( json, _heatmapGradientColorsKey, - gradient.colors - .map((HeatmapGradientColor e) => e.color.toARGB32()) - .toList(), + gradient.colors.map((HeatmapGradientColor e) => e.color.value).toList(), ); _addIfNonNull( json, 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 8ad4752685f9..ef40f0ef7512 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 @@ -1107,9 +1107,8 @@ class PinConfig extends BitmapDescriptor { Object toJson() => [ type, { - if (backgroundColor != null) - 'backgroundColor': backgroundColor?.toARGB32(), - if (borderColor != null) 'borderColor': borderColor?.toARGB32(), + if (backgroundColor != null) 'backgroundColor': backgroundColor?.value, + if (borderColor != null) 'borderColor': borderColor?.value, if (glyph != null) 'glyph': glyph?.toJson(), }, ]; @@ -1132,7 +1131,7 @@ class CircleGlyph extends AdvancedMarkerGlyph { @override Object toJson() => [ 'circleGlyph', - {'color': color.toARGB32()}, + {'color': color.value}, ]; } @@ -1176,7 +1175,7 @@ class TextGlyph extends AdvancedMarkerGlyph { 'textGlyph', { 'text': text, - if (textColor != null) 'textColor': textColor!.toARGB32(), + if (textColor != null) 'textColor': textColor!.value, }, ]; } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart index 3dc0161d9536..c81e2184cbf1 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart @@ -121,10 +121,10 @@ class Circle implements MapsObject { addIfPresent('circleId', circleId.value); addIfPresent('consumeTapEvents', consumeTapEvents); - addIfPresent('fillColor', fillColor.toARGB32()); + addIfPresent('fillColor', fillColor.value); addIfPresent('center', center.toJson()); addIfPresent('radius', radius); - addIfPresent('strokeColor', strokeColor.toARGB32()); + addIfPresent('strokeColor', strokeColor.value); addIfPresent('strokeWidth', strokeWidth); addIfPresent('visible', visible); addIfPresent('zIndex', zIndex); 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 1eb10292aa8a..950711868ea4 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 @@ -293,7 +293,7 @@ class HeatmapGradient { addIfPresent( 'colors', - colors.map((HeatmapGradientColor e) => e.color.toARGB32()).toList(), + colors.map((HeatmapGradientColor e) => e.color.value).toList(), ); addIfPresent( 'startPoints', diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart index fed4a2c9e48f..1cf820f08497 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart @@ -141,9 +141,9 @@ class Polygon implements MapsObject { addIfPresent('polygonId', polygonId.value); addIfPresent('consumeTapEvents', consumeTapEvents); - addIfPresent('fillColor', fillColor.toARGB32()); + addIfPresent('fillColor', fillColor.value); addIfPresent('geodesic', geodesic); - addIfPresent('strokeColor', strokeColor.toARGB32()); + addIfPresent('strokeColor', strokeColor.value); addIfPresent('strokeWidth', strokeWidth); addIfPresent('visible', visible); addIfPresent('zIndex', zIndex); diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart index 085ed9e34be5..6dcee15fd63b 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart @@ -171,7 +171,7 @@ class Polyline implements MapsObject { addIfPresent('polylineId', polylineId.value); addIfPresent('consumeTapEvents', consumeTapEvents); - addIfPresent('color', color.toARGB32()); + addIfPresent('color', color.value); addIfPresent('endCap', endCap.toJson()); addIfPresent('geodesic', geodesic); addIfPresent('jointType', jointType.value); 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 9aa5ed828406..9f98762bd09a 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 @@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/google_maps_f issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22 # NOTE: We strongly prefer non-breaking changes, even at the expense of a # less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes -version: 2.14.1 +version: 2.14.0 environment: sdk: ^3.8.0 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 16aa10d28eeb..13ccb726840b 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 @@ -784,8 +784,8 @@ void main() { expect(pinConfig.toJson(), [ PinConfig.type, { - 'backgroundColor': Colors.green.toARGB32(), - 'borderColor': Colors.blue.toARGB32(), + 'backgroundColor': Colors.green.value, + 'borderColor': Colors.blue.value, }, ]); }); @@ -802,14 +802,11 @@ void main() { expect(pinConfig.toJson(), [ PinConfig.type, { - 'backgroundColor': Colors.green.toARGB32(), - 'borderColor': Colors.blue.toARGB32(), + 'backgroundColor': Colors.green.value, + 'borderColor': Colors.blue.value, 'glyph': [ 'textGlyph', - { - 'text': 'Hello', - 'textColor': Colors.red.toARGB32(), - }, + {'text': 'Hello', 'textColor': Colors.red.value}, ], }, ]); @@ -834,8 +831,8 @@ void main() { 'bitmap': ['fromAsset', 'red_square.png'], }, ], - 'backgroundColor': Colors.black.toARGB32(), - 'borderColor': Colors.red.toARGB32(), + 'backgroundColor': Colors.black.value, + 'borderColor': Colors.red.value, }, ]); }); 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 93329adbdf3b..44f3a135b4f9 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 @@ -303,7 +303,7 @@ void main() { expect(gradient.toJson(), { 'colors': colors - .map((HeatmapGradientColor e) => e.color.toARGB32()) + .map((HeatmapGradientColor e) => e.color.value) .toList(), 'startPoints': colors .map((HeatmapGradientColor e) => e.startPoint) From 18162b5a868ce17bdd9ed3b6bc80e5f7d8bc7e64 Mon Sep 17 00:00:00 2001 From: Stuart Morgan Date: Mon, 24 Nov 2025 18:32:07 -0500 Subject: [PATCH 5/5] Apply Dart changes from head --- .../integration_test/src/maps_controller.dart | 74 ++- .../integration_test/src/maps_inspector.dart | 84 ++-- .../integration_test/src/tiles_inspector.dart | 56 +-- .../example/lib/clustering.dart | 17 +- .../example/lib/custom_marker_icon.dart | 8 +- .../example/lib/ground_overlay.dart | 10 +- .../google_maps_flutter/example/lib/main.dart | 3 +- .../example/lib/map_click.dart | 8 +- .../example/lib/map_coordinates.dart | 2 +- .../example/lib/map_map_id.dart | 4 +- .../example/lib/map_ui.dart | 4 +- .../example/lib/marker_icons.dart | 12 +- .../example/lib/padding.dart | 4 +- .../example/lib/place_circle.dart | 6 +- .../example/lib/place_marker.dart | 16 +- .../example/lib/place_polygon.dart | 14 +- .../example/lib/place_polyline.dart | 8 +- .../example/lib/tile_overlay.dart | 14 +- .../google_maps_flutter/test/camera_test.dart | 5 +- .../test/circle_updates_test.dart | 58 +-- .../test/clustermanager_updates_test.dart | 50 +- .../test/controller_test.dart | 8 +- .../test/google_map_test.dart | 2 +- .../test/groundoverlay_updates_test.dart | 54 +-- .../test/heatmap_updates_test.dart | 44 +- .../test/marker_updates_test.dart | 61 ++- .../test/polygon_updates_test.dart | 97 ++-- .../test/polyline_updates_test.dart | 74 ++- .../test/tile_overlay_updates_test.dart | 22 +- .../integration_test/google_maps_test.dart | 213 ++++---- .../example/lib/clustering.dart | 17 +- .../example/lib/custom_marker_icon.dart | 8 +- .../example/lib/ground_overlay.dart | 10 +- .../example/lib/main.dart | 5 +- .../example/lib/map_click.dart | 8 +- .../example/lib/map_coordinates.dart | 2 +- .../example/lib/map_map_id.dart | 4 +- .../example/lib/map_ui.dart | 4 +- .../example/lib/marker_icons.dart | 12 +- .../example/lib/padding.dart | 4 +- .../example/lib/place_circle.dart | 6 +- .../example/lib/place_marker.dart | 16 +- .../example/lib/place_polygon.dart | 14 +- .../example/lib/place_polyline.dart | 8 +- .../example/lib/tile_overlay.dart | 14 +- .../example/test/example_google_map_test.dart | 44 +- .../lib/src/google_map_inspector_android.dart | 2 +- .../lib/src/google_maps_flutter_android.dart | 70 ++- .../lib/src/serialization.dart | 12 +- .../google_maps_flutter_android_test.dart | 456 ++++++++---------- .../integration_test/google_maps_test.dart | 218 ++++----- .../maps_example_dart/lib/clustering.dart | 17 +- .../lib/custom_marker_icon.dart | 8 +- .../maps_example_dart/lib/ground_overlay.dart | 10 +- .../maps_example_dart/lib/map_click.dart | 8 +- .../lib/map_coordinates.dart | 2 +- .../maps_example_dart/lib/map_map_id.dart | 4 +- .../shared/maps_example_dart/lib/map_ui.dart | 4 +- .../maps_example_dart/lib/marker_icons.dart | 12 +- .../shared/maps_example_dart/lib/padding.dart | 4 +- .../maps_example_dart/lib/place_circle.dart | 6 +- .../maps_example_dart/lib/place_marker.dart | 16 +- .../maps_example_dart/lib/place_polygon.dart | 14 +- .../maps_example_dart/lib/place_polyline.dart | 8 +- .../maps_example_dart/lib/tile_overlay.dart | 14 +- .../test/example_google_map_test.dart | 44 +- .../lib/src/google_map_inspector_ios.dart | 2 +- .../lib/src/google_maps_flutter_ios.dart | 68 ++- .../lib/src/serialization.dart | 12 +- .../test/google_maps_flutter_ios_test.dart | 426 +++++++--------- .../method_channel_google_maps_flutter.dart | 15 +- .../lib/src/method_channel/serialization.dart | 14 +- .../lib/src/types/bitmap.dart | 24 +- .../lib/src/types/callbacks.dart | 4 +- .../lib/src/types/circle.dart | 2 +- .../lib/src/types/cluster_manager.dart | 2 +- .../lib/src/types/ground_overlay.dart | 2 +- .../lib/src/types/heatmap.dart | 4 +- .../lib/src/types/location.dart | 4 +- .../lib/src/types/maps_object_updates.dart | 2 +- .../lib/src/types/marker.dart | 4 +- .../lib/src/types/polygon.dart | 10 +- .../lib/src/types/polyline.dart | 6 +- .../lib/src/types/tile.dart | 2 +- .../lib/src/types/tile_overlay.dart | 2 +- ...thod_channel_google_maps_flutter_test.dart | 33 +- .../google_maps_flutter_platform_test.dart | 8 +- .../test/types/advanced_marker_test.dart | 34 +- .../test/types/bitmap_test.dart | 16 +- .../test/types/camera_test.dart | 38 +- .../test/types/cluster_manager_test.dart | 12 +- .../test/types/cluster_test.dart | 2 +- .../test/types/ground_overlay_test.dart | 50 +- .../test/types/heatmap_test.dart | 221 ++++----- .../test/types/location_test.dart | 30 +- .../test/types/map_configuration_test.dart | 204 ++++---- .../test/types/maps_object_test.dart | 24 +- .../test/types/maps_object_updates_test.dart | 184 ++----- .../test/types/marker_test.dart | 36 +- .../test/types/tile_overlay_test.dart | 24 +- .../test/types/tile_overlay_updates_test.dart | 117 ++--- .../test/types/tile_test.dart | 6 +- .../test/utils/cluster_manager_test.dart | 8 +- .../map_configuration_serialization_test.dart | 10 +- .../cloud_map_styles_test.dart | 18 +- .../google_maps_controller_test.dart | 80 ++- .../google_maps_plugin_test.dart | 102 ++-- .../marker_clustering_test.dart | 25 +- .../example/integration_test/marker_test.dart | 25 +- .../integration_test/markers_test.dart | 76 ++- .../integration_test/overlay_test.dart | 14 +- .../integration_test/overlays_test.dart | 5 +- .../integration_test/projection_test.dart | 25 +- .../example/integration_test/shape_test.dart | 36 +- .../example/integration_test/shapes_test.dart | 70 ++- .../lib/src/circles.dart | 4 +- .../lib/src/convert.dart | 86 ++-- .../lib/src/google_maps_controller.dart | 11 +- .../lib/src/google_maps_flutter_web.dart | 5 +- .../lib/src/ground_overlays.dart | 13 +- .../lib/src/heatmaps.dart | 8 +- .../lib/src/marker_clustering_js_interop.dart | 2 +- .../lib/src/markers.dart | 6 +- .../lib/src/overlay.dart | 3 +- .../lib/src/overlays.dart | 4 +- .../lib/src/polygons.dart | 5 +- .../lib/src/polylines.dart | 5 +- 127 files changed, 1910 insertions(+), 2517 deletions(-) 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 adaee6429af2..9f60a28874f7 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 @@ -26,8 +26,7 @@ void runTests() { (WidgetTester tester) async { await tester.binding.setSurfaceSize(const Size(800, 600)); - final Completer mapControllerCompleter = - Completer(); + final mapControllerCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( Directionality( @@ -88,13 +87,12 @@ void runTests() { 'testGetVisibleRegion', (WidgetTester tester) async { final Key key = GlobalKey(); - final LatLngBounds zeroLatLngBounds = LatLngBounds( + final zeroLatLngBounds = LatLngBounds( southwest: const LatLng(0, 0), northeast: const LatLng(0, 0), ); - final Completer mapControllerCompleter = - Completer(); + final mapControllerCompleter = Completer(); await pumpMap( tester, @@ -123,15 +121,15 @@ void runTests() { // 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( + final southWest = LatLng( firstVisibleRegion.southwest.latitude - 20, firstVisibleRegion.southwest.longitude - 20, ); - final LatLng northEast = LatLng( + final northEast = LatLng( firstVisibleRegion.southwest.latitude - 10, firstVisibleRegion.southwest.longitude - 10, ); - final LatLng newCenter = LatLng( + final newCenter = LatLng( (northEast.latitude + southWest.latitude) / 2, (northEast.longitude + southWest.longitude) / 2, ); @@ -139,7 +137,7 @@ void runTests() { expect(firstVisibleRegion.contains(northEast), isFalse); expect(firstVisibleRegion.contains(southWest), isFalse); - final LatLngBounds latLngBounds = LatLngBounds( + final latLngBounds = LatLngBounds( southwest: southWest, northeast: northEast, ); @@ -166,8 +164,7 @@ void runTests() { testWidgets('testSetMapStyle valid Json String', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -181,7 +178,7 @@ void runTests() { ); final GoogleMapController controller = await controllerCompleter.future; - const String mapStyle = + const mapStyle = '[{"elementType":"geometry","stylers":[{"color":"#242f3e"}]}]'; // Intentionally testing the deprecated code path. // ignore: deprecated_member_use @@ -192,8 +189,7 @@ void runTests() { WidgetTester tester, ) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -219,8 +215,7 @@ void runTests() { testWidgets('testSetMapStyle null string', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -241,8 +236,7 @@ void runTests() { testWidgets('testGetLatLng', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -266,7 +260,7 @@ void runTests() { final LatLng topLeft = await controller.getLatLng( const ScreenCoordinate(x: 0, y: 0), ); - final LatLng northWest = LatLng( + final northWest = LatLng( visibleRegion.northeast.latitude, visibleRegion.southwest.longitude, ); @@ -278,8 +272,7 @@ void runTests() { 'testGetZoomLevel', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -315,8 +308,7 @@ void runTests() { 'testScreenCoordinate', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -337,7 +329,7 @@ void runTests() { await Future.delayed(const Duration(seconds: 1)); final LatLngBounds visibleRegion = await controller.getVisibleRegion(); - final LatLng northWest = LatLng( + final northWest = LatLng( visibleRegion.northeast.latitude, visibleRegion.southwest.longitude, ); @@ -351,8 +343,7 @@ void runTests() { ); testWidgets('testResizeWidget', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -392,14 +383,13 @@ void runTests() { }); testWidgets('testToggleInfoWindow', (WidgetTester tester) async { - const Marker marker = Marker( + const marker = Marker( markerId: MarkerId('marker'), infoWindow: InfoWindow(title: 'InfoWindow'), ); - final Set markers = {marker}; + final markers = {marker}; - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -444,7 +434,7 @@ void runTests() { }); testWidgets('markerWithAssetMapBitmap', (WidgetTester tester) async { - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: AssetMapBitmap('assets/red_square.png', imagePixelRatio: 1.0), @@ -460,10 +450,10 @@ void runTests() { }); testWidgets('markerWithAssetMapBitmapCreate', (WidgetTester tester) async { - final ImageConfiguration imageConfiguration = ImageConfiguration( + final imageConfiguration = ImageConfiguration( devicePixelRatio: tester.view.devicePixelRatio, ); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: await AssetMapBitmap.create( @@ -483,7 +473,7 @@ void runTests() { testWidgets('markerWithBytesMapBitmap', (WidgetTester tester) async { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: BytesMapBitmap( @@ -503,11 +493,11 @@ void runTests() { testWidgets('markerWithLegacyAsset', (WidgetTester tester) async { tester.view.devicePixelRatio = 2.0; - final ImageConfiguration imageConfiguration = ImageConfiguration( + final imageConfiguration = ImageConfiguration( devicePixelRatio: tester.view.devicePixelRatio, size: const Size(100, 100), ); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), // Intentionally testing the deprecated code path. @@ -532,7 +522,7 @@ void runTests() { testWidgets('markerWithLegacyBytes', (WidgetTester tester) async { tester.view.devicePixelRatio = 2.0; final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), // Intentionally testing the deprecated code path. @@ -554,8 +544,7 @@ void runTests() { testWidgets( 'testTakeSnapshot', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -579,7 +568,7 @@ void runTests() { ); testWidgets('testCloudMapId', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); await pumpMap( @@ -601,8 +590,7 @@ void runTests() { testWidgets('getStyleError reports last error', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -638,7 +626,7 @@ Future waitForValueMatchingPredicate( bool Function(T) predicate, { int maxTries = 100, }) async { - for (int i = 0; i < maxTries; i++) { + for (var i = 0; i < maxTries; i++) { final T value = await getValue(); if (predicate(value)) { return 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 501be0233b65..06588979e29c 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 @@ -43,7 +43,7 @@ void runTests() { testWidgets('testCompassToggle', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, GoogleMap( @@ -77,7 +77,7 @@ void runTests() { testWidgets('testMapToolbarToggle', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -122,11 +122,10 @@ void runTests() { // // Thus we test iOS and Android a little differently here. final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); - const MinMaxZoomPreference initialZoomLevel = MinMaxZoomPreference(4, 8); - const MinMaxZoomPreference finalZoomLevel = MinMaxZoomPreference(6, 10); + const initialZoomLevel = MinMaxZoomPreference(4, 8); + const finalZoomLevel = MinMaxZoomPreference(6, 10); await pumpMap( tester, @@ -189,7 +188,7 @@ void runTests() { testWidgets('testZoomGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -226,7 +225,7 @@ void runTests() { testWidgets('testZoomControlsEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -268,7 +267,7 @@ void runTests() { testWidgets('testLiteModeEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -303,7 +302,7 @@ void runTests() { testWidgets('testRotateGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -342,7 +341,7 @@ void runTests() { testWidgets('testTiltGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -379,7 +378,7 @@ void runTests() { testWidgets('testScrollGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -418,7 +417,7 @@ void runTests() { testWidgets('testTraffic', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -453,7 +452,7 @@ void runTests() { testWidgets('testBuildings', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -478,7 +477,7 @@ void runTests() { group('MyLocationButton', () { testWidgets('testMyLocationButtonToggle', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -519,7 +518,7 @@ void runTests() { WidgetTester tester, ) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -543,7 +542,7 @@ void runTests() { WidgetTester tester, ) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await pumpMap( tester, @@ -565,27 +564,21 @@ void runTests() { testWidgets('marker clustering', (WidgetTester tester) async { final Key key = GlobalKey(); - const int clusterManagersAmount = 2; - const int markersPerClusterManager = 5; - final Map markers = {}; - final Set clusterManagers = {}; - - for (int i = 0; i < clusterManagersAmount; i++) { - final ClusterManagerId clusterManagerId = ClusterManagerId( - 'cluster_manager_$i', - ); - final ClusterManager clusterManager = ClusterManager( - clusterManagerId: clusterManagerId, - ); + const clusterManagersAmount = 2; + const markersPerClusterManager = 5; + final markers = {}; + final clusterManagers = {}; + + for (var i = 0; i < clusterManagersAmount; i++) { + final clusterManagerId = ClusterManagerId('cluster_manager_$i'); + final 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 Marker marker = Marker( + for (final cm in clusterManagers) { + for (var i = 0; i < markersPerClusterManager; i++) { + final markerId = MarkerId('${cm.clusterManagerId.value}_marker_$i'); + final marker = Marker( markerId: markerId, clusterManagerId: cm.clusterManagerId, position: LatLng( @@ -597,8 +590,7 @@ void runTests() { } } - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await pumpMap( tester, @@ -618,7 +610,7 @@ void runTests() { final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - for (final ClusterManager cm in clusterManagers) { + for (final cm in clusterManagers) { final List clusters = await inspector.getClusters( mapId: controller.mapId, clusterManagerId: cm.clusterManagerId, @@ -644,7 +636,7 @@ void runTests() { ), ); - for (final ClusterManager cm in clusterManagers) { + for (final cm in clusterManagers) { final List clusters = await inspector.getClusters( mapId: controller.mapId, clusterManagerId: cm.clusterManagerId, @@ -657,8 +649,7 @@ void runTests() { 'testAnimateCameraWithoutDuration', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; @@ -762,16 +753,15 @@ void runTests() { 'testAnimateCameraWithDuration', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; /// Completer to track when the camera has come to rest. Completer? cameraIdleCompleter; - const int shortCameraAnimationDurationMS = 200; - const int longCameraAnimationDurationMS = 1000; + const shortCameraAnimationDurationMS = 200; + const longCameraAnimationDurationMS = 1000; /// Calculate the midpoint duration of the animation test, which will /// serve as a reference to verify that animations complete more quickly @@ -780,7 +770,7 @@ void runTests() { (shortCameraAnimationDurationMS + longCameraAnimationDurationMS) ~/ 2; // Stopwatch to measure the time taken for the animation to complete. - final Stopwatch stopwatch = Stopwatch(); + final stopwatch = Stopwatch(); await tester.pumpWidget( Directionality( @@ -980,7 +970,7 @@ Future _checkCameraUpdateByType( ) async { // As the target might differ a bit from the expected target, a threshold is // used. - const double latLngThreshold = 0.05; + const latLngThreshold = 0.05; switch (type) { case CameraUpdateType.newCameraPosition: 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 079ac894192b..c6641a806b20 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 @@ -21,7 +21,7 @@ void main() { } void runTests() { - const double floatTolerance = 1e-6; + const floatTolerance = 1e-6; GoogleMapsFlutterPlatform.instance.enableDebugInspection(); @@ -30,15 +30,15 @@ void runTests() { group('Tiles', () { testWidgets('set tileOverlay correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final TileOverlay tileOverlay1 = TileOverlay( + final mapIdCompleter = Completer(); + final tileOverlay1 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 2, transparency: 0.2, ); - final TileOverlay tileOverlay2 = TileOverlay( + final tileOverlay2 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_2'), tileProvider: _DebugTileProvider(), zIndex: 1, @@ -89,16 +89,16 @@ void runTests() { }); testWidgets('update tileOverlays correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( + final tileOverlay1 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 2, transparency: 0.2, ); - final TileOverlay tileOverlay2 = TileOverlay( + final tileOverlay2 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_2'), tileProvider: _DebugTileProvider(), zIndex: 3, @@ -120,7 +120,7 @@ void runTests() { final int mapId = await mapIdCompleter.future; - final TileOverlay tileOverlay1New = TileOverlay( + final tileOverlay1New = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 1, @@ -166,9 +166,9 @@ void runTests() { }); testWidgets('remove tileOverlays correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( + final tileOverlay1 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 2, @@ -221,7 +221,7 @@ void runTests() { List data2, ) { expect(data1.length, data2.length); - for (int i = 0; i < data1.length; i++) { + for (var i = 0; i < data1.length; i++) { final WeightedLatLng wll1 = data1[i]; final WeightedLatLng wll2 = data2[i]; expect(wll1.weight, wll2.weight); @@ -242,7 +242,7 @@ void runTests() { expect(gradient2, isNotNull); expect(gradient1.colors.length, gradient2.colors.length); - for (int i = 0; i < gradient1.colors.length; i++) { + for (var i = 0; i < gradient1.colors.length; i++) { final HeatmapGradientColor color1 = gradient1.colors[i]; final HeatmapGradientColor color2 = gradient2.colors[i]; expect(color1.color, color2.color); @@ -288,7 +288,7 @@ void runTests() { } } - const Heatmap heatmap1 = Heatmap( + const heatmap1 = Heatmap( heatmapId: HeatmapId('heatmap_1'), data: [ WeightedLatLng(LatLng(37.782, -122.447)), @@ -322,8 +322,8 @@ void runTests() { ); testWidgets('set heatmap correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final Heatmap heatmap2 = Heatmap( + final mapIdCompleter = Completer(); + final heatmap2 = Heatmap( heatmapId: const HeatmapId('heatmap_2'), data: heatmap1.data, dissipating: heatmap1.dissipating, @@ -369,7 +369,7 @@ void runTests() { }); testWidgets('update heatmaps correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( @@ -429,7 +429,7 @@ void runTests() { }); testWidgets('remove heatmaps correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( @@ -478,12 +478,12 @@ void runTests() { }); group('GroundOverlay', () { - final LatLngBounds kGroundOverlayBounds = LatLngBounds( + final kGroundOverlayBounds = LatLngBounds( southwest: const LatLng(37.77483, -122.41942), northeast: const LatLng(37.78183, -122.39105), ); - final GroundOverlay groundOverlayBounds1 = GroundOverlay.fromBounds( + final groundOverlayBounds1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('bounds_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -496,7 +496,7 @@ void runTests() { zIndex: 10, ); - final GroundOverlay groundOverlayPosition1 = GroundOverlay.fromPosition( + final groundOverlayPosition1 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('position_1'), position: kGroundOverlayBounds.northeast, width: 100, @@ -573,8 +573,8 @@ void runTests() { } testWidgets('set ground overlays correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final GroundOverlay groundOverlayBounds2 = GroundOverlay.fromBounds( + final mapIdCompleter = Completer(); + final groundOverlayBounds2 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('bounds_2'), bounds: groundOverlayBounds1.bounds!, image: groundOverlayBounds1.image, @@ -636,7 +636,7 @@ void runTests() { testWidgets('update ground overlays correctly', ( WidgetTester tester, ) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( @@ -728,7 +728,7 @@ void runTests() { testWidgets('remove ground overlays correctly', ( WidgetTester tester, ) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( @@ -803,10 +803,10 @@ class _DebugTileProvider implements TileProvider { @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 TextPainter textPainter = TextPainter( + final recorder = ui.PictureRecorder(); + final canvas = Canvas(recorder); + final textSpan = TextSpan(text: '$x,$y', style: textStyle); + final textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); 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 0a22df4fdaa0..d5fe7eb43019 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 @@ -116,14 +116,11 @@ class ClusteringBodyState extends State { return; } - final String clusterManagerIdVal = - 'cluster_manager_id_$_clusterManagerIdCounter'; + final clusterManagerIdVal = 'cluster_manager_id_$_clusterManagerIdCounter'; _clusterManagerIdCounter++; - final ClusterManagerId clusterManagerId = ClusterManagerId( - clusterManagerIdVal, - ); + final clusterManagerId = ClusterManagerId(clusterManagerIdVal); - final ClusterManager clusterManager = ClusterManager( + final clusterManager = ClusterManager( clusterManagerId: clusterManagerId, onClusterTap: (Cluster cluster) => setState(() { lastCluster = cluster; @@ -149,11 +146,11 @@ class ClusteringBodyState extends State { } void _addMarkersToCluster(ClusterManager clusterManager) { - for (int i = 0; i < _markersToAddToClusterManagerCount; i++) { - final String markerIdVal = + for (var i = 0; i < _markersToAddToClusterManagerCount; i++) { + final markerIdVal = '${clusterManager.clusterManagerId.value}_marker_id_$_markerIdCounter'; _markerIdCounter++; - final MarkerId markerId = MarkerId(markerIdVal); + final markerId = MarkerId(markerIdVal); final int clusterManagerIndex = clusterManagers.values.toList().indexOf( clusterManager, @@ -164,7 +161,7 @@ class ClusteringBodyState extends State { final double clusterManagerLongitudeOffset = clusterManagerIndex * _clusterManagerLongitudeOffset; - final Marker marker = Marker( + final marker = Marker( clusterManagerId: clusterManager.clusterManagerId, markerId: markerId, position: LatLng( 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 6206787f3475..548146c6206c 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 @@ -9,9 +9,9 @@ import 'package:flutter/material.dart'; /// Returns a generated png image in [ByteData] format with the requested size. Future createCustomMarkerIconImage({required Size size}) async { - final ui.PictureRecorder recorder = ui.PictureRecorder(); - final Canvas canvas = Canvas(recorder); - final _MarkerPainter painter = _MarkerPainter(); + final recorder = ui.PictureRecorder(); + final canvas = Canvas(recorder); + final painter = _MarkerPainter(); painter.paint(canvas, size); @@ -30,7 +30,7 @@ class _MarkerPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { final Rect rect = Offset.zero & size; - const RadialGradient gradient = RadialGradient( + const gradient = RadialGradient( colors: [Colors.yellow, Colors.red], stops: [0.4, 1.0], ); 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 2b5772af8b8b..41df905569aa 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 @@ -95,9 +95,7 @@ class GroundOverlayBodyState extends State { _groundOverlayIndex += 1; - final GroundOverlayId id = GroundOverlayId( - 'ground_overlay_$_groundOverlayIndex', - ); + final id = GroundOverlayId('ground_overlay_$_groundOverlayIndex'); final GroundOverlay groundOverlay = switch (_placingType) { _GroundOverlayPlacing.position => GroundOverlay.fromPosition( @@ -146,9 +144,7 @@ class GroundOverlayBodyState extends State { void _changeTransparency() { assert(_groundOverlay != null); setState(() { - final double transparency = _groundOverlay!.transparency == 0.0 - ? 0.5 - : 0.0; + final transparency = _groundOverlay!.transparency == 0.0 ? 0.5 : 0.0; _groundOverlay = _groundOverlay!.copyWith( transparencyParam: transparency, ); @@ -242,7 +238,7 @@ class GroundOverlayBodyState extends State { @override Widget build(BuildContext context) { - final Set overlays = { + final overlays = { if (_groundOverlay != null) _groundOverlay!, }; return Column( 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 8b33fc9ddafb..2cee263eeba3 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 @@ -103,8 +103,7 @@ Future initializeMapRenderer() async { return _initializedRendererCompleter!.future; } - final Completer completer = - Completer(); + final completer = Completer(); _initializedRendererCompleter = completer; WidgetsFlutterBinding.ensureInitialized(); 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 a426ec8bea25..b80c545b1093 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 @@ -39,7 +39,7 @@ class _MapClickBodyState extends State<_MapClickBody> { @override Widget build(BuildContext context) { - final GoogleMap googleMap = GoogleMap( + final googleMap = GoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, onTap: (LatLng pos) { @@ -54,7 +54,7 @@ class _MapClickBodyState extends State<_MapClickBody> { }, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( @@ -64,8 +64,8 @@ class _MapClickBodyState extends State<_MapClickBody> { ]; if (mapController != null) { - final String lastTap = 'Tap:\n${_lastTap ?? ""}\n'; - final String lastLongPress = 'Long press:\n${_lastLongPress ?? ""}'; + final lastTap = 'Tap:\n${_lastTap ?? ""}\n'; + final lastLongPress = 'Long press:\n${_lastLongPress ?? ""}'; columnChildren.add( Center(child: Text(lastTap, textAlign: TextAlign.center)), ); 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 2b20bbeda750..3a8d282c67a8 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 @@ -41,7 +41,7 @@ class _MapCoordinatesBodyState extends State<_MapCoordinatesBody> { @override Widget build(BuildContext context) { - final GoogleMap googleMap = GoogleMap( + final googleMap = GoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, onCameraIdle: 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 362cbea31de1..8ac61c1f1c8f 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 @@ -75,7 +75,7 @@ class MapIdBodyState extends State { @override Widget build(BuildContext context) { - final GoogleMap googleMap = GoogleMap( + final googleMap = GoogleMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition( target: _kMapCenter, @@ -85,7 +85,7 @@ class MapIdBodyState extends State { cloudMapId: _mapId, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( 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 3afa4a596f42..d954ee7d3c7c 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 @@ -325,7 +325,7 @@ class MapUiBodyState extends State { @override Widget build(BuildContext context) { - final GoogleMap googleMap = GoogleMap( + final googleMap = GoogleMap( webCameraControlEnabled: _webCameraControlEnabled, webCameraControlPosition: _webCameraControlPosition, onMapCreated: onMapCreated, @@ -348,7 +348,7 @@ class MapUiBodyState extends State { onCameraMove: _updateCameraPosition, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( 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 303adcce6863..2e239cc99032 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 @@ -209,7 +209,7 @@ class MarkerIconsBodyState extends State { } Marker _createAssetMarker(int index) { - final LatLng position = LatLng( + final position = LatLng( _kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude - 1, ); @@ -222,7 +222,7 @@ class MarkerIconsBodyState extends State { } Marker _createBytesMarker(int index) { - final LatLng position = LatLng( + final position = LatLng( _kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude + 1, ); @@ -235,8 +235,8 @@ class MarkerIconsBodyState extends State { } void _updateMarkers() { - final Set markers = {}; - for (int i = 0; i < _markersAmountPerType; i++) { + final markers = {}; + for (var i = 0; i < _markersAmountPerType; i++) { if (_markerIconAsset != null) { markers.add(_createAssetMarker(i)); } @@ -298,7 +298,7 @@ class MarkerIconsBodyState extends State { final double? imagePixelRatio = _scalingEnabled ? devicePixelRatio : null; // Create canvasSize with physical marker size - final Size canvasSize = Size( + final canvasSize = Size( bitmapLogicalSize.width * (imagePixelRatio ?? 1.0), bitmapLogicalSize.height * (imagePixelRatio ?? 1.0), ); @@ -313,7 +313,7 @@ class MarkerIconsBodyState extends State { ? _getCurrentMarkerSize() : (null, null); - final BytesMapBitmap bitmap = BytesMapBitmap( + final bitmap = BytesMapBitmap( bytes.buffer.asUint8List(), imagePixelRatio: imagePixelRatio, width: width, 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 65a98d6a7754..c5d224144a5c 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 @@ -34,7 +34,7 @@ class MarkerIconsBodyState extends State { @override Widget build(BuildContext context) { - final GoogleMap googleMap = GoogleMap( + final googleMap = GoogleMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition( target: _kMapCenter, @@ -43,7 +43,7 @@ class MarkerIconsBodyState extends State { padding: _padding, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( 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 44f3d23f28cf..b8a6b88fefba 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 @@ -82,11 +82,11 @@ class PlaceCircleBodyState extends State { return; } - final String circleIdVal = 'circle_id_$_circleIdCounter'; + final circleIdVal = 'circle_id_$_circleIdCounter'; _circleIdCounter++; - final CircleId circleId = CircleId(circleIdVal); + final circleId = CircleId(circleIdVal); - final Circle circle = Circle( + final circle = Circle( circleId: circleId, consumeTapEvents: true, strokeColor: Colors.orange, 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 96ff31d0a3ae..4c4b71ca1750 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 @@ -122,11 +122,11 @@ class PlaceMarkerBodyState extends State { return; } - final String markerIdVal = 'marker_id_$_markerIdCounter'; + final markerIdVal = 'marker_id_$_markerIdCounter'; _markerIdCounter++; - final MarkerId markerId = MarkerId(markerIdVal); + final markerId = MarkerId(markerIdVal); - final Marker marker = Marker( + final marker = Marker( markerId: markerId, position: LatLng( center.latitude + sin(_markerIdCounter * pi / 6.0) / 20.0, @@ -154,7 +154,7 @@ class PlaceMarkerBodyState extends State { void _changePosition(MarkerId markerId) { final Marker marker = markers[markerId]!; final LatLng current = marker.position; - final Offset offset = Offset( + final offset = Offset( center.latitude - current.latitude, center.longitude - current.longitude, ); @@ -171,7 +171,7 @@ class PlaceMarkerBodyState extends State { void _changeAnchor(MarkerId markerId) { final Marker marker = markers[markerId]!; final Offset currentAnchor = marker.anchor; - final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); + final newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { markers[markerId] = marker.copyWith(anchorParam: newAnchor); }); @@ -180,7 +180,7 @@ class PlaceMarkerBodyState extends State { Future _changeInfoAnchor(MarkerId markerId) async { final Marker marker = markers[markerId]!; final Offset currentAnchor = marker.infoWindow.anchor; - final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); + final newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { markers[markerId] = marker.copyWith( infoWindowParam: marker.infoWindow.copyWith(anchorParam: newAnchor), @@ -204,7 +204,7 @@ class PlaceMarkerBodyState extends State { Future _changeInfo(MarkerId markerId) async { final Marker marker = markers[markerId]!; - final String newSnippet = '${marker.infoWindow.snippet!}*'; + final newSnippet = '${marker.infoWindow.snippet!}*'; setState(() { markers[markerId] = marker.copyWith( infoWindowParam: marker.infoWindow.copyWith(snippetParam: newSnippet), @@ -257,7 +257,7 @@ class PlaceMarkerBodyState extends State { } Future _getMarkerIcon(BuildContext context) async { - const Size canvasSize = Size(48, 48); + const canvasSize = Size(48, 48); final ByteData bytes = await createCustomMarkerIconImage(size: canvasSize); return BytesMapBitmap(bytes.buffer.asUint8List()); } 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 e8cf201a41eb..b70273179ee5 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 @@ -81,10 +81,10 @@ class PlacePolygonBodyState extends State { return; } - final String polygonIdVal = 'polygon_id_$_polygonIdCounter'; - final PolygonId polygonId = PolygonId(polygonIdVal); + final polygonIdVal = 'polygon_id_$_polygonIdCounter'; + final polygonId = PolygonId(polygonIdVal); - final Polygon polygon = Polygon( + final polygon = Polygon( polygonId: polygonId, consumeTapEvents: true, strokeColor: Colors.orange, @@ -261,7 +261,7 @@ class PlacePolygonBodyState extends State { } List _createPoints() { - final List points = []; + final points = []; final double offset = _polygonIdCounter.ceilToDouble(); points.add(_createLatLng(51.2395 + offset, -3.4314)); points.add(_createLatLng(53.5234 + offset, -3.5314)); @@ -271,17 +271,17 @@ class PlacePolygonBodyState extends State { } List> _createHoles(PolygonId polygonId) { - final List> holes = >[]; + final holes = >[]; final double offset = polygonOffsets[polygonId]!; - final List hole1 = []; + final hole1 = []; hole1.add(_createLatLng(51.8395 + offset, -3.8814)); hole1.add(_createLatLng(52.0234 + offset, -3.9914)); hole1.add(_createLatLng(52.1351 + offset, -4.4435)); hole1.add(_createLatLng(52.0231 + offset, -4.5829)); holes.add(hole1); - final List hole2 = []; + final hole2 = []; hole2.add(_createLatLng(52.2395 + offset, -3.6814)); hole2.add(_createLatLng(52.4234 + offset, -3.7914)); hole2.add(_createLatLng(52.5351 + offset, -4.2435)); 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 083c575cc903..ce931ad2d5ca 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 @@ -109,11 +109,11 @@ class PlacePolylineBodyState extends State { return; } - final String polylineIdVal = 'polyline_id_$_polylineIdCounter'; + final polylineIdVal = 'polyline_id_$_polylineIdCounter'; _polylineIdCounter++; - final PolylineId polylineId = PolylineId(polylineIdVal); + final polylineId = PolylineId(polylineIdVal); - final Polyline polyline = Polyline( + final polyline = Polyline( polylineId: polylineId, consumeTapEvents: true, color: Colors.orange, @@ -306,7 +306,7 @@ class PlacePolylineBodyState extends State { } List _createPoints() { - final List points = []; + final points = []; final double offset = _polylineIdCounter.ceilToDouble(); points.add(_createLatLng(51.4816 + offset, -3.1791)); points.add(_createLatLng(53.0430 + offset, -2.9925)); 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 9378cb091a38..524a9d450f92 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 @@ -52,7 +52,7 @@ class TileOverlayBodyState extends State { } void _addTileOverlay() { - final TileOverlay tileOverlay = TileOverlay( + final tileOverlay = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), ); @@ -69,9 +69,7 @@ class TileOverlayBodyState extends State { @override Widget build(BuildContext context) { - final Set overlays = { - if (_tileOverlay != null) _tileOverlay!, - }; + final overlays = {if (_tileOverlay != null) _tileOverlay!}; return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -123,10 +121,10 @@ class _DebugTileProvider implements TileProvider { @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 TextPainter textPainter = TextPainter( + final recorder = ui.PictureRecorder(); + final canvas = Canvas(recorder); + final textSpan = TextSpan(text: '$x,$y', style: textStyle); + final textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); 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 7db2374f90bd..07350dd69568 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 @@ -20,8 +20,7 @@ void main() { }); testWidgets('Can animate camera with duration', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -42,7 +41,7 @@ void main() { final CameraUpdate newCameraUpdate = CameraUpdate.newLatLng( const LatLng(20.0, 25.0), ); - const Duration updateDuration = Duration(seconds: 10); + const updateDuration = Duration(seconds: 10); await controller.animateCamera(newCameraUpdate, duration: updateDuration); diff --git a/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart b/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart index 58f9b334a9cb..b822f41a888f 100644 --- a/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter/test/circle_updates_test.dart @@ -28,7 +28,7 @@ void main() { }); testWidgets('Initializing a circle', (WidgetTester tester) async { - const Circle c1 = Circle(circleId: CircleId('circle_1')); + const c1 = Circle(circleId: CircleId('circle_1')); await tester.pumpWidget(_mapWithCircles({c1})); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -41,8 +41,8 @@ void main() { }); testWidgets('Adding a circle', (WidgetTester tester) async { - const Circle c1 = Circle(circleId: CircleId('circle_1')); - const Circle c2 = Circle(circleId: CircleId('circle_2')); + const c1 = Circle(circleId: CircleId('circle_1')); + const c2 = Circle(circleId: CircleId('circle_2')); await tester.pumpWidget(_mapWithCircles({c1})); await tester.pumpWidget(_mapWithCircles({c1, c2})); @@ -59,7 +59,7 @@ void main() { }); testWidgets('Removing a circle', (WidgetTester tester) async { - const Circle c1 = Circle(circleId: CircleId('circle_1')); + const c1 = Circle(circleId: CircleId('circle_1')); await tester.pumpWidget(_mapWithCircles({c1})); await tester.pumpWidget(_mapWithCircles({})); @@ -73,8 +73,8 @@ void main() { }); testWidgets('Updating a circle', (WidgetTester tester) async { - const Circle c1 = Circle(circleId: CircleId('circle_1')); - const Circle c2 = Circle(circleId: CircleId('circle_1'), radius: 10); + const c1 = Circle(circleId: CircleId('circle_1')); + const c2 = Circle(circleId: CircleId('circle_1'), radius: 10); await tester.pumpWidget(_mapWithCircles({c1})); await tester.pumpWidget(_mapWithCircles({c2})); @@ -88,8 +88,8 @@ void main() { }); testWidgets('Updating a circle', (WidgetTester tester) async { - const Circle c1 = Circle(circleId: CircleId('circle_1')); - const Circle c2 = Circle(circleId: CircleId('circle_1'), radius: 10); + const c1 = Circle(circleId: CircleId('circle_1')); + const c2 = Circle(circleId: CircleId('circle_1'), radius: 10); await tester.pumpWidget(_mapWithCircles({c1})); await tester.pumpWidget(_mapWithCircles({c2})); @@ -103,12 +103,12 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - Circle c1 = const Circle(circleId: CircleId('circle_1')); - Circle c2 = const Circle(circleId: CircleId('circle_2')); - final Set prev = {c1, c2}; + var c1 = const Circle(circleId: CircleId('circle_1')); + var c2 = const Circle(circleId: CircleId('circle_2')); + final prev = {c1, c2}; c1 = const Circle(circleId: CircleId('circle_1'), visible: false); c2 = const Circle(circleId: CircleId('circle_2'), radius: 10); - final Set cur = {c1, c2}; + final cur = {c1, c2}; await tester.pumpWidget(_mapWithCircles(prev)); await tester.pumpWidget(_mapWithCircles(cur)); @@ -121,14 +121,14 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - Circle c2 = const Circle(circleId: CircleId('circle_2')); - const Circle c3 = Circle(circleId: CircleId('circle_3')); - final Set prev = {c2, c3}; + var c2 = const Circle(circleId: CircleId('circle_2')); + const c3 = Circle(circleId: CircleId('circle_3')); + final prev = {c2, c3}; // c1 is added, c2 is updated, c3 is removed. - const Circle c1 = Circle(circleId: CircleId('circle_1')); + const c1 = Circle(circleId: CircleId('circle_1')); c2 = const Circle(circleId: CircleId('circle_2'), radius: 10); - final Set cur = {c1, c2}; + final cur = {c1, c2}; await tester.pumpWidget(_mapWithCircles(prev)); await tester.pumpWidget(_mapWithCircles(cur)); @@ -145,12 +145,12 @@ void main() { }); testWidgets('Partial Update', (WidgetTester tester) async { - const Circle c1 = Circle(circleId: CircleId('circle_1')); - const Circle c2 = Circle(circleId: CircleId('circle_2')); - Circle c3 = const Circle(circleId: CircleId('circle_3')); - final Set prev = {c1, c2, c3}; + const c1 = Circle(circleId: CircleId('circle_1')); + const c2 = Circle(circleId: CircleId('circle_2')); + var c3 = const Circle(circleId: CircleId('circle_3')); + final prev = {c1, c2, c3}; c3 = const Circle(circleId: CircleId('circle_3'), radius: 10); - final Set cur = {c1, c2, c3}; + final cur = {c1, c2, c3}; await tester.pumpWidget(_mapWithCircles(prev)); await tester.pumpWidget(_mapWithCircles(cur)); @@ -163,10 +163,10 @@ void main() { }); testWidgets('Update non platform related attr', (WidgetTester tester) async { - Circle c1 = const Circle(circleId: CircleId('circle_1')); - final Set prev = {c1}; + var c1 = const Circle(circleId: CircleId('circle_1')); + final prev = {c1}; c1 = Circle(circleId: const CircleId('circle_1'), onTap: () {}); - final Set cur = {c1}; + final cur = {c1}; await tester.pumpWidget(_mapWithCircles(prev)); await tester.pumpWidget(_mapWithCircles(cur)); @@ -181,10 +181,10 @@ void main() { testWidgets('multi-update with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - const Circle c1 = Circle(circleId: CircleId('circle_1')); - const Circle c2 = Circle(circleId: CircleId('circle_2')); - const Circle c3 = Circle(circleId: CircleId('circle_3'), radius: 1); - const Circle c3updated = Circle(circleId: CircleId('circle_3'), radius: 10); + const c1 = Circle(circleId: CircleId('circle_1')); + const c2 = Circle(circleId: CircleId('circle_2')); + const c3 = Circle(circleId: CircleId('circle_3'), radius: 1); + const c3updated = Circle(circleId: CircleId('circle_3'), radius: 10); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithCircles({c1, c2})); 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 acecbf126983..1e466e7c9624 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 @@ -28,9 +28,7 @@ void main() { }); testWidgets('Initializing a cluster manager', (WidgetTester tester) async { - const ClusterManager cm1 = ClusterManager( - clusterManagerId: ClusterManagerId('cm_1'), - ); + const cm1 = ClusterManager(clusterManagerId: ClusterManagerId('cm_1')); await tester.pumpWidget(_mapWithClusterManagers({cm1})); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -50,12 +48,8 @@ void main() { }); testWidgets('Adding a cluster manager', (WidgetTester tester) async { - const ClusterManager cm1 = ClusterManager( - clusterManagerId: ClusterManagerId('cm_1'), - ); - const ClusterManager cm2 = ClusterManager( - clusterManagerId: ClusterManagerId('cm_2'), - ); + const cm1 = ClusterManager(clusterManagerId: ClusterManagerId('cm_1')); + const cm2 = ClusterManager(clusterManagerId: ClusterManagerId('cm_2')); await tester.pumpWidget(_mapWithClusterManagers({cm1})); await tester.pumpWidget( @@ -81,9 +75,7 @@ void main() { }); testWidgets('Removing a cluster manager', (WidgetTester tester) async { - const ClusterManager cm1 = ClusterManager( - clusterManagerId: ClusterManagerId('cm_1'), - ); + const cm1 = ClusterManager(clusterManagerId: ClusterManagerId('cm_1')); await tester.pumpWidget(_mapWithClusterManagers({cm1})); await tester.pumpWidget(_mapWithClusterManagers({})); @@ -110,12 +102,8 @@ void main() { testWidgets('Updating a cluster manager with same data', ( WidgetTester tester, ) async { - const ClusterManager cm1 = ClusterManager( - clusterManagerId: ClusterManagerId('cm_1'), - ); - const ClusterManager cm2 = ClusterManager( - clusterManagerId: ClusterManagerId('cm_1'), - ); + const cm1 = ClusterManager(clusterManagerId: ClusterManagerId('cm_1')); + const cm2 = ClusterManager(clusterManagerId: ClusterManagerId('cm_1')); await tester.pumpWidget(_mapWithClusterManagers({cm1})); await tester.pumpWidget(_mapWithClusterManagers({cm2})); @@ -141,16 +129,12 @@ void main() { // are added to [ClusterManager] in the future, this test will need to be // updated accordingly to check that changes are triggered. testWidgets('Multi update with same data', (WidgetTester tester) async { - ClusterManager cm1 = const ClusterManager( - clusterManagerId: ClusterManagerId('cm_1'), - ); - ClusterManager cm2 = const ClusterManager( - clusterManagerId: ClusterManagerId('cm_2'), - ); - final Set prev = {cm1, cm2}; + var cm1 = const ClusterManager(clusterManagerId: ClusterManagerId('cm_1')); + var cm2 = const ClusterManager(clusterManagerId: ClusterManagerId('cm_2')); + final prev = {cm1, cm2}; cm1 = const ClusterManager(clusterManagerId: ClusterManagerId('cm_1')); cm2 = const ClusterManager(clusterManagerId: ClusterManagerId('cm_2')); - final Set cur = {cm1, cm2}; + final cur = {cm1, cm2}; await tester.pumpWidget(_mapWithClusterManagers(prev)); await tester.pumpWidget(_mapWithClusterManagers(cur)); @@ -173,18 +157,14 @@ void main() { // are added to [ClusterManager] in the future, this test will need to be // updated accordingly to check that changes are triggered. testWidgets('Partial update with same data', (WidgetTester tester) async { - const ClusterManager cm1 = ClusterManager( - clusterManagerId: ClusterManagerId('heatmap_1'), - ); - const ClusterManager cm2 = ClusterManager( - clusterManagerId: ClusterManagerId('heatmap_2'), - ); - ClusterManager cm3 = const ClusterManager( + const cm1 = ClusterManager(clusterManagerId: ClusterManagerId('heatmap_1')); + const cm2 = ClusterManager(clusterManagerId: ClusterManagerId('heatmap_2')); + var cm3 = const ClusterManager( clusterManagerId: ClusterManagerId('heatmap_3'), ); - final Set prev = {cm1, cm2, cm3}; + final prev = {cm1, cm2, cm3}; cm3 = const ClusterManager(clusterManagerId: ClusterManagerId('heatmap_3')); - final Set cur = {cm1, cm2, cm3}; + final cur = {cm1, cm2, cm3}; await tester.pumpWidget(_mapWithClusterManagers(prev)); await tester.pumpWidget(_mapWithClusterManagers(cur)); 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 7c27597c11a5..69734e6dc163 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 @@ -17,15 +17,13 @@ void main() { testWidgets('Subscriptions are canceled on dispose', ( WidgetTester tester, ) async { - final FakeGoogleMapsFlutterPlatform platform = - FakeGoogleMapsFlutterPlatform(); + final platform = FakeGoogleMapsFlutterPlatform(); GoogleMapsFlutterPlatform.instance = platform; - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); - final GoogleMap googleMap = GoogleMap( + final googleMap = GoogleMap( onMapCreated: (GoogleMapController controller) { controllerCompleter.complete(controller); }, 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 e5a1fca9a30b..4aedfdbb78f8 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 @@ -574,7 +574,7 @@ void main() { }); testWidgets('Can update style', (WidgetTester tester) async { - const String initialStyle = '[]'; + const initialStyle = '[]'; await tester.pumpWidget( const Directionality( textDirection: TextDirection.ltr, 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 9042c63bd59b..b67118e81d35 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 @@ -20,7 +20,7 @@ Widget _mapWithMarkers(Set groundOverlays) { } void main() { - final LatLngBounds kGroundOverlayBounds = LatLngBounds( + final kGroundOverlayBounds = LatLngBounds( southwest: const LatLng(37.77483, -122.41942), northeast: const LatLng(37.78183, -122.39105), ); @@ -33,7 +33,7 @@ void main() { }); testWidgets('Initializing a groundOverlay', (WidgetTester tester) async { - final GroundOverlay go1 = GroundOverlay.fromBounds( + final go1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('go_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -46,7 +46,7 @@ void main() { zIndex: 10, ); - final GroundOverlay go2 = GroundOverlay.fromPosition( + final go2 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('go_2'), position: kGroundOverlayBounds.northeast, width: 100, @@ -81,7 +81,7 @@ void main() { }); testWidgets('Adding a groundOverlay', (WidgetTester tester) async { - final GroundOverlay go1 = GroundOverlay.fromBounds( + final go1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('go_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -94,7 +94,7 @@ void main() { zIndex: 10, ); - final GroundOverlay go2 = GroundOverlay.fromPosition( + final go2 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('go_2'), position: kGroundOverlayBounds.northeast, width: 100, @@ -130,7 +130,7 @@ void main() { }); testWidgets('Removing a groundOverlay', (WidgetTester tester) async { - final GroundOverlay go1 = GroundOverlay.fromBounds( + final go1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('go_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -158,7 +158,7 @@ void main() { }); testWidgets('Updating a groundOverlay', (WidgetTester tester) async { - final GroundOverlay go1 = GroundOverlay.fromBounds( + final go1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('go_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -191,7 +191,7 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - GroundOverlay go1 = GroundOverlay.fromBounds( + var go1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('go_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -204,7 +204,7 @@ void main() { zIndex: 10, ); - GroundOverlay go2 = GroundOverlay.fromPosition( + var go2 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('go_2'), position: kGroundOverlayBounds.northeast, width: 100, @@ -221,10 +221,10 @@ void main() { zoomLevel: 14.0, ); - final Set prev = {go1, go2}; + final prev = {go1, go2}; go1 = go1.copyWith(visibleParam: false); go2 = go2.copyWith(clickableParam: false); - final Set cur = {go1, go2}; + final cur = {go1, go2}; await tester.pumpWidget(_mapWithMarkers(prev)); await tester.pumpWidget(_mapWithMarkers(cur)); @@ -240,7 +240,7 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - final GroundOverlay go1 = GroundOverlay.fromBounds( + final go1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('go_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -253,7 +253,7 @@ void main() { zIndex: 10, ); - GroundOverlay go2 = GroundOverlay.fromPosition( + var go2 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('go_2'), position: kGroundOverlayBounds.northeast, width: 100, @@ -270,7 +270,7 @@ void main() { zoomLevel: 14.0, ); - final GroundOverlay go3 = GroundOverlay.fromPosition( + final go3 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('go_3'), position: kGroundOverlayBounds.southwest, width: 100, @@ -287,11 +287,11 @@ void main() { zoomLevel: 14.0, ); - final Set prev = {go2, go3}; + final prev = {go2, go3}; // go1 is added, go2 is updated, go3 is removed. go2 = go2.copyWith(clickableParam: false); - final Set cur = {go1, go2}; + final cur = {go1, go2}; await tester.pumpWidget(_mapWithMarkers(prev)); await tester.pumpWidget(_mapWithMarkers(cur)); @@ -317,7 +317,7 @@ void main() { }); testWidgets('Partial Update', (WidgetTester tester) async { - final GroundOverlay go1 = GroundOverlay.fromBounds( + final go1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('go_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -330,7 +330,7 @@ void main() { zIndex: 10, ); - final GroundOverlay go2 = GroundOverlay.fromPosition( + final go2 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('go_2'), position: kGroundOverlayBounds.northeast, width: 100, @@ -347,7 +347,7 @@ void main() { zoomLevel: 14.0, ); - GroundOverlay go3 = GroundOverlay.fromPosition( + var go3 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('go_3'), position: kGroundOverlayBounds.southwest, width: 100, @@ -363,9 +363,9 @@ void main() { zIndex: 10, zoomLevel: 14.0, ); - final Set prev = {go1, go2, go3}; + final prev = {go1, go2, go3}; go3 = go3.copyWith(visibleParam: false); - final Set cur = {go1, go2, go3}; + final cur = {go1, go2, go3}; await tester.pumpWidget(_mapWithMarkers(prev)); await tester.pumpWidget(_mapWithMarkers(cur)); @@ -384,7 +384,7 @@ void main() { }); testWidgets('Update non platform related attr', (WidgetTester tester) async { - GroundOverlay go1 = GroundOverlay.fromBounds( + var go1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('go_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -396,9 +396,9 @@ void main() { bearing: 10, zIndex: 10, ); - final Set prev = {go1}; + final prev = {go1}; go1 = go1.copyWith(onTapParam: () {}); - final Set cur = {go1}; + final cur = {go1}; await tester.pumpWidget(_mapWithMarkers(prev)); await tester.pumpWidget(_mapWithMarkers(cur)); @@ -416,7 +416,7 @@ void main() { testWidgets('multi-update with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - final GroundOverlay go1 = GroundOverlay.fromBounds( + final go1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('go_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -429,7 +429,7 @@ void main() { zIndex: 10, ); - final GroundOverlay go2 = GroundOverlay.fromPosition( + final go2 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('go_2'), position: kGroundOverlayBounds.northeast, width: 100, @@ -446,7 +446,7 @@ void main() { zoomLevel: 14.0, ); - final GroundOverlay go3 = GroundOverlay.fromPosition( + final go3 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('go_3'), position: kGroundOverlayBounds.southwest, width: 100, 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 ec01bb67114b..891468ced66d 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 @@ -45,7 +45,7 @@ void main() { }); testWidgets('Initializing a heatmap', (WidgetTester tester) async { - const Heatmap h1 = Heatmap( + const h1 = Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), @@ -63,12 +63,12 @@ void main() { }); testWidgets('Adding a heatmap', (WidgetTester tester) async { - const Heatmap h1 = Heatmap( + const h1 = Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), ); - const Heatmap h2 = Heatmap( + const h2 = Heatmap( heatmapId: HeatmapId('heatmap_2'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), @@ -89,7 +89,7 @@ void main() { }); testWidgets('Removing a heatmap', (WidgetTester tester) async { - const Heatmap h1 = Heatmap( + const h1 = Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), @@ -110,12 +110,12 @@ void main() { }); testWidgets('Updating a heatmap', (WidgetTester tester) async { - const Heatmap h1 = Heatmap( + const h1 = Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), ); - const Heatmap h2 = Heatmap( + const h2 = Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(10), @@ -133,12 +133,12 @@ void main() { }); testWidgets('Updating a heatmap', (WidgetTester tester) async { - const Heatmap h1 = Heatmap( + const h1 = Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), ); - const Heatmap h2 = Heatmap( + const h2 = Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(10), @@ -156,17 +156,17 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - Heatmap h1 = const Heatmap( + var h1 = const Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), ); - Heatmap h2 = const Heatmap( + var h2 = const Heatmap( heatmapId: HeatmapId('heatmap_2'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), ); - final Set prev = {h1, h2}; + final prev = {h1, h2}; h1 = const Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, @@ -178,7 +178,7 @@ void main() { data: _heatmapPoints, radius: HeatmapRadius.fromPixels(10), ); - final Set cur = {h1, h2}; + final cur = {h1, h2}; await tester.pumpWidget(_mapWithHeatmaps(prev)); await tester.pumpWidget(_mapWithHeatmaps(cur)); @@ -191,20 +191,20 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - Heatmap h2 = const Heatmap( + var h2 = const Heatmap( heatmapId: HeatmapId('heatmap_2'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), ); - const Heatmap h3 = Heatmap( + const h3 = Heatmap( heatmapId: HeatmapId('heatmap_3'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), ); - final Set prev = {h2, h3}; + final prev = {h2, h3}; // h1 is added, h2 is updated, h3 is removed. - const Heatmap h1 = Heatmap( + const h1 = Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), @@ -214,7 +214,7 @@ void main() { data: _heatmapPoints, radius: HeatmapRadius.fromPixels(10), ); - final Set cur = {h1, h2}; + final cur = {h1, h2}; await tester.pumpWidget(_mapWithHeatmaps(prev)); await tester.pumpWidget(_mapWithHeatmaps(cur)); @@ -234,28 +234,28 @@ void main() { }); testWidgets('Partial Update', (WidgetTester tester) async { - const Heatmap h1 = Heatmap( + const h1 = Heatmap( heatmapId: HeatmapId('heatmap_1'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), ); - const Heatmap h2 = Heatmap( + const h2 = Heatmap( heatmapId: HeatmapId('heatmap_2'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), ); - Heatmap h3 = const Heatmap( + var h3 = const Heatmap( heatmapId: HeatmapId('heatmap_3'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(20), ); - final Set prev = {h1, h2, h3}; + final prev = {h1, h2, h3}; h3 = const Heatmap( heatmapId: HeatmapId('heatmap_3'), data: _heatmapPoints, radius: HeatmapRadius.fromPixels(10), ); - final Set cur = {h1, h2, h3}; + final cur = {h1, h2, h3}; await tester.pumpWidget(_mapWithHeatmaps(prev)); await tester.pumpWidget(_mapWithHeatmaps(cur)); 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 ae87d1e7a3db..73755e4603fc 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 @@ -28,7 +28,7 @@ void main() { }); testWidgets('Initializing a marker', (WidgetTester tester) async { - const Marker m1 = Marker(markerId: MarkerId('marker_1')); + const m1 = Marker(markerId: MarkerId('marker_1')); await tester.pumpWidget(_mapWithMarkers({m1})); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -41,8 +41,8 @@ void main() { }); testWidgets('Adding a marker', (WidgetTester tester) async { - const Marker m1 = Marker(markerId: MarkerId('marker_1')); - const Marker m2 = Marker(markerId: MarkerId('marker_2')); + const m1 = Marker(markerId: MarkerId('marker_1')); + const m2 = Marker(markerId: MarkerId('marker_2')); await tester.pumpWidget(_mapWithMarkers({m1})); await tester.pumpWidget(_mapWithMarkers({m1, m2})); @@ -59,7 +59,7 @@ void main() { }); testWidgets('Removing a marker', (WidgetTester tester) async { - const Marker m1 = Marker(markerId: MarkerId('marker_1')); + const m1 = Marker(markerId: MarkerId('marker_1')); await tester.pumpWidget(_mapWithMarkers({m1})); await tester.pumpWidget(_mapWithMarkers({})); @@ -73,8 +73,8 @@ void main() { }); testWidgets('Updating a marker', (WidgetTester tester) async { - const Marker m1 = Marker(markerId: MarkerId('marker_1')); - const Marker m2 = Marker(markerId: MarkerId('marker_1'), alpha: 0.5); + const m1 = Marker(markerId: MarkerId('marker_1')); + const m2 = Marker(markerId: MarkerId('marker_1'), alpha: 0.5); await tester.pumpWidget(_mapWithMarkers({m1})); await tester.pumpWidget(_mapWithMarkers({m2})); @@ -88,8 +88,8 @@ void main() { }); testWidgets('Updating a marker', (WidgetTester tester) async { - const Marker m1 = Marker(markerId: MarkerId('marker_1')); - const Marker m2 = Marker( + const m1 = Marker(markerId: MarkerId('marker_1')); + const m2 = Marker( markerId: MarkerId('marker_1'), infoWindow: InfoWindow(snippet: 'changed'), ); @@ -106,12 +106,12 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - Marker m1 = const Marker(markerId: MarkerId('marker_1')); - Marker m2 = const Marker(markerId: MarkerId('marker_2')); - final Set prev = {m1, m2}; + var m1 = const Marker(markerId: MarkerId('marker_1')); + var m2 = const Marker(markerId: MarkerId('marker_2')); + final prev = {m1, m2}; m1 = const Marker(markerId: MarkerId('marker_1'), visible: false); m2 = const Marker(markerId: MarkerId('marker_2'), draggable: true); - final Set cur = {m1, m2}; + final cur = {m1, m2}; await tester.pumpWidget(_mapWithMarkers(prev)); await tester.pumpWidget(_mapWithMarkers(cur)); @@ -124,14 +124,14 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - Marker m2 = const Marker(markerId: MarkerId('marker_2')); - const Marker m3 = Marker(markerId: MarkerId('marker_3')); - final Set prev = {m2, m3}; + var m2 = const Marker(markerId: MarkerId('marker_2')); + const m3 = Marker(markerId: MarkerId('marker_3')); + final prev = {m2, m3}; // m1 is added, m2 is updated, m3 is removed. - const Marker m1 = Marker(markerId: MarkerId('marker_1')); + const m1 = Marker(markerId: MarkerId('marker_1')); m2 = const Marker(markerId: MarkerId('marker_2'), draggable: true); - final Set cur = {m1, m2}; + final cur = {m1, m2}; await tester.pumpWidget(_mapWithMarkers(prev)); await tester.pumpWidget(_mapWithMarkers(cur)); @@ -148,12 +148,12 @@ void main() { }); testWidgets('Partial Update', (WidgetTester tester) async { - const Marker m1 = Marker(markerId: MarkerId('marker_1')); - const Marker m2 = Marker(markerId: MarkerId('marker_2')); - Marker m3 = const Marker(markerId: MarkerId('marker_3')); - final Set prev = {m1, m2, m3}; + const m1 = Marker(markerId: MarkerId('marker_1')); + const m2 = Marker(markerId: MarkerId('marker_2')); + var m3 = const Marker(markerId: MarkerId('marker_3')); + final prev = {m1, m2, m3}; m3 = const Marker(markerId: MarkerId('marker_3'), draggable: true); - final Set cur = {m1, m2, m3}; + final cur = {m1, m2, m3}; await tester.pumpWidget(_mapWithMarkers(prev)); await tester.pumpWidget(_mapWithMarkers(cur)); @@ -166,14 +166,14 @@ void main() { }); testWidgets('Update non platform related attr', (WidgetTester tester) async { - Marker m1 = const Marker(markerId: MarkerId('marker_1')); - final Set prev = {m1}; + var m1 = const Marker(markerId: MarkerId('marker_1')); + final prev = {m1}; m1 = Marker( markerId: const MarkerId('marker_1'), onTap: () {}, onDragEnd: (LatLng latLng) {}, ); - final Set cur = {m1}; + final cur = {m1}; await tester.pumpWidget(_mapWithMarkers(prev)); await tester.pumpWidget(_mapWithMarkers(cur)); @@ -188,13 +188,10 @@ void main() { testWidgets('multi-update with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - 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 m1 = Marker(markerId: MarkerId('marker_1')); + const m2 = Marker(markerId: MarkerId('marker_2')); + const m3 = Marker(markerId: MarkerId('marker_3')); + const 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 778a89e2d17b..e174d9d10de5 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 @@ -51,7 +51,7 @@ void main() { }); testWidgets('Initializing a polygon', (WidgetTester tester) async { - const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p1 = Polygon(polygonId: PolygonId('polygon_1')); await tester.pumpWidget(_mapWithPolygons({p1})); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -65,8 +65,8 @@ void main() { }); testWidgets('Adding a polygon', (WidgetTester tester) async { - const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); - const Polygon p2 = Polygon(polygonId: PolygonId('polygon_2')); + const p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p2 = Polygon(polygonId: PolygonId('polygon_2')); await tester.pumpWidget(_mapWithPolygons({p1})); await tester.pumpWidget(_mapWithPolygons({p1, p2})); @@ -83,7 +83,7 @@ void main() { }); testWidgets('Removing a polygon', (WidgetTester tester) async { - const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p1 = Polygon(polygonId: PolygonId('polygon_1')); await tester.pumpWidget(_mapWithPolygons({p1})); await tester.pumpWidget(_mapWithPolygons({})); @@ -100,11 +100,8 @@ 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 p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p2 = Polygon(polygonId: PolygonId('polygon_1'), geodesic: true); await tester.pumpWidget(_mapWithPolygons({p1})); await tester.pumpWidget(_mapWithPolygons({p2})); @@ -118,11 +115,8 @@ void main() { }); testWidgets('Mutate a polygon', (WidgetTester tester) async { - final List points = [const LatLng(0.0, 0.0)]; - final Polygon p1 = Polygon( - polygonId: const PolygonId('polygon_1'), - points: points, - ); + final points = [const LatLng(0.0, 0.0)]; + final p1 = Polygon(polygonId: const PolygonId('polygon_1'), points: points); await tester.pumpWidget(_mapWithPolygons({p1})); p1.points.add(const LatLng(1.0, 1.0)); @@ -137,12 +131,12 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - Polygon p1 = const Polygon(polygonId: PolygonId('polygon_1')); - Polygon p2 = const Polygon(polygonId: PolygonId('polygon_2')); - final Set prev = {p1, p2}; + var p1 = const Polygon(polygonId: PolygonId('polygon_1')); + var p2 = const Polygon(polygonId: PolygonId('polygon_2')); + final prev = {p1, p2}; p1 = const Polygon(polygonId: PolygonId('polygon_1'), visible: false); p2 = const Polygon(polygonId: PolygonId('polygon_2'), geodesic: true); - final Set cur = {p1, p2}; + final cur = {p1, p2}; await tester.pumpWidget(_mapWithPolygons(prev)); await tester.pumpWidget(_mapWithPolygons(cur)); @@ -155,14 +149,14 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - Polygon p2 = const Polygon(polygonId: PolygonId('polygon_2')); - const Polygon p3 = Polygon(polygonId: PolygonId('polygon_3')); - final Set prev = {p2, p3}; + var p2 = const Polygon(polygonId: PolygonId('polygon_2')); + const p3 = Polygon(polygonId: PolygonId('polygon_3')); + final prev = {p2, p3}; // p1 is added, p2 is updated, p3 is removed. - const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p1 = Polygon(polygonId: PolygonId('polygon_1')); p2 = const Polygon(polygonId: PolygonId('polygon_2'), geodesic: true); - final Set cur = {p1, p2}; + final cur = {p1, p2}; await tester.pumpWidget(_mapWithPolygons(prev)); await tester.pumpWidget(_mapWithPolygons(cur)); @@ -182,12 +176,12 @@ void main() { }); testWidgets('Partial Update', (WidgetTester tester) async { - const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); - const Polygon p2 = Polygon(polygonId: PolygonId('polygon_2')); - Polygon p3 = const Polygon(polygonId: PolygonId('polygon_3')); - final Set prev = {p1, p2, p3}; + const p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p2 = Polygon(polygonId: PolygonId('polygon_2')); + var p3 = const Polygon(polygonId: PolygonId('polygon_3')); + final prev = {p1, p2, p3}; p3 = const Polygon(polygonId: PolygonId('polygon_3'), geodesic: true); - final Set cur = {p1, p2, p3}; + final cur = {p1, p2, p3}; await tester.pumpWidget(_mapWithPolygons(prev)); await tester.pumpWidget(_mapWithPolygons(cur)); @@ -200,10 +194,10 @@ void main() { }); testWidgets('Update non platform related attr', (WidgetTester tester) async { - Polygon p1 = const Polygon(polygonId: PolygonId('polygon_1')); - final Set prev = {p1}; + var p1 = const Polygon(polygonId: PolygonId('polygon_1')); + final prev = {p1}; p1 = Polygon(polygonId: const PolygonId('polygon_1'), onTap: () {}); - final Set cur = {p1}; + final cur = {p1}; await tester.pumpWidget(_mapWithPolygons(prev)); await tester.pumpWidget(_mapWithPolygons(cur)); @@ -234,7 +228,7 @@ void main() { testWidgets('Adding a polygon with points and hole', ( WidgetTester tester, ) async { - const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p1 = Polygon(polygonId: PolygonId('polygon_1')); final Polygon p2 = _polygonWithPointsAndHole(const PolygonId('polygon_2')); await tester.pumpWidget(_mapWithPolygons({p1})); @@ -273,7 +267,7 @@ void main() { testWidgets('Updating a polygon by adding points and hole', ( WidgetTester tester, ) async { - const Polygon p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p1 = Polygon(polygonId: PolygonId('polygon_1')); final Polygon p2 = _polygonWithPointsAndHole(const PolygonId('polygon_1')); await tester.pumpWidget(_mapWithPolygons({p1})); @@ -290,7 +284,7 @@ void main() { testWidgets('Mutate a polygon with points and holes', ( WidgetTester tester, ) async { - final Polygon p1 = Polygon( + final p1 = Polygon( polygonId: const PolygonId('polygon_1'), points: _rectPoints(size: 1), holes: >[_rectPoints(size: 0.5)], @@ -316,19 +310,19 @@ void main() { testWidgets('Multi Update polygons with points and hole', ( WidgetTester tester, ) async { - Polygon p1 = const Polygon(polygonId: PolygonId('polygon_1')); - Polygon p2 = Polygon( + var p1 = const Polygon(polygonId: PolygonId('polygon_1')); + var p2 = Polygon( polygonId: const PolygonId('polygon_2'), points: _rectPoints(size: 2), holes: >[_rectPoints(size: 1)], ); - final Set prev = {p1, p2}; + final prev = {p1, p2}; p1 = const Polygon(polygonId: PolygonId('polygon_1'), visible: false); p2 = p2.copyWith( pointsParam: _rectPoints(size: 5), holesParam: >[_rectPoints(size: 2)], ); - final Set cur = {p1, p2}; + final cur = {p1, p2}; await tester.pumpWidget(_mapWithPolygons(prev)); await tester.pumpWidget(_mapWithPolygons(cur)); @@ -343,13 +337,13 @@ void main() { testWidgets('Multi Update polygons with points and hole', ( WidgetTester tester, ) async { - Polygon p2 = Polygon( + var p2 = Polygon( polygonId: const PolygonId('polygon_2'), points: _rectPoints(size: 2), holes: >[_rectPoints(size: 1)], ); - const Polygon p3 = Polygon(polygonId: PolygonId('polygon_3')); - final Set prev = {p2, p3}; + const p3 = Polygon(polygonId: PolygonId('polygon_3')); + final prev = {p2, p3}; // p1 is added, p2 is updated, p3 is removed. final Polygon p1 = _polygonWithPointsAndHole(const PolygonId('polygon_1')); @@ -357,7 +351,7 @@ void main() { pointsParam: _rectPoints(size: 5), holesParam: >[_rectPoints(size: 3)], ); - final Set cur = {p1, p2}; + final cur = {p1, p2}; await tester.pumpWidget(_mapWithPolygons(prev)); await tester.pumpWidget(_mapWithPolygons(cur)); @@ -380,18 +374,18 @@ void main() { WidgetTester tester, ) async { final Polygon p1 = _polygonWithPointsAndHole(const PolygonId('polygon_1')); - const Polygon p2 = Polygon(polygonId: PolygonId('polygon_2')); - Polygon p3 = Polygon( + const p2 = Polygon(polygonId: PolygonId('polygon_2')); + var p3 = Polygon( polygonId: const PolygonId('polygon_3'), points: _rectPoints(size: 2), holes: >[_rectPoints(size: 1)], ); - final Set prev = {p1, p2, p3}; + final prev = {p1, p2, p3}; p3 = p3.copyWith( pointsParam: _rectPoints(size: 5), holesParam: >[_rectPoints(size: 3)], ); - final Set cur = {p1, p2, p3}; + final cur = {p1, p2, p3}; await tester.pumpWidget(_mapWithPolygons(prev)); await tester.pumpWidget(_mapWithPolygons(cur)); @@ -406,13 +400,10 @@ void main() { testWidgets('multi-update with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - 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( + const p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p2 = Polygon(polygonId: PolygonId('polygon_2')); + const p3 = Polygon(polygonId: PolygonId('polygon_3'), strokeWidth: 1); + const p3updated = Polygon( polygonId: PolygonId('polygon_3'), strokeWidth: 2, ); 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 9c00e61e2e4b..42da2d46945f 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 @@ -28,7 +28,7 @@ void main() { }); testWidgets('Initializing a polyline', (WidgetTester tester) async { - const Polyline p1 = Polyline(polylineId: PolylineId('polyline_1')); + const p1 = Polyline(polylineId: PolylineId('polyline_1')); await tester.pumpWidget(_mapWithPolylines({p1})); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -42,8 +42,8 @@ void main() { }); testWidgets('Adding a polyline', (WidgetTester tester) async { - const Polyline p1 = Polyline(polylineId: PolylineId('polyline_1')); - const Polyline p2 = Polyline(polylineId: PolylineId('polyline_2')); + const p1 = Polyline(polylineId: PolylineId('polyline_1')); + const p2 = Polyline(polylineId: PolylineId('polyline_2')); await tester.pumpWidget(_mapWithPolylines({p1})); await tester.pumpWidget(_mapWithPolylines({p1, p2})); @@ -61,7 +61,7 @@ void main() { }); testWidgets('Removing a polyline', (WidgetTester tester) async { - const Polyline p1 = Polyline(polylineId: PolylineId('polyline_1')); + const p1 = Polyline(polylineId: PolylineId('polyline_1')); await tester.pumpWidget(_mapWithPolylines({p1})); await tester.pumpWidget(_mapWithPolylines({})); @@ -78,11 +78,8 @@ 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 p1 = Polyline(polylineId: PolylineId('polyline_1')); + const p2 = Polyline(polylineId: PolylineId('polyline_1'), geodesic: true); await tester.pumpWidget(_mapWithPolylines({p1})); await tester.pumpWidget(_mapWithPolylines({p2})); @@ -96,11 +93,8 @@ 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 p1 = Polyline(polylineId: PolylineId('polyline_1')); + const p2 = Polyline(polylineId: PolylineId('polyline_1'), geodesic: true); await tester.pumpWidget(_mapWithPolylines({p1})); await tester.pumpWidget(_mapWithPolylines({p2})); @@ -114,8 +108,8 @@ void main() { }); testWidgets('Mutate a polyline', (WidgetTester tester) async { - final List points = [const LatLng(0.0, 0.0)]; - final Polyline p1 = Polyline( + final points = [const LatLng(0.0, 0.0)]; + final p1 = Polyline( polylineId: const PolylineId('polyline_1'), points: points, ); @@ -133,12 +127,12 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - Polyline p1 = const Polyline(polylineId: PolylineId('polyline_1')); - Polyline p2 = const Polyline(polylineId: PolylineId('polyline_2')); - final Set prev = {p1, p2}; + var p1 = const Polyline(polylineId: PolylineId('polyline_1')); + var p2 = const Polyline(polylineId: PolylineId('polyline_2')); + final prev = {p1, p2}; p1 = const Polyline(polylineId: PolylineId('polyline_1'), visible: false); p2 = const Polyline(polylineId: PolylineId('polyline_2'), geodesic: true); - final Set cur = {p1, p2}; + final cur = {p1, p2}; await tester.pumpWidget(_mapWithPolylines(prev)); await tester.pumpWidget(_mapWithPolylines(cur)); @@ -151,14 +145,14 @@ void main() { }); testWidgets('Multi Update', (WidgetTester tester) async { - Polyline p2 = const Polyline(polylineId: PolylineId('polyline_2')); - const Polyline p3 = Polyline(polylineId: PolylineId('polyline_3')); - final Set prev = {p2, p3}; + var p2 = const Polyline(polylineId: PolylineId('polyline_2')); + const p3 = Polyline(polylineId: PolylineId('polyline_3')); + final prev = {p2, p3}; // p1 is added, p2 is updated, p3 is removed. - const Polyline p1 = Polyline(polylineId: PolylineId('polyline_1')); + const p1 = Polyline(polylineId: PolylineId('polyline_1')); p2 = const Polyline(polylineId: PolylineId('polyline_2'), geodesic: true); - final Set cur = {p1, p2}; + final cur = {p1, p2}; await tester.pumpWidget(_mapWithPolylines(prev)); await tester.pumpWidget(_mapWithPolylines(cur)); @@ -178,12 +172,12 @@ void main() { }); testWidgets('Partial Update', (WidgetTester tester) async { - const Polyline p1 = Polyline(polylineId: PolylineId('polyline_1')); - const Polyline p2 = Polyline(polylineId: PolylineId('polyline_2')); - Polyline p3 = const Polyline(polylineId: PolylineId('polyline_3')); - final Set prev = {p1, p2, p3}; + const p1 = Polyline(polylineId: PolylineId('polyline_1')); + const p2 = Polyline(polylineId: PolylineId('polyline_2')); + var p3 = const Polyline(polylineId: PolylineId('polyline_3')); + final prev = {p1, p2, p3}; p3 = const Polyline(polylineId: PolylineId('polyline_3'), geodesic: true); - final Set cur = {p1, p2, p3}; + final cur = {p1, p2, p3}; await tester.pumpWidget(_mapWithPolylines(prev)); await tester.pumpWidget(_mapWithPolylines(cur)); @@ -196,10 +190,10 @@ void main() { }); testWidgets('Update non platform related attr', (WidgetTester tester) async { - Polyline p1 = const Polyline(polylineId: PolylineId('polyline_1')); - final Set prev = {p1}; + var p1 = const Polyline(polylineId: PolylineId('polyline_1')); + final prev = {p1}; p1 = Polyline(polylineId: const PolylineId('polyline_1'), onTap: () {}); - final Set cur = {p1}; + final cur = {p1}; await tester.pumpWidget(_mapWithPolylines(prev)); await tester.pumpWidget(_mapWithPolylines(cur)); @@ -214,16 +208,10 @@ void main() { testWidgets('multi-update with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - 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 p1 = Polyline(polylineId: PolylineId('polyline_1')); + const p2 = Polyline(polylineId: PolylineId('polyline_2')); + const p3 = Polyline(polylineId: PolylineId('polyline_3'), width: 1); + const 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})); 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 28b273451756..ff9889eed39b 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,9 +28,7 @@ void main() { }); testWidgets('Initializing a tile overlay', (WidgetTester tester) async { - const TileOverlay t1 = TileOverlay( - tileOverlayId: TileOverlayId('tile_overlay_1'), - ); + const t1 = TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_1')); await tester.pumpWidget(_mapWithTileOverlays({t1})); final PlatformMapStateRecorder map = platform.lastCreatedMap; @@ -38,12 +36,8 @@ 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 t1 = TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_1')); + const t2 = TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_2')); await tester.pumpWidget(_mapWithTileOverlays({t1})); await tester.pumpWidget(_mapWithTileOverlays({t1, t2})); @@ -53,9 +47,7 @@ void main() { }); testWidgets('Removing a tile overlay', (WidgetTester tester) async { - const TileOverlay t1 = TileOverlay( - tileOverlayId: TileOverlayId('tile_overlay_1'), - ); + const t1 = TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_1')); await tester.pumpWidget(_mapWithTileOverlays({t1})); await tester.pumpWidget(_mapWithTileOverlays({})); @@ -65,10 +57,8 @@ void main() { }); testWidgets('Updating a tile overlay', (WidgetTester tester) async { - const TileOverlay t1 = TileOverlay( - tileOverlayId: TileOverlayId('tile_overlay_1'), - ); - const TileOverlay t2 = TileOverlay( + const t1 = TileOverlay(tileOverlayId: TileOverlayId('tile_overlay_1')); + const t2 = TileOverlay( tileOverlayId: TileOverlayId('tile_overlay_1'), zIndex: 10, ); 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 89dcced09183..83e7b3d3d91c 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 @@ -51,7 +51,7 @@ void main() { GoogleMapsFlutterPlatform.instance.enableDebugInspection(); setUpAll(() async { - final GoogleMapsFlutterAndroid instance = + final instance = GoogleMapsFlutterPlatform.instance as GoogleMapsFlutterAndroid; initializedRenderer = await instance.initializeWithRenderer( AndroidMapRenderer.latest, @@ -74,7 +74,7 @@ void main() { testWidgets('throws PlatformException on multiple renderer initializations', ( WidgetTester _, ) async { - final GoogleMapsFlutterAndroid instance = + final instance = GoogleMapsFlutterPlatform.instance as GoogleMapsFlutterAndroid; expect( () async => instance.initializeWithRenderer(AndroidMapRenderer.latest), @@ -103,7 +103,7 @@ void main() { bool Function(T) predicate, { int maxTries = 100, }) async { - for (int i = 0; i < maxTries; i++) { + for (var i = 0; i < maxTries; i++) { final T value = await getValue(); if (predicate(value)) { return value; @@ -114,14 +114,14 @@ void main() { } testWidgets('uses surface view', (WidgetTester tester) async { - final GoogleMapsFlutterAndroid instance = + final instance = GoogleMapsFlutterPlatform.instance as GoogleMapsFlutterAndroid; final bool previousUseAndroidViewSurfaceValue = instance.useAndroidViewSurface; instance.useAndroidViewSurface = true; final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -151,7 +151,7 @@ void main() { testWidgets('testCompassToggle', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -191,7 +191,7 @@ void main() { testWidgets('testMapToolbarToggle', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -232,11 +232,10 @@ void main() { testWidgets('updateMinMaxZoomLevels', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); - const MinMaxZoomPreference initialZoomLevel = MinMaxZoomPreference(4, 8); - const MinMaxZoomPreference finalZoomLevel = MinMaxZoomPreference(6, 10); + const initialZoomLevel = MinMaxZoomPreference(4, 8); + const finalZoomLevel = MinMaxZoomPreference(6, 10); await tester.pumpWidget( Directionality( @@ -293,7 +292,7 @@ void main() { testWidgets('testZoomGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -336,7 +335,7 @@ void main() { testWidgets('testZoomControlsEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -379,7 +378,7 @@ void main() { testWidgets('testLiteModeEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -420,7 +419,7 @@ void main() { testWidgets('testRotateGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -465,7 +464,7 @@ void main() { testWidgets('testTiltGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -508,7 +507,7 @@ void main() { testWidgets('testScrollGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -554,8 +553,7 @@ void main() { testWidgets('testInitialCenterLocationAtCenter', (WidgetTester tester) async { await tester.binding.setSurfaceSize(const Size(800, 600)); - final Completer mapControllerCompleter = - Completer(); + final mapControllerCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( Directionality( @@ -599,13 +597,12 @@ void main() { testWidgets('testGetVisibleRegion', (WidgetTester tester) async { final Key key = GlobalKey(); - final LatLngBounds zeroLatLngBounds = LatLngBounds( + final zeroLatLngBounds = LatLngBounds( southwest: const LatLng(0, 0), northeast: const LatLng(0, 0), ); - final Completer mapControllerCompleter = - Completer(); + final mapControllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -639,15 +636,15 @@ void main() { // 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( + final southWest = LatLng( firstVisibleRegion.southwest.latitude - 20, firstVisibleRegion.southwest.longitude - 20, ); - final LatLng northEast = LatLng( + final northEast = LatLng( firstVisibleRegion.southwest.latitude - 10, firstVisibleRegion.southwest.longitude - 10, ); - final LatLng newCenter = LatLng( + final newCenter = LatLng( (northEast.latitude + southWest.latitude) / 2, (northEast.longitude + southWest.longitude) / 2, ); @@ -655,7 +652,7 @@ void main() { expect(firstVisibleRegion.contains(northEast), isFalse); expect(firstVisibleRegion.contains(southWest), isFalse); - final LatLngBounds latLngBounds = LatLngBounds( + final latLngBounds = LatLngBounds( southwest: southWest, northeast: northEast, ); @@ -679,7 +676,7 @@ void main() { testWidgets('testTraffic', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -720,7 +717,7 @@ void main() { testWidgets('testBuildings', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -748,7 +745,7 @@ void main() { 'testMyLocationButtonToggle', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -798,7 +795,7 @@ void main() { 'testMyLocationButton initial value false', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -829,7 +826,7 @@ void main() { 'testMyLocationButton initial value true', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -857,8 +854,7 @@ void main() { testWidgets('testSetMapStyle valid Json String', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -875,7 +871,7 @@ void main() { final ExampleGoogleMapController controller = await controllerCompleter.future; - const String mapStyle = + const mapStyle = '[{"elementType":"geometry","stylers":[{"color":"#242f3e"}]}]'; await GoogleMapsFlutterPlatform.instance.setMapStyle( mapStyle, @@ -887,8 +883,7 @@ void main() { WidgetTester tester, ) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -920,8 +915,7 @@ void main() { testWidgets('testSetMapStyle null string', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -946,8 +940,7 @@ void main() { testWidgets('testGetLatLng', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -975,7 +968,7 @@ void main() { final LatLng topLeft = await controller.getLatLng( const ScreenCoordinate(x: 0, y: 0), ); - final LatLng northWest = LatLng( + final northWest = LatLng( visibleRegion.northeast.latitude, visibleRegion.southwest.longitude, ); @@ -985,8 +978,7 @@ void main() { testWidgets('testGetZoomLevel', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1021,8 +1013,7 @@ void main() { testWidgets('testScreenCoordinate', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1046,7 +1037,7 @@ void main() { await Future.delayed(const Duration(seconds: 1)); final LatLngBounds visibleRegion = await controller.getVisibleRegion(); - final LatLng northWest = LatLng( + final northWest = LatLng( visibleRegion.northeast.latitude, visibleRegion.southwest.longitude, ); @@ -1057,9 +1048,8 @@ void main() { }); testWidgets('testResizeWidget', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); - final ExampleGoogleMap map = ExampleGoogleMap( + final controllerCompleter = Completer(); + final map = ExampleGoogleMap( initialCameraPosition: _kInitialCameraPosition, onMapCreated: (ExampleGoogleMapController controller) async { controllerCompleter.complete(controller); @@ -1098,14 +1088,13 @@ void main() { }); testWidgets('testToggleInfoWindow', (WidgetTester tester) async { - const Marker marker = Marker( + const marker = Marker( markerId: MarkerId('marker'), infoWindow: InfoWindow(title: 'InfoWindow'), ); - final Set markers = {marker}; + final markers = {marker}; - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1158,8 +1147,7 @@ void main() { testWidgets( 'testTakeSnapshot', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1186,15 +1174,15 @@ void main() { ); testWidgets('set tileOverlay correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final TileOverlay tileOverlay1 = TileOverlay( + final mapIdCompleter = Completer(); + final tileOverlay1 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 2, transparency: 0.2, ); - final TileOverlay tileOverlay2 = TileOverlay( + final tileOverlay2 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_2'), tileProvider: _DebugTileProvider(), zIndex: 1, @@ -1247,16 +1235,16 @@ void main() { }); testWidgets('update tileOverlays correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( + final tileOverlay1 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 2, transparency: 0.2, ); - final TileOverlay tileOverlay2 = TileOverlay( + final tileOverlay2 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_2'), tileProvider: _DebugTileProvider(), zIndex: 3, @@ -1280,7 +1268,7 @@ void main() { final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - final TileOverlay tileOverlay1New = TileOverlay( + final tileOverlay1New = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 1, @@ -1326,9 +1314,9 @@ void main() { }); testWidgets('remove tileOverlays correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( + final tileOverlay1 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 2, @@ -1377,27 +1365,21 @@ void main() { testWidgets('marker clustering', (WidgetTester tester) async { final Key key = GlobalKey(); - const int clusterManagersAmount = 2; - const int markersPerClusterManager = 5; - final Map markers = {}; - final Set clusterManagers = {}; - - for (int i = 0; i < clusterManagersAmount; i++) { - final ClusterManagerId clusterManagerId = ClusterManagerId( - 'cluster_manager_$i', - ); - final ClusterManager clusterManager = ClusterManager( - clusterManagerId: clusterManagerId, - ); + const clusterManagersAmount = 2; + const markersPerClusterManager = 5; + final markers = {}; + final clusterManagers = {}; + + for (var i = 0; i < clusterManagersAmount; i++) { + final clusterManagerId = ClusterManagerId('cluster_manager_$i'); + final 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 Marker marker = Marker( + for (final cm in clusterManagers) { + for (var i = 0; i < markersPerClusterManager; i++) { + final markerId = MarkerId('${cm.clusterManagerId.value}_marker_$i'); + final marker = Marker( markerId: markerId, clusterManagerId: cm.clusterManagerId, position: LatLng( @@ -1409,8 +1391,7 @@ void main() { } } - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1433,7 +1414,7 @@ void main() { final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - for (final ClusterManager cm in clusterManagers) { + for (final cm in clusterManagers) { final List clusters = await inspector.getClusters( mapId: controller.mapId, clusterManagerId: cm.clusterManagerId, @@ -1460,7 +1441,7 @@ void main() { ), ); - for (final ClusterManager cm in clusterManagers) { + for (final cm in clusterManagers) { final List clusters = await inspector.getClusters( mapId: controller.mapId, clusterManagerId: cm.clusterManagerId, @@ -1470,7 +1451,7 @@ void main() { }); testWidgets('testMapId', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( @@ -1494,8 +1475,7 @@ void main() { testWidgets('getStyleError reports last error', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1514,7 +1494,7 @@ void main() { final ExampleGoogleMapController controller = await controllerCompleter.future; String? error = await controller.getStyleError(); - for (int i = 0; i < 1000 && error == null; i++) { + for (var i = 0; i < 1000 && error == null; i++) { await Future.delayed(const Duration(milliseconds: 10)); error = await controller.getStyleError(); } @@ -1525,8 +1505,7 @@ void main() { WidgetTester tester, ) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1550,7 +1529,7 @@ void main() { }); testWidgets('markerWithAssetMapBitmap', (WidgetTester tester) async { - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: AssetMapBitmap('assets/red_square.png', imagePixelRatio: 1.0), @@ -1570,10 +1549,10 @@ void main() { }); testWidgets('markerWithAssetMapBitmapCreate', (WidgetTester tester) async { - final ImageConfiguration imageConfiguration = ImageConfiguration( + final imageConfiguration = ImageConfiguration( devicePixelRatio: tester.view.devicePixelRatio, ); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: await AssetMapBitmap.create( @@ -1597,7 +1576,7 @@ void main() { testWidgets('markerWithBytesMapBitmap', (WidgetTester tester) async { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: BytesMapBitmap( @@ -1621,11 +1600,11 @@ void main() { testWidgets('markerWithLegacyAsset', (WidgetTester tester) async { tester.view.devicePixelRatio = 2.0; - final ImageConfiguration imageConfiguration = ImageConfiguration( + final imageConfiguration = ImageConfiguration( devicePixelRatio: tester.view.devicePixelRatio, size: const Size(100, 100), ); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), // Intentionally testing the deprecated code path. @@ -1654,7 +1633,7 @@ void main() { testWidgets('markerWithLegacyBytes', (WidgetTester tester) async { tester.view.devicePixelRatio = 2.0; final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), // Intentionally testing the deprecated code path. @@ -1678,12 +1657,12 @@ void main() { }); group('GroundOverlay', () { - final LatLngBounds kGroundOverlayBounds = LatLngBounds( + final kGroundOverlayBounds = LatLngBounds( southwest: const LatLng(37.77483, -122.41942), northeast: const LatLng(37.78183, -122.39105), ); - final GroundOverlay groundOverlayBounds1 = GroundOverlay.fromBounds( + final groundOverlayBounds1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('bounds_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -1693,7 +1672,7 @@ void main() { ), ); - final GroundOverlay groundOverlayPosition1 = GroundOverlay.fromPosition( + final groundOverlayPosition1 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('position_1'), position: kGroundOverlayBounds.northeast, width: 100, @@ -1748,8 +1727,8 @@ void main() { } testWidgets('set ground overlays correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final GroundOverlay groundOverlayBounds2 = GroundOverlay.fromBounds( + final mapIdCompleter = Completer(); + final groundOverlayBounds2 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('bounds_2'), bounds: groundOverlayBounds1.bounds!, image: groundOverlayBounds1.image, @@ -1806,7 +1785,7 @@ void main() { testWidgets('update ground overlays correctly', ( WidgetTester tester, ) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( @@ -1890,7 +1869,7 @@ void main() { testWidgets('remove ground overlays correctly', ( WidgetTester tester, ) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( @@ -1945,8 +1924,7 @@ void main() { 'testAnimateCameraWithoutDuration', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; @@ -2040,16 +2018,15 @@ void main() { 'testAnimateCameraWithDuration', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; /// Completer to track when the camera has come to rest. Completer? cameraIdleCompleter; - const int shortCameraAnimationDurationMS = 200; - const int longCameraAnimationDurationMS = 1000; + const shortCameraAnimationDurationMS = 200; + const longCameraAnimationDurationMS = 1000; /// Calculate the midpoint duration of the animation test, which will /// serve as a reference to verify that animations complete more quickly @@ -2058,7 +2035,7 @@ void main() { (shortCameraAnimationDurationMS + longCameraAnimationDurationMS) ~/ 2; // Stopwatch to measure the time taken for the animation to complete. - final Stopwatch stopwatch = Stopwatch(); + final stopwatch = Stopwatch(); await tester.pumpWidget( Directionality( @@ -2201,10 +2178,10 @@ class _DebugTileProvider implements TileProvider { @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 TextPainter textPainter = TextPainter( + final recorder = ui.PictureRecorder(); + final canvas = Canvas(recorder); + final textSpan = TextSpan(text: '$x,$y', style: textStyle); + final textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); @@ -2286,7 +2263,7 @@ Future _checkCameraUpdateByType( ) async { // As the target might differ a bit from the expected target, a threshold is // used. - const double latLngThreshold = 0.05; + const latLngThreshold = 0.05; switch (type) { case CameraUpdateType.newCameraPosition: 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 ca60d810373c..3aa9b8b54091 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 @@ -122,14 +122,11 @@ class ClusteringBodyState extends State { return; } - final String clusterManagerIdVal = - 'cluster_manager_id_$_clusterManagerIdCounter'; + final clusterManagerIdVal = 'cluster_manager_id_$_clusterManagerIdCounter'; _clusterManagerIdCounter++; - final ClusterManagerId clusterManagerId = ClusterManagerId( - clusterManagerIdVal, - ); + final clusterManagerId = ClusterManagerId(clusterManagerIdVal); - final ClusterManager clusterManager = ClusterManager( + final clusterManager = ClusterManager( clusterManagerId: clusterManagerId, onClusterTap: (Cluster cluster) => setState(() { lastCluster = cluster; @@ -155,11 +152,11 @@ class ClusteringBodyState extends State { } void _addMarkersToCluster(ClusterManager clusterManager) { - for (int i = 0; i < _markersToAddToClusterManagerCount; i++) { - final String markerIdVal = + for (var i = 0; i < _markersToAddToClusterManagerCount; i++) { + final markerIdVal = '${clusterManager.clusterManagerId.value}_marker_id_$_markerIdCounter'; _markerIdCounter++; - final MarkerId markerId = MarkerId(markerIdVal); + final markerId = MarkerId(markerIdVal); final int clusterManagerIndex = clusterManagers.values.toList().indexOf( clusterManager, @@ -170,7 +167,7 @@ class ClusteringBodyState extends State { final double clusterManagerLongitudeOffset = clusterManagerIndex * _clusterManagerLongitudeOffset; - final Marker marker = Marker( + final marker = Marker( clusterManagerId: clusterManager.clusterManagerId, markerId: markerId, position: LatLng( 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 6206787f3475..548146c6206c 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 @@ -9,9 +9,9 @@ import 'package:flutter/material.dart'; /// Returns a generated png image in [ByteData] format with the requested size. Future createCustomMarkerIconImage({required Size size}) async { - final ui.PictureRecorder recorder = ui.PictureRecorder(); - final Canvas canvas = Canvas(recorder); - final _MarkerPainter painter = _MarkerPainter(); + final recorder = ui.PictureRecorder(); + final canvas = Canvas(recorder); + final painter = _MarkerPainter(); painter.paint(canvas, size); @@ -30,7 +30,7 @@ class _MarkerPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { final Rect rect = Offset.zero & size; - const RadialGradient gradient = RadialGradient( + const gradient = RadialGradient( colors: [Colors.yellow, Colors.red], stops: [0.4, 1.0], ); 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 33f310de2b26..2f1937b04fbf 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 @@ -95,9 +95,7 @@ class GroundOverlayBodyState extends State { _groundOverlayIndex += 1; - final GroundOverlayId id = GroundOverlayId( - 'ground_overlay_$_groundOverlayIndex', - ); + final id = GroundOverlayId('ground_overlay_$_groundOverlayIndex'); final GroundOverlay groundOverlay = switch (_placingType) { _GroundOverlayPlacing.position => GroundOverlay.fromPosition( @@ -147,9 +145,7 @@ class GroundOverlayBodyState extends State { void _changeTransparency() { assert(_groundOverlay != null); setState(() { - final double transparency = _groundOverlay!.transparency == 0.0 - ? 0.5 - : 0.0; + final transparency = _groundOverlay!.transparency == 0.0 ? 0.5 : 0.0; _groundOverlay = _groundOverlay!.copyWith( transparencyParam: transparency, ); @@ -244,7 +240,7 @@ class GroundOverlayBodyState extends State { @override Widget build(BuildContext context) { - final Set overlays = { + final overlays = { if (_groundOverlay != null) _groundOverlay!, }; return Column( 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 b980e1d2a64b..f7b60568657c 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 @@ -98,13 +98,12 @@ Future initializeMapRenderer() async { return _initializedRendererCompleter!.future; } - final Completer completer = - Completer(); + final completer = Completer(); _initializedRendererCompleter = completer; WidgetsFlutterBinding.ensureInitialized(); - final GoogleMapsFlutterAndroid platform = + final platform = GoogleMapsFlutterPlatform.instance as GoogleMapsFlutterAndroid; unawaited( platform 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 a2cbca5c7e08..4d45e961d63e 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 @@ -41,7 +41,7 @@ class _MapClickBodyState extends State<_MapClickBody> { @override Widget build(BuildContext context) { - final ExampleGoogleMap googleMap = ExampleGoogleMap( + final googleMap = ExampleGoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, onTap: (LatLng pos) { @@ -56,7 +56,7 @@ class _MapClickBodyState extends State<_MapClickBody> { }, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( @@ -66,8 +66,8 @@ class _MapClickBodyState extends State<_MapClickBody> { ]; if (mapController != null) { - final String lastTap = 'Tap:\n${_lastTap ?? ""}\n'; - final String lastLongPress = 'Long press:\n${_lastLongPress ?? ""}'; + final lastTap = 'Tap:\n${_lastTap ?? ""}\n'; + final lastLongPress = 'Long press:\n${_lastLongPress ?? ""}'; columnChildren.add( Center(child: Text(lastTap, textAlign: TextAlign.center)), ); 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 eee22bb5d7db..5ec74b708a4b 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 @@ -43,7 +43,7 @@ class _MapCoordinatesBodyState extends State<_MapCoordinatesBody> { @override Widget build(BuildContext context) { - final ExampleGoogleMap googleMap = ExampleGoogleMap( + final googleMap = ExampleGoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, onCameraIdle: 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 fb33ce4ab9b2..2e98a88b80e4 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 @@ -74,7 +74,7 @@ class MapIdBodyState extends State { @override Widget build(BuildContext context) { - final ExampleGoogleMap googleMap = ExampleGoogleMap( + final googleMap = ExampleGoogleMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition( target: _kMapCenter, @@ -84,7 +84,7 @@ class MapIdBodyState extends State { mapId: _mapId, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( 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 3cad6f0f84e2..ce0d7d68378f 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 @@ -265,7 +265,7 @@ class MapUiBodyState extends State { @override Widget build(BuildContext context) { - final ExampleGoogleMap googleMap = ExampleGoogleMap( + final googleMap = ExampleGoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, compassEnabled: _compassEnabled, @@ -286,7 +286,7 @@ class MapUiBodyState extends State { onCameraMove: _updateCameraPosition, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( 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 40df30c94acd..2959c7c0dcf0 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 @@ -210,7 +210,7 @@ class MarkerIconsBodyState extends State { } Marker _createAssetMarker(int index) { - final LatLng position = LatLng( + final position = LatLng( _kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude - 1, ); @@ -223,7 +223,7 @@ class MarkerIconsBodyState extends State { } Marker _createBytesMarker(int index) { - final LatLng position = LatLng( + final position = LatLng( _kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude + 1, ); @@ -236,8 +236,8 @@ class MarkerIconsBodyState extends State { } void _updateMarkers() { - final Set markers = {}; - for (int i = 0; i < _markersAmountPerType; i++) { + final markers = {}; + for (var i = 0; i < _markersAmountPerType; i++) { if (_markerIconAsset != null) { markers.add(_createAssetMarker(i)); } @@ -299,7 +299,7 @@ class MarkerIconsBodyState extends State { final double? imagePixelRatio = _scalingEnabled ? devicePixelRatio : null; // Create canvasSize with physical marker size - final Size canvasSize = Size( + final canvasSize = Size( bitmapLogicalSize.width * (imagePixelRatio ?? 1.0), bitmapLogicalSize.height * (imagePixelRatio ?? 1.0), ); @@ -314,7 +314,7 @@ class MarkerIconsBodyState extends State { ? _getCurrentMarkerSize() : (null, null); - final BytesMapBitmap bitmap = BytesMapBitmap( + final bitmap = BytesMapBitmap( bytes.buffer.asUint8List(), imagePixelRatio: imagePixelRatio, width: width, 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 5154b88782b1..beb39b305f58 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 @@ -36,7 +36,7 @@ class MarkerIconsBodyState extends State { @override Widget build(BuildContext context) { - final ExampleGoogleMap googleMap = ExampleGoogleMap( + final googleMap = ExampleGoogleMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition( target: _kMapCenter, @@ -45,7 +45,7 @@ class MarkerIconsBodyState extends State { padding: _padding, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( 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 d45ec7e5c270..88c84c79e124 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 @@ -83,11 +83,11 @@ class PlaceCircleBodyState extends State { return; } - final String circleIdVal = 'circle_id_$_circleIdCounter'; + final circleIdVal = 'circle_id_$_circleIdCounter'; _circleIdCounter++; - final CircleId circleId = CircleId(circleIdVal); + final circleId = CircleId(circleIdVal); - final Circle circle = Circle( + final circle = Circle( circleId: circleId, consumeTapEvents: true, strokeColor: Colors.orange, 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 e32b7b277476..dd8d526d1436 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 @@ -123,11 +123,11 @@ class PlaceMarkerBodyState extends State { return; } - final String markerIdVal = 'marker_id_$_markerIdCounter'; + final markerIdVal = 'marker_id_$_markerIdCounter'; _markerIdCounter++; - final MarkerId markerId = MarkerId(markerIdVal); + final markerId = MarkerId(markerIdVal); - final Marker marker = Marker( + final marker = Marker( markerId: markerId, position: LatLng( center.latitude + sin(_markerIdCounter * pi / 6.0) / 20.0, @@ -155,7 +155,7 @@ class PlaceMarkerBodyState extends State { void _changePosition(MarkerId markerId) { final Marker marker = markers[markerId]!; final LatLng current = marker.position; - final Offset offset = Offset( + final offset = Offset( center.latitude - current.latitude, center.longitude - current.longitude, ); @@ -172,7 +172,7 @@ class PlaceMarkerBodyState extends State { void _changeAnchor(MarkerId markerId) { final Marker marker = markers[markerId]!; final Offset currentAnchor = marker.anchor; - final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); + final newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { markers[markerId] = marker.copyWith(anchorParam: newAnchor); }); @@ -181,7 +181,7 @@ class PlaceMarkerBodyState extends State { Future _changeInfoAnchor(MarkerId markerId) async { final Marker marker = markers[markerId]!; final Offset currentAnchor = marker.infoWindow.anchor; - final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); + final newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { markers[markerId] = marker.copyWith( infoWindowParam: marker.infoWindow.copyWith(anchorParam: newAnchor), @@ -205,7 +205,7 @@ class PlaceMarkerBodyState extends State { Future _changeInfo(MarkerId markerId) async { final Marker marker = markers[markerId]!; - final String newSnippet = '${marker.infoWindow.snippet!}*'; + final newSnippet = '${marker.infoWindow.snippet!}*'; setState(() { markers[markerId] = marker.copyWith( infoWindowParam: marker.infoWindow.copyWith(snippetParam: newSnippet), @@ -258,7 +258,7 @@ class PlaceMarkerBodyState extends State { } Future _getMarkerIcon(BuildContext context) async { - const Size canvasSize = Size(48, 48); + const canvasSize = Size(48, 48); final ByteData bytes = await createCustomMarkerIconImage(size: canvasSize); return BytesMapBitmap(bytes.buffer.asUint8List()); } 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 79475381c158..ff9eac82210c 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 @@ -82,10 +82,10 @@ class PlacePolygonBodyState extends State { return; } - final String polygonIdVal = 'polygon_id_$_polygonIdCounter'; - final PolygonId polygonId = PolygonId(polygonIdVal); + final polygonIdVal = 'polygon_id_$_polygonIdCounter'; + final polygonId = PolygonId(polygonIdVal); - final Polygon polygon = Polygon( + final polygon = Polygon( polygonId: polygonId, consumeTapEvents: true, strokeColor: Colors.orange, @@ -262,7 +262,7 @@ class PlacePolygonBodyState extends State { } List _createPoints() { - final List points = []; + final points = []; final double offset = _polygonIdCounter.ceilToDouble(); points.add(_createLatLng(51.2395 + offset, -3.4314)); points.add(_createLatLng(53.5234 + offset, -3.5314)); @@ -272,17 +272,17 @@ class PlacePolygonBodyState extends State { } List> _createHoles(PolygonId polygonId) { - final List> holes = >[]; + final holes = >[]; final double offset = polygonOffsets[polygonId]!; - final List hole1 = []; + final hole1 = []; hole1.add(_createLatLng(51.8395 + offset, -3.8814)); hole1.add(_createLatLng(52.0234 + offset, -3.9914)); hole1.add(_createLatLng(52.1351 + offset, -4.4435)); hole1.add(_createLatLng(52.0231 + offset, -4.5829)); holes.add(hole1); - final List hole2 = []; + final hole2 = []; hole2.add(_createLatLng(52.2395 + offset, -3.6814)); hole2.add(_createLatLng(52.4234 + offset, -3.7914)); hole2.add(_createLatLng(52.5351 + offset, -4.2435)); 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 854046b30535..f749cac5f268 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 @@ -110,11 +110,11 @@ class PlacePolylineBodyState extends State { return; } - final String polylineIdVal = 'polyline_id_$_polylineIdCounter'; + final polylineIdVal = 'polyline_id_$_polylineIdCounter'; _polylineIdCounter++; - final PolylineId polylineId = PolylineId(polylineIdVal); + final polylineId = PolylineId(polylineIdVal); - final Polyline polyline = Polyline( + final polyline = Polyline( polylineId: polylineId, consumeTapEvents: true, color: Colors.orange, @@ -307,7 +307,7 @@ class PlacePolylineBodyState extends State { } List _createPoints() { - final List points = []; + final points = []; final double offset = _polylineIdCounter.ceilToDouble(); points.add(_createLatLng(51.4816 + offset, -3.1791)); points.add(_createLatLng(53.0430 + offset, -2.9925)); 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 340ac4ce48de..bcce3b5f387b 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 @@ -53,7 +53,7 @@ class TileOverlayBodyState extends State { } void _addTileOverlay() { - final TileOverlay tileOverlay = TileOverlay( + final tileOverlay = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), ); @@ -70,9 +70,7 @@ class TileOverlayBodyState extends State { @override Widget build(BuildContext context) { - final Set overlays = { - if (_tileOverlay != null) _tileOverlay!, - }; + final overlays = {if (_tileOverlay != null) _tileOverlay!}; return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -124,10 +122,10 @@ class _DebugTileProvider implements TileProvider { @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 TextPainter textPainter = TextPainter( + final recorder = ui.PictureRecorder(); + final canvas = Canvas(recorder); + final textSpan = TextSpan(text: '$x,$y', style: textStyle); + final textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); 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 334dde79c772..261fc473e8bb 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 @@ -40,10 +40,10 @@ void main() { testWidgets('circle updates with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - const Circle c1 = Circle(circleId: CircleId('circle_1')); - const Circle c2 = Circle(circleId: CircleId('circle_2')); - const Circle c3 = Circle(circleId: CircleId('circle_3'), radius: 1); - const Circle c3updated = Circle(circleId: CircleId('circle_3'), radius: 10); + const c1 = Circle(circleId: CircleId('circle_1')); + const c2 = Circle(circleId: CircleId('circle_2')); + const c3 = Circle(circleId: CircleId('circle_3'), radius: 1); + const c3updated = Circle(circleId: CircleId('circle_3'), radius: 10); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithObjects(circles: {c1, c2})); @@ -72,13 +72,10 @@ void main() { testWidgets('marker updates with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - 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 m1 = Marker(markerId: MarkerId('marker_1')); + const m2 = Marker(markerId: MarkerId('marker_2')); + const m3 = Marker(markerId: MarkerId('marker_3')); + const 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,13 +104,10 @@ void main() { testWidgets('polygon updates with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - 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( + const p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p2 = Polygon(polygonId: PolygonId('polygon_2')); + const p3 = Polygon(polygonId: PolygonId('polygon_3'), strokeWidth: 1); + const p3updated = Polygon( polygonId: PolygonId('polygon_3'), strokeWidth: 2, ); @@ -147,16 +141,10 @@ void main() { testWidgets('polyline updates with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - 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 p1 = Polyline(polylineId: PolylineId('polyline_1')); + const p2 = Polyline(polylineId: PolylineId('polyline_2')); + const p3 = Polyline(polylineId: PolylineId('polyline_3'), width: 1); + const 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})); 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 ef0b0aeb351e..0c09c6d789eb 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 @@ -101,7 +101,7 @@ class GoogleMapsInspectorAndroid extends GoogleMapsInspectorPlatform { } // Create dummy image to represent the image of the ground overlay. - final BytesMapBitmap dummyImage = BytesMapBitmap( + final dummyImage = BytesMapBitmap( Uint8List.fromList([0]), bitmapScaling: MapBitmapScaling.none, ); 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 7996c8c7967f..5d77d736f461 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 @@ -329,10 +329,7 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { final Set previousSet = currentTileOverlays != null ? currentTileOverlays.values.toSet() : {}; - final _TileOverlayUpdates updates = _TileOverlayUpdates.from( - previousSet, - newTileOverlays, - ); + final updates = _TileOverlayUpdates.from(previousSet, newTileOverlays); _tileOverlays[mapId] = keyTileOverlayId(newTileOverlays); return _hostApi(mapId).updateTileOverlays( updates.tileOverlaysToAdd @@ -562,39 +559,38 @@ class GoogleMapsFlutterAndroid extends GoogleMapsFlutterPlatform { '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(), - ); + final 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(), + ); - const String viewType = 'plugins.flutter.dev/google_maps_android'; + const viewType = 'plugins.flutter.dev/google_maps_android'; if (useAndroidViewSurface) { return PlatformViewLink( viewType: viewType, @@ -1383,7 +1379,7 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( // to support this legacy API that relied on cross-package magic strings. final List? padding = (options['padding'] as List?) ?.cast(); - final int? mapType = options['mapType'] as int?; + final mapType = options['mapType'] as int?; return PlatformMapConfiguration( compassEnabled: options['compassEnabled'] as bool?, cameraTargetBounds: _platformCameraTargetBoundsFromCameraTargetBoundsJson( 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 4e744a9af532..5dbd8315b2ff 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 @@ -24,7 +24,7 @@ void _addIfNonNull(Map map, String fieldName, Object? value) { /// Serialize [Heatmap] Map serializeHeatmap(Heatmap heatmap) { - final Map json = {}; + final json = {}; _addIfNonNull(json, _heatmapIdKey, heatmap.heatmapId.value); _addIfNonNull( @@ -59,7 +59,7 @@ WeightedLatLng? deserializeWeightedLatLng(Object? json) { return null; } assert(json is List && json.length == 2); - final List list = json as List; + final list = json as List; final LatLng latLng = deserializeLatLng(list[0])!; return WeightedLatLng(latLng, weight: list[1] as double); } @@ -75,13 +75,13 @@ LatLng? deserializeLatLng(Object? json) { return null; } assert(json is List && json.length == 2); - final List list = json as List; + final list = json as List; return LatLng(list[0]! as double, list[1]! as double); } /// Serialize [HeatmapGradient] Object serializeHeatmapGradient(HeatmapGradient gradient) { - final Map json = {}; + final json = {}; _addIfNonNull( json, @@ -115,8 +115,8 @@ HeatmapGradient? deserializeHeatmapGradient(Object? json) { (map[_heatmapGradientStartPointsKey]! as List) .whereType() .toList(); - final List gradientColors = []; - for (int i = 0; i < colors.length; i++) { + final gradientColors = []; + for (var i = 0; i < colors.length; i++) { gradientColors.add(HeatmapGradientColor(colors[i], startPoints[i])); } return HeatmapGradient( 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 55d1ba2eec1f..403adf3df6c6 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 @@ -23,10 +23,8 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); (GoogleMapsFlutterAndroid, MockMapsApi) setUpMockMap({required int mapId}) { - final MockMapsApi api = MockMapsApi(); - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( - apiProvider: (_) => api, - ); + final api = MockMapsApi(); + final maps = GoogleMapsFlutterAndroid(apiProvider: (_) => api); maps.ensureApiInitialized(mapId); return (maps, api); } @@ -37,13 +35,13 @@ void main() { }); test('normal usage does not call MapsInitializerApi', () async { - final MockMapsApi api = MockMapsApi(); - final MockMapsInitializerApi initializerApi = MockMapsInitializerApi(); - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( + final api = MockMapsApi(); + final initializerApi = MockMapsInitializerApi(); + final maps = GoogleMapsFlutterAndroid( apiProvider: (_) => api, initializerApi: initializerApi, ); - const int mapId = 1; + const mapId = 1; maps.ensureApiInitialized(mapId); await maps.init(1); @@ -53,9 +51,9 @@ void main() { test( 'initializeWithPreferredRenderer forwards the initialization call', () async { - final MockMapsApi api = MockMapsApi(); - final MockMapsInitializerApi initializerApi = MockMapsInitializerApi(); - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( + final api = MockMapsApi(); + final initializerApi = MockMapsInitializerApi(); + final maps = GoogleMapsFlutterAndroid( apiProvider: (_) => api, initializerApi: initializerApi, ); @@ -70,9 +68,9 @@ void main() { ); test('warmup forwards the initialization call', () async { - final MockMapsApi api = MockMapsApi(); - final MockMapsInitializerApi initializerApi = MockMapsInitializerApi(); - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( + final api = MockMapsApi(); + final initializerApi = MockMapsInitializerApi(); + final maps = GoogleMapsFlutterAndroid( apiProvider: (_) => api, initializerApi: initializerApi, ); @@ -82,10 +80,8 @@ void main() { }); test('init calls waitForMap', () async { - final MockMapsApi api = MockMapsApi(); - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid( - apiProvider: (_) => api, - ); + final api = MockMapsApi(); + final maps = GoogleMapsFlutterAndroid(apiProvider: (_) => api); await maps.init(1); @@ -93,14 +89,14 @@ void main() { }); test('getScreenCoordinate converts and passes values correctly', () async { - const int mapId = 1; + const mapId = 1; 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); + const latLng = LatLng(10, 20); + const expectedCoord = ScreenCoordinate(x: 30, y: 40); when(api.getScreenCoordinate(any)).thenAnswer( (_) async => PlatformPoint(x: expectedCoord.x, y: expectedCoord.y), ); @@ -113,21 +109,20 @@ void main() { final VerificationResult verification = verify( api.getScreenCoordinate(captureAny), ); - final PlatformLatLng passedLatLng = - verification.captured[0] as PlatformLatLng; + final passedLatLng = verification.captured[0] as PlatformLatLng; expect(passedLatLng.latitude, latLng.latitude); expect(passedLatLng.longitude, latLng.longitude); }); test('getLatLng converts and passes values correctly', () async { - const int mapId = 1; + const mapId = 1; 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); + const expectedLatLng = LatLng(10, 20); + const coord = ScreenCoordinate(x: 30, y: 40); when(api.getLatLng(any)).thenAnswer( (_) async => PlatformLatLng( latitude: expectedLatLng.latitude, @@ -138,19 +133,19 @@ void main() { final LatLng latLng = await maps.getLatLng(coord, mapId: mapId); expect(latLng, expectedLatLng); final VerificationResult verification = verify(api.getLatLng(captureAny)); - final PlatformPoint passedCoord = verification.captured[0] as PlatformPoint; + final passedCoord = verification.captured[0] as PlatformPoint; expect(passedCoord.x, coord.x); expect(passedCoord.y, coord.y); }); test('getVisibleRegion converts and passes values correctly', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); // Arbitrary values that are all different from each other. - final LatLngBounds expectedBounds = LatLngBounds( + final expectedBounds = LatLngBounds( southwest: const LatLng(10, 20), northeast: const LatLng(30, 40), ); @@ -172,7 +167,7 @@ void main() { }); test('moveCamera calls through with expected scrollBy', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); @@ -181,17 +176,15 @@ void main() { await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateScrollBy scroll = - passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final scroll = passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; update as CameraUpdateScrollBy; expect(scroll.dx, update.dx); expect(scroll.dy, update.dy); }); test('animateCamera calls through with expected scrollBy', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); @@ -202,26 +195,25 @@ void main() { final VerificationResult verification = verify( api.animateCamera(captureAny, captureAny), ); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateScrollBy scroll = - passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final scroll = passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; update as CameraUpdateScrollBy; expect(scroll.dx, update.dx); expect(scroll.dy, update.dy); - final int? passedDuration = verification.captured[1] as int?; + final passedDuration = verification.captured[1] as int?; expect(passedDuration, isNull); }); test('animateCameraWithConfiguration calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); final CameraUpdate update = CameraUpdate.scrollBy(10, 20); - const CameraUpdateAnimationConfiguration configuration = - CameraUpdateAnimationConfiguration(duration: Duration(seconds: 1)); + const configuration = CameraUpdateAnimationConfiguration( + duration: Duration(seconds: 1), + ); expect(configuration.duration?.inSeconds, 1); await maps.animateCameraWithConfiguration( update, @@ -232,25 +224,23 @@ void main() { final VerificationResult verification = verify( api.animateCamera(captureAny, captureAny), ); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateScrollBy scroll = - passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final scroll = passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; update as CameraUpdateScrollBy; expect(scroll.dx, update.dx); expect(scroll.dy, update.dy); - final int? passedDuration = verification.captured[1] as int?; + final passedDuration = verification.captured[1] as int?; expect(passedDuration, configuration.duration?.inMilliseconds); }); test('getZoomLevel passes values correctly', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const double expectedZoom = 4.2; + const expectedZoom = 4.2; when(api.getZoomLevel()).thenAnswer((_) async => expectedZoom); final double zoom = await maps.getZoomLevel(mapId: mapId); @@ -258,36 +248,36 @@ void main() { }); test('showInfoWindow calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const String markedId = 'a_marker'; + const markedId = 'a_marker'; await maps.showMarkerInfoWindow(const MarkerId(markedId), mapId: mapId); verify(api.showInfoWindow(markedId)); }); test('hideInfoWindow calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const String markedId = 'a_marker'; + const markedId = 'a_marker'; await maps.hideMarkerInfoWindow(const MarkerId(markedId), mapId: mapId); verify(api.hideInfoWindow(markedId)); }); test('isInfoWindowShown calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const String markedId = 'a_marker'; + const markedId = 'a_marker'; when(api.isInfoWindowShown(markedId)).thenAnswer((_) async => true); expect( @@ -300,43 +290,43 @@ void main() { }); test('takeSnapshot calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - final Uint8List fakeSnapshot = Uint8List(10); + final fakeSnapshot = Uint8List(10); when(api.takeSnapshot()).thenAnswer((_) async => fakeSnapshot); expect(await maps.takeSnapshot(mapId: mapId), fakeSnapshot); }); test('clearTileCache calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const String tileOverlayId = 'overlay'; + const tileOverlayId = 'overlay'; await maps.clearTileCache(const TileOverlayId(tileOverlayId), mapId: mapId); verify(api.clearTileCache(tileOverlayId)); }); test('updateMapConfiguration passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); // Set some arbitrary options. - final CameraTargetBounds cameraBounds = CameraTargetBounds( + final cameraBounds = CameraTargetBounds( LatLngBounds( southwest: const LatLng(10, 20), northeast: const LatLng(30, 40), ), ); - final MapConfiguration config = MapConfiguration( + final config = MapConfiguration( compassEnabled: true, mapType: MapType.terrain, cameraTargetBounds: cameraBounds, @@ -346,8 +336,7 @@ void main() { final VerificationResult verification = verify( api.updateMapConfiguration(captureAny), ); - final PlatformMapConfiguration passedConfig = - verification.captured[0] as PlatformMapConfiguration; + final passedConfig = verification.captured[0] as PlatformMapConfiguration; // Each set option should be present. expect(passedConfig.compassEnabled, true); expect(passedConfig.mapType, PlatformMapType.terrain); @@ -374,19 +363,19 @@ void main() { }); test('updateMapOptions passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); // Set some arbitrary options. - final CameraTargetBounds cameraBounds = CameraTargetBounds( + final cameraBounds = CameraTargetBounds( LatLngBounds( southwest: const LatLng(10, 20), northeast: const LatLng(30, 40), ), ); - final Map config = { + final config = { 'compassEnabled': true, 'mapType': MapType.terrain.index, 'cameraTargetBounds': cameraBounds.toJson(), @@ -396,8 +385,7 @@ void main() { final VerificationResult verification = verify( api.updateMapConfiguration(captureAny), ); - final PlatformMapConfiguration passedConfig = - verification.captured[0] as PlatformMapConfiguration; + final passedConfig = verification.captured[0] as PlatformMapConfiguration; // Each set option should be present. expect(passedConfig.compassEnabled, true); expect(passedConfig.mapType, PlatformMapType.terrain); @@ -424,15 +412,15 @@ void main() { }); test('updateCircles passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const Circle object1 = Circle(circleId: CircleId('1')); - const Circle object2old = Circle(circleId: CircleId('2')); + const object1 = Circle(circleId: CircleId('1')); + const object2old = Circle(circleId: CircleId('2')); final Circle object2new = object2old.copyWith(radiusParam: 42); - const Circle object3 = Circle(circleId: CircleId('3')); + const object3 = Circle(circleId: CircleId('3')); await maps.updateCircles( CircleUpdates.from( {object1, object2old}, @@ -444,11 +432,9 @@ void main() { final VerificationResult verification = verify( api.updateCircles(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.circleId.value); @@ -488,17 +474,13 @@ void main() { }); test('updateClusterManagers passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const ClusterManager object1 = ClusterManager( - clusterManagerId: ClusterManagerId('1'), - ); - const ClusterManager object3 = ClusterManager( - clusterManagerId: ClusterManagerId('3'), - ); + const object1 = ClusterManager(clusterManagerId: ClusterManagerId('1')); + const object3 = ClusterManager(clusterManagerId: ClusterManagerId('3')); await maps.updateClusterManagers( ClusterManagerUpdates.from( {object1}, @@ -510,9 +492,8 @@ void main() { final VerificationResult verification = verify( api.updateClusterManagers(captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toRemove = verification.captured[1] as List; + final toAdd = verification.captured[0] as List; + final toRemove = verification.captured[1] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.clusterManagerId.value); @@ -524,15 +505,15 @@ void main() { }); test('updateMarkers passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const Marker object1 = Marker(markerId: MarkerId('1')); - const Marker object2old = Marker(markerId: MarkerId('2')); + const object1 = Marker(markerId: MarkerId('1')); + const object2old = Marker(markerId: MarkerId('2')); final Marker object2new = object2old.copyWith(rotationParam: 42); - const Marker object3 = Marker(markerId: MarkerId('3')); + const object3 = Marker(markerId: MarkerId('3')); await maps.updateMarkers( MarkerUpdates.from( {object1, object2old}, @@ -544,11 +525,9 @@ void main() { final VerificationResult verification = verify( api.updateMarkers(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.markerId.value); @@ -613,15 +592,15 @@ void main() { }); test('updatePolygons passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const Polygon object1 = Polygon(polygonId: PolygonId('1')); - const Polygon object2old = Polygon(polygonId: PolygonId('2')); + const object1 = Polygon(polygonId: PolygonId('1')); + const object2old = Polygon(polygonId: PolygonId('2')); final Polygon object2new = object2old.copyWith(strokeWidthParam: 42); - const Polygon object3 = Polygon(polygonId: PolygonId('3')); + const object3 = Polygon(polygonId: PolygonId('3')); await maps.updatePolygons( PolygonUpdates.from( {object1, object2old}, @@ -633,11 +612,9 @@ void main() { final VerificationResult verification = verify( api.updatePolygons(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.polygonId.value); @@ -674,13 +651,13 @@ void main() { }); test('updatePolylines passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const Polyline object1 = Polyline(polylineId: PolylineId('1')); - const Polyline object2old = Polyline(polylineId: PolylineId('2')); + const object1 = Polyline(polylineId: PolylineId('1')); + const object2old = Polyline(polylineId: PolylineId('2')); final Polyline object2new = object2old.copyWith( widthParam: 42, startCapParam: Cap.squareCap, @@ -690,7 +667,7 @@ void main() { BitmapDescriptor.defaultMarker, refWidth: 15, ); - final Polyline object3 = Polyline( + final object3 = Polyline( polylineId: const PolylineId('3'), startCap: customCap, endCap: Cap.roundCap, @@ -706,11 +683,9 @@ void main() { final VerificationResult verification = verify( api.updatePolylines(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; void expectPolyline(PlatformPolyline actual, Polyline expected) { expect(actual.polylineId, expected.polylineId.value); expect(actual.consumesTapEvents, expected.consumeTapEvents); @@ -766,17 +741,15 @@ void main() { }); test('updateTileOverlays passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const TileOverlay object1 = TileOverlay(tileOverlayId: TileOverlayId('1')); - const TileOverlay object2old = TileOverlay( - tileOverlayId: TileOverlayId('2'), - ); + const object1 = TileOverlay(tileOverlayId: TileOverlayId('1')); + const object2old = TileOverlay(tileOverlayId: TileOverlayId('2')); final TileOverlay object2new = object2old.copyWith(zIndexParam: 42); - const TileOverlay object3 = TileOverlay(tileOverlayId: TileOverlayId('3')); + const object3 = TileOverlay(tileOverlayId: TileOverlayId('3')); // Pre-set the initial state, since this update method doesn't take the old // state. await maps.updateTileOverlays( @@ -793,11 +766,9 @@ void main() { final VerificationResult verification = verify( api.updateTileOverlays(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; void expectTileOverlay(PlatformTileOverlay actual, TileOverlay expected) { expect(actual.tileOverlayId, expected.tileOverlayId.value); expect(actual.fadeIn, expected.fadeIn); @@ -819,18 +790,18 @@ void main() { }); test('updateGroundOverlays passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - final AssetMapBitmap image = AssetMapBitmap( + final image = AssetMapBitmap( 'assets/red_square.png', imagePixelRatio: 1.0, bitmapScaling: MapBitmapScaling.none, ); - final GroundOverlay object1 = GroundOverlay.fromBounds( + final object1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('1'), bounds: LatLngBounds( southwest: const LatLng(10, 20), @@ -838,7 +809,7 @@ void main() { ), image: image, ); - final GroundOverlay object2old = GroundOverlay.fromBounds( + final object2old = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('2'), bounds: LatLngBounds( southwest: const LatLng(10, 20), @@ -853,7 +824,7 @@ void main() { transparencyParam: 0.5, zIndexParam: 100, ); - final GroundOverlay object3 = GroundOverlay.fromPosition( + final object3 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('3'), position: const LatLng(10, 20), width: 100, @@ -871,11 +842,9 @@ void main() { api.updateGroundOverlays(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.groundOverlayId.value); @@ -960,18 +929,18 @@ void main() { test( 'updateGroundOverlays throws assertion error on unsupported ground overlays', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - final AssetMapBitmap image = AssetMapBitmap( + final image = AssetMapBitmap( 'assets/red_square.png', imagePixelRatio: 1.0, bitmapScaling: MapBitmapScaling.none, ); - final GroundOverlay groundOverlay = GroundOverlay.fromPosition( + final groundOverlay = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('1'), position: const LatLng(10, 20), // Assert should be thrown because width is not set for position-based @@ -1009,26 +978,26 @@ void main() { ); 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, - ); + const mapId = 1; + const dragStartId = 'drag-start-marker'; + const dragId = 'drag-marker'; + const dragEndId = 'drag-end-marker'; + final fakePosition = PlatformLatLng(latitude: 1.0, longitude: 1.0); - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue markerDragStartStream = - StreamQueue(maps.onMarkerDragStart(mapId: mapId)); - final StreamQueue markerDragStream = - StreamQueue(maps.onMarkerDrag(mapId: mapId)); - final StreamQueue markerDragEndStream = - StreamQueue(maps.onMarkerDragEnd(mapId: mapId)); + final markerDragStartStream = StreamQueue( + maps.onMarkerDragStart(mapId: mapId), + ); + final markerDragStream = StreamQueue( + maps.onMarkerDrag(mapId: mapId), + ); + final markerDragEndStream = StreamQueue( + maps.onMarkerDragEnd(mapId: mapId), + ); // Simulate messages from the native side. callbackHandler.onMarkerDragStart(dragStartId, fakePosition); @@ -1041,17 +1010,15 @@ void main() { }); test('markers send tap events to correct stream', () async { - const int mapId = 1; - const String objectId = 'object-id'; + const mapId = 1; + const objectId = 'object-id'; - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = StreamQueue( - maps.onMarkerTap(mapId: mapId), - ); + final stream = StreamQueue(maps.onMarkerTap(mapId: mapId)); // Simulate message from the native side. callbackHandler.onMarkerTap(objectId); @@ -1060,17 +1027,15 @@ void main() { }); test('circles send tap events to correct stream', () async { - const int mapId = 1; - const String objectId = 'object-id'; + const mapId = 1; + const objectId = 'object-id'; - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = StreamQueue( - maps.onCircleTap(mapId: mapId), - ); + final stream = StreamQueue(maps.onCircleTap(mapId: mapId)); // Simulate message from the native side. callbackHandler.onCircleTap(objectId); @@ -1079,30 +1044,27 @@ 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 PlatformLatLngBounds fakeBounds = PlatformLatLngBounds( + const mapId = 1; + const managerId = 'manager-id'; + final fakePosition = PlatformLatLng(latitude: 10, longitude: 20); + final fakeBounds = PlatformLatLngBounds( southwest: PlatformLatLng(latitude: 30, longitude: 40), northeast: PlatformLatLng(latitude: 50, longitude: 60), ); - const List markerIds = ['marker-1', 'marker-2']; - final PlatformCluster cluster = PlatformCluster( + const markerIds = ['marker-1', 'marker-2']; + final cluster = PlatformCluster( clusterManagerId: managerId, position: fakePosition, bounds: fakeBounds, markerIds: markerIds, ); - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = StreamQueue( + final stream = StreamQueue( maps.onClusterTap(mapId: mapId), ); @@ -1128,15 +1090,15 @@ void main() { }); test('polygons send tap events to correct stream', () async { - const int mapId = 1; - const String objectId = 'object-id'; + const mapId = 1; + const objectId = 'object-id'; - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = StreamQueue( + final stream = StreamQueue( maps.onPolygonTap(mapId: mapId), ); @@ -1147,15 +1109,15 @@ void main() { }); test('polylines send tap events to correct stream', () async { - const int mapId = 1; - const String objectId = 'object-id'; + const mapId = 1; + const objectId = 'object-id'; - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = StreamQueue( + final stream = StreamQueue( maps.onPolylineTap(mapId: mapId), ); @@ -1166,18 +1128,17 @@ void main() { }); test('ground overlays send tap events to correct stream', () async { - const int mapId = 1; - const String objectId = 'object-id'; + const mapId = 1; + const objectId = 'object-id'; - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = - StreamQueue( - maps.onGroundOverlayTap(mapId: mapId), - ); + final stream = StreamQueue( + maps.onGroundOverlayTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onGroundOverlayTap(objectId); @@ -1186,7 +1147,7 @@ void main() { }); test('Does not use PlatformViewLink when using TLHC', () async { - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); maps.useAndroidViewSurface = false; final Widget widget = maps.buildViewWithConfiguration( 1, @@ -1201,20 +1162,19 @@ void main() { }); test('moveCamera calls through with expected newCameraPosition', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const LatLng latLng = LatLng(10.0, 20.0); - const CameraPosition position = CameraPosition(target: latLng); + const latLng = LatLng(10.0, 20.0); + const position = CameraPosition(target: latLng); final CameraUpdate update = CameraUpdate.newCameraPosition(position); await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateNewCameraPosition typedUpdate = + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewCameraPosition; update as CameraUpdateNewCameraPosition; expect( @@ -1228,19 +1188,18 @@ void main() { }); test('moveCamera calls through with expected newLatLng', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const LatLng latLng = LatLng(10.0, 20.0); + const latLng = LatLng(10.0, 20.0); final CameraUpdate update = CameraUpdate.newLatLng(latLng); await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateNewLatLng typedUpdate = + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLng; update as CameraUpdateNewLatLng; expect(typedUpdate.latLng.latitude, update.latLng.latitude); @@ -1248,12 +1207,12 @@ void main() { }); test('moveCamera calls through with expected newLatLngBounds', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - final LatLngBounds latLng = LatLngBounds( + final latLng = LatLngBounds( northeast: const LatLng(10.0, 20.0), southwest: const LatLng(9.0, 21.0), ); @@ -1261,9 +1220,8 @@ void main() { await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateNewLatLngBounds typedUpdate = + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLngBounds; update as CameraUpdateNewLatLngBounds; expect( @@ -1286,19 +1244,18 @@ void main() { }); test('moveCamera calls through with expected newLatLngZoom', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const LatLng latLng = LatLng(10.0, 20.0); + const latLng = LatLng(10.0, 20.0); final CameraUpdate update = CameraUpdate.newLatLngZoom(latLng, 2.0); await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateNewLatLngZoom typedUpdate = + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLngZoom; update as CameraUpdateNewLatLngZoom; expect(typedUpdate.latLng.latitude, update.latLng.latitude); @@ -1307,20 +1264,18 @@ void main() { }); test('moveCamera calls through with expected zoomBy', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const Offset focus = Offset(10.0, 20.0); + const focus = Offset(10.0, 20.0); final CameraUpdate update = CameraUpdate.zoomBy(2.0, focus); await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateZoomBy typedUpdate = - passedUpdate.cameraUpdate as PlatformCameraUpdateZoomBy; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateZoomBy; update as CameraUpdateZoomBy; expect(typedUpdate.focus?.x, update.focus?.dx); expect(typedUpdate.focus?.y, update.focus?.dy); @@ -1328,7 +1283,7 @@ void main() { }); test('moveCamera calls through with expected zoomTo', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); @@ -1337,16 +1292,14 @@ void main() { await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateZoomTo typedUpdate = - passedUpdate.cameraUpdate as PlatformCameraUpdateZoomTo; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateZoomTo; update as CameraUpdateZoomTo; expect(typedUpdate.zoom, update.zoom); }); test('moveCamera calls through with expected zoomIn', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); @@ -1355,15 +1308,13 @@ void main() { await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateZoom typedUpdate = - passedUpdate.cameraUpdate as PlatformCameraUpdateZoom; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateZoom; expect(typedUpdate.out, false); }); test('moveCamera calls through with expected zoomOut', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterAndroid maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); @@ -1372,10 +1323,8 @@ void main() { await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateZoom typedUpdate = - passedUpdate.cameraUpdate as PlatformCameraUpdateZoom; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateZoom; expect(typedUpdate.out, true); }); @@ -1399,13 +1348,12 @@ void main() { final PlatformBitmap platformBitmap = GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor(bitmap); expect(platformBitmap.bitmap, isA()); - final PlatformBitmapDefaultMarker typedBitmap = - platformBitmap.bitmap as PlatformBitmapDefaultMarker; + final typedBitmap = platformBitmap.bitmap as PlatformBitmapDefaultMarker; expect(typedBitmap.hue, 10.0); }); test('BytesMapBitmap bitmap to PlatformBitmap', () { - final Uint8List data = Uint8List.fromList([1, 2, 3, 4]); + final data = Uint8List.fromList([1, 2, 3, 4]); final BytesMapBitmap bitmap = BitmapDescriptor.bytes( data, imagePixelRatio: 2.0, @@ -1415,8 +1363,7 @@ void main() { final PlatformBitmap platformBitmap = GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor(bitmap); expect(platformBitmap.bitmap, isA()); - final PlatformBitmapBytesMap typedBitmap = - platformBitmap.bitmap as PlatformBitmapBytesMap; + final typedBitmap = platformBitmap.bitmap as PlatformBitmapBytesMap; expect(typedBitmap.byteData, data); expect(typedBitmap.bitmapScaling, PlatformMapBitmapScaling.auto); expect(typedBitmap.imagePixelRatio, 2.0); @@ -1425,8 +1372,8 @@ void main() { }); test('AssetMapBitmap bitmap to PlatformBitmap', () { - const String assetName = 'fake_asset_name'; - final AssetMapBitmap bitmap = AssetMapBitmap( + const assetName = 'fake_asset_name'; + final bitmap = AssetMapBitmap( assetName, imagePixelRatio: 2.0, width: 100.0, @@ -1435,8 +1382,7 @@ void main() { final PlatformBitmap platformBitmap = GoogleMapsFlutterAndroid.platformBitmapFromBitmapDescriptor(bitmap); expect(platformBitmap.bitmap, isA()); - final PlatformBitmapAssetMap typedBitmap = - platformBitmap.bitmap as PlatformBitmapAssetMap; + final typedBitmap = platformBitmap.bitmap as PlatformBitmapAssetMap; expect(typedBitmap.assetName, assetName); expect(typedBitmap.bitmapScaling, PlatformMapBitmapScaling.auto); expect(typedBitmap.imagePixelRatio, 2.0); @@ -1459,7 +1405,7 @@ void main() { ); const BitmapDescriptor bitmap = BitmapDescriptor.defaultMarker; - const CustomCap customCap = CustomCap(bitmap, refWidth: 15.0); + const customCap = CustomCap(bitmap, refWidth: 15.0); final PlatformCap platformCap = GoogleMapsFlutterAndroid.platformCapFromCap( customCap, ); @@ -1470,7 +1416,7 @@ void main() { testWidgets('Use PlatformViewLink when using surface view', ( WidgetTester tester, ) async { - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); maps.useAndroidViewSurface = true; final Widget widget = maps.buildViewWithConfiguration( @@ -1486,7 +1432,7 @@ void main() { }); testWidgets('Defaults to AndroidView', (WidgetTester tester) async { - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); final Widget widget = maps.buildViewWithConfiguration( 1, @@ -1501,21 +1447,21 @@ void main() { }); testWidgets('mapId is passed', (WidgetTester tester) async { - const String cloudMapId = '000000000000000'; // Dummy map ID. - final Completer passedMapIdCompleter = Completer(); + const cloudMapId = '000000000000000'; // Dummy map ID. + final passedMapIdCompleter = Completer(); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler(SystemChannels.platform_views, ( MethodCall methodCall, ) async { if (methodCall.method == 'create') { - final Map args = Map.from( + final 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 = + final paramsUint8List = args['params'] as Uint8List; + final byteData = ByteData.sublistView(paramsUint8List); + final creationParams = MapsApi.pigeonChannelCodec.decodeMessage(byteData) as PlatformMapViewCreationParams?; if (creationParams != null) { @@ -1530,7 +1476,7 @@ void main() { return 0; }); - final GoogleMapsFlutterAndroid maps = GoogleMapsFlutterAndroid(); + final maps = GoogleMapsFlutterAndroid(); await tester.pumpWidget( maps.buildViewWithConfiguration( 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 46c0442b9677..cc7439f22170 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 @@ -50,7 +50,7 @@ void main() { testWidgets('testCompassToggle', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -90,7 +90,7 @@ void main() { testWidgets('testMapToolbar returns false', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -117,11 +117,10 @@ void main() { testWidgets('updateMinMaxZoomLevels', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); - const MinMaxZoomPreference initialZoomLevel = MinMaxZoomPreference(4, 8); - const MinMaxZoomPreference finalZoomLevel = MinMaxZoomPreference(6, 10); + const initialZoomLevel = MinMaxZoomPreference(4, 8); + const finalZoomLevel = MinMaxZoomPreference(6, 10); await tester.pumpWidget( Directionality( @@ -167,7 +166,7 @@ void main() { testWidgets('testZoomGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -210,7 +209,7 @@ void main() { testWidgets('testZoomControlsEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -238,7 +237,7 @@ void main() { testWidgets('testRotateGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -283,7 +282,7 @@ void main() { testWidgets('testTiltGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -326,7 +325,7 @@ void main() { testWidgets('testScrollGesturesEnabled', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -374,8 +373,7 @@ void main() { (WidgetTester tester) async { await tester.binding.setSurfaceSize(const Size(800, 600)); - final Completer mapControllerCompleter = - Completer(); + final mapControllerCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( Directionality( @@ -415,13 +413,12 @@ void main() { 'testGetVisibleRegion', (WidgetTester tester) async { final Key key = GlobalKey(); - final LatLngBounds zeroLatLngBounds = LatLngBounds( + final zeroLatLngBounds = LatLngBounds( southwest: const LatLng(0, 0), northeast: const LatLng(0, 0), ); - final Completer mapControllerCompleter = - Completer(); + final mapControllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -451,15 +448,15 @@ void main() { // 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( + final southWest = LatLng( firstVisibleRegion.southwest.latitude - 20, firstVisibleRegion.southwest.longitude - 20, ); - final LatLng northEast = LatLng( + final northEast = LatLng( firstVisibleRegion.southwest.latitude - 10, firstVisibleRegion.southwest.longitude - 10, ); - final LatLng newCenter = LatLng( + final newCenter = LatLng( (northEast.latitude + southWest.latitude) / 2, (northEast.longitude + southWest.longitude) / 2, ); @@ -467,7 +464,7 @@ void main() { expect(firstVisibleRegion.contains(northEast), isFalse); expect(firstVisibleRegion.contains(southWest), isFalse); - final LatLngBounds latLngBounds = LatLngBounds( + final latLngBounds = LatLngBounds( southwest: southWest, northeast: northEast, ); @@ -497,7 +494,7 @@ void main() { testWidgets('testTraffic', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -538,7 +535,7 @@ void main() { testWidgets('testBuildings', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -564,7 +561,7 @@ void main() { testWidgets('testMyLocationButtonToggle', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -611,7 +608,7 @@ void main() { WidgetTester tester, ) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -639,7 +636,7 @@ void main() { WidgetTester tester, ) async { final Key key = GlobalKey(); - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -664,8 +661,7 @@ void main() { testWidgets('testSetMapStyle valid Json String', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -682,7 +678,7 @@ void main() { final ExampleGoogleMapController controller = await controllerCompleter.future; - const String mapStyle = + const mapStyle = '[{"elementType":"geometry","stylers":[{"color":"#242f3e"}]}]'; await GoogleMapsFlutterPlatform.instance.setMapStyle( mapStyle, @@ -694,8 +690,7 @@ void main() { WidgetTester tester, ) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -727,8 +722,7 @@ void main() { testWidgets('testSetMapStyle null string', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -753,8 +747,7 @@ void main() { testWidgets('testGetLatLng', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -782,7 +775,7 @@ void main() { final LatLng topLeft = await controller.getLatLng( const ScreenCoordinate(x: 0, y: 0), ); - final LatLng northWest = LatLng( + final northWest = LatLng( visibleRegion.northeast.latitude, visibleRegion.southwest.longitude, ); @@ -794,8 +787,7 @@ void main() { 'testGetZoomLevel', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -835,8 +827,7 @@ void main() { 'testScreenCoordinate', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -860,7 +851,7 @@ void main() { await Future.delayed(const Duration(seconds: 1)); final LatLngBounds visibleRegion = await controller.getVisibleRegion(); - final LatLng northWest = LatLng( + final northWest = LatLng( visibleRegion.northeast.latitude, visibleRegion.southwest.longitude, ); @@ -874,9 +865,8 @@ void main() { ); testWidgets('testResizeWidget', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); - final ExampleGoogleMap map = ExampleGoogleMap( + final controllerCompleter = Completer(); + final map = ExampleGoogleMap( initialCameraPosition: _kInitialCameraPosition, onMapCreated: (ExampleGoogleMapController controller) async { controllerCompleter.complete(controller); @@ -915,14 +905,13 @@ void main() { }); testWidgets('testToggleInfoWindow', (WidgetTester tester) async { - const Marker marker = Marker( + const marker = Marker( markerId: MarkerId('marker'), infoWindow: InfoWindow(title: 'InfoWindow'), ); - final Set markers = {marker}; + final markers = {marker}; - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -960,21 +949,18 @@ void main() { WidgetTester tester, ) async { final Key key = GlobalKey(); - const Marker marker = Marker( + const marker = Marker( markerId: MarkerId('marker'), infoWindow: InfoWindow(title: 'InfoWindow'), ); - Set markers = {marker}; + var markers = {marker}; - const ClusterManager clusterManager = ClusterManager( + const clusterManager = ClusterManager( clusterManagerId: ClusterManagerId('cluster_manager'), ); - final Set clusterManagers = { - clusterManager, - }; + final clusterManagers = {clusterManager}; - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1029,8 +1015,7 @@ void main() { testWidgets( 'testTakeSnapshot', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1056,15 +1041,15 @@ void main() { ); testWidgets('set tileOverlay correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final TileOverlay tileOverlay1 = TileOverlay( + final mapIdCompleter = Completer(); + final tileOverlay1 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 2, transparency: 0.2, ); - final TileOverlay tileOverlay2 = TileOverlay( + final tileOverlay2 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_2'), tileProvider: _DebugTileProvider(), zIndex: 1, @@ -1117,16 +1102,16 @@ void main() { }); testWidgets('update tileOverlays correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( + final tileOverlay1 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 2, transparency: 0.2, ); - final TileOverlay tileOverlay2 = TileOverlay( + final tileOverlay2 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_2'), tileProvider: _DebugTileProvider(), zIndex: 3, @@ -1150,7 +1135,7 @@ void main() { final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - final TileOverlay tileOverlay1New = TileOverlay( + final tileOverlay1New = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 1, @@ -1196,9 +1181,9 @@ void main() { }); testWidgets('remove tileOverlays correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); - final TileOverlay tileOverlay1 = TileOverlay( + final tileOverlay1 = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), zIndex: 2, @@ -1247,27 +1232,21 @@ void main() { testWidgets('marker clustering', (WidgetTester tester) async { final Key key = GlobalKey(); - const int clusterManagersAmount = 2; - const int markersPerClusterManager = 5; - final Map markers = {}; - final Set clusterManagers = {}; - - for (int i = 0; i < clusterManagersAmount; i++) { - final ClusterManagerId clusterManagerId = ClusterManagerId( - 'cluster_manager_$i', - ); - final ClusterManager clusterManager = ClusterManager( - clusterManagerId: clusterManagerId, - ); + const clusterManagersAmount = 2; + const markersPerClusterManager = 5; + final markers = {}; + final clusterManagers = {}; + + for (var i = 0; i < clusterManagersAmount; i++) { + final clusterManagerId = ClusterManagerId('cluster_manager_$i'); + final 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 Marker marker = Marker( + for (final cm in clusterManagers) { + for (var i = 0; i < markersPerClusterManager; i++) { + final markerId = MarkerId('${cm.clusterManagerId.value}_marker_$i'); + final marker = Marker( markerId: markerId, clusterManagerId: cm.clusterManagerId, position: LatLng( @@ -1279,8 +1258,7 @@ void main() { } } - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; @@ -1303,7 +1281,7 @@ void main() { final ExampleGoogleMapController controller = await controllerCompleter.future; - for (final ClusterManager cm in clusterManagers) { + for (final cm in clusterManagers) { final List clusters = await inspector.getClusters( mapId: controller.mapId, clusterManagerId: cm.clusterManagerId, @@ -1379,7 +1357,7 @@ void main() { ), ); - for (final ClusterManager cm in clusterManagers) { + for (final cm in clusterManagers) { final List clusters = await inspector.getClusters( mapId: controller.mapId, clusterManagerId: cm.clusterManagerId, @@ -1405,8 +1383,7 @@ void main() { testWidgets('getStyleError reports last error', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1432,8 +1409,7 @@ void main() { WidgetTester tester, ) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( @@ -1457,7 +1433,7 @@ void main() { }); testWidgets('markerWithAssetMapBitmap', (WidgetTester tester) async { - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: AssetMapBitmap('assets/red_square.png', imagePixelRatio: 1.0), @@ -1479,10 +1455,10 @@ void main() { }); testWidgets('markerWithAssetMapBitmapCreate', (WidgetTester tester) async { - final ImageConfiguration imageConfiguration = ImageConfiguration( + final imageConfiguration = ImageConfiguration( devicePixelRatio: tester.view.devicePixelRatio, ); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: await AssetMapBitmap.create( @@ -1508,7 +1484,7 @@ void main() { testWidgets('markerWithBytesMapBitmap', (WidgetTester tester) async { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: BytesMapBitmap( @@ -1535,11 +1511,11 @@ void main() { testWidgets('markerWithLegacyAsset', (WidgetTester tester) async { //tester.view.devicePixelRatio = 2.0; - const ImageConfiguration imageConfiguration = ImageConfiguration( + const imageConfiguration = ImageConfiguration( devicePixelRatio: 2.0, size: Size(100, 100), ); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), // Intentionally testing the deprecated code path. @@ -1550,8 +1526,7 @@ void main() { ), ), }; - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -1576,11 +1551,8 @@ void main() { // ignore: deprecated_member_use final BitmapDescriptor icon = BitmapDescriptor.fromBytes(bytes); - final Set markers = { - Marker(markerId: const MarkerId('1'), icon: icon), - }; - final Completer controllerCompleter = - Completer(); + final markers = {Marker(markerId: const MarkerId('1'), icon: icon)}; + final controllerCompleter = Completer(); await tester.pumpWidget( Directionality( textDirection: TextDirection.ltr, @@ -1598,12 +1570,12 @@ void main() { }); group('GroundOverlay', () { - final LatLngBounds kGroundOverlayBounds = LatLngBounds( + final kGroundOverlayBounds = LatLngBounds( southwest: const LatLng(37.77483, -122.41942), northeast: const LatLng(37.78183, -122.39105), ); - final GroundOverlay groundOverlayBounds1 = GroundOverlay.fromBounds( + final groundOverlayBounds1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('bounds_1'), bounds: kGroundOverlayBounds, image: AssetMapBitmap( @@ -1613,7 +1585,7 @@ void main() { ), ); - final GroundOverlay groundOverlayPosition1 = GroundOverlay.fromPosition( + final groundOverlayPosition1 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('position_1'), position: kGroundOverlayBounds.northeast, width: 100, @@ -1665,8 +1637,8 @@ void main() { } testWidgets('set ground overlays correctly', (WidgetTester tester) async { - final Completer mapIdCompleter = Completer(); - final GroundOverlay groundOverlayBounds2 = GroundOverlay.fromBounds( + final mapIdCompleter = Completer(); + final groundOverlayBounds2 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('bounds_2'), bounds: groundOverlayBounds1.bounds!, image: groundOverlayBounds1.image, @@ -1723,7 +1695,7 @@ void main() { testWidgets('update ground overlays correctly', ( WidgetTester tester, ) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( @@ -1807,7 +1779,7 @@ void main() { testWidgets('remove ground overlays correctly', ( WidgetTester tester, ) async { - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); final Key key = GlobalKey(); await tester.pumpWidget( @@ -1862,8 +1834,7 @@ void main() { 'testAnimateCameraWithoutDuration', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; @@ -1956,16 +1927,15 @@ void main() { 'testAnimateCameraWithDuration', (WidgetTester tester) async { final Key key = GlobalKey(); - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; /// Completer to track when the camera has come to rest. Completer? cameraIdleCompleter; - const int shortCameraAnimationDurationMS = 200; - const int longCameraAnimationDurationMS = 1000; + const shortCameraAnimationDurationMS = 200; + const longCameraAnimationDurationMS = 1000; /// Calculate the midpoint duration of the animation test, which will /// serve as a reference to verify that animations complete more quickly @@ -1974,7 +1944,7 @@ void main() { (shortCameraAnimationDurationMS + longCameraAnimationDurationMS) ~/ 2; // Stopwatch to measure the time taken for the animation to complete. - final Stopwatch stopwatch = Stopwatch(); + final stopwatch = Stopwatch(); await tester.pumpWidget( Directionality( @@ -2116,10 +2086,10 @@ class _DebugTileProvider implements TileProvider { @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 TextPainter textPainter = TextPainter( + final recorder = ui.PictureRecorder(); + final canvas = Canvas(recorder); + final textSpan = TextSpan(text: '$x,$y', style: textStyle); + final textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); @@ -2199,7 +2169,7 @@ Future _checkCameraUpdateByType( ) async { // As the target might differ a bit from the expected target, a threshold is // used. - const double latLngThreshold = 0.05; + const latLngThreshold = 0.05; switch (type) { case CameraUpdateType.newCameraPosition: 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 e7ed25a30438..5757717c215b 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 @@ -116,14 +116,11 @@ class ClusteringBodyState extends State { return; } - final String clusterManagerIdVal = - 'cluster_manager_id_$_clusterManagerIdCounter'; + final clusterManagerIdVal = 'cluster_manager_id_$_clusterManagerIdCounter'; _clusterManagerIdCounter++; - final ClusterManagerId clusterManagerId = ClusterManagerId( - clusterManagerIdVal, - ); + final clusterManagerId = ClusterManagerId(clusterManagerIdVal); - final ClusterManager clusterManager = ClusterManager( + final clusterManager = ClusterManager( clusterManagerId: clusterManagerId, onClusterTap: (Cluster cluster) => setState(() { lastCluster = cluster; @@ -149,11 +146,11 @@ class ClusteringBodyState extends State { } void _addMarkersToCluster(ClusterManager clusterManager) { - for (int i = 0; i < _markersToAddToClusterManagerCount; i++) { - final String markerIdVal = + for (var i = 0; i < _markersToAddToClusterManagerCount; i++) { + final markerIdVal = '${clusterManager.clusterManagerId.value}_marker_id_$_markerIdCounter'; _markerIdCounter++; - final MarkerId markerId = MarkerId(markerIdVal); + final markerId = MarkerId(markerIdVal); final int clusterManagerIndex = clusterManagers.values.toList().indexOf( clusterManager, @@ -164,7 +161,7 @@ class ClusteringBodyState extends State { final double clusterManagerLongitudeOffset = clusterManagerIndex * _clusterManagerLongitudeOffset; - final Marker marker = Marker( + final marker = Marker( clusterManagerId: clusterManager.clusterManagerId, markerId: markerId, position: LatLng( 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 6206787f3475..548146c6206c 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 @@ -9,9 +9,9 @@ import 'package:flutter/material.dart'; /// Returns a generated png image in [ByteData] format with the requested size. Future createCustomMarkerIconImage({required Size size}) async { - final ui.PictureRecorder recorder = ui.PictureRecorder(); - final Canvas canvas = Canvas(recorder); - final _MarkerPainter painter = _MarkerPainter(); + final recorder = ui.PictureRecorder(); + final canvas = Canvas(recorder); + final painter = _MarkerPainter(); painter.paint(canvas, size); @@ -30,7 +30,7 @@ class _MarkerPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { final Rect rect = Offset.zero & size; - const RadialGradient gradient = RadialGradient( + const gradient = RadialGradient( colors: [Colors.yellow, Colors.red], stops: [0.4, 1.0], ); 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 8c8f5dcf1594..d8f474eb7d5e 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 @@ -93,9 +93,7 @@ class GroundOverlayBodyState extends State { _groundOverlayIndex += 1; - final GroundOverlayId id = GroundOverlayId( - 'ground_overlay_$_groundOverlayIndex', - ); + final id = GroundOverlayId('ground_overlay_$_groundOverlayIndex'); final GroundOverlay groundOverlay = switch (_placingType) { _GroundOverlayPlacing.position => GroundOverlay.fromPosition( @@ -144,9 +142,7 @@ class GroundOverlayBodyState extends State { void _changeTransparency() { assert(_groundOverlay != null); setState(() { - final double transparency = _groundOverlay!.transparency == 0.0 - ? 0.5 - : 0.0; + final transparency = _groundOverlay!.transparency == 0.0 ? 0.5 : 0.0; _groundOverlay = _groundOverlay!.copyWith( transparencyParam: transparency, ); @@ -227,7 +223,7 @@ class GroundOverlayBodyState extends State { @override Widget build(BuildContext context) { - final Set overlays = { + final overlays = { if (_groundOverlay != null) _groundOverlay!, }; return Column( 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 a2cbca5c7e08..4d45e961d63e 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 @@ -41,7 +41,7 @@ class _MapClickBodyState extends State<_MapClickBody> { @override Widget build(BuildContext context) { - final ExampleGoogleMap googleMap = ExampleGoogleMap( + final googleMap = ExampleGoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, onTap: (LatLng pos) { @@ -56,7 +56,7 @@ class _MapClickBodyState extends State<_MapClickBody> { }, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( @@ -66,8 +66,8 @@ class _MapClickBodyState extends State<_MapClickBody> { ]; if (mapController != null) { - final String lastTap = 'Tap:\n${_lastTap ?? ""}\n'; - final String lastLongPress = 'Long press:\n${_lastLongPress ?? ""}'; + final lastTap = 'Tap:\n${_lastTap ?? ""}\n'; + final lastLongPress = 'Long press:\n${_lastLongPress ?? ""}'; columnChildren.add( Center(child: Text(lastTap, textAlign: TextAlign.center)), ); 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 59858c4d3213..3a93b0db93b7 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 @@ -43,7 +43,7 @@ class _MapCoordinatesBodyState extends State<_MapCoordinatesBody> { @override Widget build(BuildContext context) { - final ExampleGoogleMap googleMap = ExampleGoogleMap( + final googleMap = ExampleGoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, onCameraIdle: 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 cca097752fdb..c62152f149d0 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 @@ -47,7 +47,7 @@ class MapIdBodyState extends State { @override Widget build(BuildContext context) { - final ExampleGoogleMap googleMap = ExampleGoogleMap( + final googleMap = ExampleGoogleMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition( target: _kMapCenter, @@ -57,7 +57,7 @@ class MapIdBodyState extends State { mapId: _mapId, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( 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 53109eeac4d9..46fa320ad3a0 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 @@ -253,7 +253,7 @@ class MapUiBodyState extends State { @override Widget build(BuildContext context) { - final ExampleGoogleMap googleMap = ExampleGoogleMap( + final googleMap = ExampleGoogleMap( onMapCreated: onMapCreated, initialCameraPosition: _kInitialPosition, compassEnabled: _compassEnabled, @@ -273,7 +273,7 @@ class MapUiBodyState extends State { onCameraMove: _updateCameraPosition, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( 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 40df30c94acd..2959c7c0dcf0 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 @@ -210,7 +210,7 @@ class MarkerIconsBodyState extends State { } Marker _createAssetMarker(int index) { - final LatLng position = LatLng( + final position = LatLng( _kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude - 1, ); @@ -223,7 +223,7 @@ class MarkerIconsBodyState extends State { } Marker _createBytesMarker(int index) { - final LatLng position = LatLng( + final position = LatLng( _kMapCenter.latitude - (index * 0.5), _kMapCenter.longitude + 1, ); @@ -236,8 +236,8 @@ class MarkerIconsBodyState extends State { } void _updateMarkers() { - final Set markers = {}; - for (int i = 0; i < _markersAmountPerType; i++) { + final markers = {}; + for (var i = 0; i < _markersAmountPerType; i++) { if (_markerIconAsset != null) { markers.add(_createAssetMarker(i)); } @@ -299,7 +299,7 @@ class MarkerIconsBodyState extends State { final double? imagePixelRatio = _scalingEnabled ? devicePixelRatio : null; // Create canvasSize with physical marker size - final Size canvasSize = Size( + final canvasSize = Size( bitmapLogicalSize.width * (imagePixelRatio ?? 1.0), bitmapLogicalSize.height * (imagePixelRatio ?? 1.0), ); @@ -314,7 +314,7 @@ class MarkerIconsBodyState extends State { ? _getCurrentMarkerSize() : (null, null); - final BytesMapBitmap bitmap = BytesMapBitmap( + final bitmap = BytesMapBitmap( bytes.buffer.asUint8List(), imagePixelRatio: imagePixelRatio, width: width, 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 5154b88782b1..beb39b305f58 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 @@ -36,7 +36,7 @@ class MarkerIconsBodyState extends State { @override Widget build(BuildContext context) { - final ExampleGoogleMap googleMap = ExampleGoogleMap( + final googleMap = ExampleGoogleMap( onMapCreated: _onMapCreated, initialCameraPosition: const CameraPosition( target: _kMapCenter, @@ -45,7 +45,7 @@ class MarkerIconsBodyState extends State { padding: _padding, ); - final List columnChildren = [ + final columnChildren = [ Padding( padding: const EdgeInsets.all(10.0), child: Center( 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 d45ec7e5c270..88c84c79e124 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 @@ -83,11 +83,11 @@ class PlaceCircleBodyState extends State { return; } - final String circleIdVal = 'circle_id_$_circleIdCounter'; + final circleIdVal = 'circle_id_$_circleIdCounter'; _circleIdCounter++; - final CircleId circleId = CircleId(circleIdVal); + final circleId = CircleId(circleIdVal); - final Circle circle = Circle( + final circle = Circle( circleId: circleId, consumeTapEvents: true, strokeColor: Colors.orange, 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 9674927fe37b..926c2db2e426 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 @@ -141,11 +141,11 @@ class PlaceMarkerBodyState extends State { return; } - final String markerIdVal = 'marker_id_$_markerIdCounter'; + final markerIdVal = 'marker_id_$_markerIdCounter'; _markerIdCounter++; - final MarkerId markerId = MarkerId(markerIdVal); + final markerId = MarkerId(markerIdVal); - final Marker marker = Marker( + final marker = Marker( markerId: markerId, position: LatLng( center.latitude + sin(_markerIdCounter * pi / 6.0) / 20.0, @@ -174,7 +174,7 @@ class PlaceMarkerBodyState extends State { void _changePosition(MarkerId markerId) { final Marker marker = markers[markerId]!; final LatLng current = marker.position; - final Offset offset = Offset( + final offset = Offset( center.latitude - current.latitude, center.longitude - current.longitude, ); @@ -191,7 +191,7 @@ class PlaceMarkerBodyState extends State { void _changeAnchor(MarkerId markerId) { final Marker marker = markers[markerId]!; final Offset currentAnchor = marker.anchor; - final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); + final newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { markers[markerId] = marker.copyWith(anchorParam: newAnchor); }); @@ -200,7 +200,7 @@ class PlaceMarkerBodyState extends State { Future _changeInfoAnchor(MarkerId markerId) async { final Marker marker = markers[markerId]!; final Offset currentAnchor = marker.infoWindow.anchor; - final Offset newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); + final newAnchor = Offset(1.0 - currentAnchor.dy, currentAnchor.dx); setState(() { markers[markerId] = marker.copyWith( infoWindowParam: marker.infoWindow.copyWith(anchorParam: newAnchor), @@ -224,7 +224,7 @@ class PlaceMarkerBodyState extends State { Future _changeInfo(MarkerId markerId) async { final Marker marker = markers[markerId]!; - final String newSnippet = '${marker.infoWindow.snippet!}*'; + final newSnippet = '${marker.infoWindow.snippet!}*'; setState(() { markers[markerId] = marker.copyWith( infoWindowParam: marker.infoWindow.copyWith(snippetParam: newSnippet), @@ -277,7 +277,7 @@ class PlaceMarkerBodyState extends State { } Future _getMarkerIcon(BuildContext context) async { - const Size canvasSize = Size(48, 48); + const canvasSize = Size(48, 48); final ByteData bytes = await createCustomMarkerIconImage(size: canvasSize); return BytesMapBitmap(bytes.buffer.asUint8List()); } 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 79475381c158..ff9eac82210c 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 @@ -82,10 +82,10 @@ class PlacePolygonBodyState extends State { return; } - final String polygonIdVal = 'polygon_id_$_polygonIdCounter'; - final PolygonId polygonId = PolygonId(polygonIdVal); + final polygonIdVal = 'polygon_id_$_polygonIdCounter'; + final polygonId = PolygonId(polygonIdVal); - final Polygon polygon = Polygon( + final polygon = Polygon( polygonId: polygonId, consumeTapEvents: true, strokeColor: Colors.orange, @@ -262,7 +262,7 @@ class PlacePolygonBodyState extends State { } List _createPoints() { - final List points = []; + final points = []; final double offset = _polygonIdCounter.ceilToDouble(); points.add(_createLatLng(51.2395 + offset, -3.4314)); points.add(_createLatLng(53.5234 + offset, -3.5314)); @@ -272,17 +272,17 @@ class PlacePolygonBodyState extends State { } List> _createHoles(PolygonId polygonId) { - final List> holes = >[]; + final holes = >[]; final double offset = polygonOffsets[polygonId]!; - final List hole1 = []; + final hole1 = []; hole1.add(_createLatLng(51.8395 + offset, -3.8814)); hole1.add(_createLatLng(52.0234 + offset, -3.9914)); hole1.add(_createLatLng(52.1351 + offset, -4.4435)); hole1.add(_createLatLng(52.0231 + offset, -4.5829)); holes.add(hole1); - final List hole2 = []; + final hole2 = []; hole2.add(_createLatLng(52.2395 + offset, -3.6814)); hole2.add(_createLatLng(52.4234 + offset, -3.7914)); hole2.add(_createLatLng(52.5351 + offset, -4.2435)); 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 854046b30535..f749cac5f268 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 @@ -110,11 +110,11 @@ class PlacePolylineBodyState extends State { return; } - final String polylineIdVal = 'polyline_id_$_polylineIdCounter'; + final polylineIdVal = 'polyline_id_$_polylineIdCounter'; _polylineIdCounter++; - final PolylineId polylineId = PolylineId(polylineIdVal); + final polylineId = PolylineId(polylineIdVal); - final Polyline polyline = Polyline( + final polyline = Polyline( polylineId: polylineId, consumeTapEvents: true, color: Colors.orange, @@ -307,7 +307,7 @@ class PlacePolylineBodyState extends State { } List _createPoints() { - final List points = []; + final points = []; final double offset = _polylineIdCounter.ceilToDouble(); points.add(_createLatLng(51.4816 + offset, -3.1791)); points.add(_createLatLng(53.0430 + offset, -2.9925)); 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 340ac4ce48de..bcce3b5f387b 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 @@ -53,7 +53,7 @@ class TileOverlayBodyState extends State { } void _addTileOverlay() { - final TileOverlay tileOverlay = TileOverlay( + final tileOverlay = TileOverlay( tileOverlayId: const TileOverlayId('tile_overlay_1'), tileProvider: _DebugTileProvider(), ); @@ -70,9 +70,7 @@ class TileOverlayBodyState extends State { @override Widget build(BuildContext context) { - final Set overlays = { - if (_tileOverlay != null) _tileOverlay!, - }; + final overlays = {if (_tileOverlay != null) _tileOverlay!}; return Column( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceEvenly, @@ -124,10 +122,10 @@ class _DebugTileProvider implements TileProvider { @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 TextPainter textPainter = TextPainter( + final recorder = ui.PictureRecorder(); + final canvas = Canvas(recorder); + final textSpan = TextSpan(text: '$x,$y', style: textStyle); + final textPainter = TextPainter( text: textSpan, textDirection: TextDirection.ltr, ); 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 8cb555d3d541..74ba4fc9ac03 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 @@ -40,10 +40,10 @@ void main() { testWidgets('circle updates with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - const Circle c1 = Circle(circleId: CircleId('circle_1')); - const Circle c2 = Circle(circleId: CircleId('circle_2')); - const Circle c3 = Circle(circleId: CircleId('circle_3'), radius: 1); - const Circle c3updated = Circle(circleId: CircleId('circle_3'), radius: 10); + const c1 = Circle(circleId: CircleId('circle_1')); + const c2 = Circle(circleId: CircleId('circle_2')); + const c3 = Circle(circleId: CircleId('circle_3'), radius: 1); + const c3updated = Circle(circleId: CircleId('circle_3'), radius: 10); // First remove one and add another, then update the new one. await tester.pumpWidget(_mapWithObjects(circles: {c1, c2})); @@ -72,13 +72,10 @@ void main() { testWidgets('marker updates with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - 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 m1 = Marker(markerId: MarkerId('marker_1')); + const m2 = Marker(markerId: MarkerId('marker_2')); + const m3 = Marker(markerId: MarkerId('marker_3')); + const 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,13 +104,10 @@ void main() { testWidgets('polygon updates with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - 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( + const p1 = Polygon(polygonId: PolygonId('polygon_1')); + const p2 = Polygon(polygonId: PolygonId('polygon_2')); + const p3 = Polygon(polygonId: PolygonId('polygon_3'), strokeWidth: 1); + const p3updated = Polygon( polygonId: PolygonId('polygon_3'), strokeWidth: 2, ); @@ -147,16 +141,10 @@ void main() { testWidgets('polyline updates with delays', (WidgetTester tester) async { platform.simulatePlatformDelay = true; - 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 p1 = Polyline(polylineId: PolylineId('polyline_1')); + const p2 = Polyline(polylineId: PolylineId('polyline_2')); + const p3 = Polyline(polylineId: PolylineId('polyline_3'), width: 1); + const 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})); 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 b00703f72040..9ab35fc6aae2 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 @@ -128,7 +128,7 @@ class GoogleMapsInspectorIOS extends GoogleMapsInspectorPlatform { } // Create dummy image to represent the image of the ground overlay. - final BytesMapBitmap dummyImage = BytesMapBitmap( + final dummyImage = BytesMapBitmap( Uint8List.fromList([0]), bitmapScaling: MapBitmapScaling.none, ); 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 51a7d1afd473..87fae9a1507d 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 @@ -307,10 +307,7 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { final Set previousSet = currentTileOverlays != null ? currentTileOverlays.values.toSet() : {}; - final _TileOverlayUpdates updates = _TileOverlayUpdates.from( - previousSet, - newTileOverlays, - ); + final updates = _TileOverlayUpdates.from(previousSet, newTileOverlays); _tileOverlays[mapId] = keyTileOverlayId(newTileOverlays); return _hostApi(mapId).updateTileOverlays( updates.tileOverlaysToAdd @@ -491,37 +488,36 @@ class GoogleMapsFlutterIOS extends GoogleMapsFlutterPlatform { '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(), - ); + final 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(), + ); return UiKitView( viewType: 'plugins.flutter.dev/google_maps_ios', @@ -1256,7 +1252,7 @@ PlatformMapConfiguration _platformMapConfigurationFromOptionsJson( // to support this legacy API that relied on cross-package magic strings. final List? padding = (options['padding'] as List?) ?.cast(); - final int? mapType = options['mapType'] as int?; + final mapType = options['mapType'] as int?; return PlatformMapConfiguration( compassEnabled: options['compassEnabled'] as bool?, cameraTargetBounds: _platformCameraTargetBoundsFromCameraTargetBoundsJson( 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 f31f9f760cd9..2e174a4a7524 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 @@ -25,7 +25,7 @@ void _addIfNonNull(Map map, String fieldName, Object? value) { /// Serialize [Heatmap] Object serializeHeatmap(Heatmap heatmap) { - final Map json = {}; + final json = {}; _addIfNonNull(json, _heatmapIdKey, heatmap.heatmapId.value); _addIfNonNull( @@ -69,7 +69,7 @@ WeightedLatLng? deserializeWeightedLatLng(Object? json) { return null; } assert(json is List && json.length == 2); - final List list = json as List; + final list = json as List; final LatLng latLng = deserializeLatLng(list[0])!; return WeightedLatLng(latLng, weight: list[1] as double); } @@ -85,13 +85,13 @@ LatLng? deserializeLatLng(Object? json) { return null; } assert(json is List && json.length == 2); - final List list = json as List; + final list = json as List; return LatLng(list[0]! as double, list[1]! as double); } /// Serialize [HeatmapGradient] Object serializeHeatmapGradient(HeatmapGradient gradient) { - final Map json = {}; + final json = {}; _addIfNonNull( json, @@ -125,8 +125,8 @@ HeatmapGradient? deserializeHeatmapGradient(Object? json) { (map[_heatmapGradientStartPointsKey]! as List) .whereType() .toList(); - final List gradientColors = []; - for (int i = 0; i < colors.length; i++) { + final gradientColors = []; + for (var i = 0; i < colors.length; i++) { gradientColors.add(HeatmapGradientColor(colors[i], startPoints[i])); } return HeatmapGradient( 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 1b91f2a4a89a..23c7fd0c9fac 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 @@ -20,10 +20,8 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); (GoogleMapsFlutterIOS, MockMapsApi) setUpMockMap({required int mapId}) { - final MockMapsApi api = MockMapsApi(); - final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS( - apiProvider: (_) => api, - ); + final api = MockMapsApi(); + final maps = GoogleMapsFlutterIOS(apiProvider: (_) => api); maps.ensureApiInitialized(mapId); return (maps, api); } @@ -34,10 +32,8 @@ void main() { }); test('init calls waitForMap', () async { - final MockMapsApi api = MockMapsApi(); - final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS( - apiProvider: (_) => api, - ); + final api = MockMapsApi(); + final maps = GoogleMapsFlutterIOS(apiProvider: (_) => api); await maps.init(1); @@ -45,14 +41,14 @@ void main() { }); test('getScreenCoordinate converts and passes values correctly', () async { - const int mapId = 1; + const mapId = 1; 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); + const latLng = LatLng(10, 20); + const expectedCoord = ScreenCoordinate(x: 30, y: 40); when(api.getScreenCoordinate(any)).thenAnswer( (_) async => PlatformPoint( x: expectedCoord.x.toDouble(), @@ -68,21 +64,20 @@ void main() { final VerificationResult verification = verify( api.getScreenCoordinate(captureAny), ); - final PlatformLatLng passedLatLng = - verification.captured[0] as PlatformLatLng; + final passedLatLng = verification.captured[0] as PlatformLatLng; expect(passedLatLng.latitude, latLng.latitude); expect(passedLatLng.longitude, latLng.longitude); }); test('getLatLng converts and passes values correctly', () async { - const int mapId = 1; + const mapId = 1; 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); + const expectedLatLng = LatLng(10, 20); + const coord = ScreenCoordinate(x: 30, y: 40); when(api.getLatLng(any)).thenAnswer( (_) async => PlatformLatLng( latitude: expectedLatLng.latitude, @@ -93,19 +88,19 @@ void main() { final LatLng latLng = await maps.getLatLng(coord, mapId: mapId); expect(latLng, expectedLatLng); final VerificationResult verification = verify(api.getLatLng(captureAny)); - final PlatformPoint passedCoord = verification.captured[0] as PlatformPoint; + final passedCoord = verification.captured[0] as PlatformPoint; expect(passedCoord.x, coord.x); expect(passedCoord.y, coord.y); }); test('getVisibleRegion converts and passes values correctly', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); // Arbitrary values that are all different from each other. - final LatLngBounds expectedBounds = LatLngBounds( + final expectedBounds = LatLngBounds( southwest: const LatLng(10, 20), northeast: const LatLng(30, 40), ); @@ -127,7 +122,7 @@ void main() { }); test('moveCamera calls through with expected scrollBy', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); @@ -136,17 +131,15 @@ void main() { await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateScrollBy scroll = - passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final scroll = passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; update as CameraUpdateScrollBy; expect(scroll.dx, update.dx); expect(scroll.dy, update.dy); }); test('animateCamera calls through with expected scrollBy', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); @@ -157,10 +150,8 @@ void main() { final VerificationResult verification = verify( api.animateCamera(captureAny, captureAny), ); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateScrollBy scroll = - passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final scroll = passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; update as CameraUpdateScrollBy; expect(scroll.dx, update.dx); expect(scroll.dy, update.dy); @@ -168,14 +159,15 @@ void main() { }); test('animateCameraWithConfiguration calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); final CameraUpdate update = CameraUpdate.scrollBy(10, 20); - const CameraUpdateAnimationConfiguration configuration = - CameraUpdateAnimationConfiguration(duration: Duration(seconds: 1)); + const configuration = CameraUpdateAnimationConfiguration( + duration: Duration(seconds: 1), + ); expect(configuration.duration?.inSeconds, 1); await maps.animateCameraWithConfiguration( update, @@ -186,25 +178,23 @@ void main() { final VerificationResult verification = verify( api.animateCamera(captureAny, captureAny), ); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateScrollBy scroll = - passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final scroll = passedUpdate.cameraUpdate as PlatformCameraUpdateScrollBy; update as CameraUpdateScrollBy; expect(scroll.dx, update.dx); expect(scroll.dy, update.dy); - final int? passedDuration = verification.captured[1] as int?; + final passedDuration = verification.captured[1] as int?; expect(passedDuration, configuration.duration?.inMilliseconds); }); test('getZoomLevel passes values correctly', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const double expectedZoom = 4.2; + const expectedZoom = 4.2; when(api.getZoomLevel()).thenAnswer((_) async => expectedZoom); final double zoom = await maps.getZoomLevel(mapId: mapId); @@ -212,36 +202,36 @@ void main() { }); test('showInfoWindow calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const String markedId = 'a_marker'; + const markedId = 'a_marker'; await maps.showMarkerInfoWindow(const MarkerId(markedId), mapId: mapId); verify(api.showInfoWindow(markedId)); }); test('hideInfoWindow calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const String markedId = 'a_marker'; + const markedId = 'a_marker'; await maps.hideMarkerInfoWindow(const MarkerId(markedId), mapId: mapId); verify(api.hideInfoWindow(markedId)); }); test('isInfoWindowShown calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const String markedId = 'a_marker'; + const markedId = 'a_marker'; when(api.isInfoWindowShown(markedId)).thenAnswer((_) async => true); expect( @@ -254,43 +244,43 @@ void main() { }); test('takeSnapshot calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - final Uint8List fakeSnapshot = Uint8List(10); + final fakeSnapshot = Uint8List(10); when(api.takeSnapshot()).thenAnswer((_) async => fakeSnapshot); expect(await maps.takeSnapshot(mapId: mapId), fakeSnapshot); }); test('clearTileCache calls through', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const String tileOverlayId = 'overlay'; + const tileOverlayId = 'overlay'; await maps.clearTileCache(const TileOverlayId(tileOverlayId), mapId: mapId); verify(api.clearTileCache(tileOverlayId)); }); test('updateMapConfiguration passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); // Set some arbitrary options. - final CameraTargetBounds cameraBounds = CameraTargetBounds( + final cameraBounds = CameraTargetBounds( LatLngBounds( southwest: const LatLng(10, 20), northeast: const LatLng(30, 40), ), ); - final MapConfiguration config = MapConfiguration( + final config = MapConfiguration( compassEnabled: true, mapType: MapType.terrain, cameraTargetBounds: cameraBounds, @@ -300,8 +290,7 @@ void main() { final VerificationResult verification = verify( api.updateMapConfiguration(captureAny), ); - final PlatformMapConfiguration passedConfig = - verification.captured[0] as PlatformMapConfiguration; + final passedConfig = verification.captured[0] as PlatformMapConfiguration; // Each set option should be present. expect(passedConfig.compassEnabled, true); expect(passedConfig.mapType, PlatformMapType.terrain); @@ -328,19 +317,19 @@ void main() { }); test('updateMapOptions passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); // Set some arbitrary options. - final CameraTargetBounds cameraBounds = CameraTargetBounds( + final cameraBounds = CameraTargetBounds( LatLngBounds( southwest: const LatLng(10, 20), northeast: const LatLng(30, 40), ), ); - final Map config = { + final config = { 'compassEnabled': true, 'mapType': MapType.terrain.index, 'cameraTargetBounds': cameraBounds.toJson(), @@ -350,8 +339,7 @@ void main() { final VerificationResult verification = verify( api.updateMapConfiguration(captureAny), ); - final PlatformMapConfiguration passedConfig = - verification.captured[0] as PlatformMapConfiguration; + final passedConfig = verification.captured[0] as PlatformMapConfiguration; // Each set option should be present. expect(passedConfig.compassEnabled, true); expect(passedConfig.mapType, PlatformMapType.terrain); @@ -378,15 +366,15 @@ void main() { }); test('updateCircles passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const Circle object1 = Circle(circleId: CircleId('1')); - const Circle object2old = Circle(circleId: CircleId('2')); + const object1 = Circle(circleId: CircleId('1')); + const object2old = Circle(circleId: CircleId('2')); final Circle object2new = object2old.copyWith(radiusParam: 42); - const Circle object3 = Circle(circleId: CircleId('3')); + const object3 = Circle(circleId: CircleId('3')); await maps.updateCircles( CircleUpdates.from( {object1, object2old}, @@ -398,11 +386,9 @@ void main() { final VerificationResult verification = verify( api.updateCircles(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.circleId.value); @@ -439,17 +425,13 @@ void main() { }); test('updateClusterManagers passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const ClusterManager object1 = ClusterManager( - clusterManagerId: ClusterManagerId('1'), - ); - const ClusterManager object3 = ClusterManager( - clusterManagerId: ClusterManagerId('3'), - ); + const object1 = ClusterManager(clusterManagerId: ClusterManagerId('1')); + const object3 = ClusterManager(clusterManagerId: ClusterManagerId('3')); await maps.updateClusterManagers( ClusterManagerUpdates.from( {object1}, @@ -461,9 +443,8 @@ void main() { final VerificationResult verification = verify( api.updateClusterManagers(captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toRemove = verification.captured[1] as List; + final toAdd = verification.captured[0] as List; + final toRemove = verification.captured[1] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.clusterManagerId.value); @@ -475,15 +456,15 @@ void main() { }); test('updateMarkers passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const Marker object1 = Marker(markerId: MarkerId('1')); - const Marker object2old = Marker(markerId: MarkerId('2')); + const object1 = Marker(markerId: MarkerId('1')); + const object2old = Marker(markerId: MarkerId('2')); final Marker object2new = object2old.copyWith(rotationParam: 42); - const Marker object3 = Marker(markerId: MarkerId('3')); + const object3 = Marker(markerId: MarkerId('3')); await maps.updateMarkers( MarkerUpdates.from( {object1, object2old}, @@ -495,11 +476,9 @@ void main() { final VerificationResult verification = verify( api.updateMarkers(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.markerId.value); @@ -562,15 +541,15 @@ void main() { }); test('updatePolygons passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const Polygon object1 = Polygon(polygonId: PolygonId('1')); - const Polygon object2old = Polygon(polygonId: PolygonId('2')); + const object1 = Polygon(polygonId: PolygonId('1')); + const object2old = Polygon(polygonId: PolygonId('2')); final Polygon object2new = object2old.copyWith(strokeWidthParam: 42); - const Polygon object3 = Polygon(polygonId: PolygonId('3')); + const object3 = Polygon(polygonId: PolygonId('3')); await maps.updatePolygons( PolygonUpdates.from( {object1, object2old}, @@ -582,11 +561,9 @@ void main() { final VerificationResult verification = verify( api.updatePolygons(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.polygonId.value); @@ -623,13 +600,13 @@ void main() { }); test('updatePolylines passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const Polyline object1 = Polyline(polylineId: PolylineId('1')); - const Polyline object2old = Polyline(polylineId: PolylineId('2')); + const object1 = Polyline(polylineId: PolylineId('1')); + const object2old = Polyline(polylineId: PolylineId('2')); final Polyline object2new = object2old.copyWith( widthParam: 42, startCapParam: Cap.squareCap, @@ -639,7 +616,7 @@ void main() { BitmapDescriptor.defaultMarker, refWidth: 15, ); - final Polyline object3 = Polyline( + final object3 = Polyline( polylineId: const PolylineId('3'), startCap: customCap, endCap: Cap.roundCap, @@ -655,11 +632,9 @@ void main() { final VerificationResult verification = verify( api.updatePolylines(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; void expectPolyline(PlatformPolyline actual, Polyline expected) { expect(actual.polylineId, expected.polylineId.value); expect(actual.consumesTapEvents, expected.consumeTapEvents); @@ -699,17 +674,15 @@ void main() { }); test('updateTileOverlays passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const TileOverlay object1 = TileOverlay(tileOverlayId: TileOverlayId('1')); - const TileOverlay object2old = TileOverlay( - tileOverlayId: TileOverlayId('2'), - ); + const object1 = TileOverlay(tileOverlayId: TileOverlayId('1')); + const object2old = TileOverlay(tileOverlayId: TileOverlayId('2')); final TileOverlay object2new = object2old.copyWith(zIndexParam: 42); - const TileOverlay object3 = TileOverlay(tileOverlayId: TileOverlayId('3')); + const object3 = TileOverlay(tileOverlayId: TileOverlayId('3')); // Pre-set the initial state, since this update method doesn't take the old // state. await maps.updateTileOverlays( @@ -726,11 +699,9 @@ void main() { final VerificationResult verification = verify( api.updateTileOverlays(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; void expectTileOverlay(PlatformTileOverlay actual, TileOverlay expected) { expect(actual.tileOverlayId, expected.tileOverlayId.value); expect(actual.fadeIn, expected.fadeIn); @@ -752,18 +723,18 @@ void main() { }); test('updateGroundOverlays passes expected arguments', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - final AssetMapBitmap image = AssetMapBitmap( + final image = AssetMapBitmap( 'assets/red_square.png', imagePixelRatio: 1.0, bitmapScaling: MapBitmapScaling.none, ); - final GroundOverlay object1 = GroundOverlay.fromBounds( + final object1 = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('1'), bounds: LatLngBounds( southwest: const LatLng(10, 20), @@ -771,7 +742,7 @@ void main() { ), image: image, ); - final GroundOverlay object2old = GroundOverlay.fromBounds( + final object2old = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('2'), bounds: LatLngBounds( southwest: const LatLng(10, 20), @@ -786,7 +757,7 @@ void main() { transparencyParam: 0.5, zIndexParam: 100, ); - final GroundOverlay object3 = GroundOverlay.fromPosition( + final object3 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('3'), position: const LatLng(10, 20), width: 100, @@ -805,11 +776,9 @@ void main() { api.updateGroundOverlays(captureAny, captureAny, captureAny), ); - final List toAdd = - verification.captured[0] as List; - final List toChange = - verification.captured[1] as List; - final List toRemove = verification.captured[2] as List; + final toAdd = verification.captured[0] as List; + final toChange = verification.captured[1] as List; + final toRemove = verification.captured[2] as List; // Object one should be removed. expect(toRemove.length, 1); expect(toRemove.first, object1.groundOverlayId.value); @@ -892,18 +861,18 @@ void main() { test( 'updateGroundOverlays throws assertion error on unsupported ground overlays', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - final AssetMapBitmap image = AssetMapBitmap( + final image = AssetMapBitmap( 'assets/red_square.png', imagePixelRatio: 1.0, bitmapScaling: MapBitmapScaling.none, ); - final GroundOverlay object3 = GroundOverlay.fromPosition( + final object3 = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('1'), position: const LatLng(10, 20), // Assert should be thrown because zoomLevel is not set for position-based @@ -926,26 +895,26 @@ void main() { ); 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, - ); + const mapId = 1; + const dragStartId = 'drag-start-marker'; + const dragId = 'drag-marker'; + const dragEndId = 'drag-end-marker'; + final fakePosition = PlatformLatLng(latitude: 1.0, longitude: 1.0); - final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); + final maps = GoogleMapsFlutterIOS(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue markerDragStartStream = - StreamQueue(maps.onMarkerDragStart(mapId: mapId)); - final StreamQueue markerDragStream = - StreamQueue(maps.onMarkerDrag(mapId: mapId)); - final StreamQueue markerDragEndStream = - StreamQueue(maps.onMarkerDragEnd(mapId: mapId)); + final markerDragStartStream = StreamQueue( + maps.onMarkerDragStart(mapId: mapId), + ); + final markerDragStream = StreamQueue( + maps.onMarkerDrag(mapId: mapId), + ); + final markerDragEndStream = StreamQueue( + maps.onMarkerDragEnd(mapId: mapId), + ); // Simulate messages from the native side. callbackHandler.onMarkerDragStart(dragStartId, fakePosition); @@ -958,17 +927,15 @@ void main() { }); test('markers send tap events to correct stream', () async { - const int mapId = 1; - const String objectId = 'object-id'; + const mapId = 1; + const objectId = 'object-id'; - final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); + final maps = GoogleMapsFlutterIOS(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = StreamQueue( - maps.onMarkerTap(mapId: mapId), - ); + final stream = StreamQueue(maps.onMarkerTap(mapId: mapId)); // Simulate message from the native side. callbackHandler.onMarkerTap(objectId); @@ -977,17 +944,15 @@ void main() { }); test('circles send tap events to correct stream', () async { - const int mapId = 1; - const String objectId = 'object-id'; + const mapId = 1; + const objectId = 'object-id'; - final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); + final maps = GoogleMapsFlutterIOS(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = StreamQueue( - maps.onCircleTap(mapId: mapId), - ); + final stream = StreamQueue(maps.onCircleTap(mapId: mapId)); // Simulate message from the native side. callbackHandler.onCircleTap(objectId); @@ -996,30 +961,27 @@ 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 PlatformLatLngBounds fakeBounds = PlatformLatLngBounds( + const mapId = 1; + const managerId = 'manager-id'; + final fakePosition = PlatformLatLng(latitude: 10, longitude: 20); + final fakeBounds = PlatformLatLngBounds( southwest: PlatformLatLng(latitude: 30, longitude: 40), northeast: PlatformLatLng(latitude: 50, longitude: 60), ); - const List markerIds = ['marker-1', 'marker-2']; - final PlatformCluster cluster = PlatformCluster( + const markerIds = ['marker-1', 'marker-2']; + final cluster = PlatformCluster( clusterManagerId: managerId, position: fakePosition, bounds: fakeBounds, markerIds: markerIds, ); - final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); + final maps = GoogleMapsFlutterIOS(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = StreamQueue( + final stream = StreamQueue( maps.onClusterTap(mapId: mapId), ); @@ -1045,15 +1007,15 @@ void main() { }); test('polygons send tap events to correct stream', () async { - const int mapId = 1; - const String objectId = 'object-id'; + const mapId = 1; + const objectId = 'object-id'; - final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); + final maps = GoogleMapsFlutterIOS(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = StreamQueue( + final stream = StreamQueue( maps.onPolygonTap(mapId: mapId), ); @@ -1064,15 +1026,15 @@ void main() { }); test('polylines send tap events to correct stream', () async { - const int mapId = 1; - const String objectId = 'object-id'; + const mapId = 1; + const objectId = 'object-id'; - final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); + final maps = GoogleMapsFlutterIOS(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = StreamQueue( + final stream = StreamQueue( maps.onPolylineTap(mapId: mapId), ); @@ -1083,18 +1045,17 @@ void main() { }); test('ground overlays send tap events to correct stream', () async { - const int mapId = 1; - const String objectId = 'object-id'; + const mapId = 1; + const objectId = 'object-id'; - final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); + final maps = GoogleMapsFlutterIOS(); final HostMapMessageHandler callbackHandler = maps.ensureHandlerInitialized( mapId, ); - final StreamQueue stream = - StreamQueue( - maps.onGroundOverlayTap(mapId: mapId), - ); + final stream = StreamQueue( + maps.onGroundOverlayTap(mapId: mapId), + ); // Simulate message from the native side. callbackHandler.onGroundOverlayTap(objectId); @@ -1103,20 +1064,19 @@ void main() { }); test('moveCamera calls through with expected newCameraPosition', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const LatLng latLng = LatLng(10.0, 20.0); - const CameraPosition position = CameraPosition(target: latLng); + const latLng = LatLng(10.0, 20.0); + const position = CameraPosition(target: latLng); final CameraUpdate update = CameraUpdate.newCameraPosition(position); await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateNewCameraPosition typedUpdate = + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewCameraPosition; update as CameraUpdateNewCameraPosition; expect( @@ -1130,19 +1090,18 @@ void main() { }); test('moveCamera calls through with expected newLatLng', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const LatLng latLng = LatLng(10.0, 20.0); + const latLng = LatLng(10.0, 20.0); final CameraUpdate update = CameraUpdate.newLatLng(latLng); await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateNewLatLng typedUpdate = + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLng; update as CameraUpdateNewLatLng; expect(typedUpdate.latLng.latitude, update.latLng.latitude); @@ -1150,12 +1109,12 @@ void main() { }); test('moveCamera calls through with expected newLatLngBounds', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - final LatLngBounds latLng = LatLngBounds( + final latLng = LatLngBounds( northeast: const LatLng(10.0, 20.0), southwest: const LatLng(9.0, 21.0), ); @@ -1163,9 +1122,8 @@ void main() { await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateNewLatLngBounds typedUpdate = + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLngBounds; update as CameraUpdateNewLatLngBounds; expect( @@ -1188,19 +1146,18 @@ void main() { }); test('moveCamera calls through with expected newLatLngZoom', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const LatLng latLng = LatLng(10.0, 20.0); + const latLng = LatLng(10.0, 20.0); final CameraUpdate update = CameraUpdate.newLatLngZoom(latLng, 2.0); await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateNewLatLngZoom typedUpdate = + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateNewLatLngZoom; update as CameraUpdateNewLatLngZoom; expect(typedUpdate.latLng.latitude, update.latLng.latitude); @@ -1209,20 +1166,18 @@ void main() { }); test('moveCamera calls through with expected zoomBy', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); - const Offset focus = Offset(10.0, 20.0); + const focus = Offset(10.0, 20.0); final CameraUpdate update = CameraUpdate.zoomBy(2.0, focus); await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateZoomBy typedUpdate = - passedUpdate.cameraUpdate as PlatformCameraUpdateZoomBy; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateZoomBy; update as CameraUpdateZoomBy; expect(typedUpdate.focus?.x, update.focus?.dx); expect(typedUpdate.focus?.y, update.focus?.dy); @@ -1230,7 +1185,7 @@ void main() { }); test('moveCamera calls through with expected zoomTo', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); @@ -1239,16 +1194,14 @@ void main() { await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateZoomTo typedUpdate = - passedUpdate.cameraUpdate as PlatformCameraUpdateZoomTo; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateZoomTo; update as CameraUpdateZoomTo; expect(typedUpdate.zoom, update.zoom); }); test('moveCamera calls through with expected zoomIn', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); @@ -1257,15 +1210,13 @@ void main() { await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateZoom typedUpdate = - passedUpdate.cameraUpdate as PlatformCameraUpdateZoom; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateZoom; expect(typedUpdate.out, false); }); test('moveCamera calls through with expected zoomOut', () async { - const int mapId = 1; + const mapId = 1; final (GoogleMapsFlutterIOS maps, MockMapsApi api) = setUpMockMap( mapId: mapId, ); @@ -1274,10 +1225,8 @@ void main() { await maps.moveCamera(update, mapId: mapId); final VerificationResult verification = verify(api.moveCamera(captureAny)); - final PlatformCameraUpdate passedUpdate = - verification.captured[0] as PlatformCameraUpdate; - final PlatformCameraUpdateZoom typedUpdate = - passedUpdate.cameraUpdate as PlatformCameraUpdateZoom; + final passedUpdate = verification.captured[0] as PlatformCameraUpdate; + final typedUpdate = passedUpdate.cameraUpdate as PlatformCameraUpdateZoom; expect(typedUpdate.out, true); }); @@ -1301,13 +1250,12 @@ void main() { final PlatformBitmap platformBitmap = GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(bitmap); expect(platformBitmap.bitmap, isA()); - final PlatformBitmapDefaultMarker typedBitmap = - platformBitmap.bitmap as PlatformBitmapDefaultMarker; + final typedBitmap = platformBitmap.bitmap as PlatformBitmapDefaultMarker; expect(typedBitmap.hue, 10.0); }); test('BytesMapBitmap bitmap to PlatformBitmap', () { - final Uint8List data = Uint8List.fromList([1, 2, 3, 4]); + final data = Uint8List.fromList([1, 2, 3, 4]); final BytesMapBitmap bitmap = BitmapDescriptor.bytes( data, imagePixelRatio: 2.0, @@ -1317,8 +1265,7 @@ void main() { final PlatformBitmap platformBitmap = GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(bitmap); expect(platformBitmap.bitmap, isA()); - final PlatformBitmapBytesMap typedBitmap = - platformBitmap.bitmap as PlatformBitmapBytesMap; + final typedBitmap = platformBitmap.bitmap as PlatformBitmapBytesMap; expect(typedBitmap.byteData, data); expect(typedBitmap.bitmapScaling, PlatformMapBitmapScaling.auto); expect(typedBitmap.imagePixelRatio, 2.0); @@ -1327,8 +1274,8 @@ void main() { }); test('AssetMapBitmap bitmap to PlatformBitmap', () { - const String assetName = 'fake_asset_name'; - final AssetMapBitmap bitmap = AssetMapBitmap( + const assetName = 'fake_asset_name'; + final bitmap = AssetMapBitmap( assetName, imagePixelRatio: 2.0, width: 100.0, @@ -1337,8 +1284,7 @@ void main() { final PlatformBitmap platformBitmap = GoogleMapsFlutterIOS.platformBitmapFromBitmapDescriptor(bitmap); expect(platformBitmap.bitmap, isA()); - final PlatformBitmapAssetMap typedBitmap = - platformBitmap.bitmap as PlatformBitmapAssetMap; + final typedBitmap = platformBitmap.bitmap as PlatformBitmapAssetMap; expect(typedBitmap.assetName, assetName); expect(typedBitmap.bitmapScaling, PlatformMapBitmapScaling.auto); expect(typedBitmap.imagePixelRatio, 2.0); @@ -1347,21 +1293,21 @@ void main() { }); testWidgets('mapId is passed', (WidgetTester tester) async { - const String cloudMapId = '000000000000000'; // Dummy map ID. - final Completer passedCloudMapIdCompleter = Completer(); + const cloudMapId = '000000000000000'; // Dummy map ID. + final passedCloudMapIdCompleter = Completer(); TestDefaultBinaryMessengerBinding.instance.defaultBinaryMessenger .setMockMethodCallHandler(SystemChannels.platform_views, ( MethodCall methodCall, ) { if (methodCall.method == 'create') { - final Map args = Map.from( + final 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 = + final paramsUint8List = args['params'] as Uint8List; + final byteData = ByteData.sublistView(paramsUint8List); + final creationParams = MapsApi.pigeonChannelCodec.decodeMessage(byteData) as PlatformMapViewCreationParams?; if (creationParams != null) { @@ -1376,7 +1322,7 @@ void main() { return null; }); - final GoogleMapsFlutterIOS maps = GoogleMapsFlutterIOS(); + final maps = GoogleMapsFlutterIOS(); await tester.pumpWidget( Directionality( 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 67c8d78570e2..f9ad5d8def7b 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 @@ -256,7 +256,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { final Map arguments = _getArgumentDictionary(call); final Map? tileOverlaysForThisMap = _tileOverlays[mapId]; - final String tileOverlayId = arguments['tileOverlayId']! as String; + final tileOverlayId = arguments['tileOverlayId']! as String; final TileOverlay? tileOverlay = tileOverlaysForThisMap?[TileOverlayId(tileOverlayId)]; final TileProvider? tileProvider = tileOverlay?.tileProvider; @@ -271,7 +271,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { return tile.toJson(); case 'cluster#onTap': final Map arguments = _getArgumentDictionary(call); - final ClusterManagerId clusterManagerId = ClusterManagerId( + final clusterManagerId = ClusterManagerId( arguments['clusterManagerId']! as String, ); final LatLng position = LatLng.fromJson(arguments['position'])!; @@ -284,7 +284,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { ), ); - final LatLngBounds bounds = LatLngBounds( + final bounds = LatLngBounds( northeast: LatLng.fromJson(latLngData['northeast'])!, southwest: LatLng.fromJson(latLngData['southwest'])!, ); @@ -389,10 +389,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { final Set previousSet = currentTileOverlays != null ? currentTileOverlays.values.toSet() : {}; - final TileOverlayUpdates updates = TileOverlayUpdates.from( - previousSet, - newTileOverlays, - ); + final updates = TileOverlayUpdates.from(previousSet, newTileOverlays); _tileOverlays[mapId] = keyTileOverlayId(newTileOverlays); return channel( mapId, @@ -440,7 +437,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { final List successAndError = (await channel( mapId, ).invokeMethod>('map#setStyle', mapStyle))!; - final bool success = successAndError[0] as bool; + final success = successAndError[0] as bool; if (!success) { throw MapStyleException(successAndError[1] as String); } @@ -540,7 +537,7 @@ class MethodChannelGoogleMapsFlutter extends GoogleMapsFlutterPlatform { MapObjects mapObjects = const MapObjects(), Map mapOptions = const {}, }) { - final Map creationParams = { + final creationParams = { 'initialCameraPosition': widgetConfiguration.initialCameraPosition .toMap(), 'options': 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 66d5d24c6e41..e26d9dd5cbee 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 @@ -32,7 +32,7 @@ Object serializeMapsObjectUpdates>( MapsObjectUpdates updates, Object Function(T) serialize, ) { - final Map json = {}; + final json = {}; _addIfNonNull( json, @@ -57,7 +57,7 @@ Object serializeMapsObjectUpdates>( /// Serialize [Heatmap] Object serializeHeatmap(Heatmap heatmap) { - final Map json = {}; + final json = {}; _addIfNonNull(json, _heatmapIdKey, heatmap.heatmapId.value); _addIfNonNull( @@ -103,7 +103,7 @@ WeightedLatLng? deserializeWeightedLatLng(Object? json) { return null; } assert(json is List && json.length == 2); - final List list = json as List; + final list = json as List; final LatLng latLng = deserializeLatLng(list[0])!; return WeightedLatLng(latLng, weight: list[1] as double); } @@ -119,13 +119,13 @@ LatLng? deserializeLatLng(Object? json) { return null; } assert(json is List && json.length == 2); - final List list = json as List; + final list = json as List; return LatLng(list[0]! as double, list[1]! as double); } /// Serialize [HeatmapGradient] Object serializeHeatmapGradient(HeatmapGradient gradient) { - final Map json = {}; + final json = {}; _addIfNonNull( json, @@ -157,8 +157,8 @@ HeatmapGradient? deserializeHeatmapGradient(Object? json) { (map[_heatmapGradientStartPointsKey]! as List) .whereType() .toList(); - final List gradientColors = []; - for (int i = 0; i < colors.length; i++) { + final gradientColors = []; + for (var i = 0; i < colors.length; i++) { gradientColors.add(HeatmapGradientColor(colors[i], startPoints[i])); } return HeatmapGradient( 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 ef40f0ef7512..204daeb144e3 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 @@ -63,14 +63,14 @@ abstract class BitmapDescriptor { @Deprecated('No longer supported') static BitmapDescriptor fromJson(Object json) { assert(json is List); - final List jsonList = json as List; + final jsonList = json as List; assert(_validTypes.contains(jsonList[0])); switch (jsonList[0]) { case _defaultMarker: assert(jsonList.length <= 2); if (jsonList.length == 2) { assert(jsonList[1] is num); - final num secondElement = jsonList[1] as num; + final secondElement = jsonList[1] as num; assert(0 <= secondElement && secondElement < 360); return DefaultMarker(hue: secondElement); } @@ -101,7 +101,7 @@ abstract class BitmapDescriptor { if (jsonList.length == 4) { assert(jsonList[3] != null && jsonList[3] is List); assert((jsonList[3] as List).length == 2); - final List sizeList = jsonList[3] as List; + final sizeList = jsonList[3] as List; return AssetImageBitmap( name: jsonList[1] as String, scale: jsonList[2] as double, @@ -118,8 +118,7 @@ abstract class BitmapDescriptor { case AssetMapBitmap.type: assert(jsonList.length == 2); assert(jsonList[1] != null && jsonList[1] is Map); - final Map jsonMap = - jsonList[1] as Map; + final jsonMap = jsonList[1] as Map; assert(jsonMap.containsKey('assetName')); assert(jsonMap.containsKey('bitmapScaling')); assert(jsonMap.containsKey('imagePixelRatio')); @@ -146,8 +145,7 @@ abstract class BitmapDescriptor { case BytesMapBitmap.type: assert(jsonList.length == 2); assert(jsonList[1] != null && jsonList[1] is Map); - final Map jsonMap = - jsonList[1] as Map; + final jsonMap = jsonList[1] as Map; assert(jsonMap.containsKey('byteData')); assert(jsonMap.containsKey('bitmapScaling')); assert(jsonMap.containsKey('imagePixelRatio')); @@ -256,11 +254,7 @@ abstract class BitmapDescriptor { if (!mipmaps && devicePixelRatio != null) { return AssetImageBitmap(name: assetName, scale: devicePixelRatio); } - final AssetImage assetImage = AssetImage( - assetName, - package: package, - bundle: bundle, - ); + final assetImage = AssetImage(assetName, package: package, bundle: bundle); final AssetBundleImageKey assetBundleImageKey = await assetImage.obtainKey( configuration, ); @@ -811,11 +805,7 @@ 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 assetImage = AssetImage(assetName, package: package, bundle: bundle); final AssetBundleImageKey assetBundleImageKey = await assetImage.obtainKey( configuration, ); 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 2bf92bec7e68..76dd69455c4b 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,9 +35,7 @@ class ArgumentCallbacks { if (length == 1) { _callbacks[0].call(argument); } else if (0 < length) { - for (final ArgumentCallback callback in List>.from( - _callbacks, - )) { + for (final callback in List>.from(_callbacks)) { callback(argument); } } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart index c81e2184cbf1..be23b0e72868 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/circle.dart @@ -111,7 +111,7 @@ class Circle implements MapsObject { /// Converts this object to something serializable in JSON. @override Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { 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 67df384078d5..db6cc0e455e8 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 @@ -46,7 +46,7 @@ class ClusterManager implements MapsObject { /// Converts this object to something serializable in JSON. @override Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { 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 bf712c71ab6e..62d77a98c25e 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 @@ -310,7 +310,7 @@ class GroundOverlay implements MapsObject { /// Converts this object to something serializable in JSON. @override Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { 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 950711868ea4..993a482c9409 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 @@ -166,7 +166,7 @@ class Heatmap implements MapsObject { /// Converts this object to something serializable in JSON. @override Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { @@ -283,7 +283,7 @@ class HeatmapGradient { /// Converts this object to something serializable in JSON. Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { 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 6879757087f5..9c193950a3ac 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 @@ -39,7 +39,7 @@ class LatLng { return null; } assert(json is List && json.length == 2); - final List list = json as List; + final list = json as List; return LatLng(list[0]! as double, list[1]! as double); } @@ -111,7 +111,7 @@ class LatLngBounds { return null; } assert(json is List && json.length == 2); - final List list = json as List; + final list = json as List; return LatLngBounds( southwest: LatLng.fromJson(list[0])!, northeast: LatLng.fromJson(list[1])!, 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 85f9d2da4c11..33bf6efdc7ea 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 @@ -82,7 +82,7 @@ class MapsObjectUpdates> { /// Converts this object to JSON. Object toJson() { - final Map updateMap = {}; + final updateMap = {}; void addIfNonNull(String fieldName, Object? value) { if (value != null) { 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 3de612c04e5e..7756ce422955 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 @@ -66,7 +66,7 @@ class InfoWindow { /// Converts this object to something serializable in JSON. Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { @@ -317,7 +317,7 @@ class Marker implements MapsObject { /// Converts this object to something serializable in JSON. @override Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart index 1cf820f08497..d555074d7a69 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polygon.dart @@ -131,7 +131,7 @@ class Polygon implements MapsObject { /// Converts this object to something serializable in JSON. @override Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { @@ -180,7 +180,7 @@ class Polygon implements MapsObject { int get hashCode => polygonId.hashCode; Object _pointsToJson() { - final List result = []; + final result = []; for (final LatLng point in points) { result.add(point.toJson()); } @@ -188,10 +188,10 @@ class Polygon implements MapsObject { } List> _holesToJson() { - final List> result = >[]; + final result = >[]; for (final List hole in holes) { - final List jsonHole = []; - for (final LatLng point in hole) { + final jsonHole = []; + for (final point in hole) { jsonHole.add(point.toJson()); } result.add(jsonHole); diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart index 6dcee15fd63b..6312d2635e98 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/polyline.dart @@ -161,7 +161,7 @@ class Polyline implements MapsObject { /// Converts this object to something serializable in JSON. @override Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { @@ -214,7 +214,7 @@ class Polyline implements MapsObject { int get hashCode => polylineId.hashCode; Object _pointsToJson() { - final List result = []; + final result = []; for (final LatLng point in points) { result.add(point.toJson()); } @@ -222,7 +222,7 @@ class Polyline implements MapsObject { } Object _patternToJson() { - final List result = []; + final result = []; for (final PatternItem patternItem in patterns) { result.add(patternItem.toJson()); } diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile.dart index 6a14cfbc6850..654095b7ae2c 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/lib/src/types/tile.dart @@ -25,7 +25,7 @@ class Tile { /// Converts this object to JSON. Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { 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 e12458d83a07..7732b841306b 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 @@ -112,7 +112,7 @@ class TileOverlay implements MapsObject { /// Converts this object to JSON. @override Object toJson() { - final Map json = {}; + final json = {}; void addIfPresent(String fieldName, Object? value) { if (value != null) { 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 6a998465c421..83d9adfe247d 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 @@ -54,9 +54,8 @@ void main() { // TODO(stuartmorgan): Remove this once there is real test coverage of // each method, since that would cover this issue. test('non-void invokeMethods handle types correctly', () async { - const int mapId = 0; - final MethodChannelGoogleMapsFlutter maps = - MethodChannelGoogleMapsFlutter(); + const mapId = 0; + final maps = MethodChannelGoogleMapsFlutter(); configureMockMap( maps, mapId: mapId, @@ -87,35 +86,35 @@ void main() { ]); }); test('markers send drag event to correct streams', () async { - const int mapId = 1; - final Map jsonMarkerDragStartEvent = { + const mapId = 1; + final jsonMarkerDragStartEvent = { 'mapId': mapId, 'markerId': 'drag-start-marker', 'position': [1.0, 1.0], }; - final Map jsonMarkerDragEvent = { + final jsonMarkerDragEvent = { 'mapId': mapId, 'markerId': 'drag-marker', 'position': [1.0, 1.0], }; - final Map jsonMarkerDragEndEvent = { + final jsonMarkerDragEndEvent = { 'mapId': mapId, 'markerId': 'drag-end-marker', 'position': [1.0, 1.0], }; - final MethodChannelGoogleMapsFlutter maps = - MethodChannelGoogleMapsFlutter(); + final maps = MethodChannelGoogleMapsFlutter(); maps.ensureChannelInitialized(mapId); - final StreamQueue markerDragStartStream = - StreamQueue( - maps.onMarkerDragStart(mapId: mapId), - ); - final StreamQueue markerDragStream = - StreamQueue(maps.onMarkerDrag(mapId: mapId)); - final StreamQueue markerDragEndStream = - StreamQueue(maps.onMarkerDragEnd(mapId: mapId)); + final markerDragStartStream = StreamQueue( + maps.onMarkerDragStart(mapId: mapId), + ); + final markerDragStream = StreamQueue( + maps.onMarkerDrag(mapId: mapId), + ); + final markerDragEndStream = StreamQueue( + maps.onMarkerDragEnd(mapId: mapId), + ); await sendPlatformMessage( mapId, 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 033421ea014a..1f72413a9485 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 @@ -38,8 +38,7 @@ void main() { }); test('Can be mocked with `implements`', () { - final GoogleMapsFlutterPlatformMock mock = - GoogleMapsFlutterPlatformMock(); + final mock = GoogleMapsFlutterPlatformMock(); GoogleMapsFlutterPlatform.instance = mock; }); @@ -131,8 +130,9 @@ void main() { ExtendsGoogleMapsFlutterPlatform(); GoogleMapsFlutterPlatform.instance = platform; - const CameraUpdateAnimationConfiguration animationConfig = - CameraUpdateAnimationConfiguration(duration: Duration(seconds: 2)); + const animationConfig = CameraUpdateAnimationConfiguration( + duration: Duration(seconds: 2), + ); final CameraUpdate cameraUpdate = CameraUpdate.newCameraPosition( const CameraPosition(target: LatLng(10.0, 15.0)), ); 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 a794cd5986ff..1db90a8dd14d 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,9 +9,7 @@ void main() { group('$AdvancedMarker', () { test('constructor defaults', () { - final AdvancedMarker marker = AdvancedMarker( - markerId: const MarkerId('ABC123'), - ); + final marker = AdvancedMarker(markerId: const MarkerId('ABC123')); expect(marker.alpha, equals(1.0)); expect(marker.anchor, equals(const Offset(0.5, 1.0))); @@ -46,7 +44,7 @@ void main() { test('toJson', () { final BitmapDescriptor testDescriptor = BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueCyan); - final AdvancedMarker marker = AdvancedMarker( + final marker = AdvancedMarker( markerId: const MarkerId('ABC123'), alpha: 0.12345, anchor: const Offset(100, 100), @@ -70,7 +68,7 @@ void main() { collisionBehavior: MarkerCollisionBehavior.requiredAndHidesOptional, ); - final Map json = marker.toJson() as Map; + final json = marker.toJson() as Map; expect(json, { 'markerId': 'ABC123', @@ -104,26 +102,24 @@ void main() { }); test('copyWith', () { - const MarkerId markerId = MarkerId('ABC123'); - final AdvancedMarker marker = AdvancedMarker(markerId: markerId); + const markerId = MarkerId('ABC123'); + final marker = AdvancedMarker(markerId: markerId); final BitmapDescriptor testDescriptor = BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueCyan); - const double testAlphaParam = 0.12345; - const Offset testAnchorParam = Offset(100, 100); + const testAlphaParam = 0.12345; + const testAnchorParam = Offset(100, 100); final bool testConsumeTapEventsParam = !marker.consumeTapEvents; final bool testDraggableParam = !marker.draggable; final bool testFlatParam = !marker.flat; - final BitmapDescriptor testIconParam = testDescriptor; - const InfoWindow testInfoWindowParam = InfoWindow(title: 'Test'); - const LatLng testPositionParam = LatLng(100, 100); + final testIconParam = testDescriptor; + const testInfoWindowParam = InfoWindow(title: 'Test'); + const testPositionParam = LatLng(100, 100); const double testRotationParam = 100; final bool testVisibleParam = !marker.visible; const double testZIndexParam = 100; - const ClusterManagerId testClusterManagerIdParam = ClusterManagerId( - 'DEF123', - ); - final List log = []; + const testClusterManagerIdParam = ClusterManagerId('DEF123'); + final log = []; const MarkerCollisionBehavior testCollisionBehavior = MarkerCollisionBehavior.requiredAndHidesOptional; @@ -184,7 +180,7 @@ void main() { }); test('zIndex param', () { - final AdvancedMarker marker = AdvancedMarker( + final marker = AdvancedMarker( markerId: const MarkerId('ABC123'), zIndex: 5, ); @@ -194,7 +190,7 @@ void main() { }); test('zIndexInt param copyWith', () { - final AdvancedMarker marker = AdvancedMarker( + final marker = AdvancedMarker( markerId: const MarkerId('ABC123'), zIndex: 5, ); @@ -204,7 +200,7 @@ void main() { }); test('zIndex param copyWith', () { - final AdvancedMarker marker = AdvancedMarker( + final marker = AdvancedMarker( markerId: const MarkerId('ABC123'), zIndex: 5, ); 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 13ccb726840b..dee07c006a2b 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 @@ -219,9 +219,7 @@ void main() { test( 'mipmaps determines dpi', () async { - const ImageConfiguration imageConfiguration = ImageConfiguration( - devicePixelRatio: 3, - ); + const imageConfiguration = ImageConfiguration(devicePixelRatio: 3); final BitmapDescriptor mip = await BitmapDescriptor.fromAssetImage( imageConfiguration, @@ -592,10 +590,8 @@ void main() { ); test('create with size', () async { - const Size size = Size(100, 200); - const ImageConfiguration imageConfiguration = ImageConfiguration( - size: size, - ); + const size = Size(100, 200); + const imageConfiguration = ImageConfiguration(size: size); final BitmapDescriptor descriptor = await AssetMapBitmap.create( imageConfiguration, 'red_square.png', @@ -774,7 +770,7 @@ void main() { }); test('construct', () { - const PinConfig pinConfig = PinConfig( + const pinConfig = PinConfig( backgroundColor: Colors.green, borderColor: Colors.blue, ); @@ -791,7 +787,7 @@ void main() { }); test('construct with glyph text', () { - const PinConfig pinConfig = PinConfig( + const pinConfig = PinConfig( backgroundColor: Colors.green, borderColor: Colors.blue, glyph: TextGlyph(text: 'Hello', textColor: Colors.red), @@ -814,7 +810,7 @@ void main() { test('construct with glyph bitmap', () async { const BitmapDescriptor bitmap = AssetBitmap(name: 'red_square.png'); - const PinConfig pinConfig = PinConfig( + const pinConfig = PinConfig( backgroundColor: Colors.black, borderColor: Colors.red, glyph: BitmapGlyph(bitmap: bitmap), 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 7a7449ea2138..0ecb775e2cf9 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 @@ -9,7 +9,7 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); test('toMap / fromMap', () { - const CameraPosition cameraPosition = CameraPosition( + const cameraPosition = CameraPosition( target: LatLng(10.0, 15.0), bearing: 0.5, tilt: 30.0, @@ -26,7 +26,7 @@ void main() { }); test('CameraUpdate.newCameraPosition', () { - const CameraPosition cameraPosition = CameraPosition( + const cameraPosition = CameraPosition( target: LatLng(10.0, 15.0), bearing: 0.5, tilt: 30.0, @@ -39,27 +39,27 @@ void main() { expect(cameraUpdate.updateType, CameraUpdateType.newCameraPosition); cameraUpdate as CameraUpdateNewCameraPosition; expect(cameraUpdate.cameraPosition, cameraPosition); - final List jsonList = cameraUpdate.toJson() as List; + final jsonList = cameraUpdate.toJson() as List; expect(jsonList[0], 'newCameraPosition'); }); test('CameraUpdate.newLatLng', () { - const LatLng latLng = LatLng(1.0, 2.0); + const latLng = LatLng(1.0, 2.0); final CameraUpdate cameraUpdate = CameraUpdate.newLatLng(latLng); expect(cameraUpdate.runtimeType, CameraUpdateNewLatLng); expect(cameraUpdate.updateType, CameraUpdateType.newLatLng); cameraUpdate as CameraUpdateNewLatLng; expect(cameraUpdate.latLng, latLng); - final List jsonList = cameraUpdate.toJson() as List; + final jsonList = cameraUpdate.toJson() as List; expect(jsonList[0], 'newLatLng'); }); test('CameraUpdate.newLatLngBounds', () { - final LatLngBounds latLngBounds = LatLngBounds( + final latLngBounds = LatLngBounds( northeast: const LatLng(1.0, 2.0), southwest: const LatLng(-2.0, -3.0), ); - const double padding = 1.0; + const padding = 1.0; final CameraUpdate cameraUpdate = CameraUpdate.newLatLngBounds( latLngBounds, padding, @@ -69,46 +69,46 @@ void main() { cameraUpdate as CameraUpdateNewLatLngBounds; expect(cameraUpdate.bounds, latLngBounds); expect(cameraUpdate.padding, padding); - final List jsonList = cameraUpdate.toJson() as List; + final jsonList = cameraUpdate.toJson() as List; expect(jsonList[0], 'newLatLngBounds'); }); test('CameraUpdate.newLatLngZoom', () { - const LatLng latLng = LatLng(1.0, 2.0); - const double zoom = 2.0; + const latLng = LatLng(1.0, 2.0); + const zoom = 2.0; final CameraUpdate cameraUpdate = CameraUpdate.newLatLngZoom(latLng, zoom); expect(cameraUpdate.runtimeType, CameraUpdateNewLatLngZoom); expect(cameraUpdate.updateType, CameraUpdateType.newLatLngZoom); cameraUpdate as CameraUpdateNewLatLngZoom; expect(cameraUpdate.latLng, latLng); expect(cameraUpdate.zoom, zoom); - final List jsonList = cameraUpdate.toJson() as List; + final jsonList = cameraUpdate.toJson() as List; expect(jsonList[0], 'newLatLngZoom'); }); test('CameraUpdate.scrollBy', () { - const double dx = 2.0; - const double dy = 5.0; + const dx = 2.0; + const dy = 5.0; final CameraUpdate cameraUpdate = CameraUpdate.scrollBy(dx, dy); expect(cameraUpdate.runtimeType, CameraUpdateScrollBy); expect(cameraUpdate.updateType, CameraUpdateType.scrollBy); cameraUpdate as CameraUpdateScrollBy; expect(cameraUpdate.dx, dx); expect(cameraUpdate.dy, dy); - final List jsonList = cameraUpdate.toJson() as List; + final jsonList = cameraUpdate.toJson() as List; expect(jsonList[0], 'scrollBy'); }); test('CameraUpdate.zoomBy', () { - const double amount = 1.5; - const Offset focus = Offset(-1.0, -2.0); + const amount = 1.5; + const focus = Offset(-1.0, -2.0); final CameraUpdate cameraUpdate = CameraUpdate.zoomBy(amount, focus); expect(cameraUpdate.runtimeType, CameraUpdateZoomBy); expect(cameraUpdate.updateType, CameraUpdateType.zoomBy); cameraUpdate as CameraUpdateZoomBy; expect(cameraUpdate.amount, amount); expect(cameraUpdate.focus, focus); - final List jsonList = cameraUpdate.toJson() as List; + final jsonList = cameraUpdate.toJson() as List; expect(jsonList[0], 'zoomBy'); }); @@ -116,7 +116,7 @@ void main() { final CameraUpdate cameraUpdate = CameraUpdate.zoomIn(); expect(cameraUpdate.runtimeType, CameraUpdateZoomIn); expect(cameraUpdate.updateType, CameraUpdateType.zoomIn); - final List jsonList = cameraUpdate.toJson() as List; + final jsonList = cameraUpdate.toJson() as List; expect(jsonList[0], 'zoomIn'); }); @@ -124,7 +124,7 @@ void main() { final CameraUpdate cameraUpdate = CameraUpdate.zoomOut(); expect(cameraUpdate.runtimeType, CameraUpdateZoomOut); expect(cameraUpdate.updateType, CameraUpdateType.zoomOut); - final List jsonList = cameraUpdate.toJson() as List; + final jsonList = cameraUpdate.toJson() as List; expect(jsonList[0], 'zoomOut'); }); } 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 31aed908b9ce..a842eed38dfa 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,7 +11,7 @@ void main() { group('$ClusterManager', () { test('constructor defaults', () { - const ClusterManager manager = ClusterManager( + const manager = ClusterManager( clusterManagerId: ClusterManagerId('1234'), ); @@ -19,16 +19,16 @@ void main() { }); test('toJson', () { - const ClusterManager manager = ClusterManager( + const manager = ClusterManager( clusterManagerId: ClusterManagerId('1234'), ); - final Map json = manager.toJson() as Map; + final json = manager.toJson() as Map; expect(json, {'clusterManagerId': '1234'}); }); test('clone', () { - const ClusterManager manager = ClusterManager( + const manager = ClusterManager( clusterManagerId: ClusterManagerId('1234'), ); final ClusterManager clone = manager.clone(); @@ -37,10 +37,10 @@ void main() { expect(clone, equals(manager)); }); test('copyWith', () { - const ClusterManager manager = ClusterManager( + const manager = ClusterManager( clusterManagerId: ClusterManagerId('1234'), ); - final List log = []; + final log = []; final ClusterManager copy = manager.copyWith( onClusterTapParam: (Cluster cluster) { 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 0cd37b2d40f1..8641cb5fc854 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 @@ -11,7 +11,7 @@ void main() { group('$Cluster', () { test('constructor', () { - final Cluster cluster = Cluster( + final cluster = Cluster( const ClusterManagerId('3456787654'), const [MarkerId('23456')], position: const LatLng(55.0, 66.0), diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/ground_overlay_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/ground_overlay_test.dart index 471b60412fb8..0b756643dcd5 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/ground_overlay_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/ground_overlay_test.dart @@ -9,29 +9,29 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); group('GroundOverlay', () { - const GroundOverlayId kID = GroundOverlayId('groundOverlay'); - final LatLngBounds kBounds = LatLngBounds( + const kID = GroundOverlayId('groundOverlay'); + final kBounds = LatLngBounds( southwest: const LatLng(37.42, -122.08), northeast: const LatLng(37.43, -122.09), ); - const LatLng kPosition = LatLng(37.42, -122.08); + const kPosition = LatLng(37.42, -122.08); final MapBitmap kMapBitmap = AssetMapBitmap( 'assets/asset.png', imagePixelRatio: 1.0, bitmapScaling: MapBitmapScaling.none, ); - const Offset kAnchor = Offset(0.3, 0.7); - const double kBearing = 45.0; - const double kTransparency = 0.5; - const int kZIndex = 1; - const bool kVisible = false; - const bool kClickable = false; + const kAnchor = Offset(0.3, 0.7); + const kBearing = 45.0; + const kTransparency = 0.5; + const kZIndex = 1; + const kVisible = false; + const kClickable = false; const double kWidth = 200; const double kHeight = 300; - const double kZoomLevel = 10.0; + const kZoomLevel = 10.0; test('fromBounds constructor defaults', () { - final GroundOverlay groundOverlay = GroundOverlay.fromBounds( + final groundOverlay = GroundOverlay.fromBounds( groundOverlayId: kID, image: kMapBitmap, bounds: kBounds, @@ -50,7 +50,7 @@ void main() { }); test('fromBounds construct with values', () { - final GroundOverlay groundOverlay = GroundOverlay.fromBounds( + final groundOverlay = GroundOverlay.fromBounds( groundOverlayId: kID, image: kMapBitmap, bounds: kBounds, @@ -74,7 +74,7 @@ void main() { }); test('fromPosition constructor defaults', () { - final GroundOverlay groundOverlay = GroundOverlay.fromPosition( + final groundOverlay = GroundOverlay.fromPosition( groundOverlayId: kID, image: kMapBitmap, position: kPosition, @@ -97,7 +97,7 @@ void main() { }); test('fromPosition construct with values', () { - final GroundOverlay groundOverlay = GroundOverlay.fromPosition( + final groundOverlay = GroundOverlay.fromPosition( groundOverlayId: kID, image: kMapBitmap, position: kPosition, @@ -127,7 +127,7 @@ void main() { }); test('copyWith fromPosition', () { - final GroundOverlay groundOverlay1 = GroundOverlay.fromPosition( + final groundOverlay1 = GroundOverlay.fromPosition( groundOverlayId: kID, image: kMapBitmap, position: kPosition, @@ -159,7 +159,7 @@ void main() { }); test('copyWith fromBounds', () { - final GroundOverlay groundOverlay1 = GroundOverlay.fromBounds( + final groundOverlay1 = GroundOverlay.fromBounds( groundOverlayId: kID, image: kMapBitmap, bounds: kBounds, @@ -189,7 +189,7 @@ void main() { }); test('fromPosition clone', () { - final GroundOverlay groundOverlay1 = GroundOverlay.fromPosition( + final groundOverlay1 = GroundOverlay.fromPosition( groundOverlayId: kID, image: kMapBitmap, position: kPosition, @@ -203,7 +203,7 @@ void main() { }); test('fromBounds clone', () { - final GroundOverlay groundOverlay1 = GroundOverlay.fromBounds( + final groundOverlay1 = GroundOverlay.fromBounds( groundOverlayId: kID, image: kMapBitmap, bounds: kBounds, @@ -215,7 +215,7 @@ void main() { }); test('==', () { - final GroundOverlay groundOverlayPosition1 = GroundOverlay.fromPosition( + final groundOverlayPosition1 = GroundOverlay.fromPosition( groundOverlayId: kID, image: kMapBitmap, position: kPosition, @@ -230,7 +230,7 @@ void main() { zoomLevel: kZoomLevel, ); - final GroundOverlay groundOverlayPosition2 = GroundOverlay.fromPosition( + final groundOverlayPosition2 = GroundOverlay.fromPosition( groundOverlayId: kID, image: kMapBitmap, position: kPosition, @@ -245,7 +245,7 @@ void main() { zoomLevel: kZoomLevel, ); - final GroundOverlay groundOverlayPosition3 = GroundOverlay.fromPosition( + final groundOverlayPosition3 = GroundOverlay.fromPosition( groundOverlayId: kID, image: kMapBitmap, position: kPosition, @@ -260,7 +260,7 @@ void main() { zoomLevel: kZoomLevel + 1, ); - final GroundOverlay groundOverlayBounds1 = GroundOverlay.fromBounds( + final groundOverlayBounds1 = GroundOverlay.fromBounds( groundOverlayId: kID, image: kMapBitmap, bounds: kBounds, @@ -272,7 +272,7 @@ void main() { clickable: kClickable, ); - final GroundOverlay groundOverlayBounds2 = GroundOverlay.fromBounds( + final groundOverlayBounds2 = GroundOverlay.fromBounds( groundOverlayId: kID, image: kMapBitmap, bounds: kBounds, @@ -284,7 +284,7 @@ void main() { clickable: kClickable, ); - final GroundOverlay groundOverlayBounds3 = GroundOverlay.fromBounds( + final groundOverlayBounds3 = GroundOverlay.fromBounds( groundOverlayId: kID, image: kMapBitmap, bounds: kBounds, @@ -304,7 +304,7 @@ void main() { }); test('hashCode', () { - final GroundOverlay groundOverlay = GroundOverlay.fromPosition( + final groundOverlay = GroundOverlay.fromPosition( groundOverlayId: kID, image: kMapBitmap, position: kPosition, 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 44f3a135b4f9..83d3b848bd38 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 @@ -11,37 +11,31 @@ void main() { group('$HeatmapRadius', () { test('fromPixels', () { - const HeatmapRadius radius = HeatmapRadius.fromPixels(10); + const radius = HeatmapRadius.fromPixels(10); expect(radius.radius, 10); }); test('==', () { - const HeatmapRadius radius1 = HeatmapRadius.fromPixels(10); - const HeatmapRadius radius2 = HeatmapRadius.fromPixels(10); - const HeatmapRadius radius3 = HeatmapRadius.fromPixels(20); + const radius1 = HeatmapRadius.fromPixels(10); + const radius2 = HeatmapRadius.fromPixels(10); + const radius3 = HeatmapRadius.fromPixels(20); expect(radius1, radius2); expect(radius1, isNot(radius3)); }); test('hashCode', () { - const int radius = 10; - const HeatmapRadius heatmapRadius = HeatmapRadius.fromPixels(radius); + const radius = 10; + const heatmapRadius = HeatmapRadius.fromPixels(radius); expect(heatmapRadius.hashCode, radius.hashCode); }); }); group('$Heatmap', () { test('constructor defaults', () { - const HeatmapId id = HeatmapId('heatmap'); - const List data = [ - WeightedLatLng(LatLng(1, 1)), - ]; - const HeatmapRadius radius = HeatmapRadius.fromPixels(10); - const Heatmap heatmap = Heatmap( - heatmapId: id, - data: data, - radius: radius, - ); + const id = HeatmapId('heatmap'); + const data = [WeightedLatLng(LatLng(1, 1))]; + const radius = HeatmapRadius.fromPixels(10); + const heatmap = Heatmap(heatmapId: id, data: data, radius: radius); expect(heatmap.heatmapId, id); expect(heatmap.data, data); @@ -57,19 +51,17 @@ void main() { }); test('construct with values', () { - const HeatmapId id = HeatmapId('heatmap'); - const List data = [ - WeightedLatLng(LatLng(1, 1)), - ]; - const HeatmapGradient gradient = HeatmapGradient([ + const id = HeatmapId('heatmap'); + const data = [WeightedLatLng(LatLng(1, 1))]; + const gradient = HeatmapGradient([ HeatmapGradientColor(Colors.red, 0.0), ]); - const double maxIntensity = 1.0; - const double opacity = 0.5; - const HeatmapRadius radius = HeatmapRadius.fromPixels(10); - const int minimumZoomIntensity = 1; - const int maximumZoomIntensity = 20; - const Heatmap heatmap = Heatmap( + const maxIntensity = 1.0; + const opacity = 0.5; + const radius = HeatmapRadius.fromPixels(10); + const minimumZoomIntensity = 1; + const maximumZoomIntensity = 20; + const heatmap = Heatmap( heatmapId: id, data: data, dissipating: false, @@ -93,23 +85,21 @@ void main() { }); test('copyWith', () { - const Heatmap heatmap1 = Heatmap( + const heatmap1 = Heatmap( heatmapId: HeatmapId('heatmap'), data: [], radius: HeatmapRadius.fromPixels(10), ); - const List data = [ - WeightedLatLng(LatLng(1, 1)), - ]; - const HeatmapGradient gradient = HeatmapGradient([ + const data = [WeightedLatLng(LatLng(1, 1))]; + const gradient = HeatmapGradient([ HeatmapGradientColor(Colors.red, 0.0), ]); - const double maxIntensity = 1.0; - const double opacity = 0.5; - const HeatmapRadius radius = HeatmapRadius.fromPixels(20); - const int minimumZoomIntensity = 1; - const int maximumZoomIntensity = 20; + const maxIntensity = 1.0; + const opacity = 0.5; + const radius = HeatmapRadius.fromPixels(20); + const minimumZoomIntensity = 1; + const maximumZoomIntensity = 20; final Heatmap heatmap2 = heatmap1.copyWith( dataParam: data, @@ -133,7 +123,7 @@ void main() { }); test('clone', () { - const Heatmap heatmap1 = Heatmap( + const heatmap1 = Heatmap( heatmapId: HeatmapId('heatmap'), data: [], radius: HeatmapRadius.fromPixels(10), @@ -145,22 +135,12 @@ void main() { }); test('==', () { - const HeatmapId id = HeatmapId('heatmap'); - const List data = [ - WeightedLatLng(LatLng(1, 1)), - ]; - const HeatmapRadius radius = HeatmapRadius.fromPixels(10); - const Heatmap heatmap1 = Heatmap( - heatmapId: id, - data: data, - radius: radius, - ); - const Heatmap heatmap2 = Heatmap( - heatmapId: id, - data: data, - radius: radius, - ); - const Heatmap heatmap3 = Heatmap( + const id = HeatmapId('heatmap'); + const data = [WeightedLatLng(LatLng(1, 1))]; + const radius = HeatmapRadius.fromPixels(10); + const heatmap1 = Heatmap(heatmapId: id, data: data, radius: radius); + const heatmap2 = Heatmap(heatmapId: id, data: data, radius: radius); + const heatmap3 = Heatmap( heatmapId: id, data: data, radius: HeatmapRadius.fromPixels(20), @@ -171,8 +151,8 @@ void main() { }); test('hashCode', () { - const HeatmapId id = HeatmapId('heatmap'); - const Heatmap heatmap = Heatmap( + const id = HeatmapId('heatmap'); + const heatmap = Heatmap( heatmapId: id, data: [], radius: HeatmapRadius.fromPixels(10), @@ -184,26 +164,26 @@ void main() { group('$WeightedLatLng', () { test('constructor defaults', () { - const LatLng point = LatLng(1, 1); - const WeightedLatLng wll = WeightedLatLng(point); + const point = LatLng(1, 1); + const wll = WeightedLatLng(point); expect(wll.point, point); expect(wll.weight, 1.0); }); test('construct with values', () { - const LatLng point = LatLng(1, 1); - const double weight = 2.0; - const WeightedLatLng wll = WeightedLatLng(point, weight: weight); + const point = LatLng(1, 1); + const weight = 2.0; + const wll = WeightedLatLng(point, weight: weight); expect(wll.point, point); expect(wll.weight, weight); }); test('toJson', () { - const LatLng point = LatLng(1, 1); - const double weight = 2.0; - const WeightedLatLng wll = WeightedLatLng(point, weight: weight); + const point = LatLng(1, 1); + const weight = 2.0; + const wll = WeightedLatLng(point, weight: weight); expect(wll.toJson(), [ [point.latitude, point.longitude], @@ -212,28 +192,28 @@ void main() { }); test('toString', () { - const LatLng point = LatLng(1, 1); - const double weight = 2.0; - const WeightedLatLng wll = WeightedLatLng(point, weight: weight); + const point = LatLng(1, 1); + const weight = 2.0; + const wll = WeightedLatLng(point, weight: weight); expect(wll.toString(), 'WeightedLatLng($point, $weight)'); }); test('==', () { - const LatLng point = LatLng(1, 1); - const double weight = 2.0; - const WeightedLatLng wll1 = WeightedLatLng(point, weight: weight); - const WeightedLatLng wll2 = WeightedLatLng(point, weight: weight); - const WeightedLatLng wll3 = WeightedLatLng(point, weight: 3.0); + const point = LatLng(1, 1); + const weight = 2.0; + const wll1 = WeightedLatLng(point, weight: weight); + const wll2 = WeightedLatLng(point, weight: weight); + const wll3 = WeightedLatLng(point, weight: 3.0); expect(wll1, wll2); expect(wll1, isNot(wll3)); }); test('hashCode', () { - const LatLng point = LatLng(1, 1); - const double weight = 2.0; - const WeightedLatLng wll = WeightedLatLng(point, weight: weight); + const point = LatLng(1, 1); + const weight = 2.0; + const wll = WeightedLatLng(point, weight: weight); expect(wll.hashCode, Object.hash(point, weight)); }); @@ -241,38 +221,35 @@ void main() { group('$HeatmapGradient', () { test('constructor defaults', () { - const List colors = [ + const colors = [ HeatmapGradientColor(Colors.red, 0.0), ]; - const HeatmapGradient gradient = HeatmapGradient(colors); + const gradient = HeatmapGradient(colors); expect(gradient.colors, colors); expect(gradient.colorMapSize, 256); }); test('construct with values', () { - const List colors = [ + const colors = [ HeatmapGradientColor(Colors.red, 0.0), ]; - const int colorMapSize = 512; - const HeatmapGradient gradient = HeatmapGradient( - colors, - colorMapSize: colorMapSize, - ); + const colorMapSize = 512; + const gradient = HeatmapGradient(colors, colorMapSize: colorMapSize); expect(gradient.colors, colors); expect(gradient.colorMapSize, colorMapSize); }); test('copyWith', () { - const HeatmapGradient gradient1 = HeatmapGradient([ + const gradient1 = HeatmapGradient([ HeatmapGradientColor(Colors.red, 0.0), ]); - const List colors = [ + const colors = [ HeatmapGradientColor(Colors.blue, 0.0), ]; - const int colorMapSize = 512; + const colorMapSize = 512; final HeatmapGradient gradient2 = gradient1.copyWith( colorsParam: colors, colorMapSizeParam: colorMapSize, @@ -283,7 +260,7 @@ void main() { }); test('clone', () { - const HeatmapGradient gradient1 = HeatmapGradient([ + const gradient1 = HeatmapGradient([ HeatmapGradientColor(Colors.red, 0.0), ], colorMapSize: 512); @@ -292,14 +269,11 @@ void main() { }); test('toJson', () { - const List colors = [ + const colors = [ HeatmapGradientColor(Colors.red, 0.0), ]; - const int colorMapSize = 512; - const HeatmapGradient gradient = HeatmapGradient( - colors, - colorMapSize: colorMapSize, - ); + const colorMapSize = 512; + const gradient = HeatmapGradient(colors, colorMapSize: colorMapSize); expect(gradient.toJson(), { 'colors': colors @@ -313,12 +287,12 @@ void main() { }); test('==', () { - const List colors = [ + const colors = [ HeatmapGradientColor(Colors.red, 0.0), ]; - const HeatmapGradient gradient1 = HeatmapGradient(colors); - const HeatmapGradient gradient2 = HeatmapGradient(colors); - const HeatmapGradient gradient3 = HeatmapGradient([ + const gradient1 = HeatmapGradient(colors); + const gradient2 = HeatmapGradient(colors); + const gradient3 = HeatmapGradient([ HeatmapGradientColor(Colors.blue, 0.0), ], colorMapSize: 512); @@ -327,14 +301,11 @@ void main() { }); test('hashCode', () { - const List colors = [ + const colors = [ HeatmapGradientColor(Colors.red, 0.0), ]; - const int colorMapSize = 512; - const HeatmapGradient gradient = HeatmapGradient( - colors, - colorMapSize: colorMapSize, - ); + const colorMapSize = 512; + const gradient = HeatmapGradient(colors, colorMapSize: colorMapSize); expect(gradient.hashCode, Object.hash(colors, colorMapSize)); }); @@ -343,24 +314,18 @@ void main() { group('$HeatmapGradientColor', () { test('construct with values', () { const Color color = Colors.red; - const double startPoint = 0.0; - const HeatmapGradientColor gradientColor = HeatmapGradientColor( - color, - startPoint, - ); + const startPoint = 0.0; + const gradientColor = HeatmapGradientColor(color, startPoint); expect(gradientColor.color, color); expect(gradientColor.startPoint, startPoint); }); test('copyWith', () { - const HeatmapGradientColor gradientColor1 = HeatmapGradientColor( - Colors.red, - 0.0, - ); + const gradientColor1 = HeatmapGradientColor(Colors.red, 0.0); const Color color = Colors.blue; - const double startPoint = 0.5; + const startPoint = 0.5; final HeatmapGradientColor gradientColor2 = gradientColor1.copyWith( colorParam: color, startPointParam: startPoint, @@ -371,38 +336,23 @@ void main() { }); test('clone', () { - const HeatmapGradientColor gradientColor1 = HeatmapGradientColor( - Colors.red, - 0.0, - ); + const 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 gradientColor1 = HeatmapGradientColor(Colors.red, 0.0); + const gradientColor2 = HeatmapGradientColor(Colors.red, 0.0); + const gradientColor3 = HeatmapGradientColor(Colors.blue, 0.0); expect(gradientColor1, gradientColor2); expect(gradientColor1, isNot(gradientColor3)); }); test('hashCode', () { - const HeatmapGradientColor gradientColor = HeatmapGradientColor( - Colors.red, - 0.0, - ); + const gradientColor = HeatmapGradientColor(Colors.red, 0.0); expect( gradientColor.hashCode, @@ -411,10 +361,7 @@ void main() { }); test('toString', () { - const HeatmapGradientColor gradientColor = HeatmapGradientColor( - Colors.red, - 0.0, - ); + const gradientColor = HeatmapGradientColor(Colors.red, 0.0); expect( gradientColor.toString(), diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/location_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/location_test.dart index f7c9461fe663..55d8740fb3fa 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/location_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/location_test.dart @@ -10,50 +10,50 @@ void main() { group('LanLng constructor', () { test('Maintains longitude precision if within acceptable range', () async { - const double lat = -34.509981; - const double lng = 150.792384; + const lat = -34.509981; + const lng = 150.792384; - const LatLng latLng = LatLng(lat, lng); + const latLng = LatLng(lat, lng); expect(latLng.latitude, equals(lat)); expect(latLng.longitude, equals(lng)); }); test('Normalizes longitude that is below lower limit', () async { - const double lat = -34.509981; - const double lng = -270.0; + const lat = -34.509981; + const lng = -270.0; - const LatLng latLng = LatLng(lat, lng); + const latLng = LatLng(lat, lng); expect(latLng.latitude, equals(lat)); expect(latLng.longitude, equals(90.0)); }); test('Normalizes longitude that is above upper limit', () async { - const double lat = -34.509981; - const double lng = 270.0; + const lat = -34.509981; + const lng = 270.0; - const LatLng latLng = LatLng(lat, lng); + const latLng = LatLng(lat, lng); expect(latLng.latitude, equals(lat)); expect(latLng.longitude, equals(-90.0)); }); test('Includes longitude set to lower limit', () async { - const double lat = -34.509981; - const double lng = -180.0; + const lat = -34.509981; + const lng = -180.0; - const LatLng latLng = LatLng(lat, lng); + const latLng = LatLng(lat, lng); expect(latLng.latitude, equals(lat)); expect(latLng.longitude, equals(-180.0)); }); test('Normalizes longitude set to upper limit', () async { - const double lat = -34.509981; - const double lng = 180.0; + const lat = -34.509981; + const lng = 180.0; - const LatLng latLng = LatLng(lat, lng); + const latLng = LatLng(lat, lng); expect(latLng.latitude, equals(lat)); expect(latLng.longitude, equals(-180.0)); 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 e06d5daccf7b..493f5cc13936 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 @@ -11,7 +11,7 @@ const String _kMapId = '000000000000000'; // Dummy map ID. void main() { group('diffs', () { // A options instance with every field set, to test diffs against. - final MapConfiguration diffBase = MapConfiguration( + final diffBase = MapConfiguration( webCameraControlPosition: WebCameraControlPosition.topRight, webCameraControlEnabled: false, webGestureHandling: WebGestureHandling.auto, @@ -43,14 +43,14 @@ void main() { ); test('only include changed fields', () async { - const MapConfiguration nullOptions = MapConfiguration(); + const nullOptions = MapConfiguration(); // Everything should be null since nothing changed. expect(diffBase.diffFrom(diffBase), nullOptions); }); test('only apply non-null fields', () async { - const MapConfiguration smallDiff = MapConfiguration(compassEnabled: true); + const smallDiff = MapConfiguration(compassEnabled: true); final MapConfiguration updated = diffBase.applyDiff(smallDiff); @@ -70,11 +70,11 @@ void main() { }); test('handle webGestureHandling', () async { - const MapConfiguration diff = MapConfiguration( + const diff = MapConfiguration( webGestureHandling: WebGestureHandling.none, ); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -88,11 +88,11 @@ void main() { }); test('handle webCameraControlPosition', () async { - const MapConfiguration diff = MapConfiguration( + const diff = MapConfiguration( webCameraControlPosition: WebCameraControlPosition.blockEndInlineEnd, ); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -109,11 +109,9 @@ void main() { }); test('handle webCameraControlEnabled', () async { - const MapConfiguration diff = MapConfiguration( - webCameraControlEnabled: true, - ); + const diff = MapConfiguration(webCameraControlEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -127,9 +125,9 @@ void main() { }); test('handle compassEnabled', () async { - const MapConfiguration diff = MapConfiguration(compassEnabled: true); + const diff = MapConfiguration(compassEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -143,9 +141,9 @@ void main() { }); test('handle mapToolbarEnabled', () async { - const MapConfiguration diff = MapConfiguration(mapToolbarEnabled: true); + const diff = MapConfiguration(mapToolbarEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -159,17 +157,15 @@ void main() { }); test('handle cameraTargetBounds', () async { - final CameraTargetBounds newBounds = CameraTargetBounds( + final newBounds = CameraTargetBounds( LatLngBounds( northeast: const LatLng(55, 15), southwest: const LatLng(5, 15), ), ); - final MapConfiguration diff = MapConfiguration( - cameraTargetBounds: newBounds, - ); + final diff = MapConfiguration(cameraTargetBounds: newBounds); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -183,11 +179,9 @@ void main() { }); test('handle mapType', () async { - const MapConfiguration diff = MapConfiguration( - mapType: MapType.satellite, - ); + const diff = MapConfiguration(mapType: MapType.satellite); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -201,12 +195,10 @@ void main() { }); test('handle minMaxZoomPreference', () async { - const MinMaxZoomPreference newZoomPref = MinMaxZoomPreference(3.3, 4.5); - const MapConfiguration diff = MapConfiguration( - minMaxZoomPreference: newZoomPref, - ); + const newZoomPref = MinMaxZoomPreference(3.3, 4.5); + const diff = MapConfiguration(minMaxZoomPreference: newZoomPref); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -220,11 +212,9 @@ void main() { }); test('handle rotateGesturesEnabled', () async { - const MapConfiguration diff = MapConfiguration( - rotateGesturesEnabled: true, - ); + const diff = MapConfiguration(rotateGesturesEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -238,11 +228,9 @@ void main() { }); test('handle scrollGesturesEnabled', () async { - const MapConfiguration diff = MapConfiguration( - scrollGesturesEnabled: true, - ); + const diff = MapConfiguration(scrollGesturesEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -256,9 +244,9 @@ void main() { }); test('handle tiltGesturesEnabled', () async { - const MapConfiguration diff = MapConfiguration(tiltGesturesEnabled: true); + const diff = MapConfiguration(tiltGesturesEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -272,11 +260,9 @@ void main() { }); test('handle fortyFiveDegreeImageryEnabled', () async { - const MapConfiguration diff = MapConfiguration( - fortyFiveDegreeImageryEnabled: true, - ); + const diff = MapConfiguration(fortyFiveDegreeImageryEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -290,9 +276,9 @@ void main() { }); test('handle trackCameraPosition', () async { - const MapConfiguration diff = MapConfiguration(trackCameraPosition: true); + const diff = MapConfiguration(trackCameraPosition: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -306,9 +292,9 @@ void main() { }); test('handle zoomControlsEnabled', () async { - const MapConfiguration diff = MapConfiguration(zoomControlsEnabled: true); + const diff = MapConfiguration(zoomControlsEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -322,9 +308,9 @@ void main() { }); test('handle zoomGesturesEnabled', () async { - const MapConfiguration diff = MapConfiguration(zoomGesturesEnabled: true); + const diff = MapConfiguration(zoomGesturesEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -338,9 +324,9 @@ void main() { }); test('handle liteModeEnabled', () async { - const MapConfiguration diff = MapConfiguration(liteModeEnabled: true); + const diff = MapConfiguration(liteModeEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -354,9 +340,9 @@ void main() { }); test('handle myLocationEnabled', () async { - const MapConfiguration diff = MapConfiguration(myLocationEnabled: true); + const diff = MapConfiguration(myLocationEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -370,11 +356,9 @@ void main() { }); test('handle myLocationButtonEnabled', () async { - const MapConfiguration diff = MapConfiguration( - myLocationButtonEnabled: true, - ); + const diff = MapConfiguration(myLocationButtonEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -388,13 +372,10 @@ void main() { }); test('handle padding', () async { - const EdgeInsets newPadding = EdgeInsets.symmetric( - vertical: 1.0, - horizontal: 3.0, - ); - const MapConfiguration diff = MapConfiguration(padding: newPadding); + const newPadding = EdgeInsets.symmetric(vertical: 1.0, horizontal: 3.0); + const diff = MapConfiguration(padding: newPadding); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -408,9 +389,9 @@ void main() { }); test('handle indoorViewEnabled', () async { - const MapConfiguration diff = MapConfiguration(indoorViewEnabled: true); + const diff = MapConfiguration(indoorViewEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -424,9 +405,9 @@ void main() { }); test('handle trafficEnabled', () async { - const MapConfiguration diff = MapConfiguration(trafficEnabled: true); + const diff = MapConfiguration(trafficEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -440,9 +421,9 @@ void main() { }); test('handle buildingsEnabled', () async { - const MapConfiguration diff = MapConfiguration(buildingsEnabled: true); + const diff = MapConfiguration(buildingsEnabled: true); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -456,9 +437,9 @@ void main() { }); test('handle cloudMapId', () async { - const MapConfiguration diff = MapConfiguration(cloudMapId: _kMapId); + const diff = MapConfiguration(cloudMapId: _kMapId); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -473,9 +454,9 @@ void main() { }); test('handle mapId', () async { - const MapConfiguration diff = MapConfiguration(mapId: _kMapId); + const diff = MapConfiguration(mapId: _kMapId); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -489,10 +470,10 @@ void main() { }); test('handle style', () async { - const String aStlye = 'a style'; - const MapConfiguration diff = MapConfiguration(style: aStlye); + const aStlye = 'a style'; + const diff = MapConfiguration(style: aStlye); - const MapConfiguration empty = MapConfiguration(); + const empty = MapConfiguration(); final MapConfiguration updated = diffBase.applyDiff(diff); // A diff applied to empty options should be the diff itself. @@ -508,21 +489,19 @@ void main() { group('isEmpty', () { test('is true for empty', () async { - const MapConfiguration nullOptions = MapConfiguration(); + const nullOptions = MapConfiguration(); expect(nullOptions.isEmpty, true); }); test('is false with webCameraControlEnabled', () async { - const MapConfiguration diff = MapConfiguration( - webCameraControlEnabled: true, - ); + const diff = MapConfiguration(webCameraControlEnabled: true); expect(diff.isEmpty, false); }); test('is false with webCameraControlPosition', () async { - const MapConfiguration diff = MapConfiguration( + const diff = MapConfiguration( webCameraControlPosition: WebCameraControlPosition.blockEndInlineCenter, ); @@ -530,150 +509,135 @@ void main() { }); test('is false with compassEnabled', () async { - const MapConfiguration diff = MapConfiguration(compassEnabled: true); + const diff = MapConfiguration(compassEnabled: true); expect(diff.isEmpty, false); }); test('is false with mapToolbarEnabled', () async { - const MapConfiguration diff = MapConfiguration(mapToolbarEnabled: true); + const diff = MapConfiguration(mapToolbarEnabled: true); expect(diff.isEmpty, false); }); test('is false with cameraTargetBounds', () async { - final CameraTargetBounds newBounds = CameraTargetBounds( + final newBounds = CameraTargetBounds( LatLngBounds( northeast: const LatLng(55, 15), southwest: const LatLng(5, 15), ), ); - final MapConfiguration diff = MapConfiguration( - cameraTargetBounds: newBounds, - ); + final diff = MapConfiguration(cameraTargetBounds: newBounds); expect(diff.isEmpty, false); }); test('is false with mapType', () async { - const MapConfiguration diff = MapConfiguration( - mapType: MapType.satellite, - ); + const 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 newZoomPref = MinMaxZoomPreference(3.3, 4.5); + const diff = MapConfiguration(minMaxZoomPreference: newZoomPref); expect(diff.isEmpty, false); }); test('is false with rotateGesturesEnabled', () async { - const MapConfiguration diff = MapConfiguration( - rotateGesturesEnabled: true, - ); + const diff = MapConfiguration(rotateGesturesEnabled: true); expect(diff.isEmpty, false); }); test('is false with scrollGesturesEnabled', () async { - const MapConfiguration diff = MapConfiguration( - scrollGesturesEnabled: true, - ); + const diff = MapConfiguration(scrollGesturesEnabled: true); expect(diff.isEmpty, false); }); test('is false with tiltGesturesEnabled', () async { - const MapConfiguration diff = MapConfiguration(tiltGesturesEnabled: true); + const diff = MapConfiguration(tiltGesturesEnabled: true); expect(diff.isEmpty, false); }); test('is false with trackCameraPosition', () async { - const MapConfiguration diff = MapConfiguration(trackCameraPosition: true); + const diff = MapConfiguration(trackCameraPosition: true); expect(diff.isEmpty, false); }); test('is false with zoomControlsEnabled', () async { - const MapConfiguration diff = MapConfiguration(zoomControlsEnabled: true); + const diff = MapConfiguration(zoomControlsEnabled: true); expect(diff.isEmpty, false); }); test('is false with zoomGesturesEnabled', () async { - const MapConfiguration diff = MapConfiguration(zoomGesturesEnabled: true); + const diff = MapConfiguration(zoomGesturesEnabled: true); expect(diff.isEmpty, false); }); test('is false with liteModeEnabled', () async { - const MapConfiguration diff = MapConfiguration(liteModeEnabled: true); + const diff = MapConfiguration(liteModeEnabled: true); expect(diff.isEmpty, false); }); test('is false with myLocationEnabled', () async { - const MapConfiguration diff = MapConfiguration(myLocationEnabled: true); + const diff = MapConfiguration(myLocationEnabled: true); expect(diff.isEmpty, false); }); test('is false with myLocationButtonEnabled', () async { - const MapConfiguration diff = MapConfiguration( - myLocationButtonEnabled: true, - ); + const 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 MapConfiguration diff = MapConfiguration(padding: newPadding); + const newPadding = EdgeInsets.symmetric(vertical: 1.0, horizontal: 3.0); + const diff = MapConfiguration(padding: newPadding); expect(diff.isEmpty, false); }); test('is false with indoorViewEnabled', () async { - const MapConfiguration diff = MapConfiguration(indoorViewEnabled: true); + const diff = MapConfiguration(indoorViewEnabled: true); expect(diff.isEmpty, false); }); test('is false with trafficEnabled', () async { - const MapConfiguration diff = MapConfiguration(trafficEnabled: true); + const diff = MapConfiguration(trafficEnabled: true); expect(diff.isEmpty, false); }); test('is false with buildingsEnabled', () async { - const MapConfiguration diff = MapConfiguration(buildingsEnabled: true); + const diff = MapConfiguration(buildingsEnabled: true); expect(diff.isEmpty, false); }); test('is false with cloudMapId', () async { - const MapConfiguration diff = MapConfiguration(mapId: _kMapId); + const diff = MapConfiguration(mapId: _kMapId); expect(diff.isEmpty, false); }); test('is false with mapId', () async { - const MapConfiguration diff = MapConfiguration(mapId: _kMapId); + const diff = MapConfiguration(mapId: _kMapId); expect(diff.isEmpty, false); }); test('is false with style', () async { - const MapConfiguration diff = MapConfiguration(style: 'a style'); + const diff = MapConfiguration(style: 'a style'); 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 37d5e9430c05..4dadb84ef9f4 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 @@ -12,12 +12,12 @@ void main() { TestWidgetsFlutterBinding.ensureInitialized(); test('keyByMapsObjectId', () async { - const MapsObjectId id1 = MapsObjectId('1'); - const MapsObjectId id2 = MapsObjectId('2'); - const MapsObjectId id3 = MapsObjectId('3'); - const TestMapsObject object1 = TestMapsObject(id1); - const TestMapsObject object2 = TestMapsObject(id2, data: 2); - const TestMapsObject object3 = TestMapsObject(id3); + const id1 = MapsObjectId('1'); + const id2 = MapsObjectId('2'); + const id3 = MapsObjectId('3'); + const object1 = TestMapsObject(id1); + const object2 = TestMapsObject(id2, data: 2); + const object3 = TestMapsObject(id3); expect( keyByMapsObjectId({object1, object2, object3}), , TestMapsObject>{ @@ -29,12 +29,12 @@ void main() { }); test('serializeMapsObjectSet', () async { - const MapsObjectId id1 = MapsObjectId('1'); - const MapsObjectId id2 = MapsObjectId('2'); - const MapsObjectId id3 = MapsObjectId('3'); - const TestMapsObject object1 = TestMapsObject(id1); - const TestMapsObject object2 = TestMapsObject(id2, data: 2); - const TestMapsObject object3 = TestMapsObject(id3); + const id1 = MapsObjectId('1'); + const id2 = MapsObjectId('2'); + const id3 = MapsObjectId('3'); + const object1 = TestMapsObject(id1); + const object2 = TestMapsObject(id2, data: 2); + const object3 = TestMapsObject(id3); expect( serializeMapsObjectSet({object1, object2, object3}), >[ 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 c2fb440eb5e0..8b70c2f22ec0 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 @@ -19,73 +19,42 @@ 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( + const to1 = TestMapsObject(MapsObjectId('id1')); + const to2 = TestMapsObject(MapsObjectId('id2')); + const to3 = TestMapsObject(MapsObjectId('id3')); + const to3Changed = TestMapsObject( MapsObjectId('id3'), data: 2, ); - const TestMapsObject to4 = TestMapsObject( - MapsObjectId('id4'), - ); - final Set previous = {to1, to2, to3}; - final Set current = { - to2, - to3Changed, - to4, - }; - final TestMapsObjectUpdate updates = TestMapsObjectUpdate.from( - previous, - current, - ); + const to4 = TestMapsObject(MapsObjectId('id4')); + final previous = {to1, to2, to3}; + final current = {to2, to3Changed, to4}; + final updates = TestMapsObjectUpdate.from(previous, current); - final Set> toRemove = - >{ - const MapsObjectId('id1'), - }; + final toRemove = >{ + const MapsObjectId('id1'), + }; expect(updates.objectIdsToRemove, toRemove); - final Set toAdd = {to4}; + final toAdd = {to4}; expect(updates.objectsToAdd, toAdd); - final Set toChange = {to3Changed}; + final toChange = {to3Changed}; expect(updates.objectsToChange, toChange); }); 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( + const to1 = TestMapsObject(MapsObjectId('id1')); + const to2 = TestMapsObject(MapsObjectId('id2')); + const to3 = TestMapsObject(MapsObjectId('id3')); + const to3Changed = TestMapsObject( MapsObjectId('id3'), data: 2, ); - const TestMapsObject to4 = TestMapsObject( - MapsObjectId('id4'), - ); - final Set previous = {to1, to2, to3}; - final Set current = { - to2, - to3Changed, - to4, - }; - final TestMapsObjectUpdate updates = TestMapsObjectUpdate.from( - previous, - current, - ); + const to4 = TestMapsObject(MapsObjectId('id4')); + final previous = {to1, to2, to3}; + final current = {to2, to3Changed, to4}; + final updates = TestMapsObjectUpdate.from(previous, current); final Object json = updates.toJson(); expect(json, { @@ -98,77 +67,37 @@ void main() { }); 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( + const to1 = TestMapsObject(MapsObjectId('id1')); + const to2 = TestMapsObject(MapsObjectId('id2')); + const to3 = TestMapsObject(MapsObjectId('id3')); + const to3Changed = TestMapsObject( MapsObjectId('id3'), data: 2, ); - const TestMapsObject to4 = TestMapsObject( - MapsObjectId('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 TestMapsObjectUpdate updates1 = TestMapsObjectUpdate.from( - previous, - current1, - ); - final TestMapsObjectUpdate updates2 = TestMapsObjectUpdate.from( - previous, - current2, - ); - final TestMapsObjectUpdate updates3 = TestMapsObjectUpdate.from( - previous, - current3, - ); + const to4 = TestMapsObject(MapsObjectId('id4')); + final previous = {to1, to2, to3}; + final current1 = {to2, to3Changed, to4}; + final current2 = {to2, to3Changed, to4}; + final current3 = {to2, to4}; + final updates1 = TestMapsObjectUpdate.from(previous, current1); + final updates2 = TestMapsObjectUpdate.from(previous, current2); + final 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( + const to1 = TestMapsObject(MapsObjectId('id1')); + const to2 = TestMapsObject(MapsObjectId('id2')); + const to3 = TestMapsObject(MapsObjectId('id3')); + const to3Changed = TestMapsObject( MapsObjectId('id3'), data: 2, ); - const TestMapsObject to4 = TestMapsObject( - MapsObjectId('id4'), - ); - final Set previous = {to1, to2, to3}; - final Set current = { - to2, - to3Changed, - to4, - }; - final TestMapsObjectUpdate updates = TestMapsObjectUpdate.from( - previous, - current, - ); + const to4 = TestMapsObject(MapsObjectId('id4')); + final previous = {to1, to2, to3}; + final current = {to2, to3Changed, to4}; + final updates = TestMapsObjectUpdate.from(previous, current); expect( updates.hashCode, Object.hash( @@ -180,32 +109,17 @@ void main() { }); 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( + const to1 = TestMapsObject(MapsObjectId('id1')); + const to2 = TestMapsObject(MapsObjectId('id2')); + const to3 = TestMapsObject(MapsObjectId('id3')); + const to3Changed = TestMapsObject( MapsObjectId('id3'), data: 2, ); - const TestMapsObject to4 = TestMapsObject( - MapsObjectId('id4'), - ); - final Set previous = {to1, to2, to3}; - final Set current = { - to2, - to3Changed, - to4, - }; - final TestMapsObjectUpdate updates = TestMapsObjectUpdate.from( - previous, - current, - ); + const to4 = TestMapsObject(MapsObjectId('id4')); + final previous = {to1, to2, to3}; + final current = {to2, to3Changed, to4}; + final updates = TestMapsObjectUpdate.from(previous, current); expect( updates.toString(), 'TestMapsObjectUpdate(add: ${updates.objectsToAdd}, ' 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 18475b541f81..9b684bc6fa31 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 @@ -10,7 +10,7 @@ void main() { group('$Marker', () { test('constructor defaults', () { - const Marker marker = Marker(markerId: MarkerId('ABC123')); + const marker = Marker(markerId: MarkerId('ABC123')); expect(marker.alpha, equals(1.0)); expect(marker.anchor, equals(const Offset(0.5, 1.0))); @@ -44,7 +44,7 @@ void main() { test('toJson', () { final BitmapDescriptor testDescriptor = BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueCyan); - final Marker marker = Marker( + final marker = Marker( markerId: const MarkerId('ABC123'), alpha: 0.12345, anchor: const Offset(100, 100), @@ -67,7 +67,7 @@ void main() { onDragEnd: (LatLng latLng) {}, ); - final Map json = marker.toJson() as Map; + final json = marker.toJson() as Map; expect(json, { 'markerId': 'ABC123', @@ -90,33 +90,31 @@ void main() { }); }); test('clone', () { - const Marker marker = Marker(markerId: MarkerId('ABC123')); + const marker = Marker(markerId: MarkerId('ABC123')); final Marker clone = marker.clone(); expect(identical(clone, marker), isFalse); expect(clone, equals(marker)); }); test('copyWith', () { - const MarkerId markerId = MarkerId('ABC123'); - const Marker marker = Marker(markerId: markerId); + const markerId = MarkerId('ABC123'); + const marker = Marker(markerId: markerId); final BitmapDescriptor testDescriptor = BitmapDescriptor.defaultMarkerWithHue(BitmapDescriptor.hueCyan); - const double testAlphaParam = 0.12345; - const Offset testAnchorParam = Offset(100, 100); + const testAlphaParam = 0.12345; + const testAnchorParam = Offset(100, 100); final bool testConsumeTapEventsParam = !marker.consumeTapEvents; final bool testDraggableParam = !marker.draggable; final bool testFlatParam = !marker.flat; - final BitmapDescriptor testIconParam = testDescriptor; - const InfoWindow testInfoWindowParam = InfoWindow(title: 'Test'); - const LatLng testPositionParam = LatLng(100, 100); + final testIconParam = testDescriptor; + const testInfoWindowParam = InfoWindow(title: 'Test'); + const testPositionParam = LatLng(100, 100); const double testRotationParam = 100; final bool testVisibleParam = !marker.visible; const double testZIndexParam = 100; - const ClusterManagerId testClusterManagerIdParam = ClusterManagerId( - 'DEF123', - ); - final List log = []; + const testClusterManagerIdParam = ClusterManagerId('DEF123'); + final log = []; final Marker copy = marker.copyWith( alphaParam: testAlphaParam, @@ -184,28 +182,28 @@ void main() { }); test('zIndex param', () { - const Marker marker = Marker(markerId: MarkerId('ABC123'), zIndex: 5.00); + const 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(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(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(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/tile_overlay_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/types/tile_overlay_test.dart index c60d4d8b4d82..e4092ac385ea 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 @@ -17,22 +17,22 @@ void main() { group('tile overlay id tests', () { test('equality', () async { - const TileOverlayId id1 = TileOverlayId('1'); - const TileOverlayId id2 = TileOverlayId('1'); - const TileOverlayId id3 = TileOverlayId('2'); + const id1 = TileOverlayId('1'); + const id2 = TileOverlayId('1'); + const id3 = TileOverlayId('2'); expect(id1, id2); expect(id1, isNot(id3)); }); test('toString', () async { - const TileOverlayId id1 = TileOverlayId('1'); + const id1 = TileOverlayId('1'); expect(id1.toString(), 'TileOverlayId(1)'); }); }); group('tile overlay tests', () { test('toJson returns correct format', () async { - const TileOverlay tileOverlay = TileOverlay( + const tileOverlay = TileOverlay( tileOverlayId: TileOverlayId('id'), fadeIn: false, transparency: 0.1, @@ -70,7 +70,7 @@ void main() { test('equality', () async { final TileProvider tileProvider = _TestTileProvider(); - final TileOverlay tileOverlay1 = TileOverlay( + final tileOverlay1 = TileOverlay( tileOverlayId: const TileOverlayId('id1'), fadeIn: false, tileProvider: tileProvider, @@ -79,7 +79,7 @@ void main() { visible: false, tileSize: 128, ); - final TileOverlay tileOverlaySameValues = TileOverlay( + final tileOverlaySameValues = TileOverlay( tileOverlayId: const TileOverlayId('id1'), fadeIn: false, tileProvider: tileProvider, @@ -88,7 +88,7 @@ void main() { visible: false, tileSize: 128, ); - final TileOverlay tileOverlayDifferentId = TileOverlay( + final tileOverlayDifferentId = TileOverlay( tileOverlayId: const TileOverlayId('id2'), fadeIn: false, tileProvider: tileProvider, @@ -97,7 +97,7 @@ void main() { visible: false, tileSize: 128, ); - const TileOverlay tileOverlayDifferentProvider = TileOverlay( + const tileOverlayDifferentProvider = TileOverlay( tileOverlayId: TileOverlayId('id1'), fadeIn: false, transparency: 0.1, @@ -113,7 +113,7 @@ void main() { test('clone', () async { final TileProvider tileProvider = _TestTileProvider(); // Set non-default values for every parameter. - final TileOverlay tileOverlay = TileOverlay( + final tileOverlay = TileOverlay( tileOverlayId: const TileOverlayId('id1'), fadeIn: false, tileProvider: tileProvider, @@ -127,8 +127,8 @@ void main() { test('hashCode', () async { final TileProvider tileProvider = _TestTileProvider(); - const TileOverlayId id = TileOverlayId('id1'); - final TileOverlay tileOverlay = TileOverlay( + const id = TileOverlayId('id1'); + final tileOverlay = TileOverlay( tileOverlayId: id, fadeIn: false, tileProvider: tileProvider, 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 b7f91c06c759..3811a865a85a 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 @@ -12,48 +12,40 @@ void main() { group('tile overlay updates tests', () { test('Correctly set toRemove, toAdd and toChange', () 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( + const to1 = TileOverlay(tileOverlayId: TileOverlayId('id1')); + const to2 = TileOverlay(tileOverlayId: TileOverlayId('id2')); + const to3 = TileOverlay(tileOverlayId: TileOverlayId('id3')); + const 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, - ); + const to4 = TileOverlay(tileOverlayId: TileOverlayId('id4')); + final previous = {to1, to2, to3}; + final current = {to2, to3Changed, to4}; + final updates = TileOverlayUpdates.from(previous, current); - final Set toRemove = { - const TileOverlayId('id1'), - }; + final toRemove = {const TileOverlayId('id1')}; expect(updates.tileOverlayIdsToRemove, toRemove); - final Set toAdd = {to4}; + final toAdd = {to4}; expect(updates.tileOverlaysToAdd, toAdd); - final Set toChange = {to3Changed}; + final toChange = {to3Changed}; expect(updates.tileOverlaysToChange, toChange); }); test('toJson', () 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( + const to1 = TileOverlay(tileOverlayId: TileOverlayId('id1')); + const to2 = TileOverlay(tileOverlayId: TileOverlayId('id2')); + const to3 = TileOverlay(tileOverlayId: TileOverlayId('id3')); + const 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, - ); + const to4 = TileOverlay(tileOverlayId: TileOverlayId('id4')); + final previous = {to1, to2, to3}; + final current = {to2, to3Changed, to4}; + final updates = TileOverlayUpdates.from(previous, current); final Object json = updates.toJson(); expect(json, { @@ -68,49 +60,37 @@ void main() { }); test('equality', () 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( + const to1 = TileOverlay(tileOverlayId: TileOverlayId('id1')); + const to2 = TileOverlay(tileOverlayId: TileOverlayId('id2')); + const to3 = TileOverlay(tileOverlayId: TileOverlayId('id3')); + const 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, - ); + const to4 = TileOverlay(tileOverlayId: TileOverlayId('id4')); + final previous = {to1, to2, to3}; + final current1 = {to2, to3Changed, to4}; + final current2 = {to2, to3Changed, to4}; + final current3 = {to2, to4}; + final updates1 = TileOverlayUpdates.from(previous, current1); + final updates2 = TileOverlayUpdates.from(previous, current2); + final updates3 = TileOverlayUpdates.from(previous, current3); expect(updates1, updates2); expect(updates1, isNot(updates3)); }); test('hashCode', () 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( + const to1 = TileOverlay(tileOverlayId: TileOverlayId('id1')); + const to2 = TileOverlay(tileOverlayId: TileOverlayId('id2')); + const to3 = TileOverlay(tileOverlayId: TileOverlayId('id3')); + const 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, - ); + const to4 = TileOverlay(tileOverlayId: TileOverlayId('id4')); + final previous = {to1, to2, to3}; + final current = {to2, to3Changed, to4}; + final updates = TileOverlayUpdates.from(previous, current); expect( updates.hashCode, Object.hash( @@ -122,20 +102,17 @@ void main() { }); 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( + const to1 = TileOverlay(tileOverlayId: TileOverlayId('id1')); + const to2 = TileOverlay(tileOverlayId: TileOverlayId('id2')); + const to3 = TileOverlay(tileOverlayId: TileOverlayId('id3')); + const 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, - ); + const to4 = TileOverlay(tileOverlayId: TileOverlayId('id4')); + final previous = {to1, to2, to3}; + final current = {to2, to3Changed, to4}; + final updates = TileOverlayUpdates.from(previous, current); expect( updates.toString(), 'TileOverlayUpdates(add: ${updates.tileOverlaysToAdd}, ' 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 1c0e5359b853..4307a3597fc6 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 @@ -12,14 +12,14 @@ void main() { group('tile tests', () { test('toJson returns correct format', () async { - final Uint8List data = Uint8List.fromList([0, 1]); - final Tile tile = Tile(100, 200, data); + final data = Uint8List.fromList([0, 1]); + final tile = Tile(100, 200, data); final Object json = tile.toJson(); expect(json, {'width': 100, 'height': 200, 'data': data}); }); test('toJson handles null data', () async { - const Tile tile = Tile(0, 0, null); + const tile = Tile(0, 0, null); final Object json = tile.toJson(); expect(json, {'width': 0, 'height': 0}); }); diff --git a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/utils/cluster_manager_test.dart b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/utils/cluster_manager_test.dart index 0f096a753072..4bb0d908feb3 100644 --- a/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/utils/cluster_manager_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_platform_interface/test/utils/cluster_manager_test.dart @@ -8,11 +8,11 @@ import 'package:google_maps_flutter_platform_interface/src/types/types.dart'; void main() { group('keyByClusterManagerId', () { test('returns a Map keyed by clusterManagerId', () { - const ClusterManagerId id1 = ClusterManagerId('id1'); - const ClusterManagerId id2 = ClusterManagerId('id2'); - const ClusterManagerId id3 = ClusterManagerId('id3'); + const id1 = ClusterManagerId('id1'); + const id2 = ClusterManagerId('id2'); + const id3 = ClusterManagerId('id3'); - final List clusterManagers = [ + final clusterManagers = [ const ClusterManager(clusterManagerId: id1), const ClusterManager(clusterManagerId: id2), const ClusterManager(clusterManagerId: id3), 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 b52b977bb99c..7777f2399fe2 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 @@ -11,7 +11,7 @@ const String _kMapId = '000000000000000'; // Dummy map ID. void main() { test('empty serialization', () async { - const MapConfiguration config = MapConfiguration(); + const config = MapConfiguration(); final Map json = jsonForMapConfiguration(config); @@ -19,7 +19,7 @@ void main() { }); test('complete serialization', () async { - final MapConfiguration config = MapConfiguration( + final config = MapConfiguration( compassEnabled: false, mapToolbarEnabled: false, cameraTargetBounds: CameraTargetBounds( @@ -84,7 +84,7 @@ void main() { }); test('mapId preferred over cloudMapId', () { - const MapConfiguration config = MapConfiguration( + const config = MapConfiguration( mapId: 'map-id', cloudMapId: 'cloud-map-id', ); @@ -93,9 +93,7 @@ void main() { }); test('mapId falls back to cloudMapId', () { - const MapConfiguration config = MapConfiguration( - cloudMapId: 'cloud-map-id', - ); + const config = MapConfiguration(cloudMapId: 'cloud-map-id'); final Map json = jsonForMapConfiguration(config); expect(json, { 'mapId': 'cloud-map-id', diff --git a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/cloud_map_styles_test.dart b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/cloud_map_styles_test.dart index 2c843752934d..57555a51e457 100644 --- a/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/cloud_map_styles_test.dart +++ b/packages/google_maps_flutter/google_maps_flutter_web/example/integration_test/cloud_map_styles_test.dart @@ -29,23 +29,20 @@ void main() { testWidgets('cloudMapId present => mapId set & styles omitted', ( WidgetTester tester, ) async { - const MapConfiguration testMapConfig = MapConfiguration( - mapId: 'test-cloud-map-id', - ); + const testMapConfig = MapConfiguration(mapId: 'test-cloud-map-id'); await tester.pumpWidget( const Directionality(textDirection: TextDirection.ltr, child: SizedBox()), ); - final StreamController> stream = - StreamController>(); + final stream = StreamController>(); addTearDown(() { // Stream is closed by controller.dispose() }); gmaps.MapOptions? captured; - final GoogleMapController controller = GoogleMapController( + final controller = GoogleMapController( mapId: 1, // Internal controller ID streamController: stream, widgetConfiguration: cfg(), @@ -58,7 +55,7 @@ void main() { }, ); - final List styles = [ + final styles = [ gmaps.MapTypeStyle() ..featureType = 'road' ..elementType = 'geometry', @@ -84,14 +81,13 @@ void main() { const Directionality(textDirection: TextDirection.ltr, child: SizedBox()), ); - final StreamController> stream = - StreamController>(); + final stream = StreamController>(); addTearDown(() { // Stream is closed by controller.dispose() }); gmaps.MapOptions? captured; - final GoogleMapController controller = GoogleMapController( + final controller = GoogleMapController( mapId: 2, // Internal controller ID streamController: stream, widgetConfiguration: cfg(), @@ -103,7 +99,7 @@ void main() { }, ); - final List styles = [ + final styles = [ gmaps.MapTypeStyle() ..featureType = 'poi' ..elementType = 'labels', 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 ce102173d4c0..1649f40e7bba 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 @@ -50,7 +50,7 @@ void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('GoogleMapController', () { - const int mapId = 33930; + const mapId = 33930; late GoogleMapController controller; late StreamController> stream; @@ -374,7 +374,7 @@ void main() { }); testWidgets('renders initial geometry', (WidgetTester tester) async { - final MapObjects mapObjects = MapObjects( + final mapObjects = MapObjects( circles: { const Circle(circleId: CircleId('circle-1'), zIndex: 1234), }, @@ -614,7 +614,7 @@ void main() { testWidgets('translates cameraTargetBounds option', ( WidgetTester tester, ) async { - final LatLngBounds mockLatLngBounds = LatLngBounds( + final mockLatLngBounds = LatLngBounds( southwest: const LatLng(20, 30), northeast: const LatLng(25, 35), ); @@ -670,7 +670,7 @@ void main() { testWidgets('translates style option', (WidgetTester tester) async { gmaps.MapOptions? capturedOptions; - const String style = ''' + const style = ''' [{ "featureType": "poi.park", "elementType": "labels.text.fill", @@ -722,7 +722,7 @@ void main() { ) async { gmaps.MapOptions? initialCapturedOptions; gmaps.MapOptions? updatedCapturedOptions; - const String style = ''' + const style = ''' [{ "featureType": "poi.park", "elementType": "labels.text.fill", @@ -820,7 +820,7 @@ void main() { }); testWidgets('can update style', (WidgetTester tester) async { - const String style = ''' + const style = ''' [{ "featureType": "poi.park", "elementType": "labels.text.fill", @@ -846,7 +846,7 @@ void main() { group('viewport getters', () { testWidgets('getVisibleRegion', (WidgetTester tester) async { final gmaps.LatLng gmCenter = map.center; - final LatLng center = LatLng( + final center = LatLng( gmCenter.lat.toDouble(), gmCenter.lng.toDouble(), ); @@ -878,15 +878,15 @@ void main() { // These are the methods that get forwarded to other controllers, so we just verify calls. group('Pass-through methods', () { testWidgets('updateCircles', (WidgetTester tester) async { - final MockCirclesController mock = MockCirclesController(); + final mock = MockCirclesController(); controller = createController()..debugSetOverrides(circles: mock); - final Set previous = { + final previous = { const Circle(circleId: CircleId('to-be-updated')), const Circle(circleId: CircleId('to-be-removed')), }; - final Set current = { + final current = { const Circle(circleId: CircleId('to-be-updated'), visible: false), const Circle(circleId: CircleId('to-be-added')), }; @@ -907,10 +907,10 @@ void main() { }); testWidgets('updateHeatmaps', (WidgetTester tester) async { - final MockHeatmapsController mock = MockHeatmapsController(); + final mock = MockHeatmapsController(); controller.debugSetOverrides(heatmaps: mock); - const List heatmapPoints = [ + const heatmapPoints = [ WeightedLatLng(LatLng(37.782, -122.447)), WeightedLatLng(LatLng(37.782, -122.445)), WeightedLatLng(LatLng(37.782, -122.443)), @@ -927,7 +927,7 @@ void main() { WeightedLatLng(LatLng(37.785, -122.435)), ]; - final Set previous = { + final previous = { const Heatmap( heatmapId: HeatmapId('to-be-updated'), data: heatmapPoints, @@ -940,7 +940,7 @@ void main() { ), }; - final Set current = { + final current = { const Heatmap( heatmapId: HeatmapId('to-be-updated'), data: heatmapPoints, @@ -981,15 +981,15 @@ void main() { }); testWidgets('updateMarkers', (WidgetTester tester) async { - final MockMarkersController mock = MockMarkersController(); + final mock = MockMarkersController(); controller = createController()..debugSetOverrides(markers: mock); - final Set previous = { + final previous = { const Marker(markerId: MarkerId('to-be-updated')), const Marker(markerId: MarkerId('to-be-removed')), }; - final Set current = { + final current = { const Marker(markerId: MarkerId('to-be-updated'), visible: false), const Marker(markerId: MarkerId('to-be-added')), }; @@ -1010,15 +1010,15 @@ void main() { }); testWidgets('updatePolygons', (WidgetTester tester) async { - final MockPolygonsController mock = MockPolygonsController(); + final mock = MockPolygonsController(); controller = createController()..debugSetOverrides(polygons: mock); - final Set previous = { + final previous = { const Polygon(polygonId: PolygonId('to-be-updated')), const Polygon(polygonId: PolygonId('to-be-removed')), }; - final Set current = { + final current = { const Polygon(polygonId: PolygonId('to-be-updated'), visible: false), const Polygon(polygonId: PolygonId('to-be-added')), }; @@ -1044,15 +1044,15 @@ void main() { }); testWidgets('updatePolylines', (WidgetTester tester) async { - final MockPolylinesController mock = MockPolylinesController(); + final mock = MockPolylinesController(); controller = createController()..debugSetOverrides(polylines: mock); - final Set previous = { + final previous = { const Polyline(polylineId: PolylineId('to-be-updated')), const Polyline(polylineId: PolylineId('to-be-removed')), }; - final Set current = { + final current = { const Polyline( polylineId: PolylineId('to-be-updated'), visible: false, @@ -1081,7 +1081,7 @@ void main() { }); testWidgets('updateTileOverlays', (WidgetTester tester) async { - final MockTileOverlaysController mock = MockTileOverlaysController(); + final mock = MockTileOverlaysController(); controller = createController( mapObjects: MapObjects( tileOverlays: { @@ -1120,45 +1120,43 @@ void main() { }); testWidgets('updateGroundOverlays', (WidgetTester tester) async { - final MockGroundOverlaysController mock = - MockGroundOverlaysController(); + final mock = MockGroundOverlaysController(); controller = createController() ..debugSetOverrides(groundOverlays: mock); - final LatLngBounds bounds = LatLngBounds( + final bounds = LatLngBounds( northeast: const LatLng(100, 0), southwest: const LatLng(0, 100), ); - const LatLng position = LatLng(50, 50); - final AssetMapBitmap image = AssetMapBitmap( + const position = LatLng(50, 50); + final image = AssetMapBitmap( 'assets/red_square.png', imagePixelRatio: 1.0, bitmapScaling: MapBitmapScaling.none, ); - final GroundOverlay groundOverlayToBeUpdated = GroundOverlay.fromBounds( + final groundOverlayToBeUpdated = GroundOverlay.fromBounds( groundOverlayId: const GroundOverlayId('to-be-updated'), image: image, bounds: bounds, ); - final GroundOverlay groundOverlayToBeRemoved = - GroundOverlay.fromPosition( - groundOverlayId: const GroundOverlayId('to-be-removed'), - image: image, - position: position, - ); - final GroundOverlay groundOverlayToBeAdded = GroundOverlay.fromPosition( + final groundOverlayToBeRemoved = GroundOverlay.fromPosition( + groundOverlayId: const GroundOverlayId('to-be-removed'), + image: image, + position: position, + ); + final groundOverlayToBeAdded = GroundOverlay.fromPosition( groundOverlayId: const GroundOverlayId('to-be-added'), image: image, position: position, ); - final Set previous = { + final previous = { groundOverlayToBeUpdated, groundOverlayToBeRemoved, }; - final Set current = { + final current = { groundOverlayToBeUpdated.copyWith(visibleParam: false), groundOverlayToBeAdded, }; @@ -1181,8 +1179,8 @@ void main() { }); testWidgets('infoWindow visibility', (WidgetTester tester) async { - final MockMarkersController mock = MockMarkersController(); - const MarkerId markerId = MarkerId('marker-with-infowindow'); + final mock = MockMarkersController(); + const markerId = MarkerId('marker-with-infowindow'); when(mock.isInfoWindowShown(markerId)).thenReturn(true); controller = createController()..debugSetOverrides(markers: mock); 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 a70ef4e73c9a..24cec1d5c3a7 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 @@ -26,7 +26,7 @@ void main() { late MockGoogleMapController controller; late GoogleMapsPlugin plugin; late Completer reportedMapIdCompleter; - int numberOnPlatformViewCreatedCalls = 0; + var numberOnPlatformViewCreatedCalls = 0; void onPlatformViewCreated(int id) { reportedMapIdCompleter.complete(id); @@ -67,16 +67,13 @@ void main() { }); group('buildView', () { - const int testMapId = 33930; - const CameraPosition initialCameraPosition = CameraPosition( - target: LatLng(0, 0), - ); + const testMapId = 33930; + const initialCameraPosition = CameraPosition(target: LatLng(0, 0)); testWidgets( 'returns an HtmlElementView and caches the controller for later', (WidgetTester tester) async { - final Map cache = - {}; + final cache = {}; plugin.debugSetMapById(cache); final Widget widget = plugin.buildViewWithConfiguration( @@ -112,9 +109,7 @@ void main() { testWidgets('returns cached instance if it already exists', ( WidgetTester tester, ) async { - const HtmlElementView expected = HtmlElementView( - viewType: 'only-for-testing', - ); + const expected = HtmlElementView(viewType: 'only-for-testing'); when(controller.widget).thenReturn(expected); plugin.debugSetMapById({ testMapId: controller, @@ -135,8 +130,7 @@ void main() { testWidgets( 'asynchronously reports onPlatformViewCreated the first time it happens', (WidgetTester tester) async { - final Map cache = - {}; + final cache = {}; plugin.debugSetMapById(cache); plugin.buildViewWithConfiguration( @@ -175,7 +169,7 @@ void main() { }); group('setMapStyles', () { - const String mapStyle = ''' + const mapStyle = ''' [{ "featureType": "poi.park", "elementType": "labels.text.fill", @@ -193,8 +187,7 @@ void main() { controller.updateStyles(captureThat(isList)), ).captured[0]; - final List styles = - captured as List; + final styles = captured as List; expect(styles.length, 1); // Let's peek inside the styles... final gmaps.MapTypeStyle style = styles[0]; @@ -218,15 +211,13 @@ void main() { // These methods only pass-through values from the plugin to the controller // so we verify them all together here... group('Pass-through methods:', () { - const int mapId = 0; + const mapId = 0; setUp(() { plugin.debugSetMapById({mapId: controller}); }); // Options testWidgets('updateMapConfiguration', (WidgetTester tester) async { - const MapConfiguration configuration = MapConfiguration( - mapType: MapType.satellite, - ); + const configuration = MapConfiguration(mapType: MapType.satellite); await plugin.updateMapConfiguration(configuration, mapId: mapId); @@ -234,7 +225,7 @@ void main() { }); // Geometry testWidgets('updateMarkers', (WidgetTester tester) async { - final MarkerUpdates expectedUpdates = MarkerUpdates.from( + final expectedUpdates = MarkerUpdates.from( const {}, const {}, ); @@ -244,7 +235,7 @@ void main() { verify(controller.updateMarkers(expectedUpdates)); }); testWidgets('updatePolygons', (WidgetTester tester) async { - final PolygonUpdates expectedUpdates = PolygonUpdates.from( + final expectedUpdates = PolygonUpdates.from( const {}, const {}, ); @@ -254,7 +245,7 @@ void main() { verify(controller.updatePolygons(expectedUpdates)); }); testWidgets('updatePolylines', (WidgetTester tester) async { - final PolylineUpdates expectedUpdates = PolylineUpdates.from( + final expectedUpdates = PolylineUpdates.from( const {}, const {}, ); @@ -264,7 +255,7 @@ void main() { verify(controller.updatePolylines(expectedUpdates)); }); testWidgets('updateCircles', (WidgetTester tester) async { - final CircleUpdates expectedUpdates = CircleUpdates.from( + final expectedUpdates = CircleUpdates.from( const {}, const {}, ); @@ -274,7 +265,7 @@ void main() { verify(controller.updateCircles(expectedUpdates)); }); testWidgets('updateHeatmaps', (WidgetTester tester) async { - final HeatmapUpdates expectedUpdates = HeatmapUpdates.from( + final expectedUpdates = HeatmapUpdates.from( const {}, const {}, ); @@ -285,7 +276,7 @@ void main() { }); // Tile Overlays testWidgets('updateTileOverlays', (WidgetTester tester) async { - final Set expectedOverlays = { + final expectedOverlays = { const TileOverlay(tileOverlayId: TileOverlayId('overlay')), }; @@ -297,7 +288,7 @@ void main() { verify(controller.updateTileOverlays(expectedOverlays)); }); testWidgets('clearTileCache', (WidgetTester tester) async { - const TileOverlayId tileOverlayId = TileOverlayId('Dory'); + const tileOverlayId = TileOverlayId('Dory'); await plugin.clearTileCache(tileOverlayId, mapId: mapId); @@ -348,7 +339,7 @@ void main() { (_) async => const ScreenCoordinate(x: 320, y: 240), // fake return ); - const LatLng latLng = LatLng(43.3613, -5.8499); + const latLng = LatLng(43.3613, -5.8499); await plugin.getScreenCoordinate(latLng, mapId: mapId); @@ -360,7 +351,7 @@ void main() { (_) async => const LatLng(43.3613, -5.8499), // fake return ); - const ScreenCoordinate coordinates = ScreenCoordinate(x: 19, y: 26); + const coordinates = ScreenCoordinate(x: 19, y: 26); await plugin.getLatLng(coordinates, mapId: mapId); @@ -369,7 +360,7 @@ void main() { // InfoWindows testWidgets('showMarkerInfoWindow', (WidgetTester tester) async { - const MarkerId markerId = MarkerId('testing-123'); + const markerId = MarkerId('testing-123'); await plugin.showMarkerInfoWindow(markerId, mapId: mapId); @@ -377,7 +368,7 @@ void main() { }); testWidgets('hideMarkerInfoWindow', (WidgetTester tester) async { - const MarkerId markerId = MarkerId('testing-123'); + const markerId = MarkerId('testing-123'); await plugin.hideMarkerInfoWindow(markerId, mapId: mapId); @@ -385,7 +376,7 @@ void main() { }); testWidgets('isMarkerInfoWindowShown', (WidgetTester tester) async { - const MarkerId markerId = MarkerId('testing-123'); + const markerId = MarkerId('testing-123'); when(controller.isInfoWindowShown(markerId)).thenReturn(true); @@ -397,7 +388,7 @@ void main() { // Verify all event streams are filtered correctly from the main one... group('Event Streams', () { - const int mapId = 0; + const mapId = 0; late StreamController> streamController; setUp(() { streamController = StreamController>.broadcast(); @@ -427,7 +418,7 @@ void main() { // Camera events testWidgets('onCameraMoveStarted', (WidgetTester tester) async { - final CameraMoveStartedEvent event = CameraMoveStartedEvent(mapId); + final event = CameraMoveStartedEvent(mapId); final Stream stream = plugin .onCameraMoveStarted(mapId: mapId); @@ -435,7 +426,7 @@ void main() { await testStreamFiltering(stream, event); }); testWidgets('onCameraMoveStarted', (WidgetTester tester) async { - final CameraMoveEvent event = CameraMoveEvent( + final event = CameraMoveEvent( mapId, const CameraPosition(target: LatLng(43.3790, -5.8660)), ); @@ -447,7 +438,7 @@ void main() { await testStreamFiltering(stream, event); }); testWidgets('onCameraIdle', (WidgetTester tester) async { - final CameraIdleEvent event = CameraIdleEvent(mapId); + final event = CameraIdleEvent(mapId); final Stream stream = plugin.onCameraIdle( mapId: mapId, @@ -457,20 +448,14 @@ void main() { }); // Marker events testWidgets('onMarkerTap', (WidgetTester tester) async { - final MarkerTapEvent event = MarkerTapEvent( - mapId, - const MarkerId('test-123'), - ); + final event = MarkerTapEvent(mapId, const MarkerId('test-123')); final Stream stream = plugin.onMarkerTap(mapId: mapId); await testStreamFiltering(stream, event); }); testWidgets('onInfoWindowTap', (WidgetTester tester) async { - final InfoWindowTapEvent event = InfoWindowTapEvent( - mapId, - const MarkerId('test-123'), - ); + final event = InfoWindowTapEvent(mapId, const MarkerId('test-123')); final Stream stream = plugin.onInfoWindowTap( mapId: mapId, @@ -479,7 +464,7 @@ void main() { await testStreamFiltering(stream, event); }); testWidgets('onMarkerDragStart', (WidgetTester tester) async { - final MarkerDragStartEvent event = MarkerDragStartEvent( + final event = MarkerDragStartEvent( mapId, const LatLng(43.3677, -5.8372), const MarkerId('test-123'), @@ -492,7 +477,7 @@ void main() { await testStreamFiltering(stream, event); }); testWidgets('onMarkerDrag', (WidgetTester tester) async { - final MarkerDragEvent event = MarkerDragEvent( + final event = MarkerDragEvent( mapId, const LatLng(43.3677, -5.8372), const MarkerId('test-123'), @@ -505,7 +490,7 @@ void main() { await testStreamFiltering(stream, event); }); testWidgets('onMarkerDragEnd', (WidgetTester tester) async { - final MarkerDragEndEvent event = MarkerDragEndEvent( + final event = MarkerDragEndEvent( mapId, const LatLng(43.3677, -5.8372), const MarkerId('test-123'), @@ -519,10 +504,7 @@ void main() { }); // Geometry testWidgets('onPolygonTap', (WidgetTester tester) async { - final PolygonTapEvent event = PolygonTapEvent( - mapId, - const PolygonId('test-123'), - ); + final event = PolygonTapEvent(mapId, const PolygonId('test-123')); final Stream stream = plugin.onPolygonTap( mapId: mapId, @@ -531,10 +513,7 @@ void main() { await testStreamFiltering(stream, event); }); testWidgets('onPolylineTap', (WidgetTester tester) async { - final PolylineTapEvent event = PolylineTapEvent( - mapId, - const PolylineId('test-123'), - ); + final event = PolylineTapEvent(mapId, const PolylineId('test-123')); final Stream stream = plugin.onPolylineTap( mapId: mapId, @@ -543,10 +522,7 @@ void main() { await testStreamFiltering(stream, event); }); testWidgets('onCircleTap', (WidgetTester tester) async { - final CircleTapEvent event = CircleTapEvent( - mapId, - const CircleId('test-123'), - ); + final event = CircleTapEvent(mapId, const CircleId('test-123')); final Stream stream = plugin.onCircleTap(mapId: mapId); @@ -554,20 +530,14 @@ void main() { }); // Map taps testWidgets('onTap', (WidgetTester tester) async { - final MapTapEvent event = MapTapEvent( - mapId, - const LatLng(43.3597, -5.8458), - ); + final event = MapTapEvent(mapId, const LatLng(43.3597, -5.8458)); final Stream stream = plugin.onTap(mapId: mapId); await testStreamFiltering(stream, event); }); testWidgets('onLongPress', (WidgetTester tester) async { - final MapLongPressEvent event = MapLongPressEvent( - mapId, - const LatLng(43.3608, -5.8425), - ); + final event = MapLongPressEvent(mapId, const LatLng(43.3608, -5.8425)); final Stream stream = plugin.onLongPress( mapId: mapId, 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 c2c650156b1b..003934e61686 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 @@ -19,23 +19,21 @@ void main() { final GoogleMapsInspectorPlatform inspector = GoogleMapsInspectorPlatform.instance!; - const LatLng mapCenter = LatLng(20, 20); - const CameraPosition initialCameraPosition = CameraPosition( - target: mapCenter, - ); + const mapCenter = LatLng(20, 20); + const initialCameraPosition = CameraPosition(target: mapCenter); group('MarkersController', () { - const int testMapId = 33930; + const testMapId = 33930; testWidgets('Marker clustering', (WidgetTester tester) async { - const ClusterManagerId clusterManagerId = ClusterManagerId('cluster 1'); + const clusterManagerId = ClusterManagerId('cluster 1'); - final Set clusterManagers = { + final clusterManagers = { const ClusterManager(clusterManagerId: clusterManagerId), }; // Create the marker with clusterManagerId. - final Set initialMarkers = { + final initialMarkers = { const Marker( markerId: MarkerId('1'), position: mapCenter, @@ -48,7 +46,7 @@ void main() { ), }; - final Completer mapIdCompleter = Completer(); + final mapIdCompleter = Completer(); await _pumpMap( tester, @@ -87,14 +85,11 @@ void main() { // Copy only the first marker with null clusterManagerId. // This means that both markers should be removed from the cluster. - final Set updatedMarkers = { + final updatedMarkers = { _copyMarkerWithClusterManagerId(initialMarkers.first, null), }; - final MarkerUpdates markerUpdates = MarkerUpdates.from( - initialMarkers, - updatedMarkers, - ); + final markerUpdates = MarkerUpdates.from(initialMarkers, updatedMarkers); await plugin.updateMarkers(markerUpdates, mapId: mapId); final List updatedClusters = @@ -128,7 +123,7 @@ Future waitForValueMatchingPredicate( bool Function(T) predicate, { int maxTries = 100, }) async { - for (int i = 0; i < maxTries; i++) { + for (var i = 0; i < maxTries; i++) { final T value = await getValue(); if (predicate(value)) { return value; 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 ad74c151d64f..adf8f4e1ee4c 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 @@ -102,8 +102,8 @@ void main() { }); testWidgets('update', (WidgetTester tester) async { - final MarkerController controller = MarkerController(marker: marker); - final gmaps.MarkerOptions options = gmaps.MarkerOptions() + final controller = MarkerController(marker: marker); + final options = gmaps.MarkerOptions() ..draggable = true ..position = gmaps.LatLng(42, 54); @@ -119,7 +119,7 @@ void main() { testWidgets('infoWindow null, showInfoWindow.', ( WidgetTester tester, ) async { - final MarkerController controller = MarkerController(marker: marker); + final controller = MarkerController(marker: marker); controller.showInfoWindow(); @@ -127,10 +127,10 @@ void main() { }); testWidgets('showInfoWindow', (WidgetTester tester) async { - final gmaps.InfoWindow infoWindow = gmaps.InfoWindow(); - final gmaps.Map map = gmaps.Map(createDivElement()); + final infoWindow = gmaps.InfoWindow(); + final map = gmaps.Map(createDivElement()); marker.set('map', map); - final MarkerController controller = MarkerController( + final controller = MarkerController( marker: marker, infoWindow: infoWindow, ); @@ -142,10 +142,10 @@ void main() { }); testWidgets('hideInfoWindow', (WidgetTester tester) async { - final gmaps.InfoWindow infoWindow = gmaps.InfoWindow(); - final gmaps.Map map = gmaps.Map(createDivElement()); + final infoWindow = gmaps.InfoWindow(); + final map = gmaps.Map(createDivElement()); marker.set('map', map); - final MarkerController controller = MarkerController( + final controller = MarkerController( marker: marker, infoWindow: infoWindow, ); @@ -160,8 +160,8 @@ void main() { late MarkerController controller; setUp(() { - final gmaps.InfoWindow infoWindow = gmaps.InfoWindow(); - final gmaps.Map map = gmaps.Map(createDivElement()); + final infoWindow = gmaps.InfoWindow(); + final map = gmaps.Map(createDivElement()); marker.set('map', map); controller = MarkerController(marker: marker, infoWindow: infoWindow); }); @@ -175,8 +175,7 @@ void main() { testWidgets('cannot call update after remove', ( WidgetTester tester, ) async { - final gmaps.MarkerOptions options = gmaps.MarkerOptions() - ..draggable = true; + final options = gmaps.MarkerOptions()..draggable = true; controller.remove(); 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 b8f60ee24cd8..2ddc21379784 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 @@ -43,7 +43,7 @@ void main() { }); testWidgets('addMarkers', (WidgetTester tester) async { - final Set markers = { + final markers = { const Marker(markerId: MarkerId('1')), const Marker(markerId: MarkerId('2')), }; @@ -60,9 +60,7 @@ void main() { gmaps.Marker? marker; gmaps.LatLng? position; - final Set markers = { - const Marker(markerId: MarkerId('1')), - }; + final markers = {const Marker(markerId: MarkerId('1'))}; await controller.addMarkers(markers); marker = controller.markers[const MarkerId('1')]?.marker; @@ -76,7 +74,7 @@ void main() { expect(position.lng, equals(0)); // Update the marker with draggable and position - final Set updatedMarkers = { + final updatedMarkers = { const Marker( markerId: MarkerId('1'), draggable: true, @@ -102,7 +100,7 @@ void main() { gmaps.Marker? marker; gmaps.LatLng? position; - final Set markers = { + final markers = { const Marker(markerId: MarkerId('1'), position: LatLng(42, 54)), }; await controller.addMarkers(markers); @@ -117,7 +115,7 @@ void main() { expect(position.lng, equals(54)); // Update the marker without position - final Set updatedMarkers = { + final updatedMarkers = { const Marker(markerId: MarkerId('1'), draggable: true), }; await controller.changeMarkers(updatedMarkers); @@ -135,7 +133,7 @@ void main() { ); testWidgets('removeMarkers', (WidgetTester tester) async { - final Set markers = { + final markers = { const Marker(markerId: MarkerId('1')), const Marker(markerId: MarkerId('2')), const Marker(markerId: MarkerId('3')), @@ -146,7 +144,7 @@ void main() { expect(controller.markers.length, 3); // Remove some markers... - final Set markerIdsToRemove = { + final markerIdsToRemove = { const MarkerId('1'), const MarkerId('3'), }; @@ -160,7 +158,7 @@ void main() { }); testWidgets('InfoWindow show/hide', (WidgetTester tester) async { - final Set markers = { + final markers = { const Marker( markerId: MarkerId('1'), infoWindow: InfoWindow(title: 'Title', snippet: 'Snippet'), @@ -184,7 +182,7 @@ void main() { testWidgets('only single InfoWindow is visible', ( WidgetTester tester, ) async { - final Set markers = { + final markers = { const Marker( markerId: MarkerId('1'), infoWindow: InfoWindow(title: 'Title', snippet: 'Snippet'), @@ -213,7 +211,7 @@ void main() { testWidgets('markers with custom asset icon work', ( WidgetTester tester, ) async { - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: AssetMapBitmap('assets/red_square.png', imagePixelRatio: 1.0), @@ -223,7 +221,7 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final gmaps.Icon? icon = + final icon = controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); @@ -243,7 +241,7 @@ void main() { testWidgets('markers with custom asset icon and pixelratio work', ( WidgetTester tester, ) async { - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: AssetMapBitmap('assets/red_square.png', imagePixelRatio: 2.0), @@ -253,7 +251,7 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final gmaps.Icon? icon = + final icon = controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); @@ -273,7 +271,7 @@ void main() { testWidgets('markers with custom asset icon with width and height work', ( WidgetTester tester, ) async { - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: AssetMapBitmap( @@ -288,7 +286,7 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final gmaps.Icon? icon = + final icon = controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); @@ -309,7 +307,7 @@ void main() { testWidgets('markers with missing asset icon should not set size', ( WidgetTester tester, ) async { - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: AssetMapBitmap( @@ -322,7 +320,7 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final gmaps.Icon? icon = + final icon = controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); @@ -339,7 +337,7 @@ void main() { WidgetTester tester, ) async { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: BytesMapBitmap( @@ -352,7 +350,7 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final gmaps.Icon? icon = + final icon = controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); @@ -384,7 +382,7 @@ void main() { WidgetTester tester, ) async { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: BytesMapBitmap(bytes, imagePixelRatio: 1), @@ -394,7 +392,7 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final gmaps.Icon? icon = + final icon = controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); @@ -415,7 +413,7 @@ void main() { WidgetTester tester, ) async { final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); - final Set markers = { + final markers = { Marker( markerId: const MarkerId('1'), icon: BytesMapBitmap(bytes, width: 20, height: 30), @@ -425,7 +423,7 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final gmaps.Icon? icon = + final icon = controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon, isNotNull); @@ -442,7 +440,7 @@ void main() { testWidgets('InfoWindow snippet can have links', ( WidgetTester tester, ) async { - final Set markers = { + final markers = { const Marker( markerId: MarkerId('1'), infoWindow: InfoWindow( @@ -455,7 +453,7 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final HTMLElement? content = + final content = controller.markers[const MarkerId('1')]?.infoWindow?.content as HTMLElement?; expect(content, isNotNull); @@ -472,7 +470,7 @@ void main() { // https://github.com/flutter/flutter/issues/67289 testWidgets('InfoWindow content is clickable', (WidgetTester tester) async { - final Set markers = { + final markers = { const Marker( markerId: MarkerId('1'), infoWindow: InfoWindow( @@ -485,7 +483,7 @@ void main() { await controller.addMarkers(markers); expect(controller.markers.length, 1); - final HTMLElement? content = + final content = controller.markers[const MarkerId('1')]?.infoWindow?.content as HTMLElement?; @@ -500,27 +498,27 @@ void main() { testWidgets('markers with anchor work', (WidgetTester tester) async { const double width = 20; const double height = 30; - const Offset defaultOffset = Offset(0.5, 1); - const Offset anchorOffset = Offset(0, 0.5); + const defaultOffset = Offset(0.5, 1); + const anchorOffset = Offset(0, 0.5); final Uint8List bytes = const Base64Decoder().convert(iconImageBase64); - final Marker marker1 = Marker( + final marker1 = Marker( markerId: const MarkerId('1'), icon: BytesMapBitmap(bytes, width: width, height: height), ); - final Marker marker2 = Marker( + final marker2 = Marker( markerId: const MarkerId('2'), icon: BytesMapBitmap(bytes, width: width, height: height), anchor: anchorOffset, ); - final Set markers = {marker1, marker2}; + final markers = {marker1, marker2}; await controller.addMarkers(markers); expect(controller.markers.length, 2); - final gmaps.Icon? icon1 = + final icon1 = controller.markers[const MarkerId('1')]?.marker?.icon as gmaps.Icon?; expect(icon1, isNotNull); - final gmaps.Icon? icon2 = + final icon2 = controller.markers[const MarkerId('2')]?.marker?.icon as gmaps.Icon?; expect(icon2, isNotNull); @@ -535,11 +533,9 @@ void main() { testWidgets('interpret correct zIndex in convertsion', ( WidgetTester tester, ) async { - const MarkerId markerId = MarkerId('1'); + const markerId = MarkerId('1'); - final Set markers = { - const Marker(markerId: markerId, zIndexInt: 4), - }; + final markers = {const Marker(markerId: markerId, zIndexInt: 4)}; await controller.addMarkers(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 d657c97e866b..16a42d85b03c 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 @@ -34,10 +34,10 @@ void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('TileOverlayController', () { - const TileOverlayId id = TileOverlayId(''); + const id = TileOverlayId(''); testWidgets('minimal initialization', (WidgetTester tester) async { - final TileOverlayController controller = TileOverlayController( + final controller = TileOverlayController( tileOverlay: const TileOverlay(tileOverlayId: id), ); @@ -51,14 +51,14 @@ void main() { }); testWidgets('produces image tiles', (WidgetTester tester) async { - final TileOverlayController controller = TileOverlayController( + final controller = TileOverlayController( tileOverlay: const TileOverlay( tileOverlayId: id, tileProvider: TestTileProvider(), ), ); - final HTMLImageElement img = + final img = controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; expect(img.naturalWidth, 0); @@ -75,14 +75,14 @@ void main() { }); testWidgets('update', (WidgetTester tester) async { - final TileOverlayController controller = TileOverlayController( + final controller = TileOverlayController( tileOverlay: const TileOverlay( tileOverlayId: id, tileProvider: NoTileProvider(), ), ); { - final HTMLImageElement img = + final img = controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; await null; // let `getTile` `then` complete @@ -97,7 +97,7 @@ void main() { const TileOverlay(tileOverlayId: id, tileProvider: TestTileProvider()), ); { - final HTMLImageElement img = + final img = controller.gmMapType.getTile(gmaps.Point(0, 0), 0, document)! as HTMLImageElement; 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 208d85f7883f..6a1f23833b58 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 @@ -22,7 +22,7 @@ import 'package:web/web.dart'; import 'overlays_test.mocks.dart'; MockTileProvider neverTileProvider() { - final MockTileProvider tileProvider = MockTileProvider(); + final tileProvider = MockTileProvider(); when( tileProvider.getTile(any, any, any), ).thenAnswer((_) => Completer().future); @@ -145,8 +145,7 @@ void main() { }); testWidgets('clearTileCache', (WidgetTester tester) async { - final Completer controllerCompleter = - Completer(); + final controllerCompleter = Completer(); await tester.pumpWidget( MaterialApp( home: Scaffold( 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 b3a61c4419d6..8a8529379fa0 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 @@ -28,12 +28,9 @@ void main() { IntegrationTestWidgetsFlutterBinding.ensureInitialized(); group('Methods that require a proper Projection', () { - const LatLng center = LatLng(43.3078, -5.6958); - const Size size = Size(320, 240); - const CameraPosition initialCamera = CameraPosition( - target: center, - zoom: 14, - ); + const center = LatLng(43.3078, -5.6958); + const size = Size(320, 240); + const initialCamera = CameraPosition(target: center, zoom: 14); late Completer controllerCompleter; late void Function(GoogleMapController) onMapCreated; @@ -77,13 +74,13 @@ void main() { ); testWidgets('addPadding', (WidgetTester tester) async { - const LatLng initialMapCenter = LatLng(0, 0); + const initialMapCenter = LatLng(0, 0); const double initialZoomLevel = 5; - const CameraPosition initialCameraPosition = CameraPosition( + const initialCameraPosition = CameraPosition( target: initialMapCenter, zoom: initialZoomLevel, ); - final LatLngBounds zeroLatLngBounds = LatLngBounds( + final zeroLatLngBounds = LatLngBounds( southwest: const LatLng(0, 0), northeast: const LatLng(0, 0), ); @@ -109,7 +106,7 @@ void main() { expect(firstVisibleRegion, isNot(zeroLatLngBounds)); expect(firstVisibleRegion.contains(initialMapCenter), isTrue); - const double padding = 0.1; + const padding = 0.1; await controller.moveCamera( CameraUpdate.newLatLngBounds(firstVisibleRegion, padding), ); @@ -171,7 +168,7 @@ void main() { final GoogleMapController controller = await controllerCompleter.future; final LatLngBounds bounds = await controller.getVisibleRegion(); - final LatLng northWest = LatLng( + final northWest = LatLng( bounds.northeast.latitude, bounds.southwest.longitude, ); @@ -196,7 +193,7 @@ void main() { await controllerCompleter.future; final LatLngBounds bounds = await controller.getVisibleRegion(); - final LatLng southEast = LatLng( + final southEast = LatLng( bounds.southwest.latitude, bounds.northeast.longitude, ); @@ -249,7 +246,7 @@ void main() { final GoogleMapController controller = await controllerCompleter.future; final LatLngBounds bounds = await controller.getVisibleRegion(); - final LatLng northWest = LatLng( + final northWest = LatLng( bounds.northeast.latitude, bounds.southwest.longitude, ); @@ -280,7 +277,7 @@ void main() { final GoogleMapController controller = await controllerCompleter.future; final LatLngBounds bounds = await controller.getVisibleRegion(); - final LatLng southEast = LatLng( + final southEast = LatLng( bounds.southwest.latitude, bounds.northeast.longitude, ); 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 2816fa9c2d32..c8f7f610d67c 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 @@ -51,9 +51,8 @@ void main() { }); testWidgets('update', (WidgetTester tester) async { - final CircleController controller = CircleController(circle: circle); - final gmaps.CircleOptions options = gmaps.CircleOptions() - ..draggable = true; + final controller = CircleController(circle: circle); + final options = gmaps.CircleOptions()..draggable = true; expect(circle.isDraggableDefined(), isFalse); @@ -78,8 +77,7 @@ void main() { testWidgets('cannot call update after remove', ( WidgetTester tester, ) async { - final gmaps.CircleOptions options = gmaps.CircleOptions() - ..draggable = true; + final options = gmaps.CircleOptions()..draggable = true; controller.remove(); @@ -108,9 +106,8 @@ void main() { }); testWidgets('update', (WidgetTester tester) async { - final PolygonController controller = PolygonController(polygon: polygon); - final gmaps.PolygonOptions options = gmaps.PolygonOptions() - ..draggable = true; + final controller = PolygonController(polygon: polygon); + final options = gmaps.PolygonOptions()..draggable = true; expect(polygon.isDraggableDefined(), isFalse); @@ -135,8 +132,7 @@ void main() { testWidgets('cannot call update after remove', ( WidgetTester tester, ) async { - final gmaps.PolygonOptions options = gmaps.PolygonOptions() - ..draggable = true; + final options = gmaps.PolygonOptions()..draggable = true; controller.remove(); @@ -169,11 +165,8 @@ void main() { }); testWidgets('update', (WidgetTester tester) async { - final PolylineController controller = PolylineController( - polyline: polyline, - ); - final gmaps.PolylineOptions options = gmaps.PolylineOptions() - ..draggable = true; + final controller = PolylineController(polyline: polyline); + final options = gmaps.PolylineOptions()..draggable = true; expect(polyline.isDraggableDefined(), isFalse); @@ -198,8 +191,7 @@ void main() { testWidgets('cannot call update after remove', ( WidgetTester tester, ) async { - final gmaps.PolylineOptions options = gmaps.PolylineOptions() - ..draggable = true; + final options = gmaps.PolylineOptions()..draggable = true; controller.remove(); @@ -218,10 +210,9 @@ void main() { }); testWidgets('update', (WidgetTester tester) async { - final HeatmapController controller = HeatmapController(heatmap: heatmap); - final visualization.HeatmapLayerOptions options = - visualization.HeatmapLayerOptions() - ..data = [gmaps.LatLng(0, 0)].toJS; + final controller = HeatmapController(heatmap: heatmap); + final options = visualization.HeatmapLayerOptions() + ..data = [gmaps.LatLng(0, 0)].toJS; expect(heatmap.data.array.toDart, hasLength(0)); @@ -246,8 +237,7 @@ void main() { testWidgets('cannot call update after remove', ( WidgetTester tester, ) async { - final visualization.HeatmapLayerOptions options = - visualization.HeatmapLayerOptions()..dissipating = true; + final options = visualization.HeatmapLayerOptions()..dissipating = true; controller.remove(); 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 8aa5fb52e49b..62630275bae8 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 @@ -46,7 +46,7 @@ void main() { }); testWidgets('addCircles', (WidgetTester tester) async { - final Set circles = { + final circles = { const Circle(circleId: CircleId('1')), const Circle(circleId: CircleId('2')), }; @@ -60,14 +60,12 @@ void main() { }); testWidgets('changeCircles', (WidgetTester tester) async { - final Set circles = { - const Circle(circleId: CircleId('1')), - }; + final circles = {const Circle(circleId: CircleId('1'))}; controller.addCircles(circles); expect(controller.circles[const CircleId('1')]?.circle?.visible, isTrue); - final Set updatedCircles = { + final updatedCircles = { const Circle(circleId: CircleId('1'), visible: false), }; controller.changeCircles(updatedCircles); @@ -77,7 +75,7 @@ void main() { }); testWidgets('removeCircles', (WidgetTester tester) async { - final Set circles = { + final circles = { const Circle(circleId: CircleId('1')), const Circle(circleId: CircleId('2')), const Circle(circleId: CircleId('3')), @@ -88,7 +86,7 @@ void main() { expect(controller.circles.length, 3); // Remove some circles... - final Set circleIdsToRemove = { + final circleIdsToRemove = { const CircleId('1'), const CircleId('3'), }; @@ -102,7 +100,7 @@ void main() { }); testWidgets('Converts colors to CSS', (WidgetTester tester) async { - final Set circles = { + final circles = { const Circle( circleId: CircleId('1'), fillColor: Color(0x7FFABADA), @@ -129,7 +127,7 @@ void main() { testWidgets('addCircles sets clickable according to consumeTapEvents', ( WidgetTester tester, ) async { - final Set circles = { + final circles = { const Circle(circleId: CircleId('1'), consumeTapEvents: true), const Circle(circleId: CircleId('2')), }; @@ -162,7 +160,7 @@ void main() { }); testWidgets('addPolygons', (WidgetTester tester) async { - final Set polygons = { + final polygons = { const Polygon(polygonId: PolygonId('1')), const Polygon(polygonId: PolygonId('2')), }; @@ -176,9 +174,7 @@ void main() { }); testWidgets('changePolygons', (WidgetTester tester) async { - final Set polygons = { - const Polygon(polygonId: PolygonId('1')), - }; + final polygons = {const Polygon(polygonId: PolygonId('1'))}; controller.addPolygons(polygons); expect( @@ -187,7 +183,7 @@ void main() { ); // Update the polygon - final Set updatedPolygons = { + final updatedPolygons = { const Polygon(polygonId: PolygonId('1'), visible: false), }; controller.changePolygons(updatedPolygons); @@ -200,7 +196,7 @@ void main() { }); testWidgets('removePolygons', (WidgetTester tester) async { - final Set polygons = { + final polygons = { const Polygon(polygonId: PolygonId('1')), const Polygon(polygonId: PolygonId('2')), const Polygon(polygonId: PolygonId('3')), @@ -211,7 +207,7 @@ void main() { expect(controller.polygons.length, 3); // Remove some polygons... - final Set polygonIdsToRemove = { + final polygonIdsToRemove = { const PolygonId('1'), const PolygonId('3'), }; @@ -225,7 +221,7 @@ void main() { }); testWidgets('Converts colors to CSS', (WidgetTester tester) async { - final Set polygons = { + final polygons = { const Polygon( polygonId: PolygonId('1'), fillColor: Color(0x7FFABADA), @@ -250,7 +246,7 @@ void main() { }); testWidgets('Handle Polygons with holes', (WidgetTester tester) async { - final Set polygons = { + final polygons = { const Polygon( polygonId: PolygonId('BermudaTriangle'), points: [ @@ -276,7 +272,7 @@ void main() { }); testWidgets('Polygon with hole has a hole', (WidgetTester tester) async { - final Set polygons = { + final polygons = { const Polygon( polygonId: PolygonId('BermudaTriangle'), points: [ @@ -297,7 +293,7 @@ void main() { controller.addPolygons(polygons); final gmaps.Polygon? polygon = controller.polygons.values.first.polygon; - final gmaps.LatLng pointInHole = gmaps.LatLng(28.632, -68.401); + final pointInHole = gmaps.LatLng(28.632, -68.401); expect(geometry.poly.containsLocation(pointInHole, polygon!), false); }); @@ -305,7 +301,7 @@ void main() { testWidgets('Hole Path gets reversed to display correctly', ( WidgetTester tester, ) async { - final Set polygons = { + final polygons = { const Polygon( polygonId: PolygonId('BermudaTriangle'), points: [ @@ -336,7 +332,7 @@ void main() { testWidgets('addPolygons sets clickable according to consumeTapEvents', ( WidgetTester tester, ) async { - final Set polygons = { + final polygons = { const Polygon(polygonId: PolygonId('1'), consumeTapEvents: true), const Polygon(polygonId: PolygonId('2')), }; @@ -369,7 +365,7 @@ void main() { }); testWidgets('addPolylines', (WidgetTester tester) async { - final Set polylines = { + final polylines = { const Polyline(polylineId: PolylineId('1')), const Polyline(polylineId: PolylineId('2')), }; @@ -383,14 +379,12 @@ void main() { }); testWidgets('changePolylines', (WidgetTester tester) async { - final Set polylines = { - const Polyline(polylineId: PolylineId('1')), - }; + final polylines = {const Polyline(polylineId: PolylineId('1'))}; controller.addPolylines(polylines); expect(controller.lines[const PolylineId('1')]?.line?.visible, isTrue); - final Set updatedPolylines = { + final updatedPolylines = { const Polyline(polylineId: PolylineId('1'), visible: false), }; controller.changePolylines(updatedPolylines); @@ -400,7 +394,7 @@ void main() { }); testWidgets('removePolylines', (WidgetTester tester) async { - final Set polylines = { + final polylines = { const Polyline(polylineId: PolylineId('1')), const Polyline(polylineId: PolylineId('2')), const Polyline(polylineId: PolylineId('3')), @@ -411,7 +405,7 @@ void main() { expect(controller.lines.length, 3); // Remove some polylines... - final Set polylineIdsToRemove = { + final polylineIdsToRemove = { const PolylineId('1'), const PolylineId('3'), }; @@ -425,7 +419,7 @@ void main() { }); testWidgets('Converts colors to CSS', (WidgetTester tester) async { - final Set lines = { + final lines = { const Polyline(polylineId: PolylineId('1'), color: Color(0x7FFABADA)), }; @@ -443,7 +437,7 @@ void main() { testWidgets('addPolylines sets clickable according to consumeTapEvents', ( WidgetTester tester, ) async { - final Set polylines = { + final polylines = { const Polyline(polylineId: PolylineId('1'), consumeTapEvents: true), const Polyline(polylineId: PolylineId('2')), }; @@ -468,7 +462,7 @@ void main() { group('HeatmapsController', () { late HeatmapsController controller; - const List heatmapPoints = [ + const heatmapPoints = [ WeightedLatLng(LatLng(37.782, -122.447)), WeightedLatLng(LatLng(37.782, -122.445)), WeightedLatLng(LatLng(37.782, -122.443)), @@ -491,7 +485,7 @@ void main() { }); testWidgets('addHeatmaps', (WidgetTester tester) async { - final Set heatmaps = { + final heatmaps = { const Heatmap( heatmapId: HeatmapId('1'), data: heatmapPoints, @@ -513,7 +507,7 @@ void main() { }); testWidgets('changeHeatmaps', (WidgetTester tester) async { - final Set heatmaps = { + final heatmaps = { const Heatmap( heatmapId: HeatmapId('1'), data: [], @@ -527,7 +521,7 @@ void main() { hasLength(0), ); - final Set updatedHeatmaps = { + final updatedHeatmaps = { const Heatmap( heatmapId: HeatmapId('1'), data: [WeightedLatLng(LatLng(0, 0))], @@ -544,7 +538,7 @@ void main() { }); testWidgets('removeHeatmaps', (WidgetTester tester) async { - final Set heatmaps = { + final heatmaps = { const Heatmap( heatmapId: HeatmapId('1'), data: heatmapPoints, @@ -567,7 +561,7 @@ void main() { expect(controller.heatmaps.length, 3); // Remove some polylines... - final Set heatmapIdsToRemove = { + final heatmapIdsToRemove = { const HeatmapId('1'), const HeatmapId('3'), }; @@ -581,7 +575,7 @@ void main() { }); testWidgets('Converts colors to CSS', (WidgetTester tester) async { - final Set heatmaps = { + final heatmaps = { const Heatmap( heatmapId: HeatmapId('1'), data: heatmapPoints, 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 325489f06377..aa94f0adb240 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 @@ -30,8 +30,8 @@ class CirclesController extends GeometryController { void _addCircle(Circle circle) { final gmaps.CircleOptions circleOptions = _circleOptionsFromCircle(circle); - final gmaps.Circle gmCircle = gmaps.Circle(circleOptions)..map = googleMap; - final CircleController controller = CircleController( + final gmCircle = gmaps.Circle(circleOptions)..map = googleMap; + final controller = CircleController( circle: gmCircle, consumeTapEvents: circle.consumeTapEvents, onTap: () { 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 b647d95a9882..fc4d0cd0069a 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 @@ -62,7 +62,7 @@ gmaps.MapOptions _configurationAndStyleToGmapsOptions( MapConfiguration configuration, List styles, ) { - final gmaps.MapOptions options = gmaps.MapOptions(); + final options = gmaps.MapOptions(); if (configuration.mapType != null) { options.mapTypeId = _gmapTypeIDForPluginType(configuration.mapType!); @@ -182,7 +182,7 @@ bool _isJsonMapStyle(Map value) { // Converts an incoming JSON-encoded Style info, into the correct gmaps array. List _mapStyles(String? mapStyleJson) { - List styles = []; + var styles = []; if (mapStyleJson != null) { try { styles = @@ -191,7 +191,7 @@ List _mapStyles(String? mapStyleJson) { reviver: (Object? key, Object? value) { if (value is Map && _isJsonMapStyle(value as Map)) { - List stylers = []; + var stylers = []; if (value['stylers'] != null) { stylers = (value['stylers']! as List) .whereType>() @@ -273,10 +273,9 @@ gmaps.InfoWindowOptions? _infoWindowOptionsFromMarker(Marker marker) { ..id = 'gmaps-marker-${marker.markerId.value}-infowindow'; if (markerTitle.isNotEmpty) { - final HTMLHeadingElement title = - (document.createElement('h3') as HTMLHeadingElement) - ..className = 'infowindow-title' - ..innerText = markerTitle; + final title = (document.createElement('h3') as HTMLHeadingElement) + ..className = 'infowindow-title' + ..innerText = markerTitle; container.appendChild(title); } if (markerSnippet.isNotEmpty) { @@ -322,7 +321,7 @@ gmaps.InfoWindowOptions? _infoWindowOptionsFromMarker(Marker marker) { gmaps.Size? _gmSizeFromIconConfig(List iconConfig, int sizeIndex) { gmaps.Size? size; if (iconConfig.length >= sizeIndex + 1) { - final List? rawIconSize = iconConfig[sizeIndex] as List?; + final rawIconSize = iconConfig[sizeIndex] as List?; if (rawIconSize != null) { size = gmaps.Size(rawIconSize[0]! as double, rawIconSize[1]! as double); } @@ -332,7 +331,7 @@ gmaps.Size? _gmSizeFromIconConfig(List iconConfig, int sizeIndex) { /// Sets the size of the Google Maps icon. void _setIconSize({required Size size, required gmaps.Icon icon}) { - final gmaps.Size gmapsSize = gmaps.Size(size.width, size.height); + final gmapsSize = gmaps.Size(size.width, size.height); icon.size = gmapsSize; icon.scaledSize = gmapsSize; } @@ -342,7 +341,7 @@ void _setIconAnchor({ required Offset anchor, required gmaps.Icon icon, }) { - final gmaps.Point gmapsAnchor = gmaps.Point( + final gmapsAnchor = gmaps.Point( size.width * anchor.dx, size.height * anchor.dy, ); @@ -400,7 +399,7 @@ Future _getBitmapSize(MapBitmap mapBitmap, String url) async { /// /// This method attempts to fetch the image size for a given [url]. Future _fetchBitmapSize(String url) async { - final HTMLImageElement image = HTMLImageElement()..src = url; + final image = HTMLImageElement()..src = url; // Wait for the onLoad or onError event. await Future.any(>[image.onLoad.first, image.onError.first]); @@ -451,7 +450,7 @@ Future _gmIconFromBitmapDescriptor( // The following code is for the deprecated BitmapDescriptor.fromBytes // and BitmapDescriptor.fromAssetImage. - final List iconConfig = bitmapDescriptor.toJson() as List; + final iconConfig = bitmapDescriptor.toJson() as List; if (iconConfig[0] == 'fromAssetImage') { assert(iconConfig.length >= 2); // iconConfig[2] contains the DPIs of the screen, but that information is @@ -467,7 +466,7 @@ Future _gmIconFromBitmapDescriptor( } } else if (iconConfig[0] == 'fromBytes') { // Grab the bytes, and put them into a blob - final List bytes = iconConfig[1]! as List; + final bytes = iconConfig[1]! as List; // Create a Blob from bytes, but let the browser figure out the encoding final Blob blob; @@ -516,7 +515,7 @@ Future _markerOptionsFromMarker( } gmaps.CircleOptions _circleOptionsFromCircle(Circle circle) { - final gmaps.CircleOptions circleOptions = gmaps.CircleOptions() + final circleOptions = gmaps.CircleOptions() ..strokeColor = _getCssColor(circle.strokeColor) ..strokeOpacity = _getCssOpacity(circle.strokeColor) ..strokeWeight = circle.strokeWidth @@ -534,27 +533,26 @@ visualization.HeatmapLayerOptions _heatmapOptionsFromHeatmap(Heatmap heatmap) { 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 - ..dissipating = heatmap.dissipating - ..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; + final 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 + ..dissipating = heatmap.dissipating + ..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; return heatmapOptions; } @@ -569,9 +567,9 @@ gmaps.PolygonOptions _polygonOptionsFromPolygon( final bool isClockwisePolygon = _isPolygonClockwise(path); - final List> paths = >[path]; + final paths = >[path]; - for (int i = 0; i < polygon.holes.length; i++) { + for (var i = 0; i < polygon.holes.length; i++) { final List hole = polygon.holes[i]; final List correctHole = _ensureHoleHasReverseWinding( hole, @@ -630,8 +628,8 @@ List _ensureHoleHasReverseWinding( /// the `path` is a transformed version of [Polygon.points] or each of the /// [Polygon.holes], guaranteeing that `lat` and `lng` can be accessed with `!`. bool _isPolygonClockwise(List path) { - double direction = 0.0; - for (int i = 0; i < path.length; i++) { + var direction = 0.0; + for (var i = 0; i < path.length; i++) { direction = direction + ((path[(i + 1) % path.length].lat - path[i].lat) * @@ -677,7 +675,7 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { return value as List; } - final List json = update.toJson() as List; + final json = update.toJson() as List; switch (json[0]) { case 'newCameraPosition': final Map position = asJsonObject(json[1]); @@ -697,7 +695,7 @@ void _applyCameraUpdate(gmaps.Map map, CameraUpdate update) { final List latLngPair = asJsonList(json[1]); final List latLng1 = asJsonList(latLngPair[0]); final List latLng2 = asJsonList(latLngPair[1]); - final double padding = json[2] as double; + final padding = json[2] as double; map.fitBounds( gmaps.LatLngBounds( gmaps.LatLng(latLng1[0]! as num, latLng1[1]! as num), @@ -749,9 +747,7 @@ String urlFromMapBitmap(MapBitmap mapBitmap) { (final BytesMapBitmap bytesMapBitmap) => _bitmapBlobUrlCache.putIfAbsent( bytesMapBitmap.byteData.hashCode, () { - final Blob blob = Blob( - [bytesMapBitmap.byteData.toJS].toJS, - ); + final blob = Blob([bytesMapBitmap.byteData.toJS].toJS); return URL.createObjectURL(blob as JSObject); }, ), @@ -792,7 +788,7 @@ gmaps.LatLng _pixelToLatLng(gmaps.Map map, int x, int y) { final int scale = 1 << (zoom.toInt()); // 2 ^ zoom - final gmaps.Point point = gmaps.Point( + final point = gmaps.Point( (x / scale) + bottomLeft.x, (y / scale) + topRight.y, ); 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 b7ee0ebc0e75..8e862f6e3dd7 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 @@ -605,12 +605,11 @@ class GoogleMapController { /// Updates the set of [TileOverlay]s. void updateTileOverlays(Set newOverlays) { - final MapsObjectUpdates updates = - MapsObjectUpdates.from( - _tileOverlays, - newOverlays, - objectName: 'tileOverlay', - ); + final updates = MapsObjectUpdates.from( + _tileOverlays, + newOverlays, + objectName: 'tileOverlay', + ); assert( _tileOverlaysController != null, 'Cannot update tile overlays after dispose().', 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 4f0058b4aec8..e980252e7c89 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 @@ -334,10 +334,9 @@ class GoogleMapsPlugin extends GoogleMapsFlutterPlatform { return _mapById[creationId]!.widget!; } - final StreamController> controller = - StreamController>.broadcast(); + final controller = StreamController>.broadcast(); - final GoogleMapController mapController = GoogleMapController( + final mapController = GoogleMapController( mapId: creationId, streamController: controller, widgetConfiguration: widgetConfiguration, 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 ca2ca74c5dc9..ef22a05adccb 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 @@ -39,19 +39,18 @@ class GroundOverlaysController extends GeometryController { groundOverlay.bounds!, ); - final gmaps.GroundOverlayOptions groundOverlayOptions = - gmaps.GroundOverlayOptions() - ..opacity = 1.0 - groundOverlay.transparency - ..clickable = groundOverlay.clickable - ..map = groundOverlay.visible ? googleMap : null; + final groundOverlayOptions = gmaps.GroundOverlayOptions() + ..opacity = 1.0 - groundOverlay.transparency + ..clickable = groundOverlay.clickable + ..map = groundOverlay.visible ? googleMap : null; - final gmaps.GroundOverlay overlay = gmaps.GroundOverlay( + final overlay = gmaps.GroundOverlay( urlFromMapBitmap(groundOverlay.image), bounds, groundOverlayOptions, ); - final GroundOverlayController controller = GroundOverlayController( + final controller = GroundOverlayController( groundOverlay: overlay, onTap: () { _onGroundOverlayTap(groundOverlay.groundOverlayId); 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 047a346c9fc2..105c2fb1a0c0 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 @@ -27,11 +27,9 @@ class HeatmapsController extends GeometryController { void _addHeatmap(Heatmap heatmap) { final visualization.HeatmapLayerOptions heatmapOptions = _heatmapOptionsFromHeatmap(heatmap); - final visualization.HeatmapLayer gmHeatmap = visualization.HeatmapLayer( - heatmapOptions, - ); + final gmHeatmap = visualization.HeatmapLayer(heatmapOptions); gmHeatmap.map = googleMap; - final HeatmapController controller = HeatmapController(heatmap: gmHeatmap); + final controller = HeatmapController(heatmap: gmHeatmap); _heatmapIdToController[heatmap.heatmapId] = controller; } @@ -48,7 +46,7 @@ class HeatmapsController extends GeometryController { /// Removes a set of [HeatmapId]s from the cache. void removeHeatmaps(Set heatmapIdsToRemove) { - for (final HeatmapId heatmapId in heatmapIdsToRemove) { + for (final heatmapId in heatmapIdsToRemove) { final HeatmapController? heatmapController = _heatmapIdToController[heatmapId]; heatmapController?.remove(); 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 8d15f3546b30..d5fca430e76d 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 @@ -158,7 +158,7 @@ MarkerClusterer createMarkerClusterer( gmaps.Map map, ClusterClickHandler onClusterClickHandler, ) { - final MarkerClustererOptions options = MarkerClustererOptions( + final 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 2b69cc2e47bb..a0dc2e361c4b 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 @@ -44,7 +44,7 @@ class MarkersController extends GeometryController { // we make one... if (infoWindowOptions.content != null && infoWindowOptions.content is HTMLElement) { - final HTMLElement content = infoWindowOptions.content! as HTMLElement; + final content = infoWindowOptions.content! as HTMLElement; content.onclick = (JSAny? _) { _onInfoWindowTap(marker.markerId); @@ -60,7 +60,7 @@ class MarkersController extends GeometryController { currentMarker, ); - final gmaps.Marker gmMarker = gmaps.Marker(markerOptions); + final gmMarker = gmaps.Marker(markerOptions); gmMarker.set('markerId', marker.markerId.value.toJS); @@ -70,7 +70,7 @@ class MarkersController extends GeometryController { gmMarker.map = googleMap; } - final MarkerController controller = MarkerController( + final controller = MarkerController( marker: gmMarker, clusterManagerId: marker.clusterManagerId, infoWindow: gmInfoWindow, 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 48f0be5c7ef1..650562a30972 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 @@ -40,8 +40,7 @@ class TileOverlayController { return null; } - final HTMLImageElement img = - ownerDocument!.createElement('img') as HTMLImageElement; + final img = ownerDocument!.createElement('img') as HTMLImageElement; img.width = img.height = logicalTileSize; img.hidden = true.toJS; img.setAttribute('decoding', 'async'); 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 fa6c24fca8da..b8b9cea80959 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 @@ -43,9 +43,7 @@ class TileOverlaysController extends GeometryController { } void _addTileOverlay(TileOverlay tileOverlay) { - final TileOverlayController controller = TileOverlayController( - tileOverlay: tileOverlay, - ); + final controller = TileOverlayController(tileOverlay: tileOverlay); _tileOverlays[tileOverlay.tileOverlayId] = controller; if (tileOverlay.visible) { 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 4600cb69ec53..d79d1adf5a0a 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 @@ -33,9 +33,8 @@ class PolygonsController extends GeometryController { googleMap, polygon, ); - final gmaps.Polygon gmPolygon = gmaps.Polygon(polygonOptions) - ..map = googleMap; - final PolygonController controller = PolygonController( + final gmPolygon = gmaps.Polygon(polygonOptions)..map = googleMap; + final controller = PolygonController( polygon: gmPolygon, consumeTapEvents: polygon.consumeTapEvents, onTap: () { 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 626d20ca5c8a..4263a92b5a72 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 @@ -33,9 +33,8 @@ class PolylinesController extends GeometryController { googleMap, polyline, ); - final gmaps.Polyline gmPolyline = gmaps.Polyline(polylineOptions) - ..map = googleMap; - final PolylineController controller = PolylineController( + final gmPolyline = gmaps.Polyline(polylineOptions)..map = googleMap; + final controller = PolylineController( polyline: gmPolyline, consumeTapEvents: polyline.consumeTapEvents, onTap: () {