Conversation
336fb13 to
e125948
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 Android, iOS, and Web platforms in the google_maps_flutter plugin. It introduces the PointOfInterestId type and PointOfInterestTapEvent in the platform interface, exposes the onPointOfInterestTap callback on the GoogleMap widget, and implements the platform-specific event handling and Pigeon messaging. The review feedback suggests adding a defensive null check for the PointOfInterest parameter in the Android onPoiClick handler to prevent a potential NullPointerException.
| 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.
Defensively checking pointOfInterest for null before accessing its properties is a good practice to prevent potential NullPointerExceptions, especially since the parameter is not annotated with @NonNull.
| public void onPoiClick(PointOfInterest pointOfInterest) { | |
| if (pointOfInterest.placeId != null) { | |
| flutterApi.onPointOfInterestTap( | |
| pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE); | |
| } | |
| } | |
| public void onPoiClick(PointOfInterest pointOfInterest) { | |
| if (pointOfInterest != null && pointOfInterest.placeId != null) { | |
| flutterApi.onPointOfInterestTap( | |
| pointOfInterest.placeId, (Result<Unit> result) -> Unit.INSTANCE); | |
| } | |
| } |
There was a problem hiding this comment.
The placeId null guard is the important part, and it’s already there. The Maps SDK only calls onPoiClick with a non-null PointOfInterest when a POI is tapped, and the other click handlers in this class don’t null-check their parameters either. We already have a test for the realistic case (placeId == null), which matches iOS. An extra pointOfInterest != null check would be harmless but unnecessary.
|
Hi @stuartmorgan-g when you're ready to review ping me and I'll do it right away. I'd rather fix the conflicts onces and for all instead of doing it every commit on that part of the code ;). |
|
No need to resolve changelog/pubspec comments until the whole review process is essentially complete (per the FAQ) since the conflicts in those files don't affect the ability to review the changes. |
| - (void)didLongPressAtPosition:(FGMPlatformLatLng *)position; | ||
|
|
||
| /// Called when a point of interest is tapped. | ||
| - (void)didTapPointOfInterestWithPlaceId:(NSString *)placeId; |
There was a problem hiding this comment.
...WithPlaceIdentifier:
There was a problem hiding this comment.
Renamed. I also moved the declaration up so it sits in the same spot as the matching method in MapsCallbackApi.
| void onCircleTap(String circleId); | ||
|
|
||
| /// Called when a point of interest is tapped. | ||
| @ObjCSelector('didTapPointOfInterestWithPlaceId:') |
There was a problem hiding this comment.
...PlaceIdentifier:
There was a problem hiding this comment.
Done, it's didTapPointOfInterestWithPlaceIdentifier: now.
2247d7a to
1215581
Compare
62ef656 to
954c841
Compare
…port (#12752) This is the platform interface portion of #11872 Adds `PointOfInterestId`, `PointOfInterestTapEvent`, and `GoogleMapsFlutterPlatform.onPointOfInterestTap`. The default implementation returns an empty stream so existing platform implementations are not broken. Fixes flutter/flutter#60695 (platform interface only; app-facing and implementation packages land in follow-up PRs per the federated plugin contribution process). ## Pre-Review Checklist @stuartmorgan-g — this is the first sub-PR from #11872 as requested.
|
The platform interface change should publish shortly, at which point you can update this PR to use it (and resolve conflicts from the Swift migration), then split out the PR with the platform implementation packages. |
|
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. |
|
Opened the Android implementation sub-PR: #12880 Web implementation branch is ready at |
|
Opened implementation sub-PRs: |
|
Implementations didn't need to each be separate PRs from each other, but since you've opened them already we can proceed that way. |
Would rather have me update this PR? (I can still close the others if it is more convenient for you guys.) |
|
Please see https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins. This PR contains both implementation packages and the app-facing package, so cannot land this way. The flow we recommend for a change like this is the one described there, which involves three total PRs. |
Got it, I closed the 2 draft PRs and used the following for the implementations: #12880 |
…ns (#12880) ## Summary - Platform implementations of `onPointOfInterestTap` for **Android**, **iOS** (`sdk9` / `sdk10` + shared source), and **web** - Depends on published `google_maps_flutter_platform_interface` 2.17.0 from #12752 - Federated implementations PR (per [Changing federated plugins](https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#changing-federated-plugins)); app-facing package will follow in a separate PR **Notes** - Frozen `google_maps_flutter_ios` is intentionally unchanged (no new features per that package’s README); iOS support is in `google_maps_flutter_ios_sdk9` / `google_maps_flutter_ios_sdk10` - iOS DI follows the Swift controller conventions (required `callbackHandler` on the designated initializer) Supersedes the separate drafts #12881 (web) and #12882 (iOS). Part of #11872 / flutter/flutter#60695. ## Pre-Review Checklist
|
@tenninebt could you resolved the conflict and rebase? thanks |
Expose the POI tap callback on GoogleMap now that platform implementations from flutter#12880 are published.
954c841 to
f71e8e8
Compare
| /// Called when a point of interest on the map is tapped. | ||
| /// | ||
| /// Supported on Android and web, and on iOS when using | ||
| /// `google_maps_flutter_ios_sdk9` or `google_maps_flutter_ios_sdk10`. |
There was a problem hiding this comment.
This comment does not belong in this package; it will become incorrect when, inevitably, new _sdk* variants are introduced that also support this feature.
It should simply say that it may not be supported on all implementations. A note about google_maps_flutter_ios not supporting a feature belongs in the google_maps_flutter_ios README, not here.
| /// | ||
| /// Supported on Android and web, and on iOS when using | ||
| /// `google_maps_flutter_ios_sdk9` or `google_maps_flutter_ios_sdk10`. | ||
| /// The default `google_maps_flutter_ios` package does not receive new |
There was a problem hiding this comment.
When the endorsed implementation is changed, there is essentially no chance that the person making that change would remember the existence of this comment, so this also does not belong here.
| * Adds support for tapping points of interest on the map. | ||
| On iOS, this requires `google_maps_flutter_ios_sdk9` or | ||
| `google_maps_flutter_ios_sdk10` (the default `google_maps_flutter_ios` | ||
| package does not receive new features). |
There was a problem hiding this comment.
(This is fine, since CHANGELOG entries are not expected to be evergreen.)
Keep app-facing dartdoc generic, and document that the frozen iOS implementation does not support the callback in its own README.
Adds
GoogleMap.onPointOfInterestTap, a callback that fires when the user taps a built-in map point of interest. The callback receives aPointOfInterestIdcontaining the place ID only, matching maintainer feedback on #4052 and #10963.The change is wired through the federated plugin stack: platform_interface (type + event stream), Android (
OnPoiClickListener), iOS including sdk9/sdk10/shared (didTapPOIWithPlaceID), web (IconMouseEvent.placeIdon map click), and the app-facinggoogle_maps_flutterpackage. Tests cover Dart unit tests, Android Robolectric, iOS native, and web integration tests in the web example.Fixes flutter/flutter#60695
Pre-Review Checklist
[shared_preferences]///).