RouterDelegate<T> class Null safety

A delegate that is used by the Router widget to build and configure a navigating widget.

This delegate is the core piece of the Router widget. It responds to push route and pop route intents from the engine and notifies the Router to rebuild. It also acts as a builder for the Router widget and builds a navigating widget, typically a Navigator, when the Router widget builds.

When the engine pushes a new route, the route information is parsed by the RouteInformationParser to produce a configuration of type T. The router delegate receives the configuration through setInitialRoutePath or setNewRoutePath to configure itself and builds the latest navigating widget when asked (build).

When implementing subclasses, consider defining a Listenable app state object to be used for building the navigating widget. The router delegate would update the app state accordingly and notify its own listeners when the app state has changed and when it receive route related engine intents (e.g. setNewRoutePath, setInitialRoutePath, or popRoute).

All subclass must implement setNewRoutePath, popRoute, and build.

State Restoration

If the Router owning this delegate is configured for state restoration, it will persist and restore the configuration of this RouterDelegate using the following mechanism: Before the app is killed by the operating system, the value of currentConfiguration is serialized out and persisted. After the app has restarted, the value is deserialized and passed back to the RouterDelegate via a call to setRestoredRoutePath (which by default just calls setNewRoutePath). It is the responsibility of the RouterDelegate to use the configuration information provided to restore its internal state.

See also:

  • RouteInformationParser, which is responsible for parsing the route information to a configuration before passing in to router delegate.
  • Router, which is the widget that wires all the delegates together to provide a fully functional routing solution.
Inheritance

Constructors

RouterDelegate()

Properties

currentConfiguration → T?
Called by the Router when it detects a route information may have changed as a result of rebuild.
read-only
hashCode int
The hash code for this object.
read-onlyinherited
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object notifies its listeners.
inherited
build(BuildContext context) Widget
Called by the Router to obtain the widget tree that represents the current state.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
popRoute() Future<bool>
Called by the Router when the Router.backButtonDispatcher reports that the operating system is requesting that the current route be popped.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that the object notifies.
inherited
setInitialRoutePath(T configuration) Future<void>
Called by the Router at startup with the structure that the RouteInformationParser obtained from parsing the initial route.
setNewRoutePath(T 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.
setRestoredRoutePath(T configuration) Future<void>
Called by the Router during state restoration.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited