Kaisel – Routes as Values. Dart 3 Native Router for Flutter
Kaisel: Redefining Flutter Navigation with Routes as Values
Kaisel is a modern, Dart 3-native routing solution designed specifically for Flutter. It departs from traditional routing paradigms by treating routes as values rather than mere string paths.
"The core philosophy of Kaisel is simple: eliminate the fragility of string-based navigation and the overhead of code generation."
🚀 Getting Started
To integrate Kaisel into your project, run the following command in your terminal:
flutter pub add kaisel
Quick Setup Checklist:
- Install the
kaiselpackage. - Define your routes using a
sealed class. - Implement an exhaustive
switchexpression to build your pages.
🛠 Core Technical Pillars
1. Sealed Routes & Exhaustive Builds
By leveraging Dart 3's sealed classes, navigation becomes a type-safe operation. Instead of hoping a string matches a route, you use a switch over a sealed type.
Mathematically, if your set of routes is defined as: The compiler ensures that the UI build function handles .
sealed class AppRoute {}
class HomeRoute extends AppRoute {}
class ProfileRoute extends AppRoute { final String userId; ProfileRoute(this.userId); }
// The compiler forces you to handle every case!
Widget buildPage(AppRoute route) => switch (route) {
HomeRoute() => const HomePage(),
ProfileRoute(userId: var id) => ProfilePage(id: id),
};
2. The Navigation Stack as a Value
In Kaisel, your navigation history is not a hidden internal state; it is a simple List of route objects.
| Feature | Traditional Routers | Kaisel |
|---|---|---|
| State Representation | Internal/Opaque | List<Route> |
| Testing | Requires Widget Tree | Pure Dart Logic |
| Persistence | Complex Serialization | Simple List Restoration |
Because the stack is a value, operations like push, pop, and set are essentially just list manipulations.
3. Enhanced Observation
Kaisel integrates with a standard NavigatorObserver. Unlike other routers, it can detect:
- Tab switches
- Adaptive in-place layout changes
These events often produce no "route event" in other systems, but Kaisel captures them seamlessly.
4. Zero Codegen
Kaisel removes the need for , generated build_runner.g.dart files, or "magic" strings. It is pure Dart.
🗺 Navigation Architecture
The following diagram illustrates how Kaisel processes a route value to render a screen:
📚 Learning & Migration Resources
Whether you are starting fresh or moving from another ecosystem, Kaisel provides comprehensive documentation:
- The Basics: Tutorial: Your First App
- Advanced Concepts:
- Navigation Shells (for tabs)
- Modal flows & Adaptive layouts
- Route Guards
- Deep linking via URLs
- Migration Paths:
- Moving from
go_router - Moving from
auto_route - Moving from the standard
Navigator
- Moving from
- Reference: Roadmap and API Reference