Flutter - Wyatt Go Router
GoRouter Enhancements for Flutter
This package provides a set of utilities to help you use the GoRouter package.
Features
- PageProtection extension to add a protection to a page
- currentRoute method to get the current route anywhere in the app
- GoRouterRefreshStream to refresh the router when needed
- RouteBase flattenization to get a list of all the routes in the router
Usage
If you want to protect a page, you can use the PageProtection extension:
GoRoute(
path: '/sign_in',
...
)..setPublic(),
If you want to get the current route, you can use the currentRoute method:
final route = GoRouter.of(context).currentRoute;
// or
final route = context.currentRoute;
If you want to refresh the router, you can use the GoRouterRefreshStream:
GoRouterRefreshStream(
context.read<AuthenticationCubit<Session>>().stream,
)
If you want to get a list of all the routes in the router, you can use the RouteBase flattenization:
final routes = GoRouter.of(context).flattenedRoutes;