Skip to content
Back to skills

Flutter Auto Route Navigation

ASecurity

To preserve tab state with `auto_route`, structure the bottom bar as nested routes under a parent tabs route. That lets each tab keep its own navigation stack and widget tree alive instead of rebuilding from scratch on every tab switch. A typical setup looks like this: ```dart @RoutePage() class HomeTabsPage extends StatelessWidget { const HomeTabsPage({super.key}); @override Widget build(BuildContext context) { return AutoTabsScaffold( routes: const [ FeedRoute(), OrdersRoute(), ProfileRoute...

  • 584 stars
  • 0 votes
  • 0 copies
  • 5 views
  • Added September 5, 2026
development

Works with

  • cli

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-auto-route-navigation --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Flutter Auto Route Navigation?

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

Security grade badge for Flutter Auto Route Navigation
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/hoangnguyen0403-flutter-auto-route-navigation-714c1d23/badge)](https://www.skillsdirectory.com/skills/hoangnguyen0403-flutter-auto-route-navigation-714c1d23)

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
To preserve tab state with `auto_route`, structure the bottom bar as nested routes under a parent tabs route. That lets each tab keep its own navigation stack and widget tree alive instead of rebuilding from scratch on every tab switch.

A typical setup looks like this:

```dart
@RoutePage()
class HomeTabsPage extends StatelessWidget {
  const HomeTabsPage({super.key});

  @override
  Widget build(BuildContext context) {
    return AutoTabsScaffold(
      routes: const [
        FeedRoute(),
        OrdersRoute(),
        ProfileRoute(),
      ],
      bottomNavigationBuilder: (_, tabsRouter) {
        return BottomNavigationBar(
          currentIndex: tabsRouter.activeIndex,
          onTap: tabsRouter.setActiveIndex,
          items: const [
            BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Feed'),
            BottomNavigationBarItem(icon: Icon(Icons.list), label: 'Orders'),
            BottomNavigationBarItem(icon: Icon(Icons.person), label: 'Profile'),
          ],
        );
      },
    );
  }
}
```

Router configuration:

```dart
@AutoRouterConfig()
class AppRouter extends _$AppRouter {
  @override
  List<AutoRoute> get routes => [
    AutoRoute(
      page: HomeTabsRoute.page,
      initial: true,
      children: [
        AutoRoute(page: FeedRoute.page),
        AutoRoute(page: OrdersRoute.page),
        AutoRoute(page: ProfileRoute.page),
      ],
    ),
  ];
}
```

Why this preserves state:

- `AutoTabsScaffold` keeps the tab routes mounted.
- Each child route owns its own subtree and navigation history.
- Switching tabs changes the active child route instead of recreating the page from zero.

If your scroll view still resets, make sure the tab page itself also participates in Flutter state preservation. A common pattern is `AutomaticKeepAliveClientMixin`:

```dart
@RoutePage()
class OrdersPage extends StatefulWidget {
  const OrdersPage({super.key});

  @override
  State<OrdersPage> createState() => _OrdersPageState();
}

class _OrdersPageState extends State<OrdersPage>
    with AutomaticKeepAliveClientMixin {
  @override
  bool get wantKeepAlive => true;

  @override
  Widget build(BuildContext context) {
    super.build(context);

    return ListView.builder(
      itemCount: 100,
      itemBuilder: (_, index) => ListTile(title: Text('Item $index')),
    );
  }
}
```

If needed, add a `PageStorageKey` to the scrollable widget as well:

```dart
ListView.builder(
  key: const PageStorageKey('orders-list'),
  itemCount: 100,
  itemBuilder: (_, index) => ListTile(title: Text('Item $index')),
)
```

In practice, the fix is:

- use nested child routes for the tabs,
- render them through `AutoTabsScaffold`,
- keep each tab page alive with Flutter’s state-preservation tools when the page contains scrollable local UI state.

That combination usually stops the scroll position from resetting when users switch between bottom tabs.

Files in this skill

  • eval-1.baseline.md1.5 KB
  • eval-1.with-skill.md2 KB
  • eval-2.baseline.md1.5 KB
  • eval-2.with-skill.md1.6 KB
  • eval-3.baseline.md2.2 KB
  • eval-3.with-skill.md2.8 KB
  • trigger-1.md144 B
  • trigger-2.md174 B
  • trigger-3.md158 B
  • trigger-4.md163 B
  • trigger-5.md182 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.