RouteDefinerRouter class
One instance-owned route table and Navigator stack.
Keep an instance outside build and pass config to MaterialApp.router. Use separate instances for nested stacks and dispose them with their owners.
- Inheritance
-
- Object
- Listenable
- RouterDelegate<
RouteStack> - RouteDefinerRouter
- Mixed-in types
Constructors
-
RouteDefinerRouter({String initialRoute = '/', String appTitle = '', required Widget loadingBuilder(CurrentRoute), required Widget deniedBuilder(BuildContext, CurrentRoute), required Widget notFoundBuilder(BuildContext, RouteState), required Widget errorBuilder(BuildContext, RouteFailure, VoidCallback ), void onError(RouteFailure)?, Duration? resolutionTimeout, int redirectLimit = 5, RouteOptions defaultRouteOptions = const RouteOptions(), DefinedRouteFactory? routeFactory, required Iterable<
RouteDefiner> routes, List<NavigatorObserver> observers = const [], String? restorationScopeId, RouteArgumentsCodec argumentsCodec = const JsonRouteArgumentsCodec(), Listenable? refreshListenable, BackButtonDispatcher? backButtonDispatcher, int historyLimit = 0, NavigationDiagnostics? diagnostics})
Properties
- appTitle → String
-
Browser title used when the active route has no title of its own.
final
- argumentsCodec → RouteArgumentsCodec
-
final
- backButtonDispatcher → BackButtonDispatcher?
-
Supply a ChildBackButtonDispatcher for a nested Router.
final
-
config
→ RouterConfig<
RouteStack> -
Lazily creates the platform URL/history integration.
no setter
- currentConfiguration → RouteStack
-
Called by the Router when it detects a route information may have
changed as a result of rebuild.
no setteroverride
- currentRoute → RouteSnapshot
-
The top managed page of this instance, even while guarded or dialog-covered.
Independent child routers and pageless routes are not included.
no setter
- defaultRouteOptions → RouteOptions
-
final
- deniedBuilder → Widget Function(BuildContext, CurrentRoute)
-
Required UI when a guard denies access to the destination.
final
- diagnostics → NavigationDiagnostics?
-
Null disables logging. Independent of history retention and event listeners.
final
- errorBuilder → Widget Function(BuildContext, RouteFailure, VoidCallback )
-
Required UI for failed navigation, with a callback to retry its guards.
final
-
events
→ Stream<
NavigationEvent> -
Asynchronous broadcast events; no replay or retention is implied.
Closes on disposal. Use addListener for existing Router state notifications.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
history
→ List<
NavigationEvent> -
Retained activity, oldest to newest. Popped/replaced pages may appear here.
no setter
- historyLimit → int
-
Maximum retained events, oldest to newest. Zero disables retention.
final
- initialRoute → String
-
final
- loadingBuilder → Widget Function(CurrentRoute)
-
Required UI while guards are pending. Choose your own or an optional page.
final
-
The key used for retrieving the current navigator.
final
-
nestedConfig
→ RouterConfig<
RouteStack> -
Configures a nested Router that does not report to the platform URL.
no setter
- notFoundBuilder → Widget Function(BuildContext, RouteState)
-
Required UI when no route definition matches the complete location.
final
- onError → void Function(RouteFailure)?
-
final
- redirectLimit → int
-
final
- resolutionTimeout → Duration?
-
Optional total guard timeout. Null imposes no timeout.
final
- restorationScopeId → String?
-
final
- routeFactory → DefinedRouteFactory?
-
Applies to every page, including unknown/error pages, unless overridden.
final
-
routes
→ List<
RouteDefiner> -
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stack
→ List<
RouteSnapshot> -
Resolved, read-only managed pages, bottom (root) to top (current).
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
build(
BuildContext context) → Widget -
Called by the Router to obtain the widget tree that represents the
current state.
override
-
dispose(
) → void -
Discards any resources used by the object.
override
-
go(
String location, {Object? arguments}) → void - Rebuilds the canonical ancestor stack and adds a browser-history entry.
-
match(
String location, {Object? arguments}) → ({RouteDefiner? definition, RouteState state}) - Resolves a location to its definition and immutable URI state.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
pop<
T extends Object?> ([T? result]) → Future< bool> - Asks Navigator to pop, respecting PopScope and pageless dialogs.
-
popRoute(
) → Future< bool> -
Called by the Router when the Router.backButtonDispatcher reports that
the operating system is requesting that the current route be popped.
inherited
-
push<
T> (String location, {Object? arguments}) → Future< T?> - Pushes a URL-addressable page. T must match the definition's result type.
-
refresh(
) → void - Invalidates route checks, for example after authentication changes.
-
remove(
String id) → bool - Removes a managed page by snapshot ID, completing its push with null.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
replace(
String location, {Object? arguments}) → void - Replaces the top page and current browser-history entry.
-
setInitialRoutePath(
RouteStack configuration) → Future< void> -
Called by the Router at startup with the structure that the
RouteInformationParser obtained from parsing the initial route.
inherited
-
setNewRoutePath(
RouteStack configuration) → Future< void> -
Called by the Router when the Router.routeInformationProvider reports that a
new route has been pushed to the application by the operating system.
override
-
setRestoredRoutePath(
RouteStack configuration) → Future< void> -
Called by the Router during state restoration.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
updateRoutes(
Iterable< RouteDefiner> routes) → void - Replaces the registry atomically and rechecks the current stack.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited