Kaisel – Routes as Values. Dart 3 Native Router for Flutter
Kaisel introduces a Dart 3 native router for Flutter, focusing on a 'routes as values' paradigm for predictable navigation. It leverages sealed classes for exhaustive compile-time checks and manages the navigation stack as a simple list, enhancing testability. This promises a robust, zero-codegen solution for complex Flutter routing, appealing to developers tired of runtime 'unknown route' errors.
The Lowdown
Kaisel is presented as a new Dart 3 native router for Flutter, designed around the innovative concept of treating routes as values. This approach aims to bring enhanced predictability and robustness to navigation within Flutter applications, addressing common pain points developers face with existing routing solutions.
- Sealed Routes, Exhaustive Builds: Navigation is implemented as a
switchover a sealed type, ensuring that adding a new route automatically triggers compile-time checks for all places that must handle it, eliminating runtime "unknown route" errors. - The Stack is a Value: The navigation history is represented as a plain
Listof route objects, allowing push, pop, and set operations to be simple list manipulations. This design makes the navigation logic easily testable without a widget tree and restorable across process death. - Every Navigation, One Observer: Kaisel allows registering a standard
NavigatorObserveronce, which will capture all navigation events, including tab switches and adaptive in-place changes that might be missed by other routers. - Zero Codegen: The router prides itself on requiring no
build_runneror generated files. Routes are defined using plain Dart classes, simplifying the development workflow and reducing build complexity.
By focusing on compile-time safety, treating navigation as explicit data structures, and eliminating codegen, Kaisel positions itself as a compelling new option for Flutter developers seeking a more robust, testable, and maintainable routing system.