flutter-routing-and-navigation
Installation
SKILL.md
flutter-navigation-routing
Goal
Implements robust navigation and routing in Flutter applications. Evaluates application requirements to select the appropriate routing strategy (imperative Navigator, declarative Router, or nested navigation), handles deep linking, and manages data passing between routes while adhering to Flutter best practices.
Instructions
1. Determine Routing Strategy (Decision Logic)
Evaluate the application's navigation requirements using the following decision tree:
- Condition A: Does the app require complex deep linking, web URL synchronization, or advanced routing logic?
- Action: Use the declarative
RouterAPI (typically via a routing package likego_router).
- Action: Use the declarative
- Condition B: Does the app require independent sub-flows (e.g., a multi-step setup wizard or persistent bottom navigation bars)?
- Action: Implement a Nested
Navigator.
- Action: Implement a Nested
- Condition C: Is it a simple application with basic screen-to-screen transitions and no complex deep linking?
- Action: Use the imperative
NavigatorAPI (Navigator.pushandNavigator.pop) withMaterialPageRouteorCupertinoPageRoute.
- Action: Use the imperative
- Condition D: Are Named Routes requested?
- Action: Use
MaterialApp.routesoronGenerateRoute, but note the limitations regarding deep link customization and web forward-button support.
- Action: Use
STOP AND ASK THE USER: "Based on your app's requirements, should we implement simple imperative navigation (Navigator.push), declarative routing (Router/go_router for deep links/web), or a nested navigation flow?"