What problem does it solve?
Provides a consistent, testable, and auth-aware navigation architecture for Flutter apps using GoRouter so that route transitions, redirects, and deep links behave predictably across the application.
Core Features & Use Cases
- Centralized Router: Creates a singleton AppRouter with a full route tree and a single place to manage initialLocation, routes, shell routes, and nested navigation.
- Auth-aware Redirects & Guards: Implements redirect logic tied to an AuthBloc and persistent onboarding state to automatically route unauthenticated users to login or onboarding flows.
- Custom Transitions & Deep Links: Defines reusable custom page transitions and requires registration of a URI scheme for deep links, with a pattern for passing complex objects via typed extras.
- Use Case: In a ride-hailing and food delivery client, ensure the splash, onboarding, auth, and main tabbed flows are correctly gated by authentication state and that order tracking pages receive typed IDs from deep links.
Quick Start
Create the AppRouter singleton using GoRouter with GoRouterRefreshStream(authBloc.stream), implement RouteGuards.redirectLogic reading AuthBloc and onboarding flag, and use typed state.extra for complex arguments.