-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[google_maps_flutter] Converts map configuration and platform view creation params to Pigeon #7207
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
[google_maps_flutter] Converts map configuration and platform view creation params to Pigeon #7207
Conversation
|
I put both platforms together this time since the scope is smaller than the previous PRs, and the structure of the change is the same between the two, but you can each just review your platform's half. |
| this.googleMap = googleMap; | ||
| } | ||
|
|
||
| void addJsonCircles(List<Object> circlesToAdd) { |
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.
On both platforms, the pure removal of the addJson* methods is because I added the Pigeon version in previous PRs, so this is removing temporarily-quasi-duplicated code.
|
|
||
| private void updateInitialMarkers() { | ||
| markersController.addJsonMarkers(initialMarkers); | ||
| if (initialMarkers != null) { |
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.
These new null checks are because addJson* was internally no-oping for nil, but the typed versions don't do that because I think it's cleaner to forbid calling add* than to silently no-op internally.
|
|
||
| @Before | ||
| public void setUp() { | ||
| MockitoAnnotations.openMocks(this); |
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.
Opportunistic cleanup; there were warnings about the fact that we weren't cleaning this up, and when I went to fix that I noticed that there were no mockito-annotated ivars in this test class.
| } | ||
|
|
||
| @Test | ||
| public void interpretMapConfiguration_handlesNulls() { |
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.
New tests because that entire method was untested before, which didn't seem great.
| Map<String, Object?> options) { | ||
| // All of these hard-coded values and structures come from | ||
| // google_maps_flutter_platform_interface/lib/src/types/utils/map_configuration_serialization.dart | ||
| // to support this legacy API that relied on cross-package magic strings. |
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.
(This applies to Android and iOS.)
This method is gross in that it uses magic strings from another package, but the good news is that it is only in the codepath for a platform interface API that we don't use in recent versions of the app-facing package. At some point we could just decide to do a breaking change to the implementation packages and remove this, without needing to do a breaking change to the app-facing or platform interface packages. I didn't want to do that in this PR though as it requires some extra steps.
(And while this looks like new gross code, it isn't conceptually: it's just moving from native to Dart, and moving from every codepath to a codepath that will in practice almost never be used.)
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.
Thank you for adding a link to where the magic strings come from
| (zoomPrefsJson as List<Object?>).cast<double?>(); | ||
| return PlatformZoomRange(min: minMaxZoom[0], max: minMaxZoom[1]); | ||
| } | ||
|
|
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.
(This applies to Android and iOS.)
The reason there's a bunch of added conversion code without any corresponding removal of JSON versions is that the JSON serialization code is in google_maps_flutter_platform_interface. That's ugly technical debt, because having the serialization and deserialization in different packages is a bad idea, and means the entire JSON surface is effective part of the public API surface of the platform interface package, and we therefore can't do anything to that code other than add things to dictionaries.
So it looks like it's adding complexity, but is actually reducing technical debt by moving the serialization into the same package as the deserialization where it belongs. (There's actually a TODO about this at the top of the file.)
| this.onMapCreated, | ||
| this.gestureRecognizers = const <Factory<OneSequenceGestureRecognizer>>{}, | ||
| this.compassEnabled = true, | ||
| this.mapToolbarEnabled = true, |
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.
These changes to the iOS example are opportunistic cleanup; these have always been Android-only, and just got copypasta'd here when I federated the implementations out of the original shared implementation.
|
I'm not sure what's going on with that Android test; there's not much info in FTL output, and I haven't been able to repro locally. I'll keep investigating that in parallel with review. |
Turns out there was, it was just buried in all the other log output. It found a real bug where I missed a change I needed to make in Convert.java (which the compiler didn't flag because it's code casts |
reidbaker
left a comment
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.
Android LGTM
| Map<String, Object?> options) { | ||
| // All of these hard-coded values and structures come from | ||
| // google_maps_flutter_platform_interface/lib/src/types/utils/map_configuration_serialization.dart | ||
| // to support this legacy API that relied on cross-package magic strings. |
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.
Thank you for adding a link to where the magic strings come from
… view creation params to Pigeon (flutter/packages#7207)
flutter/packages@5cc0a01...bb797b9 2024-08-08 [email protected] [google_maps_flutter] Converts map configuration and platform view creation params to Pigeon (flutter/packages#7207) 2024-08-08 [email protected] [flutter_markdown] Fix table column alignment (flutter/packages#7327) 2024-08-08 [email protected] [interactive_media_ads] Fix names of unit tests (flutter/packages#7336) 2024-08-07 [email protected] [url_launcher] Convert Linux to Pigeon (flutter/packages#7215) 2024-08-07 [email protected] Roll Flutter from 0a7f8af to d595e98 (4 revisions) (flutter/packages#7334) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/packages@5cc0a01...bb797b9 2024-08-08 [email protected] [google_maps_flutter] Converts map configuration and platform view creation params to Pigeon (flutter/packages#7207) 2024-08-08 [email protected] [flutter_markdown] Fix table column alignment (flutter/packages#7327) 2024-08-08 [email protected] [interactive_media_ads] Fix names of unit tests (flutter/packages#7336) 2024-08-07 [email protected] [url_launcher] Convert Linux to Pigeon (flutter/packages#7215) 2024-08-07 [email protected] Roll Flutter from 0a7f8af to d595e98 (4 revisions) (flutter/packages#7334) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
flutter/packages@5cc0a01...bb797b9 2024-08-08 [email protected] [google_maps_flutter] Converts map configuration and platform view creation params to Pigeon (flutter/packages#7207) 2024-08-08 [email protected] [flutter_markdown] Fix table column alignment (flutter/packages#7327) 2024-08-08 [email protected] [interactive_media_ads] Fix names of unit tests (flutter/packages#7336) 2024-08-07 [email protected] [url_launcher] Convert Linux to Pigeon (flutter/packages#7215) 2024-08-07 [email protected] Roll Flutter from 0a7f8af to d595e98 (4 revisions) (flutter/packages#7334) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Flutter: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
For both Android and iOS, convert the platform view creation parameters to a typed structure using Pigeon, via the ability to set a custom codec for the parameter, instead of a JSON dictionary, as well as converting the map configuration structure used in both those params and
updateMapConfiguration.This change removes the last high-level use of non-Pigeon code in the plugin. The remaining uses of JSON are now internal to individual maps objects, which means that it should now be the case that all future changes to this plugin use Pigeon structures rather than JSON. (The individual objects don't change often, if at all, and it would be reasonable if someone does want to add a new parameter to one of those objects to require converting that specific object, as that would not require sweeping changes or knowledge of how to do a more holistic Pigeon conversion.)
Part of flutter/flutter#117907
Pre-launch Checklist
dart format.)[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or this PR is exempt from CHANGELOG changes.///).