dash_router 1.0.0
dash_router: ^1.0.0 copied to clipboard
A powerful, type-safe Flutter routing library with zero mental overhead. Features code generation, guards, middleware, and seamless navigation.
Changelog #
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
1.0.0 - 2025-12-13 #
Added #
- Initial stable release of dash_router
- Core
DashRouterclass for route management and navigation RouteEntryclass for defining route configurationsRedirectEntryclass for route redirectsDashRouterOptionsfor router configuration- Type-safe parameter access via
RouteDataandTypedParamsResolver RouteInfoCachefor O(1) parameter access using InheritedWidgetDashTypedRoutebase class for generated typed routes with$-prefixed API:$pattern- Route pattern with parameter placeholders$name- Route name for named navigation$path- Concrete path with interpolated values$query- Query parameters map$body- Body arguments (supports Record types)$transition- Optional custom transition per-navigation
- Navigation extensions on
BuildContext:- Typed Route Navigation (recommended):
push(DashTypedRoute)- Push typed routereplace(DashTypedRoute)- Replace with typed routepopAndPush(DashTypedRoute)- Pop and push typed routepushAndRemoveUntil(DashTypedRoute, predicate)- Push and removepushAndRemoveAll(DashTypedRoute)- Clear stack and push
- String Path Navigation:
pushNamed(path, {query, body, transition})- Push by pathreplaceNamed(path, ...)- Replace by pathpopAndPushNamed(path, ...)- Pop and push by pathpushNamedAndRemoveUntil(path, predicate, ...)- Push and removepushNamedAndRemoveAll(path, ...)- Clear stack and push
- Pop Operations:
pop([result])- Pop current routepopUntil(predicate)- Pop until predicatepopUntilNamed(path)- Pop until reaching pathpopToRoot()- Pop to root routemaybePop([result])- Respects route guardsback([result])- Alias for pop
- Navigation State:
canGoBack- Check if can go backpreviousPath- Get previous route path
- Typed Route Navigation (recommended):
- Built-in transitions:
DashFadeTransition- Fade animationDashSlideTransition- Slide from any directionDashScaleTransition- Scale animationDashRotationTransition- Rotation animationDashScaleFadeTransition- Combined scale and fadeDashSlideFadeTransition- Combined slide and fadePlatformTransition- Platform-adaptive transitionMaterialTransition- Material Design transitionCupertinoTransition- iOS-style transitionNoTransition- Instant transition without animation
CustomAnimatedTransitionfor runtime custom transitions- Route guards system with
DashGuardbase class:canActivate()- Check if navigation is allowedonActivated()- Called after successful navigationonDenied()- Called when navigation is deniedroutesandexcludeRoutesfor glob pattern filteringpriorityfor execution order control
- Guard results:
GuardAllow,GuardDeny,GuardRedirect - Utility guards:
FunctionalGuard,ConditionalGuard,AsyncConditionalGuard - Middleware system with
DashMiddlewarebase class:handle()- Process navigation requestafterNavigation()- Called after successful navigationonAborted()- Called when navigation is aborted
- Middleware results:
MiddlewareContinue,MiddlewareAbort,MiddlewareRedirect - Utility middleware:
FunctionalMiddleware,LoggingMiddleware,DelayMiddleware - Navigation history tracking with
NavigationHistory - Shell routes support for nested navigation with isolated animations
- Nested navigator support via
NestedNavigatorandStatefulShellScope - Automatic nested navigation detection in navigation methods
- Full cross-platform support (iOS, Android, Web, macOS, Windows, Linux)
API Design #
- Typed Routes: Use
$-prefixed properties to avoid conflicts with user parameters - Naming Convention: Path-based class names (e.g.,
/app/user/:id→AppUser$IdRoute) - Navigation Separation: Clear distinction between typed route and string path navigation
- Body Parameters: Support for complex types via Record tuples or Map