Flutter Unrouter

Test pub dart flutter license

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

Libraries

flutter_unrouter