Skip to content

[google_maps_flutter] Add onPointOfInterestTap support - #13027

Closed
tenninebt wants to merge 1 commit into
flutter:mainfrom
tenninebt:google-maps-poi-app-facing-v2
Closed

tenninebt wants to merge 1 commit into
flutter:mainfrom
tenninebt:google-maps-poi-app-facing-v2

Conversation

@tenninebt

@tenninebt tenninebt commented Sep 26, 2026 •

Copy link
Copy Markdown
Contributor

Summary

iOS note: POI taps require google_maps_flutter_ios_sdk9 or google_maps_flutter_ios_sdk10. The default/frozen google_maps_flutter_ios package does not receive new features.

Part of #11872.

Pre-Review Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [AI contribution guidelines] and understand my responsibilities, or I am not using AI tools.
  • I read the [Tree Hygiene] page, which explains my responsibilities.
  • I read and followed the [relevant style guides] and ran [the auto-formatter].
  • I signed the [CLA].
  • The title of the PR starts with the name of the package surrounded by square brackets, e.g. [shared_preferences]
  • I [linked to at least one issue that this PR fixes] in the description above.
  • I followed [the version and CHANGELOG instructions], using [semantic versioning] and the [repository CHANGELOG style].
  • I updated/added any relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making.
  • All existing and new tests are passing.

@tenninebt
tenninebt marked this pull request as ready for review September 26, 2026 11:12

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 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.

Comment on lines +712 to +717
void onPointOfInterestTap(PointOfInterestId pointOfInterestId) {
final ArgumentCallback<PointOfInterestId>? onPointOfInterestTap = widget.onPointOfInterestTap;
if (onPointOfInterestTap != null) {
onPointOfInterestTap(pointOfInterestId);
}
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.
@tenninebt
tenninebt force-pushed the google-maps-poi-app-facing-v2 branch from 6cfab92 to 8fec43b Compare September 26, 2026 11:24
@stuartmorgan-g

Copy link
Copy Markdown
Collaborator

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.

@tenninebt tenninebt closed this Sep 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants