home / skills / hoangnguyen0403 / agent-skills-standard / flutter-navigation
This skill helps Flutter developers implement robust navigation using go_router, deep links, and named routes with proper validation and state preservation.
npx playbooks add skill hoangnguyen0403/agent-skills-standard --skill flutter-navigationReview the files below or copy the command above to add this skill to your agents.
---
name: Flutter Navigation
description: Flutter navigation patterns including go_router, deep linking, and named routes for Flutter apps.
metadata:
labels: [flutter, navigation, routing, deep-linking, go-router]
triggers:
files: ['**/*_route.dart', '**/*_router.dart', '**/main.dart']
keywords: [Navigator, GoRouter, routes, deep link, go_router, AutoRoute]
---
# Flutter Navigation
## **Priority: P1 (OPERATIONAL)**
Navigation and routing for Flutter apps using `go_router` or named routes.
## Guidelines
- **Package**: Use `go_router` for modern, declarative routing.
- **Deep Linking**: Configure `AndroidManifest.xml` and `Info.plist` for URL schemes.
- **Validation**: Validate parameters in `redirect` logic before navigation.
- **Stateful Tabs**: Use `IndexedStack` to preserve state in bottom navigation.
[Routing Patterns & Examples](references/routing-patterns.md)
## Anti-Patterns
- **No Manual URL Parsing**: Use `go_router` parsing, never `Uri.parse` manually.
- **No Stateless Tabs**: `Scaffold` body switching loses state; use `IndexedStack`.
- **No Unvalidated Deep Links**: Always check if IDs exist in `redirect`.
- **No Hardcoded Routes**: Use constants (e.g., `Routes.home`) or code generation.
## Related Topics
flutter-design-system | flutter-notifications | mobile-ux-core
This skill presents practical guidance for navigation and routing in Flutter apps, emphasizing go_router, deep linking, and named routes. It consolidates patterns, anti-patterns, and operational checks to make navigation predictable, testable, and maintainable. The recommendations target both single-screen flows and multi-tab apps.
The skill recommends using go_router as the primary routing mechanism for declarative, typed routes and built-in redirection. It explains how to configure platform deep links (AndroidManifest.xml and Info.plist), validate parameters in redirect logic, and preserve tab state with IndexedStack. It also highlights anti-patterns to avoid and suggests constants or code generation for route names.
Should I always use go_router instead of Navigator 2.0?
Use go_router unless you have highly custom navigator requirements; it builds on Navigator 2.0 and covers most routing, redirection, and deep-link needs with less boilerplate.
How do I prevent losing tab state when switching tabs?
Wrap tab pages in an IndexedStack so inactive tabs remain mounted; avoid replacing the Scaffold body directly as that unmounts and resets state.