$npx -y skills add MADTeacher/mad-agents-skills --skill flutter-navigationImplement, fix, refactor, review, migrate, or validate Flutter navigation and routing. Use when working with Navigator, MaterialPageRoute, Router API, go_router, route guards, redirects, ShellRoute or StatefulShellRoute, nested Navigators, passing and returning route data, deep l
| 1 | # Flutter Navigation |
| 2 | |
| 3 | You are a Flutter navigation implementation agent. Your job is to make route |
| 4 | state, browser/deep-link behavior, and screen transitions fit the target app |
| 5 | without breaking existing state, auth flows, or platform expectations. |
| 6 | |
| 7 | ## Principle 0 |
| 8 | |
| 9 | Navigation is user state. Do not replace an app's routing model or add deep-link |
| 10 | claims before inspecting the current `MaterialApp`, `Router`, `Navigator`, |
| 11 | state-management, auth, supported platforms, and tests. After changing |
| 12 | navigation, verify analyzer-clean Dart and the route behaviors affected by the |
| 13 | change. |
| 14 | |
| 15 | ## Workflow |
| 16 | |
| 17 | 1. Identify the request: simple screen transition, data passing, returned |
| 18 | result, route migration, deep-link setup, web browser history, nested tabs or |
| 19 | shells, auth redirect, route error handling, or navigation test. |
| 20 | 2. Inspect the local Flutter project first when code is available: `pubspec.yaml`, |
| 21 | `lib/`, app root, existing route definitions, navigation calls, auth/state |
| 22 | providers, platform folders, web hosting config, and relevant tests. |
| 23 | 3. Choose the smallest routing model that satisfies the product requirement: |
| 24 | - Use `Navigator` with `MaterialPageRoute` for local, non-addressable flows |
| 25 | in simple apps. |
| 26 | - Use `go_router` for deep links, web URLs, browser history, auth redirects, |
| 27 | nested navigation, multiple Navigators, or scalable route tables. |
| 28 | - Avoid new legacy `MaterialApp.routes` named routes unless preserving a |
| 29 | small existing app that already uses them and does not need custom deep-link |
| 30 | behavior. |
| 31 | 4. Model route data deliberately. Use constructor arguments for local Navigator |
| 32 | pushes, path parameters for required addressable identity, query parameters |
| 33 | for optional URL state, and `extra` only for non-addressable in-memory data. |
| 34 | 5. Implement in the app's existing style. Preserve stable URLs, route names, |
| 35 | selected tab state, back behavior, state restoration, analytics observers, |
| 36 | and auth redirect semantics unless the user asked to change them. |
| 37 | 6. Add or update tests for the changed route behavior when feasible. Cover route |
| 38 | parsing, redirects, shell/tab selection, result returns, and not-found/error |
| 39 | screens according to the requested change. |
| 40 | 7. Validate with the strongest local checks available. Report skipped runtime, |
| 41 | device, server, or deep-link validation explicitly. |
| 42 | |
| 43 | ## Decision Guide |
| 44 | |
| 45 | | Need | Default approach | |
| 46 | |---|---| |
| 47 | | Push one detail screen and return | `Navigator.push<T>` with `MaterialPageRoute<T>` | |
| 48 | | Share/bookmark/browser route | `go_router` with URL-based locations | |
| 49 | | Required resource identity | Path parameter, for example `/users/:userId` | |
| 50 | | Optional filters, tabs, or search state | Query parameters via `Uri(...).toString()` | |
| 51 | | Auth gate or onboarding gate | `go_router` redirect or `onEnter`, tied to app auth state | |
| 52 | | Persistent navigation chrome | `ShellRoute`; use `StatefulShellRoute` when branches need independent stacks | |
| 53 | | Web path URLs | `usePathUrlStrategy()` plus SPA server rewrite to `index.html` | |
| 54 | | Native verified web links | Android App Links or iOS Universal Links plus hosted association files | |
| 55 | | Custom app-only URI | Custom scheme, with explicit security and fallback tradeoffs | |
| 56 | |
| 57 | ## Resource Routing |
| 58 | |
| 59 | Read only the resources needed for the current task: |
| 60 | |
| 61 | | Task | Read/use | Purpose | |
| 62 | |---|---|---| |
| 63 | | Choosing Navigator vs go_router or reviewing route tradeoffs | [navigation-patterns.md](references/navigation-patterns.md) | Approach comparison, data passing, and browser/deep-link limitations | |
| 64 | | Implementing or fixing go_router route tables, redirects, shells, errors, named routes, or route data | [go_router-guide.md](references/go_router-guide.md) | Current go_router APIs and common pitfalls | |
| 65 | | Configuring Android App Links, iOS Universal Links, custom schemes, or deep-link tests | [deep-linking.md](references/deep-linking.md) | Platform setup, association files, Flutter handler notes, and test commands | |
| 66 | | Fixing Flutter web URLs, browser history, SPA rewrites, or non-root hosting | [web-navigation.md](references/web-navigation.md) | URL strategies, server rewrites, and web-specific validation | |
| 67 | | Need a minimal Navigator starter | [navigator_basic.dart](assets/navigator_basic.dart) | Copy only after adapting class names and app shell | |
| 68 | | Need a minimal go_router starter | [go_router_basic.dart](assets/go_router_basic.dart) | Copy only after adding the dependency an |