首页/ AI 技能 / @skilllib/skill-2117939930272416217
Skill站外收录 @skilllib/skill-2117939930272416217

auto-route-navigation

提供类型安全的声明式路由能力,支持嵌套导航、标签页管理及基于守卫的访问控制,通过代码生成实现页面参数自动映射与强类型跳转,避免字符串路由带来的运行时错误。

0.0 (0) 21 次安装 原作者 编程导航
收录于 2026-01-22
软件开发 AI 技能

Skills.MD

# AutoRoute Navigation ## **Priority: P1 (HIGH)** Type-safe routing system with code generation using `auto_route`. ## Structure ```text 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 `_$AppRouter` and annotate with `@AutoRouterConfig`. - **Typed Navigation**: Use generated route classes (e.g., `HomeRoute()`). Never use strings. - **Nested Routes & Tabs**: Use `children` in `AutoRoute` for tabs. When navigating to a route with nested tabs, use the `children` parameter to define the initial active sub-route (e.g., `context.navigateTo(OrdersTabRoute(children: [ViewByOrdersPageRoute()]))`). - **Guards**: Implement `AutoRouteGuard` for authentication/authorization logic. - **Parameters**: Constructors of `@RoutePage` widgets automatically become route parameters. - **Declarative**: Prefer `context.pushRoute()` or `context.replaceRoute()`. ## Reference & Examples For full Router configuration and Auth Guard implementation: See [references/REFERENCE.md](references/REFERENCE.md). ## Related Topics go-router-navigation | layer-based-clean-architecture

评论 0

还没有评论,来抢沙发。