Skip to content
Back to skills

Flutter Go Router Navigation

ASecurity

Use a typed `StatefulShellRoute` with one branch per tab. Each branch has its own navigator key, so navigating within Orders does not discard its stack when the user switches to Home or Profile. ```dart import 'package:flutter/material.dart'; import 'package:go_router/go_router.dart'; part 'app_router.g.dart'; @TypedStatefulShellRoute<AppShellRoute>( branches: [ TypedStatefulShellBranch<HomeBranch>( routes: [TypedGoRoute<HomeRoute>(path: '/home')], ), TypedStatefulShellBranch<OrdersBranch>( r...

  • 584 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 5, 2026
developmentgoshell

Security analysis

A100/100

Pro scans all 12 files and shows the line behind each finding

Scanned September 5, 2026

npx -y skills add HoangNguyen0403/agent-skills-standard --skill flutter-go-router-navigation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flutter Go Router Navigation?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Flutter Go Router Navigation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-flutter-go-router-navigation-abbe76ce/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-flutter-go-router-navigation-abbe76ce)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
Use a typed `StatefulShellRoute` with one branch per tab. Each branch has its own navigator key, so navigating within Orders does not discard its stack when the user switches to Home or Profile.

```dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

part 'app_router.g.dart';

@TypedStatefulShellRoute<AppShellRoute>(
  branches: [
    TypedStatefulShellBranch<HomeBranch>(
      routes: [TypedGoRoute<HomeRoute>(path: '/home')],
    ),
    TypedStatefulShellBranch<OrdersBranch>(
      routes: [
        TypedGoRoute<OrdersRoute>(
          path: '/orders',
          routes: [TypedGoRoute<OrderDetailRoute>(path: ':orderId')],
        ),
      ],
    ),
    TypedStatefulShellBranch<ProfileBranch>(
      routes: [TypedGoRoute<ProfileRoute>(path: '/profile')],
    ),
  ],
)
class AppShellRoute extends StatefulShellRouteData {
  const AppShellRoute();

  @override
  Widget builder(
    BuildContext context,
    GoRouterState state,
    StatefulNavigationShell navigationShell,
  ) => AppScaffold(navigationShell: navigationShell);
}

class HomeBranch extends StatefulShellBranchData {
  static final $navigatorKey = GlobalKey<NavigatorState>();
}

class OrdersBranch extends StatefulShellBranchData {
  static final $navigatorKey = GlobalKey<NavigatorState>();
}

class ProfileBranch extends StatefulShellBranchData {
  static final $navigatorKey = GlobalKey<NavigatorState>();
}

class HomeRoute extends GoRouteData {
  const HomeRoute();
  @override
  Widget build(BuildContext context, GoRouterState state) => const HomeScreen();
}

class OrdersRoute extends GoRouteData {
  const OrdersRoute();
  @override
  Widget build(BuildContext context, GoRouterState state) => const OrdersScreen();
}

class OrderDetailRoute extends GoRouteData {
  const OrderDetailRoute({required this.orderId});
  final String orderId;
  @override
  Widget build(BuildContext context, GoRouterState state) =>
      OrderDetailScreen(orderId: orderId);
}

class ProfileRoute extends GoRouteData {
  const ProfileRoute();
  @override
  Widget build(BuildContext context, GoRouterState state) => const ProfileScreen();
}

class AppScaffold extends StatelessWidget {
  const AppScaffold({super.key, required this.navigationShell});

  final StatefulNavigationShell navigationShell;

  @override
  Widget build(BuildContext context) => Scaffold(
        body: navigationShell,
        bottomNavigationBar: NavigationBar(
          selectedIndex: navigationShell.currentIndex,
          onDestinationSelected: (index) => navigationShell.goBranch(
            index,
            initialLocation: index == navigationShell.currentIndex,
          ),
          destinations: const [
            NavigationDestination(icon: Icon(Icons.home), label: 'Home'),
            NavigationDestination(icon: Icon(Icons.receipt_long), label: 'Orders'),
            NavigationDestination(icon: Icon(Icons.person), label: 'Profile'),
          ],
        ),
      );
}
```

Create and register one global router from the generated routes: `final appRouter = GoRouter(routes: $appRoutes);`. Navigate with route objects, such as `const OrdersRoute().go(context)` and `OrderDetailRoute(orderId: id).push(context)`, rather than raw paths or `context.go` strings.

Files in this skill

  • eval-1.baseline.md1.7 KB
  • eval-1.with-skill.md1.4 KB
  • eval-2.baseline.md2.1 KB
  • eval-2.with-skill.md1.9 KB
  • eval-3.baseline.md2.8 KB
  • eval-3.with-skill.md3.2 KB
  • trigger-1.md134 B
  • trigger-2.md118 B
  • trigger-3.md100 B
  • trigger-4.md131 B
  • trigger-5.md116 B

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.