Hugo Pointcheval 45458e7784
Some checks failed
continuous-integration/drone/pr Build is failing
chore: initialize go router package
2023-11-14 18:19:10 +01:00

2.1 KiB

Flutter - Wyatt Go Router

Style: Wyatt Analysis SDK: Flutter

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;