-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[go_router] Support for top level onEnter
callback.
#8339
base: main
Are you sure you want to change the base?
Conversation
Added onEnter callback to enable route interception and demonstrate usage in example.
Hi @chunhtai, This PR introduces a top-level onEnter callback, addressing critical gap in go_router’s handling of deep links and redirect customizations. It allows developers to intercept routes, block navigation, or implement custom logic. Given its potential impact, your feedback would be greatly appreciated. Thank you for your time! |
…nd enhanced OnEnter test.
Hi @chunhtai, Following up on this PR. I've updated the implementation to:
typedef OnEnter = bool Function(
BuildContext context,
GoRouterState currentState,
GoRouterState nextState
);
Let me know if you'd like any adjustments to this approach. |
Provides access to GoRouter within OnEnter callback to support navigation during early routing stages when InheritedGoRouter is not yet available in the widget tree.
Hi @chunhtai, I've expanded the The implementation:
|
Description:
This PR introduces top level
onEnter
callback inRouteConfiguration
to allow developers to intercept and conditionally block navigation based on incoming routes. It adds an example (top_level_on_enter.dart
) demonstrating its usage, such as handling referral code from/referral
.What This PR Changes:
onEnter
callback (typedef OnEnter
) to intercept route navigation before processing.onEnter
inGoRouteInformationParser
.RouteConfiguration
to include theonEnter
callback.top_level_on_enter.dart
, to demonstrate the feature.onEnter
callback functionality.Simple usage example:
Impact:
Enables developers to implement route-specific logic, such as support for handling action-based deep links without navigation (160602)
Pre-launch Checklist:
dart format
.)[go_router]
.pubspec.yaml
with an appropriate new version according to the [pub versioning philosophy], or this PR is [exempt from version changes].CHANGELOG.md
to add a description of the change, [following repository CHANGELOG style], or this PR is [exempt from CHANGELOG changes].///
).