[gis_web] Make maybeEnum more robust#9093
Conversation
Fixes #166548 This change improves the robustness of the `maybeEnum` method in the `gis_web` plugin. Previously, the method would throw an exception if it encountered an unknown value. Now, it returns `null` 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.
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
|
Thanks for the contribution! I'm marking this as a draft pending the rest of the checklist being completed, as it's not currently ready for review.
Please see the testing policy in the contribution docs. The size of the change is not a consideration in test exemption evaluation. |
|
✅ Added unit tests for maybeEnum utility in shared.dart |
|
Thanks for the fix! I would have landed this, but else beat you to the punch with this fix, here: #8999 (we should have assigned them the underlying issue, sorry!) |
Fixes flutter/flutter#166548
This change improves the robustness of the
maybeEnummethod in thegis_webplugin. Previously, the method would throw an exception if it encountered an unknown value. Now, it returnsnullinstead, 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
maybeEnumfunction 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.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