unrouter

Declarative routing toolkit for Flutter and Nocterm.

Test dart flutter pub license

unrouter is the primary package for the Unrouter family. It gives you one dependency with Flutter and Nocterm entrypoints, plus shared core and history APIs from the package root.

Start here if you want one package for Flutter, Nocterm, and the shared routing building blocks.

What You Get

  • Declarative route trees
  • Shared routing and history APIs from package:unrouter/unrouter.dart
  • Named navigation, params, and query helpers
  • Guards and redirects
  • Nested route rendering
  • Flutter and Nocterm entrypoints from one package
  • A stable brand-level import path for app code

Install

dependencies:
  unrouter: <latest>
dart pub add unrouter

Flutter Entry Point

import 'package:unrouter/flutter.dart';

Use this in Flutter apps.

Other Entrypoints

import 'package:unrouter/nocterm.dart';
import 'package:unrouter/unrouter.dart';
  • package:unrouter/flutter.dart Flutter routing APIs.
  • package:unrouter/nocterm.dart Nocterm routing APIs, including history exports.
  • package:unrouter/unrouter.dart Shared core and history APIs.

If you import more than one adapter library in the same file, use prefixes to avoid symbol collisions such as Inlet, Outlet, and createRouter.

Flutter Example

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

final Unrouter router = createRouter(
  routes: [Inlet(path: '/', view: HomePage.new)],
);

void main() {
  runApp(MaterialApp.router(routerConfig: createRouterConfig(router)));
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return const Center(child: Text('Home'));
  }
}

More Examples

Run the Flutter example:

cd examples/flutter_example
flutter run -d chrome

Run the Nocterm example:

cd examples/nocterm_example
dart run