Skip to content

Commit 98c5dd9

Browse files
stuartmorgan-gagrapine
authored andcommitted
[google_maps_flutter] Replace deprecated APIs (flutter#10474)
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 representation still used for heatmaps, it just continues to use the equivalent `toARGB()`. That will change once heatmaps are converted to Pigeon. 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 (flutter/flutter#117907). Part of flutter/flutter#159739 ## Pre-Review Checklist [^1]: Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling.
1 parent 62841e3 commit 98c5dd9

File tree

53 files changed

+742
-418
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+742
-418
lines changed

packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
## NEXT
1+
## 2.14.1
22

3+
* Replaces internal use of deprecated methods.
34
* Updates minimum supported SDK version to Flutter 3.32/Dart 3.8.
45

56
## 2.14.0

packages/google_maps_flutter/google_maps_flutter/example/lib/map_map_id.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class MapIdBodyState extends State<MapIdBody> {
5454
switch (_initializedRenderer) {
5555
case AndroidMapRenderer.latest:
5656
return 'latest';
57+
// ignore: deprecated_member_use
5758
case AndroidMapRenderer.legacy:
5859
return 'legacy';
5960
case AndroidMapRenderer.platformDefault:

packages/google_maps_flutter/google_maps_flutter/lib/src/google_map.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -723,7 +723,7 @@ MapConfiguration _configurationFromMapWidget(GoogleMap map) {
723723
indoorViewEnabled: map.indoorViewEnabled,
724724
trafficEnabled: map.trafficEnabled,
725725
buildingsEnabled: map.buildingsEnabled,
726-
cloudMapId: map.cloudMapId,
726+
mapId: map.cloudMapId,
727727
// A null style in the widget means no style, which is expressed as '' in
728728
// the configuration to distinguish from no change (null).
729729
style: map.style ?? '',

packages/google_maps_flutter/google_maps_flutter/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: google_maps_flutter
22
description: A Flutter plugin for integrating Google Maps in iOS and Android applications.
33
repository: https://github.com/flutter/packages/tree/main/packages/google_maps_flutter/google_maps_flutter
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+maps%22
5-
version: 2.14.0
5+
version: 2.14.1
66

77
environment:
88
sdk: ^3.8.0

packages/google_maps_flutter/google_maps_flutter_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.18.7
2+
3+
* Replaces internal use of deprecated methods.
4+
15
## 2.18.6
26

37
* Bumps com.android.tools.build:gradle from 8.12.1 to 8.13.1.

packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/Convert.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -627,8 +627,8 @@ static String interpretPolygonOptions(Messages.PlatformPolygon polygon, PolygonO
627627
sink.setConsumeTapEvents(polygon.getConsumesTapEvents());
628628
sink.setGeodesic(polygon.getGeodesic());
629629
sink.setVisible(polygon.getVisible());
630-
sink.setFillColor(polygon.getFillColor().intValue());
631-
sink.setStrokeColor(polygon.getStrokeColor().intValue());
630+
sink.setFillColor(polygon.getFillColor().getArgbValue().intValue());
631+
sink.setStrokeColor(polygon.getStrokeColor().getArgbValue().intValue());
632632
sink.setStrokeWidth(polygon.getStrokeWidth());
633633
sink.setZIndex(polygon.getZIndex());
634634
sink.setPoints(pointsFromPigeon(polygon.getPoints()));
@@ -654,7 +654,7 @@ static String interpretPolylineOptions(
654654
AssetManager assetManager,
655655
float density) {
656656
sink.setConsumeTapEvents(polyline.getConsumesTapEvents());
657-
sink.setColor(polyline.getColor().intValue());
657+
sink.setColor(polyline.getColor().getArgbValue().intValue());
658658
sink.setEndCap(capFromPigeon(polyline.getEndCap(), assetManager, density));
659659
sink.setStartCap(capFromPigeon(polyline.getStartCap(), assetManager, density));
660660
sink.setGeodesic(polyline.getGeodesic());
@@ -669,8 +669,8 @@ static String interpretPolylineOptions(
669669

670670
static String interpretCircleOptions(Messages.PlatformCircle circle, CircleOptionsSink sink) {
671671
sink.setConsumeTapEvents(circle.getConsumeTapEvents());
672-
sink.setFillColor(circle.getFillColor().intValue());
673-
sink.setStrokeColor(circle.getStrokeColor().intValue());
672+
sink.setFillColor(circle.getFillColor().getArgbValue().intValue());
673+
sink.setStrokeColor(circle.getStrokeColor().getArgbValue().intValue());
674674
sink.setStrokeWidth(circle.getStrokeWidth());
675675
sink.setZIndex(circle.getZIndex().floatValue());
676676
sink.setCenter(toLatLng(circle.getCenter().toList()));

packages/google_maps_flutter/google_maps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public PlatformView create(@NonNull Context context, int id, @Nullable Object ar
4848
builder.setInitialTileOverlays(params.getInitialTileOverlays());
4949
builder.setInitialGroundOverlays(params.getInitialGroundOverlays());
5050

51-
final String cloudMapId = mapConfig.getCloudMapId();
51+
final String cloudMapId = mapConfig.getMapId();
5252
if (cloudMapId != null) {
5353
builder.setMapId(cloudMapId);
5454
}

0 commit comments

Comments
 (0)