[gis_web] Make maybeEnum more robust #9093
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes flutter/flutter#166548
This change improves the robustness of the
maybeEnum
method in thegis_web
plugin. Previously, the method would throw an exception if it encountered an unknown value. Now, it returnsnull
instead, aligning the behavior with the expectations outlined in the issue.I chose not to add logging for unknown values at this time in order to keep the implementation consistent with the similar method in
google_adsense
. Additionally, I was unsure what the best logging strategy would be, and I'm not fully convinced that logging unknown enum values is always beneficial, especially given the fluidity of the GIS API.No repository tests were modified, as the change was minimal and focused. I verified the behavior manually by feeding various inputs to the
maybeEnum
function and checking that the output matched expectations.I reviewed the implementation referenced in the issue, but I deliberately avoided using an extension method for consistency with the Flutter repository's style guide.
Let me know if adding logs or converting this into an extension would be preferred, and I’d be happy to revisit.
Pre-Review Checklist
[shared_preferences]
pubspec.yaml
with 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.md
to 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