Flutter Navigation
Model navigation as application state when URLs, deep links, restoration, or multiple navigators require it; use simpler imperative navigation for genuinely local flows.
Inspect first
Identify the current router, route ownership, authentication flow, tab/shell structure, supported platforms, URL requirements, and state restoration expectations. Preserve the existing routing package unless migration is requested.
Rules
- Keep route names, path parameters, and argument decoding typed or centrally validated.
- Make redirect logic deterministic and free of redirect loops.
- Preserve intended back behavior across Android system back, browser history, iOS gestures, nested navigators, and modals.
- Use nested navigation only for independent histories such as tab shells.
- Parse deep links into domain-safe state and define behavior for unknown or unauthorized destinations.
- Keep navigation side effects outside widget
build.
- Do not place large domain objects directly in URLs or restoration state.
Verification
Test cold deep links, warm links, back/forward behavior, authentication redirects, invalid parameters, restoration where required, and each supported shell/tab history.
References
When tab shell patterns or independent back histories are in scope, follow the nested shell navigation reference.
When handling deep links or state restoration, follow the deep link and restoration reference.
Sources
1---2name: flutter-navigation3description: Implement, review, or verify Flutter routing, deep-link destinations, back-stack behavior, nested navigation, restoration, redirects, and URL synchronization. Use for route correctness; pair with flutter-device-testing on a concrete runtime, and do not introduce a routing package by default.4---56# Flutter Navigation78Model navigation as application state when URLs, deep links, restoration, or multiple navigators require it; use simpler imperative navigation for genuinely local flows.910## Inspect first1112Identify the current router, route ownership, authentication flow, tab/shell structure, supported platforms, URL requirements, and state restoration expectations. Preserve the existing routing package unless migration is requested.1314## Rules1516- Keep route names, path parameters, and argument decoding typed or centrally validated.17- Make redirect logic deterministic and free of redirect loops.18- Preserve intended back behavior across Android system back, browser history, iOS gestures, nested navigators, and modals.19- Use nested navigation only for independent histories such as tab shells.20- Parse deep links into domain-safe state and define behavior for unknown or unauthorized destinations.21- Keep navigation side effects outside widget `build`.22- Do not place large domain objects directly in URLs or restoration state.2324## Verification2526Test cold deep links, warm links, back/forward behavior, authentication redirects, invalid parameters, restoration where required, and each supported shell/tab history.2728## References2930When tab shell patterns or independent back histories are in scope, follow the [nested shell navigation reference](references/nested-shell-navigation.md).31When handling deep links or state restoration, follow the [deep link and restoration reference](references/deep-link-and-restoration.md).3233## Sources3435- [Flutter navigation and routing](https://docs.flutter.dev/ui/navigation)36- [Deep linking](https://docs.flutter.dev/ui/navigation/deep-linking)