-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[google_maps_flutter] Replace deprecated APIs #10474
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
[google_maps_flutter] Replace deprecated APIs #10474
Conversation
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
(flutter/flutter#117907).
Part of flutter/flutter#159739
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully replaces deprecated APIs, namely cloudMapId and Color.value, across the google_maps_flutter package and its platform implementations. The introduction of a structured PlatformColor type in Pigeon is a significant improvement for type safety and clarity between Dart and native code. The file and class renames to address technical debt are also valuable changes. The overall implementation is systematic and well-executed. I have a few minor suggestions to enhance code clarity by renaming some local variables to align with the new mapId property, which would further improve consistency.
...ps_flutter_android/android/src/main/java/io/flutter/plugins/googlemaps/GoogleMapFactory.java
Show resolved
Hide resolved
...s/google_maps_flutter/google_maps_flutter_android/test/google_maps_flutter_android_test.dart
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/ios/Classes/GoogleMapController.m
Show resolved
Hide resolved
packages/google_maps_flutter/google_maps_flutter_ios/test/google_maps_flutter_ios_test.dart
Show resolved
Hide resolved
…face (#10477) Replaces the deprecated `Color.value` with the replacement `toARGB()`. Since this is for legacy JSON representations, it continues it must remain compatible, so uses the same representation (unlike #10474 where it's replaced with structured representations). 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.
This fixes two sets of API deprecations:
Color.valueis deprecated. Rather than just replace it withtoARGB(), 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:UIColoruses four doubles, this passes the underlyingColordoubles directly via the wrapper class, so that it's not lossy.toARGB(). That will change once heatmaps are converted to Pigeon.This also annotates a couple of intentional internal uses of the deprecated
legacyrenderer 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
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3