Skip to content

[go_router] Support asynchronous redirects #105808

@johnpryan

Description

@johnpryan

This is a proposal to change GoRouterRedirect to an asynchronous function.

typedef GoRouterRedirect = Future<String?> Function(GoRouterState state);

This would allow a redirect to make asynchronous calls, for example to check if the user is signed in:

redirect: (state) async {
  final signedIn = await _appState.auth.isSignedIn();
  if (!signedIn) return '/signin';
  return null;
},

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work listc: proposalA detailed proposal for a change to Flutterp: 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