Skip to content
pubscout

route_definer

4.0.0, released 2 weeks ago by devcom.net.br

Typed Flutter Router navigation with URI patterns, guards, and browser history without code generation.

WASM-ready
$ flutter pub add route_definer
Source repository

What it does

Defines explicit routes with URI patterns and path parameters for Flutter's Router and Navigator. Provides an ordered guard pipeline for authorization and redirects, typed page results, and independent nested stacks without relying on code generation.

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

Use it when

  • You want an explicit route table and typed navigation without code generation
  • You need asynchronous guard pipelines for authorization and redirects
  • You require browser history and navigation-stack restoration on web and native platforms

Skip it when

  • You need automatic shell or tab orchestration and wildcard path matching
  • You prefer code-generated route definitions and type safety

Strengths

  • No code generation required
  • Explicit ordered guard pipeline supporting async validation
  • Typed navigation results and parameters parsing

Weaknesses

  • Does not support wildcard matching or automatic shell/tab orchestration
  • Manual browser title updates required starting in 4.0.0

Setup

Kind
Flutter widgets
Effort
Low
Code generation
No
Direct dependencies
1

Import package:route_definer/route_definer.dart and configure router instances with defined routes.

import 'package:flutter/material.dart';
import 'package:route_definer/material.dart';

void main() => runApp(MaterialApp.router(routerConfig: router.config));

final router = createMaterialRouter(
  routes: [
    RouteDefiner<void>.simple(
      path: '/',
      builder: (context) => Scaffold(
        body: Center(
          child: FilledButton(
            onPressed: () =>
                RouteDefinerRouter.of(context).push<void>('/about'),
            child: const Text('Open About'),
          ),
        ),
      ),
    ),
    RouteDefiner<void>.simple(
      path: '/about',
      builder: (context) => Scaffold(
        appBar: AppBar(title: const Text('About')),
        body: const Center(child: Text('Hello!')),
      ),
    ),
  ],
);

Alternatives

Packages that do the same job and could replace route_definer.

  • go_router

    Widely adopted declarative routing package maintained by the Flutter team with built-in redirection and shell routing.

  • auto_route

    Provides strongly-typed routing and deep-linking with code generation and built-in nested navigation support.

  • beamer

    Handles complex navigation and deep-linking by beaming to different screens based on application state.