core/router/ — Navigation

Implement auth-aware GoRouter navigation with redirects, shell routes, and typed extras.

Updated Apr 13, 2026
One-click install
npx skills add https://github.com/Vantoan252003/Mozi --skill core-router-navigation
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: core/router/ — Navigation
Source: https://github.com/Vantoan252003/Mozi/tree/main/lib/core/router
Command: npx skills add https://github.com/Vantoan252003/Mozi --skill core-router-navigation

SYSTEM DOCUMENTATION & REQUIREMENTS

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.

Frequently Asked Questions about core/router/ — Navigation

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up auth-aware redirects and route guards in Flutter GoRouter?

Auth-aware redirects in Flutter GoRouter are set up by implementing router refresh logic tied to an AuthBloc stream and persistent onboarding state to automatically route unauthenticated users to login or onboarding flows.

How do I pass complex objects between pages using GoRouter typed extras?

You pass complex objects between pages in GoRouter by using typed state extras, which allows the receiving page to extract and cast the state.extra payload without losing type safety.

What is the best way to handle deep links and custom page transitions in a Flutter app?

Handling deep links and custom page transitions in Flutter requires registering a URI scheme for deep links and defining reusable custom page transitions within a centralized GoRouter singleton configuration.

Does GoRouter support shell routes for tabbed navigation with auth gating?

Yes, GoRouter supports shell routes for tabbed navigation, and auth gating is achieved by applying explicit route guards that read the AuthBloc state to verify user authentication before accessing main flows.

Why does my GoRouter redirect loop when checking onboarding and authentication state?

A GoRouter redirect loop occurs when redirect logic does not distinctly resolve persistent onboarding state versus AuthBloc authentication, failing to properly terminate the redirect chain for already verified users.