auto_route
11.2.0, released 9 weeks ago by codeness.ly
A Flutter package for declarative, strongly‑typed navigation with code‑gen support.
What it does
AutoRoute generates strongly‑typed route classes and navigation helpers from annotated router definitions. It handles deep linking, nested routes, guards and custom transitions automatically.
AI-written summary of version 11.2.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- App needs deep linking or guarded routes
- Complex/nested navigation structures
- You want type‑safe arguments and reduced boilerplate
Skip it when
- Very simple apps with few screens
- You prefer pure runtime routing without code generation
Strengths
- Strongly‑typed arguments and routes
- Built‑in deep‑linking and route guards
- Code generation removes boilerplate
- Supports nested and tab navigation
Weaknesses
- Requires build_runner and code‑gen step
- Learning curve for annotations and generated code
- Adds compile‑time dependency
Setup
- Kind
- Flutter widgets
- Effort
- Medium
- Code generation
- Yes (build_runner)
- Direct dependencies
- 6
Add auto_route to dependencies and auto_route_generator + build_runner to dev_dependencies, then run dart run build_runner build/watch to generate code.
@AutoRouterConfig()
class AppRouter extends RootStackRouter {
@override
List<AutoRoute> get routes => [
AutoRoute(page: HomeRoute.page),
];
}
final _appRouter = AppRouter();
MaterialApp.router(routerDelegate: _appRouter.delegate(), routeInformationParser: _appRouter.defaultRouteParser());Alternatives
Packages that do the same job and could replace auto_route.
- go_router
Declarative routing package for Flutter based on Navigation 2 supporting deep links and URL-based navigation.
98Compare - go_router_builder
A code generator for type-safe route helpers and definitions with package:go_router.
92Compare - routemaster
Easy-to-use URL-based router for Flutter web, mobile and desktop.
74Compare - qlevar_router
Router for Flutter with nested routes and navigation without context
80Compare
Works with
Packages commonly used together with auto_route: ones it builds on, ones built on it, and its own family.
- webauto_route depends on itLightweight bindings for browser APIs via JS interop
- material_uiauto_route depends on itOfficial Flutter Material UI library implementing Google’s Material Design system.
- cupertino_uiauto_route depends on itOfficial Flutter Cupertino design library implementing Apple HIG iOS and macOS user interfaces.
- auto_route_generatorBuilt on auto_routeCode generator for the auto_route declarative routing solution.