Skip to content

[go_router] Add BuildContext to redirect #99121

@chunhtai

Description

@chunhtai

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:

Metadata

Metadata

Assignees

Labels

P3Issues that are less important to the Flutter projectc: new featureNothing broken; request for a new capabilityp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions