About navigation
navigation is a skill that defines routing practices for Flutter applications using GoRouter. It focuses on typed, hierarchical routes, named navigation, and deep-link-friendly parameter choices, with guidance for redirects and tests.
Key features
- 01GoRouter-based navigation standards
- 02Typed routes with generated helpers
- 03Hierarchical route organization
- 04Named navigation and URL parameters
- 05Redirect and widget-test guidance
Use cases
- 01Adding a type-safe Flutter route
- 02Structuring screens for back navigation
- 03Setting up and testing deep links
Install
Copy the command and run it in a terminal.
npx skills add https:/ / github.com/ verygoodopensource/ vgv-ai-flutter-plugin --skill navigationAfter installing, type/navigationin Claude Code to confirm it loaded.
Bundled files
References and scripts installed along with SKILL.md.
agents/openai.yamlreferences/parameters.mdredirects.mdtesting.mdtyped-routes.mdDetails
From the project READMENavigation
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/chat
Flat Structure (Avoid)
/flutter-news
/flutter-chat
/android-news
/android-chat
Hierarchical 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