HN
Today

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.

14
Score
0
Comments
#2
Highest Rank
4h
on Front Page
First Seen
Aug 1, 5:00 PM
Last Seen
Aug 1, 8:00 PM
Rank Over Time
4247

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 switch over 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 List of 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 NavigatorObserver once, 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_runner or 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.