Skillshub flutter-auto-route-navigation
Typed routing, nested routes, and guards using auto_route. Use when implementing typed navigation, nested routes, or route guards with auto_route in Flutter. (triggers: **/router.dart, **/app_router.dart, AutoRoute, AutoRouter, router, guards, navigate, push)
install
source · Clone the upstream repo
git clone https://github.com/ComeOnOliver/skillshub
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/ComeOnOliver/skillshub "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/HoangNguyen0403/agent-skills-standard/flutter-auto-route-navigation" ~/.claude/skills/comeonoliver-skillshub-flutter-auto-route-navigation && rm -rf "$T"
manifest:
skills/HoangNguyen0403/agent-skills-standard/flutter-auto-route-navigation/SKILL.mdsource content
AutoRoute Navigation
Priority: P1 (HIGH)
Type-safe routing system with code generation using
auto_route.
Structure
core/router/ ├── app_router.dart # Router configuration └── app_router.gr.dart # Generated routes
Implementation Guidelines
-
@RoutePage: Annotate all screen/page widgets with
.@RoutePage() -
Router Config: Extend
and annotate with_$AppRouter
.@AutoRouterConfig -
Typed Navigation: Use generated route classes (e.g.,
). Never use strings.HomeRoute() -
Nested Routes & Tabs: Use
inchildren
for tabs. When navigating to a route with nested tabs, use theAutoRoute
parameter to define the initial active sub-route (e.g.,children
).context.navigateTo(OrdersTabRoute(children: [ViewByOrdersPageRoute()])) -
Guards: Implement
for authentication/authorization logic.AutoRouteGuard -
Parameters: Constructors of
widgets automatically become route parameters.@RoutePage -
Declarative: Prefer
orcontext.pushRoute()
.context.replaceRoute()
Reference & Examples
For full Router configuration and Auth Guard implementation: See references/REFERENCE.md.
Anti-Patterns
- ❌
— always use generated typed route classes (e.g.,Navigator.pushNamed(context, '/orders/123')
)OrderDetailRoute(id: 123) - ❌ Authenticated screen without an
— every protected route must declare a guard; don't rely on UI-level checks aloneAutoRouteGuard - ❌
called from a BLoC or repository — navigation is a Presentation concern; emit a state and let the UI navigatecontext.router.push(…)
Related Topics
go-router-navigation | layer-based-clean-architecture