flutter_unrouter 0.2.0
flutter_unrouter: ^0.2.0 copied to clipboard
Declarative nested router for Flutter with guards and Router API integration.
Flutter Unrouter #
Routing for Flutter apps with nested screens, guards, params, query state, and named navigation.
Install #
dart pub add flutter_unrouter
Quick Start #
import 'package:flutter/material.dart';
import 'package:flutter_unrouter/flutter_unrouter.dart';
final router = createRouter(
routes: [
Inlet(path: '/', view: HomePage.new),
Inlet(
path: '/settings',
view: SettingsPage.new,
children: [Inlet(path: 'profile', view: ProfilePage.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'));
}
}
class SettingsPage extends StatelessWidget {
const SettingsPage({super.key});
@override
Widget build(BuildContext context) {
return const Scaffold(body: Outlet());
}
}
class ProfilePage extends StatelessWidget {
const ProfilePage({super.key});
@override
Widget build(BuildContext context) {
return const Center(child: Text('Profile'));
}
}
Use this package when you want one route tree to drive both navigation and nested UI.
Learn More #
- Flutter example
- unrouter if you want the all-in-one package