askill
flutter-navigation

flutter-navigationSafety 90Repository

GoRouter navigation patterns for Flutter: routing, auth guards, deep links, shell routes, and redirect logic. Trigger: When adding routes, implementing auth guards, configuring deep links, or managing navigation in the mobile app.

0 stars
1.2k downloads
Updated 2/9/2026

Package Files

Loading files...
SKILL.md

When to Use

  • Adding a new route/screen
  • Protecting routes behind authentication
  • Setting up bottom navigation with shell routes
  • Implementing deep links
  • Passing parameters between screens

Router Setup

Full GoRouter configuration with public routes, auth redirect, and StatefulShellRoute for bottom navigation.

Example: See assets/app_router.dart

Auth Guard — Global Redirect

Redirect function that checks auth state and routes accordingly:

  • Not authenticated + protected route → /login?redirect=...
  • Authenticated + auth route → /home (or stored redirect)

Example: See assets/auth_guard.dart

Route Patterns

Four common patterns: simple route, path parameter, query parameter, and nested routes.

Examples: See assets/route_patterns.dart

Shell Routes — Bottom Navigation

StatefulShellRoute preserves state across tabs (each tab keeps its own navigation stack).

Example: See assets/main_shell.dart

Navigation in Widgets

Use context.go(), context.push(), and context.pop() for declarative navigation.

Example: See assets/navigation_commands.dart

Connecting Router to MaterialApp

Use MaterialApp.router with routerConfig from a Riverpod provider.

Example: See assets/app_entry.dart

Route Organization by Feature

FeatureRoutes
Auth/login, /register, /forgot-password
Home/home
Booking/bookings, /bookings/:id, /bookings/new
Pet/pet/:petId, /pet/:petId/edit, /pet/:petId/medical
Caregiver/caregivers, /caregivers/:id
Profile/profile, /profile/edit
Chat/chat, /chat/:chatId

Naming Conventions

ElementPatternExample
Route pathkebab-case/forgot-password
Path parametercamelCase:petId, :chatId
Query parametercamelCase?serviceType=walk
Router providerrouterProviderSingle global instance

Anti-Patterns

❌ Don't✅ Do
Navigator.push (old API)context.go() or context.push()
Hardcode auth check in every pageUse global redirect in GoRouter
Create router outside RiverpodUse Provider<GoRouter> for reactivity
Deep nest routes beyond 3 levelsFlatten with path parameters
Pass complex objects via routePass IDs, fetch data in the page via provider
Forget to handle redirect param on loginStore and restore redirect after auth

Resources

  • Templates: See assets/ for router setup, guards, shell, and route patterns

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

78/100Analyzed 2/20/2026

Well-structured Flutter/GoRouter navigation skill with comprehensive coverage of routing patterns, auth guards, shell routes, and anti-patterns. Includes clear "When to Use" section, organized tables, and metadata. Slightly penalized for relying heavily on external asset files for code examples rather than embedding them directly. Project scope is reasonable for mobile Flutter development.

90
80
80
70
70

Metadata

Licenseunknown
Version-
Updated2/9/2026
Publisher333-333-333

Tags

apisecurity