Conversation
There was a problem hiding this comment.
Code Review
This pull request adds support for tapping points of interest on the map in the google_maps_flutter package by introducing the onPointOfInterestTap callback, updating the map controller to listen to the platform stream, and adding relevant tests and example usage. The feedback suggests checking if the widget is mounted before invoking the onPointOfInterestTap callback to prevent calling callbacks on an unmounted widget.
| void onPointOfInterestTap(PointOfInterestId pointOfInterestId) { | ||
| final ArgumentCallback<PointOfInterestId>? onPointOfInterestTap = widget.onPointOfInterestTap; | ||
| if (onPointOfInterestTap != null) { | ||
| onPointOfInterestTap(pointOfInterestId); | ||
| } | ||
| } |
There was a problem hiding this comment.
Since the map controller's stream subscriptions are disposed asynchronously (via _disposeController awaiting _controller.future), there is a small window during widget disposal where a platform event can still be received. To prevent calling callbacks on an unmounted widget (which could lead to setState being called after dispose in parent widgets), it is safer to check mounted before invoking the callback.
void onPointOfInterestTap(PointOfInterestId pointOfInterestId) {
if (!mounted) {
return;
}
final ArgumentCallback<PointOfInterestId>? onPointOfInterestTap = widget.onPointOfInterestTap;
if (onPointOfInterestTap != null) {
onPointOfInterestTap(pointOfInterestId);
}
}Expose the POI tap callback on GoogleMap now that platform implementations from flutter#12880 are published.
6cfab92 to
8fec43b
Compare
|
This doesn't need to be a new PR; once you update #11872 to reconcile it with what has landed, what is left will be just the app-facing portion, and it will already have reviews so will just need a final approval of the updated version. |
Summary
GoogleMap.onPointOfInterestTapAPI, example, and testsgoogle_maps_flutter_platform_interface2.17.0 ([google_maps_flutter_platform_interface] Add onPointOfInterestTap support #12752)iOS note: POI taps require
google_maps_flutter_ios_sdk9orgoogle_maps_flutter_ios_sdk10. The default/frozengoogle_maps_flutter_iospackage does not receive new features.Part of #11872.
Pre-Review Checklist
[shared_preferences]///).