We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
instead building router manually and using uri string like
context.go("/home/product");
we can use go router builder to generate
our route like this
@TypedGoRoute<HomeScreenRoute>( path: '/', routes: [ TypedGoRoute<SongRoute>( path: 'song/:id', ) ] ) @immutable class HomeScreenRoute extends GoRouteData { @override Widget build(BuildContext context, GoRouterState state) { return const HomeScreen(); } } @immutable class SongRoute extends GoRouteData { final int id; const SongRoute({ required this.id, }); @override Widget build(BuildContext context, GoRouterState state) { return SongScreen(songId: id.toString()); } } TextButton( onPressed: () { const SongRoute(id: 2).go(context); }, child: const Text('Go to song 2'), ),
also more scalable approach to router builder config
The text was updated successfully, but these errors were encountered:
instead handling all redirect globally
we can manage redirection per route basis, more code in short term but easier route handling in the future when the app gets too big/complicated
GoRouter( routes: [ GoRoute( path: '/', builder: (context, state) => const HomePage(), ), GoRoute( path: '/secret-route', redirect: (context, state) { final user = app_state.cachedAuthedUser.of(context); if (user == null) { return Uri( path: '/auth', queryParameters: { // Note that this requires usePathUrlStrategy(); from `package:flutter_web_plugins/url_strategy.dart` // and set OidcConstants_Store.originalUri: state.uri.toString(), }, ).toString(); } return null; }, builder: (context, state) => const SecretPage(), ), GoRoute( path: '/auth', redirect: (context, state) { // final user = app_state.cachedAuthedUser.of(context); if (user != null) { final originalUri = state .uri.queryParameters[OidcConstants_Store.originalUri]; if (originalUri != null) { return originalUri; } return '/secret-route'; } return null; }, builder: (context, state) => const AuthPage(), ), ], ),
Sorry, something went wrong.
No branches or pull requests
instead building router manually and using uri string like
we can use go router builder to generate
our route like this
also more scalable approach to router builder config
The text was updated successfully, but these errors were encountered: