RestorableRouteFuture<T> class

Gives access to a Route object and its return value that was added to a navigator via one of its "restorable" API methods.

When a State object wants access to the return value of a Route object it has pushed onto the Navigator, a RestorableRouteFuture ensures that it will also have access to that value after state restoration.

To show a new route on the navigator defined by the navigatorFinder, call present, which will invoke the onPresent callback. The onPresent callback must add a new route to the navigator provided to it using one of the "restorable" API methods. When the newly added route completes, the onComplete callback executes. It is given the return value of the route, which may be null.

While the route added via present is shown on the navigator, it can be accessed via the route getter.

If the property is restored to a state in which present had been called on it, but the route has not completed yet, the RestorableRouteFuture will obtain the restored route object from the navigator again and call onComplete once it completes.

The RestorableRouteFuture can only keep track of one active route. When present has been called to add a route, it may only be called again after the previously added route has completed.

This example uses a RestorableRouteFuture in the _MyHomeState to push a new MyCounter route and to retrieve its return value.

To create a local project with this code sample, run:
flutter create --sample=widgets.RestorableRouteFuture.1 mysample



RestorableRouteFuture({NavigatorFinderCallback navigatorFinder = _defaultNavigatorFinder, required RoutePresentationCallback onPresent, RouteCompletionCallback<T>? onComplete})
Creates a RestorableRouteFuture.


enabled bool
Whether the object currently returned by toPrimitives should be included in the restoration state.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
isPresent bool
Whether the Route created by present is currently shown.
no setter
isRegistered bool
Whether this property is currently registered with a RestorationMixin.
no setterinherited
A callback that given the BuildContext of the State object to which this property is registered returns the NavigatorState of the navigator to which the route instantiated in onPresent is added.
onComplete RouteCompletionCallback<T>?
A callback that is invoked when the Route added via onPresent completes.
onPresent RoutePresentationCallback
A callback that add a new Route to the provided navigator.
route Route<T>?
The route that present added to the Navigator.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
state State<StatefulWidget>
The State object that this property is registered with.
no setterinherited


addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
createDefaultValue() String?
Called by the RestorationMixin if no restoration data is available to restore the value of the property from to obtain the default value for the property.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
fromPrimitives(Object? data) String
Called by the RestorationMixin to convert the data previously retrieved from toPrimitives back into an object of type T that this property should wrap.
initWithValue(String? value) → void
Called by the RestorationMixin with the value returned by either createDefaultValue or fromPrimitives to set the value that this property currently wraps.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
notifyListeners() → void
Call all the registered listeners.
present([Object? arguments]) → void
Shows the route created by onPresent and invoke onComplete when it completes.
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
toPrimitives() Object?
Called by the RestorationMixin to retrieve the information that this property wants to store in the restoration data.
toString() String
A string representation of this object.


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