Skip to content
pubscout

auto_route

11.2.0, released 9 weeks ago by codeness.ly

A Flutter package for declarative, strongly‑typed navigation with code‑gen support.

WASM-readyUses material_ui
$ flutter pub add auto_route
Source repository

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.

  • go_router_builder

    A code generator for type-safe route helpers and definitions with package:go_router.

  • routemaster

    Easy-to-use URL-based router for Flutter web, mobile and desktop.

  • qlevar_router

    Router for Flutter with nested routes and navigation without context

Works with

Packages commonly used together with auto_route: ones it builds on, ones built on it, and its own family.