[google_maps_flutter] Add onPointOfInterestTap platform implementations - #12880
Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for tapping points of interest (POI) on the map in the google_maps_flutter_android plugin. The changes include updating the Android implementation to handle POI clicks, adding the necessary Pigeon messaging definitions, and updating the platform interface and tests to support the new event. A review comment suggests adding a null check for the PointOfInterest object in the GoogleMapController to improve robustness.
| @Override | ||
| public void onPoiClick(PointOfInterest pointOfInterest) { | ||
| if (pointOfInterest.placeId != null) { | ||
| flutterApi.onPointOfInterestTap( | ||
| pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE); | ||
| } | ||
| } |
There was a problem hiding this comment.
To prevent potential NullPointerExceptions, it is safer to perform a null check on pointOfInterest before accessing its properties, especially since it is a parameter received from an external SDK and Java does not have compile-time null safety.
| @Override | |
| public void onPoiClick(PointOfInterest pointOfInterest) { | |
| if (pointOfInterest.placeId != null) { | |
| flutterApi.onPointOfInterestTap( | |
| pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE); | |
| } | |
| } | |
| @Override | |
| public void onPoiClick(PointOfInterest pointOfInterest) { | |
| if (pointOfInterest != null && pointOfInterest.placeId != null) { | |
| flutterApi.onPointOfInterestTap( | |
| pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE); | |
| } | |
| } |
|
Please do not put GitHub username references in PR descriptions; that becomes the commit message, and it causes a huge amount of spam for those users over time as people update forks that include the commit. Also, pinging individual people is not how reviews are assigned. We have a triage process. |
Yeah you're right, won't happen again. |
Android, iOS (sdk9/sdk10), and web implementations for the published platform interface 2.17.0 stream.
3264bab to
2592be4
Compare
There was a problem hiding this comment.
Code Review
This pull request adds support for tapping points of interest (POIs) on the map across the Android, iOS, and Web implementations of the google_maps_flutter plugin. It introduces POI tap event handling, updates the platform interface, generates Pigeon messaging bindings, and adds corresponding unit and integration tests. Feedback on the changes suggests defensively checking for a null PointOfInterest parameter in the Android onPoiClick method to prevent a potential NullPointerException, along with adding a unit test to verify this behavior.
| @Override | ||
| public void onPoiClick(PointOfInterest pointOfInterest) { | ||
| if (pointOfInterest.placeId != null) { | ||
| flutterApi.onPointOfInterestTap( | ||
| pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE); | ||
| } | ||
| } |
There was a problem hiding this comment.
To prevent a potential NullPointerException, we should defensively check if pointOfInterest is null before accessing its properties.
| @Override | |
| public void onPoiClick(PointOfInterest pointOfInterest) { | |
| if (pointOfInterest.placeId != null) { | |
| flutterApi.onPointOfInterestTap( | |
| pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE); | |
| } | |
| } | |
| @Override | |
| public void onPoiClick(PointOfInterest pointOfInterest) { | |
| if (pointOfInterest != null && pointOfInterest.placeId != null) { | |
| flutterApi.onPointOfInterestTap( | |
| pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE); | |
| } | |
| } |
| @Test | ||
| public void OnPoiClickNullPlaceIdDoesNotCallFlutterApi() { | ||
| GoogleMapController googleMapController = getGoogleMapControllerWithMockedDependencies(); | ||
| googleMapController.onMapReady(mockGoogleMap); | ||
|
|
||
| googleMapController.onPoiClick(new PointOfInterest(new LatLng(0, 0), null, "Test Place")); | ||
|
|
||
| verify(flutterApi, times(0)).onPointOfInterestTap(any(), any()); | ||
| } |
There was a problem hiding this comment.
Add a unit test to verify that onPoiClick safely handles a null PointOfInterest parameter without throwing a NullPointerException.
@Test
public void OnPoiClickNullPlaceIdDoesNotCallFlutterApi() {
GoogleMapController googleMapController = getGoogleMapControllerWithMockedDependencies();
googleMapController.onMapReady(mockGoogleMap);
googleMapController.onPoiClick(new PointOfInterest(new LatLng(0, 0), null, "Test Place"));
verify(flutterApi, times(0)).onPointOfInterestTap(any(), any());
}
@Test
public void OnPoiClickNullPoiDoesNotCallFlutterApi() {
GoogleMapController googleMapController = getGoogleMapControllerWithMockedDependencies();
googleMapController.onMapReady(mockGoogleMap);
googleMapController.onPoiClick(null);
verify(flutterApi, times(0)).onPointOfInterestTap(any(), any());
}
mdebbar
left a comment
There was a problem hiding this comment.
Web changes look good to me!
|
This pull request is not mergeable in its current state, likely because of a merge conflict. Pre-submit CI jobs were not triggered. Pushing a new commit to this branch that resolves the issue will result in pre-submit jobs being scheduled. |
| tileOverlaysController = TileOverlaysController( | ||
| mapView: mapView, | ||
| tileProvider: dartCallbackHandler | ||
| tileProvider: (callbackHandler as? MapsCallbackApi) |
There was a problem hiding this comment.
The tile provider needs to be a parameter to this init method now, not something that relies on callers passing a specific implementation type.
There was a problem hiding this comment.
Done — tileProvider is now its own init parameter. Convenience inits create one MapsCallbackApi and pass it for both that and callbackHandler.
| mapView: mapView, | ||
| tileProvider: dartCallbackHandler | ||
| tileProvider: (callbackHandler as? MapsCallbackApi) | ||
| ?? MapsCallbackApi(binaryMessenger: binaryMessenger, messageChannelSuffix: pigeonSuffix) |
There was a problem hiding this comment.
We should never be making a second instance of the API handlers that's only partially used; that would make understanding call flows extremely confusing.
Also, this won't actually do anything. The tile provider is weakly owned by the overlay controller, so this is deallocated essentially immediately.
There was a problem hiding this comment.
Yeah, that fallback was wrong on both counts. Removed it — no second handler instance anymore.
|
I cannot review code that is failing the CLA check. If you are the author of the code you pushed, you need to amend your commit to list yourself, using the email address you signed the CLA with, as the author, and then force-push. |
516bc3f to
d2e6e81
Compare
Make placeId a read-only JS interop getter, and take tileProvider as an explicit GoogleMapController init parameter instead of casting or creating a second MapsCallbackApi.
d2e6e81 to
0dad398
Compare
…r#193351) flutter/packages@431ea69...e55e7ac 2026-09-25 50643541+Mairramer@users.noreply.github.com [material_ui] Add labelTextDirection handling in InputDecorator (flutter/packages#12607) 2026-09-24 tarrinneal@gmail.com [pigeon] Fix NSnumber edge cases and null value bug (flutter/packages#12997) 2026-09-24 50643541+Mairramer@users.noreply.github.com [camera] add custom path ouput to recording (flutter/packages#11774) 2026-09-24 jessiewong401@gmail.com [Android 17] Update packages CI test runners to SDK 37 (flutter/packages#12376) 2026-09-24 21270878+elliette@users.noreply.github.com [pigeon][video_player] Disable `video_player` and `pigeon` flakes blocking latest flutter -> packages roll (flutter/packages#13003) 2026-09-24 5684363+tenninebt@users.noreply.github.com [google_maps_flutter] Add onPointOfInterestTap platform implementations (flutter/packages#12880) If this roll has caused a breakage, revert this CL and set the roller to dry run mode using the controls here: https://autoroll.skia.org/r/flutter-packages-flutter-autoroll Please CC flutter-ecosystem@google.com 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
Expose the POI tap callback on GoogleMap now that platform implementations from flutter#12880 are published.
Expose the POI tap callback on GoogleMap now that platform implementations from flutter#12880 are published.
Summary
onPointOfInterestTapfor Android, iOS (sdk9/sdk10+ shared source), and webgoogle_maps_flutter_platform_interface2.17.0 from [google_maps_flutter_platform_interface] Add onPointOfInterestTap support #12752Notes
google_maps_flutter_iosis intentionally unchanged (no new features per that package’s README); iOS support is ingoogle_maps_flutter_ios_sdk9/google_maps_flutter_ios_sdk10callbackHandleron the designated initializer)Supersedes the separate drafts #12881 (web) and #12882 (iOS).
Part of #11872 / flutter/flutter#60695.
Pre-Review Checklist
[shared_preferences]///).