navigation
Skill168 starsChanged 3 months agoMITView on GitHub
Best practices for navigation and routing in Flutter using GoRouter, covering hierarchical route trees, type-safe `@TypedGoRoute` definitions, named navigation, redirects, and deep linking setup. Use when creating, modifying, or reviewing routes, deep links, redirects, or navigation logic that uses package:go_router or package:go_router_builder, including widget tests that mock GoRouter or provide it through `InheritedGoRouter`. Also use for call-site navigation, however small: an `onTap`, button, or tap handler that takes the user from one screen to another, choosing between `context.go`, `goNamed`, `context.push`, `pushNamed`, or `pop`, navigating to a path such as `/products/p1`, passing data to a destination, or returning a result to the caller. A one-line navigation call is still navigation work. Route motion belongs to the animations skill, even inside a `GoRouteData` subclass.
9 other projects use a version of this.
Adopted by
Most recently taken up by
- astriaai/skillstheir own version, first seen Sep 12, 2026
- blyatiful1/ultrawebtheir own version, first seen Sep 2, 2026
- robium-ai/robiumtheir own version, first seen Aug 7, 2026
- mgifford/accessibility-skillstheir own version, first seen Jul 27, 2026
- TheBeardedBearSAS/claude-crafttheir own version, first seen Jul 22, 2026
- AlexeyPerov/Unity-Open-MCPtheir own version, first seen Jul 14, 2026
Other versions9 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 9
- TheBeardedBearSAS/claude-craft★ 106same name
- mgifford/accessibility-skills★ 50same name
- robium-ai/robium★ 21same name
- AlexeyPerov/Unity-Open-MCP★ 15same name
- moasq/ios-dev-agent★ 4same name
- astriaai/skills★ 2same name
- aubynsamuel/android-dev-skills★ 1same name
- blyatiful1/ultraweb★ 1same name
- miovrag/claude-skills★ 1same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository16 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- accessibilitySkill
- animationsSkill
- blocSkill
- create-projectSkill
- dart-flutter-sdk-upgradeSkill
- green-gateSkill
- internationalizationSkill
- layered-architectureSkill
- license-complianceSkill
- material-themingSkill
- static-securitySkill
- testingSkill
- ui-packageSkill
- very-good-analysis-upgradeSkill
The file
We split this skill into the rules it gives an agent
10 rules. 0 are common, 5 are distinctive, and 5 are very specific to this project.
0
Common
Most of the 7 edited versions we read keep these.
5
Distinctive
This author's own choices. Worth a look.
5
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 66
Every route is a GoRouteData class carrying a @TypedGoRoute annotation — never a raw string path.
- Very specific: line 97
Use push() only when a route must return data (e.g., a dialog collecting user input).
- Distinctive: line 101
Always use extension methods for cleaner syntax:
- Very specific: line 113
Use path parameters (:id) for resource identification and query parameters (?category=all) for optional filtering.
- Distinctive: line 133
Create the page widget (following the Page/View pattern if using Bloc)
- Distinctive: line 135
Add it as a sub-route under the appropriate parent route
- Very specific: line 136
Run dart run build_runner build --delete-conflicting-outputs to regenerate route helpers
- Distinctive: line 142
Use path parameters for resource identification
- Very specific: line 143
Use query parameters for filtering — never extra
- Distinctive: line 145
Test deep links by launching the app with the target URL
“Common” is measured: kept by at least 6 in 10 of the 7 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Navigation
Routing and navigation best practices for Flutter applications using GoRouter, the Flutter team's recommended routing package built on the Navigator 2.0 API.
Core Standards
Apply these standards to ALL navigation work:
- Use
package:go_routerfor all navigation — never raw Navigator 2.0 or Navigator 1.0 push/pop - Use
@TypedGoRouteannotations for type-safe routes — never raw string paths in route definitions - Prefer
go()overpush()— usepush()only when expecting return data from the destination - Never use the
extraparameter — it breaks deep linking and does not work on the web - Hierarchical sub-routes for proper back navigation — structure routes as parent-child trees, not flat lists
- Hyphens for URL word separation — never underscores or camelCase in URL paths
- Navigate by route name, not raw path strings — use named route navigation to decouple from path changes
- Use
BuildContextextensions for navigation — prefercontext.goNamed()overGoRouter.of(context).goNamed()
Route Organization
Structure routes hierarchically with logical parent-child relationships. Sub-routes ensure the app bar back button displays correctly and URLs remain clean.
Hierarchical Structure (Preferred)
/flutter
/flutter/news
/flutter/chat
/flutter/articles
/flutter/articles?category=all
/flutter/article/:id
/android
/android/news
/android/chatFlat Structure (Avoid)
/flutter-news
/flutter-chat
/android-news
/android-chatHierarchical sub-routes produce proper backward navigation automatically — when a user is on /flutter/news, the back button navigates to /flutter.
Type-Safe Routes
Every route is a GoRouteData class carrying a @TypedGoRoute annotation — never a raw
string path. Sub-routes nest inside the parent's routes: list so the hierarchy above is
expressed in the type system, and package:go_router_builder generates the navigation
helpers.
See references/typed-routes.md for basic routes, nested sub-routes, and shell routes.
Navigation Methods
go() vs push()
| Method | URL Updates | Back Button | Use Case |
go() | Yes | App bar | Standard navigation between screens |
push() | No | System | When expecting return data from popped route |
Using go() (Default)
const CategoriesPageRoute(size: 'small', color: 'blue').go(context);Using go() ensures the back button in the app's AppBar displays when the current route has a parent to navigate back to.
Using push() (Return Data Only)
final result = await DialogPageRoute().push<String>(context);Use push() only when a route must return data (e.g., a dialog collecting user input). On the web, push() does not update the address bar.
BuildContext Extensions
Always use extension methods for cleaner syntax:
// Preferred
context.goNamed('flutterNews');
// Avoid
GoRouter.of(context).goNamed('flutterNews');Parameter Strategies
Use path parameters (:id) for resource identification and query parameters (?category=all) for optional filtering. Never use extra — it breaks deep linking and does not work on the web.
See references/parameters.md for full examples of path parameters, query parameters, and why extra is prohibited.
Redirects
Redirects can be applied at the root router level (e.g., authentication guards) and at individual route levels (e.g., authorization guards). Parent redirects execute before child redirects.
See references/redirects.md for root-level and route-level redirect examples.
Testing
Mock GoRouter with package:mocktail and wrap widgets in InheritedGoRouter for widget tests. Test redirects by constructing a GoRouter with the target redirect logic and asserting the resulting page.
See references/testing.md for mocking GoRouter and testing redirect examples.
Common Patterns
Adding a New Route
- Create the page widget (following the Page/View pattern if using Bloc)
- Define a
GoRouteDataclass with@TypedGoRouteannotation - Add it as a sub-route under the appropriate parent route
- Run
dart run build_runner build --delete-conflicting-outputsto regenerate route helpers - Navigate using the generated type-safe route class
Deep Linking Setup
- Structure routes hierarchically with meaningful URL paths
- Use path parameters for resource identification
- Use query parameters for filtering — never
extra - Navigate by route name so path restructuring does not break links
- Test deep links by launching the app with the target URL
Additional Resources
- references/parameters.md — path parameters, query parameters, and why
extrais prohibited - references/redirects.md — root-level and route-level redirect examples
- references/typed-routes.md — basic routes, nested sub-routes, and shell routes
- references/testing.md — mocking
GoRouterand testing redirects
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

