unrouter 0.10.0
unrouter: ^0.10.0 copied to clipboard
Platform-agnostic URL-first typed router core for Dart.
unrouter core complete Dart example #
This example is a pure Dart application that demonstrates a full routing flow
using unrouter core runtime only (no Flutter/Jaspr adapters).
Run #
dart run bin/main.dart
What it demonstrates #
- typed path + query parsing with
RouteState.params/query - route-level redirect (
/->/home) - legacy URL redirect (
/p/:id->/products/:id) - async loader with
dataRoute<T, L>() - guard redirect flow (
/checkout->/login?from=...) - guard block fallback behavior (
/beta) - runtime controller APIs (
sync,go,push,pop,href,cast) - state stream observation (
controller.states) - redirect loop diagnostics (
RedirectDiagnostics)
Scenario overview #
The script runs these steps in sequence:
- bootstrap through external URL sync
- parse typed query route (
/search?q=...) - push legacy product URL and follow redirect + loader
- complete typed push result with
pop(result) - attempt checkout and get redirected to login
- sign in and continue to checkout
- attempt blocked route and verify fallback behavior
- sync to unmatched URI
- trigger redirect loop and print diagnostics