Skip to content

Latest commit

 

History

History
113 lines (80 loc) · 3.49 KB

File metadata and controls

113 lines (80 loc) · 3.49 KB
ZenRouter Logo

The Ultimate Flutter Router for Every Navigation Pattern

pub package Test Codecov - zenrouter


Architecture Overview

ZenRouter provides three navigation paradigms through a layered architecture:

RouteTarget (base class for all routes)
  ├── Imperative    → NavigationPath + NavigationStack
  ├── Declarative   → NavigationStack.declarative (Myers diff)
  └── Coordinator   → Coordinator<T> + MaterialApp.router
        └── RouteUnique (URI-based identity for deep linking)

Paradigm Selection

Need deep linking, URL sync, or browser back button?
│
├─ YES → Coordinator
│
└─ NO → Is navigation derived from state?
       │
       ├─ YES → Declarative
       │
       └─ NO → Imperative
Imperative Declarative Coordinator
Simplicity ⭐⭐⭐ ⭐⭐
Web / Deep Linking
State-Driven Compatible ✅ Native Compatible
Route Mixins Guard, Redirect, Transition Guard, Redirect, Transition Guard, Redirect, Transition, DeepLink

Quick Example

// Imperative: Direct stack control
final path = NavigationPath<AppRoute>.create();
path.push(ProfileRoute());

// Declarative: State-driven navigation via Myers diff
NavigationStack.declarative(
  routes: [
    for (final page in pages) PageRoute(page),
  ],
  resolver: (route) => StackTransition.material(...),
)

// Coordinator: Deep linking, web, and state restoration
class AppCoordinator extends Coordinator<AppRoute> {
  @override
  AppRoute parseRouteFromUri(Uri uri) => ...;
}

Repository Structure

Package Responsibility
zenrouter Flutter integration: Coordinator, NavigationStack, StackTransition, state restoration
zenrouter_core Platform-independent core: RouteTarget, CoordinatorCore, StackPath, and all route mixins
zenrouter_devtools DevTools extension for inspecting routes, testing deep links, and debugging navigation
zenrouter_file_generator Optional build_runner code generator for Next.js-style file-based routing on top of Coordinator

Documentation

Platform Support

✅ iOS · ✅ Android · ✅ Web · ✅ macOS · ✅ Windows · ✅ Linux


License

Apache 2.0 — see LICENSE

Created With Love By

definev