unrouter 0.14.0
unrouter: ^0.14.0 copied to clipboard
Primary Unrouter package with Flutter, Nocterm, and shared core entrypoints.
Declarative routing toolkit for Flutter and Nocterm.
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.dartFlutter routing APIs.package:unrouter/nocterm.dartNocterm routing APIs, including history exports.package:unrouter/unrouter.dartShared 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 #
- Flutter example app Flutter app with quickstart and advanced demos.
- Nocterm example app Terminal app showing nested routes, named routes, and route state.
Run the Flutter example:
cd examples/flutter_example
flutter run -d chrome
Run the Nocterm example:
cd examples/nocterm_example
dart run