unrouter 0.6.0
unrouter: ^0.6.0 copied to clipboard
A Flutter router that gives you routing flexibility: define routes centrally, scope them to widgets, or mix both - with browser-style history navigation.
Unreleased #
0.6.0 - 2026-01-24 #
Breaking Changes #
NavigateandLinknow use named arguments withnameorpath;queryreplacesqueryParametersfor navigation and URI generation.- Guard APIs now use
RouteLocationinGuardContextand accept named route or path data inGuardResult.redirect.
Features #
- Named routes: add
Inlet.name, name-based navigation, andNavigate.route(...)for URI generation from names or path patterns. - Route location names: expose the matched route name via
RouteLocation(available fromcontext.location). - Path patterns: allow params, optional segments, and wildcards to be substituted when navigating or generating URIs.
- File-based routing (CLI): add
unrouter init/scan/generate/watchwith aunrouter.config.dartconfig file and a routes generator from a pages directory. - Route metadata for generators: introduce
RouteMetaso pages can declare routenameandguardsfor generated routes.
Improvements #
- Route matching now prefers more specific routes (static > params > wildcard), with definition order as the tiebreaker.
- File routing generator supports nested routes, dynamic segments, and wildcards, with guard/name inference where possible.
- CLI supports
--json,--quiet,--verbose, short aliases, and improved output formatting (including watch status panels).
Fixes #
- Encode dynamic path segments when building URIs and throw clear errors for missing wildcard params.
- Include route names in
RouteLocationandRouteStateequality/hashCode. - Harden CLI file parsing and escaping for generated config/routes.
Testing #
- Added tests for named routes and specificity-based matching.
- Added CLI tests for init/scan/generate and file routing edge cases.
Documentation #
- Document file-based routing conventions, CLI usage, and RouteMeta.
0.5.1 - 2025-12-24 #
0.5.0 - 2025-12-21 #
Features #
- Route blockers: add
RouteBlockerto intercept back/pop navigation with level-aware blocking and optionalonBlockedcallbacks (supports widget-scopedRoutes).
0.4.0 - 2025-12-20 #
Breaking Changes #
Link.builderconstructor removed. UseLink(builder: ...)and provide eitherchildorbuilder(not both).Navigatemethods now returnFuture<Navigation>; await when you need to know whether navigation succeeded, redirected, or was cancelled.UnrouterNavigationContextextension renamed toUnrouterBuildContext.RouterStaterenamed toRouteState, andRouterStateProvidertoRouteStateScope. Usecontext.routeState/context.maybeRouteStateto read the state.- Removed
Navigate.of,Unrouter.of, andRouteStateScope.of/maybeOf. Usecontext.navigate,context.router, andcontext.routeStateinstead. createHistoryis no longer exported; pass aHistoryinstance explicitly.
Features #
- Navigation guards: add
guardsandmaxRedirectsto intercept navigation (allow,cancel,redirect) across push/replace/pop and external route updates. - Route-level guards: allow
Inlet.guardsto run per-route guards from root to leaf after global guards. - Route animations: add
context.routeAnimation(...)to access per-route animation controllers for push/replace/pop transitions. - Granular route state accessors: add
context.location,context.matchedRoutes,context.params,context.routeLevel,context.historyIndex, andcontext.historyActionfor fine-grained rebuilds.
Fixes #
- Preserve cached stacked-route entries when their order changes, preventing unnecessary rebuilds in layout/nested routes.
- Pop navigation without guards now resolves in the same frame.
Testing #
- Added guard tests for async guards, error handling, short-circuiting, setNewRoutePath, pop redirects, and null-delta pop events.
0.3.0 #
Features #
- Navigator 1.0 compatibility: added
enableNavigator1(defaulttrue) so APIs likeshowDialog,showModalBottomSheet,showMenu, andNavigator.push/popwork when usingUnrouter. - Example updates: the example app now demonstrates Navigator 1.0 APIs alongside existing routing patterns.
Improvements #
popRoutenow delegates to the embedded Navigator first (when enabled) before falling back to history navigation.- Relative navigation now normalizes dot segments (
./..) and clamps above-root paths.
Testing #
- Added comprehensive widget tests covering Navigator 1.0 overlays, push/pop/popUntil, and nested Navigator behavior.
- Added tests for relative navigation dot-segment normalization.
0.2.0 #
Breaking Changes #
- Navigation API refactored: History navigation methods (
back(),forward(),go()) are now accessed throughnavigateproperty- Before:
router.back() - After:
router.navigate.back()
- Before:
- Internal reorganization: Removed
router_delegate.dartfile. TheNavigateinterface and router delegate logic have been consolidated intorouter.dart
Features #
- Link widget: Added declarative navigation with the new
Linkwidget (#5)- Simple usage:
Link(to: Uri.parse('/about'), child: Text('About')) - Advanced usage:
Link.builderfor custom gesture handling - Supports
replaceandstateparameters - Automatic mouse cursor (click) and accessibility semantics (link role)
- Example: Build navigation links without imperative callbacks
- Simple usage:
- BuildContext extensions: Added convenient extensions for navigation (#6)
- Use
context.navigateto access navigation methods from any widget - Use
context.routerto access the router instance - Example:
context.navigate(.parse('/about'))
- Use
- Better error messages:
Navigate.of()now throws helpfulFlutterErrorwith clear messages when:- Called outside a Router scope
- Router delegate doesn't implement
Navigate
Improvements #
- Changed
matchRoutesparameter type fromList<Inlet>toIterable<Inlet>for better flexibility - Updated examples to demonstrate new BuildContext extension usage
- Added comprehensive tests for context navigation features
Migration Guide #
Update your navigation code to use the new API:
// Before
router.back()
router.forward()
router.go(-1)
// After
router.navigate.back()
router.navigate.forward()
router.navigate.go(-1)
// Or use the new BuildContext extension
context.navigate.back()
0.1.1 #
- Update package description and add pub topics
- Remove routingkit dependency and format product card
- Format Dart code with dart format