[go_router_builder] Fix generated onExit handling#12239
[go_router_builder] Fix generated onExit handling#12239agarwalrahul2702 wants to merge 4 commits into
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
There was a problem hiding this comment.
Code Review
This pull request updates the go_router_builder package to only enable onExit on generated routes when the route data class explicitly overrides it. It introduces a _hasOverriddenOnExit check in route_config.dart to inspect the class hierarchy and appends the hasOverriddenOnExit parameter to the generated route configurations. Additionally, the package version is bumped to 4.3.2, and corresponding test inputs and generated files are updated. Feedback suggests making the _hasOverriddenOnExit check more robust by also excluding GoRouteData and RelativeGoRouteData from being identified as user-overridden classes.
|
Follow-up pushed in 2321012 to cover review feedback:
Local checks run with the repo Flutter SDK (Dart 3.12.2):
|
Fixes flutter/flutter#189503
Description
Generated typed
GoRouteDataandRelativeGoRouteDataroute constructors now passhasOverriddenOnExitbased on whether the route data class actually overridesonExit.This keeps generated routes without
onExitoverrides aligned with handwrittenGoRoutebehavior, while still enablingonExitfor routes that define it.Root cause
go_routertreats an omittedhasOverriddenOnExitmarker astruefor backward compatibility with older generated code.go_router_builderwas omitting that marker for every generated typed route, so routes that did not overrideonExitstill received anonExitcallback. That changes pop timing and can surface Flutter's Navigator_RouteLifecycle.idleassertion during rapid system-back/re-enter navigation.Tests
GoRouteData.$routewithouthasOverriddenOnExit.test_inputs/on_exit.dart/.expectfor routes with and withoutonExitoverrides..g.dartfiles.dart run tool/run_tests.dartinpackages/go_router_builder.dart analyze --fatal-infosinpackages/go_router_builder.dart testinpackages/go_router_builder.dart format --output=none --set-exit-if-changed packages/go_router_builder.flutter_plugin_tools analyze --packages=go_router_builder --exact-match-only --no-downgrade.flutter_plugin_tools dart-test --packages=go_router_builder --exact-match-only.flutter_plugin_tools validate --packages=go_router_builder --exact-match-only.flutter_plugin_tools custom-test --packages=go_router_builder --exact-match-only.Pre-Review Checklist
[shared_preferences]///).CLA status is left for the GitHub CLA bot/account owner to verify.
If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.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