[google_maps_flutter] Fix add-marker crash on Android#11061
Conversation
Fixes a regression introduced with advanced marker support where the native code was assuming a non-null marker type, but the Dart code was not enforcing that, and assumed that all configurations explicitly set a marker type. This is now enforced at the Pigeon level, with a default value set in Dart. I also added annotations on the native side to make it explicit that the marker type is suppposed to be non-null now, instead of it being an implicit requirement of the implementation of the switch statement. Fixes flutter/flutter#182540
|
We could of course fix this locally in the switch on the Java side instead, keeping everything nullable, but it seemed both clearer and safer to me to handle this on the Dart side and just never allow null across the boundary. |
There was a problem hiding this comment.
Code Review
This pull request effectively addresses a crash on Android when adding markers by enforcing that the marker type is non-null. The fix is well-implemented across the Dart and native Android code, with a safe default provided on the Dart side and explicit @NonNull annotations and runtime checks on the Java side. The related tests have been updated correctly, and a new test has been added to verify the default behavior, which is great. I have one suggestion regarding the manual edits in a generated file to improve long-term maintainability.
Fixes a regression introduced with advanced marker support where the native code was assuming a non-null marker type, but the Dart code was not enforcing that, and assumed that all configurations explicitly set a marker type.
This is now enforced at the Pigeon level, with a default value set in Dart. I also added annotations on the native side to make it explicit that the marker type is suppposed to be non-null now, instead of it being an implicit requirement of the implementation of the switch statement.
Fixes flutter/flutter#182540
Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3