unrouter 0.4.0
unrouter: ^0.4.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.
0.4.1 (Unreleased) #
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