원클릭으로
navigation
Best practices for navigation and routing in Flutter using GoRouter.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
메뉴
Best practices for navigation and routing in Flutter using GoRouter.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
SOC 직업 분류 기준
Drives a Dart or Flutter package to a fully green state through an autonomous verify-fix-rerun loop across four quality gates — analyze, format, test, and coverage. Exits only when a single final iteration proves all four pass with observed numbers.
VGV-specific reference for bumping Dart and Flutter SDK constraints across packages. Covers pubspec.yaml environment constraints, CI workflow Flutter versions, and SDK upgrade PR preparation. CI uses ^MAJOR.MINOR.x to resolve to the latest patch; pubspec pins the exact patch version (e.g., ^3.50.1).
Upgrade very_good_analysis lint package to new version across Dart/Flutter projects. Handles version bump, lint fixes, and PR creation.
Best practices for Dart unit tests, Flutter widget tests, and golden file tests.
Audit or remediate Flutter widgets against WCAG 2.2 accessibility conformance levels A, AA, or AAA across iOS, Android, Web, macOS, Windows, and Linux.
Best practices for Flutter animations using the built-in animation framework. Use when creating, modifying, or reviewing animations, transitions, motion, or animated widgets. Covers implicit animations, explicit animations, page transitions, and Material 3 motion tokens.
| name | navigation |
| description | Best practices for navigation and routing in Flutter using GoRouter. |
| when_to_use | Use when creating, modifying, or reviewing routes, deep links, redirects, or navigation logic that uses package:go_router or package:go_router_builder. |
| allowed-tools | Read Glob Grep |
| model | sonnet |
Routing and navigation best practices for Flutter applications using GoRouter, the Flutter team's recommended routing package built on the Navigator 2.0 API.
Apply these standards to ALL navigation work:
package:go_router for all navigation — never raw Navigator 2.0 or Navigator 1.0 push/pop@TypedGoRoute annotations for type-safe routes — never raw string paths in route definitionsgo() over push() — use push() only when expecting return data from the destinationextra parameter — it breaks deep linking and does not work on the webBuildContext extensions for navigation — prefer context.goNamed() over GoRouter.of(context).goNamed()Structure routes hierarchically with logical parent-child relationships. Sub-routes ensure the app bar back button displays correctly and URLs remain clean.
/flutter
/flutter/news
/flutter/chat
/flutter/articles
/flutter/articles?category=all
/flutter/article/:id
/android
/android/news
/android/chat
/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.
Use @TypedGoRoute annotations with GoRouteData classes to eliminate typos and manual parameter casting. The go_router_builder package generates type-safe route helpers at build time.
@TypedGoRoute<CategoriesPageRoute>(
name: 'categories',
path: '/categories',
)
@immutable
class CategoriesPageRoute extends GoRouteData {
const CategoriesPageRoute({
this.size,
this.color,
});
final String? size;
final String? color;
@override
Widget build(BuildContext context, GoRouterState state) {
return CategoriesPage(size: size, color: color);
}
}
@TypedGoRoute<FlutterPageRoute>(
name: 'flutter',
path: '/flutter',
routes: [
TypedGoRoute<FlutterNewsPageRoute>(
name: 'flutterNews',
path: 'news',
),
TypedGoRoute<FlutterArticlesPageRoute>(
name: 'flutterArticles',
path: 'articles',
routes: [
TypedGoRoute<FlutterArticlePageRoute>(
name: 'flutterArticle',
path: 'article/:id',
),
],
),
],
)
@immutable
class FlutterPageRoute extends GoRouteData {
const FlutterPageRoute();
@override
Widget build(BuildContext context, GoRouterState state) {
return const FlutterPage();
}
}
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 |
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.
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.
Always use extension methods for cleaner syntax:
// Preferred
context.goNamed('flutterNews');
// Avoid
GoRouter.of(context).goNamed('flutterNews');
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 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.
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.
GoRouteData class with @TypedGoRoute annotationdart run build_runner build --delete-conflicting-outputs to regenerate route helpersextra@TypedShellRoute<AppShellRoute>(
routes: [
TypedGoRoute<HomePageRoute>(
name: 'home',
path: '/home',
),
TypedGoRoute<SettingsPageRoute>(
name: 'settings',
path: '/settings',
),
],
)
class AppShellRoute extends ShellRouteData {
@override
Widget builder(BuildContext context, GoRouterState state, Widget navigator) {
return AppShell(child: navigator);
}
}
| Package | Purpose |
|---|---|
go_router | Declarative routing built on Navigator 2.0 |
go_router_builder | Code generation for type-safe route classes |
| Command | Purpose |
|---|---|
dart run build_runner build --delete-conflicting-outputs | Generate type-safe route helpers |
dart run build_runner watch --delete-conflicting-outputs | Watch and regenerate on changes |