rolter 0.2.1
rolter: ^0.2.1 copied to clipboard
A typed, tree-based Flutter router with deep linking, nested navigation, guards, and external Page composition.
0.2.1 #
Fixed #
RoutesState.dispose()now abandons active and buffered navigation work without a late commit, notification, observer call, or pipeline error. Navigation mutations after disposal throw a genericStateErrorbefore invoking application callbacks or changing pending results.- Rolter-owned validation diagnostics no longer expose raw duplicate page keys or invalid route-name values.
Changed #
- The feature-first example now removes its exact guard-refresh callback before disposing the delegate and route state.
- Lifecycle, drain-level Future, callback ownership, and trusted telemetry guidance are documented. Public APIs and the URL format are unchanged.
0.2.0 #
Breaking changes #
- Breaking change:
RouteNodeis now navigation data only and no longer declaresbuildPage(BuildContext). RoutingDelegateandNestedNavigatorHostnow require aRouteNodePageBuilder<R>. Root and nested navigation use the same builder and reject a page unless its key is non-null and equalsroute.pageKey.
Before 0.2.0, every route implemented RouteNode.buildPage and delegates built
pages implicitly:
final delegate = RoutingDelegate<AppRoute>(state);
For the closest 0.2.0 migration, implement the permanent PageRouteNode
convenience interface and pass its adapter explicitly:
final delegate = RoutingDelegate<AppRoute>(
state,
pageBuilder: buildPageFromRouteNode<AppRoute>,
);
Alternatively, keep routes data-only and pass an application-owned external
builder. Every returned root or nested Page must set
key: route.pageKey; missing or mismatched keys now throw StateError in all
build modes.
The URL wire format and existing codecs are unchanged. This release does not require an intermediate 0.1.1 compatibility release: before 1.0, a minor version increment communicates an approved breaking Dart API change.
Added #
RouteNodePageBuilder<R>for application-owned FlutterPagecomposition.PageRouteNodeandbuildPageFromRouteNodeas a permanent convenience API for small applications that prefer route-owned page composition.- Runtime-safe validation for incompatible child types in nested navigators.
- A feature-first example page catalog with typed dispatch and narrow constructor injection.
- Four runnable composition references: feature-first constructor injection, centralized route-owned routing, external builder with a narrow inherited scope, and a deliberately limited application-only router-neutral adapter.
- A page-composition architecture guide and a complete
0.1.xto0.2.0migration guide.
See Page composition and the complete Migration to 0.2.0 for the public API diff, composition choices, scope semantics, and migration steps.
0.1.0 #
Initial release.
- Declarative, tree-based route state (
RouteNode+ pure tree operations) with typed, URL-serializable routes. Routes carry an explicit identity contract (value equality + apageKeythat encodes every identity-bearing param and is unique across the tree), with aKeyedRouteEqualitymixin for leaves and production validation that rejects a duplicate page key or a non-URL-safe route name.StrictHierarchyremains an opt-in debug diagnostic for mis-wired nesting. - URL grammar via a swappable
RouteUrlCodec(defaultTreeUrlCodec, dot-depth): lossless param round-trip (values with&,%,/, or non-ASCII are preserved) and standard?k=vquery interop, with an optionalEntryQueryStoreto keep pass-through params (e.g.utm_*) the tree does not model. - Navigator 2.0 wiring:
RoutingDelegate,RoutingInformationParser,NavigationServiceandNavigationController. - Built-in nested navigation via
NavigatorScopeandNestedNavigatorHost(path-addressed, with an optionaltransitionDelegateand a single back-button override hook). - Async-safe navigation through a public, fail-fast
NavigationQueue; the mutable queue owned byRoutesStateremains encapsulated. Composable guards (RouteGuard,GuardedPipeline) include redirect-loop protection (the guard fold re-settles, bounded bymaxResettlements). - Predicate stack operations over the typed route —
popUntil,removeWhere,pushAndResetTo— as pure tree functions and onNavigationService. - Read-only navigation telemetry via
NavObserver(each commit reports the previous/next stacks and the entered/left page keys). - Deep links are handled by guards (no separate subsystem); a
PendingLocationstore holds the intended target for return-after-login/unlock, and aStreamListenablebridges aBloc/Cubit/stream into theListenablea guard exposes (read state synchronously, re-evaluate on each event). - Browser-like
NavigationHistory— back/forward over committed states (wired as aNavObserver, replays via arestorecallback; new navigation drops the forward tail). - Mountable feature sub-routers: a
RouteRegistrycan mount sub-registries (children) so a feature owns its own route-name namespace, composed viaFeatureRouter+composeFeatureRouters(two features can each have adetailroute). Page keys remain global. Base64RouteCodec— an opaque base64url-JSON-in-pathRouteUrlCodecfor redirects that strip the fragment (OAuth / Telegram); the whole route survives as one token.- Navigation state restores from
RouteInformation(web reloads/deep links and OS-killed relaunch) viarestorationScopeId; documented and enabled in the example. - Result-returning navigation:
pushForResult/popWith(e.g. pickers and dialog-as-route that return a value), keyed bypageKeywith no leaked awaiters. - Per-route dependency scoping via
RouteScope. - Custom
Pagetypes:TransparentPage,NoAnimationPage, andTransitionPage(bespoke transitions without aRoutesubclass), plus aNoAnimationTransitionDelegatefor animation-free nested stacks. example/app demonstrating the engine end to end: flat + nested navigation,IndexedStacktabs, route guards with a lock/restore flow, push-for-result, dialog-as-route, per-route scopes, confirm-on-leave viaPopScope, and multi-tab independent stacks (each tab keeps its own stack, all in the URL).
