-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Description
copied from csells/go_router#184
https://github.com/csells/go_router/blob/master/lib/src/go_router_delegate.dart#L350
When we use the redirect we might want to check for dependencies injected in the widget tree using the context.
For instance, I have pages that are only accessible under certain user permissions. In Flutter web a user can simply type the url path to the page they want to see (navigate) but if the permission is not present the page should redirect.
I have the permissions up in the tree as the state of a bloc (using flutter bloc) and it would be great if I could receive the context in the redirect and simply find the bloc's state.
I believe this is possible, either passing the current navigator's state's context to the redirect callback or to the GoRouterState.
This should be broken into various stage:
- 1. refactor go route match to be in the routeinformationparser [go_router] Refactor RouterDelegate into functional pieces packages#1653
- 2. change native API to pass the context to RouteInformationParser Add RouteInformationParser.parseRouteInformationWithDependencies #102414
- 3. pass the context to redirect.