Skip to content
pubscout

go_router

18.1.4, released 11 days ago by flutter.dev

Declarative routing package for Flutter based on Navigation 2 supporting deep links and URL-based navigation.

Flutter FavoriteWASM-readyUses material_ui
$ flutter pub add go_router
Source repository

What it does

A declarative routing package for Flutter that uses the Router API to provide a convenient, URL-based API for navigating between different screens. It allows you to define URL patterns, navigate using URLs, handle deep links, and configure redirection.

AI-written summary of version 18.1.3, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need robust URL-based routing and deep linking support in a Flutter application.
  • You want declarative navigation based on the Flutter Navigation 2 API.
  • You need support for multiple navigators, sub-routes, and shell routes like bottom navigation bars.

Skip it when

  • You prefer a simple imperative navigator push and pop model without URL mapping.
  • The package is considered feature-complete by the Flutter team and you require active core feature additions.

Strengths

  • Built-in URL path and query parameter parsing using template syntax.
  • Comprehensive deep linking support across platforms.
  • Redirection support based on application state (e.g. authentication).

Weaknesses

  • Active feature development is not currently planned as the package is considered feature-complete by the Flutter team.
  • Navigation 2 abstractions can have a steep learning curve.

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
5

not documented

final GoRouter _router = GoRouter(
  routes: <RouteBase>[
    GoRoute(
      path: '/',
      builder: (BuildContext context, GoRouterState state) {
        return const HomeScreen();
      },
      routes: <RouteBase>[
        GoRoute(
          path: 'details',
          builder: (BuildContext context, GoRouterState state) {
            return const DetailsScreen();
          },
        ),
      ],
    ),
  ],
);

Alternatives

Packages that do the same job and could replace go_router.

  • auto_route

    Pick auto_route if you prefer code generation for strongly-typed arguments and routes.

  • beamer

    Pick beamer if you want location-based routing that synchronizes your app state with the browser URL.

Works with

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