RestorableRouteFuture<T> class
Null safety
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.
_MyHomeState
to push a
new MyCounter
route and to retrieve its return value.
flutter create --sample=widgets.RestorableRouteFuture.1 mysample
- Inheritance
-
- Object
- ChangeNotifier
- RestorableProperty<
String?> - RestorableRouteFuture
Constructors
-
RestorableRouteFuture(required RoutePresentationCallback onPresent, RouteCompletionCallback<
T> ? onComplete}) - Creates a RestorableRouteFuture.
Properties
- enabled → bool
-
Whether the object currently returned by toPrimitives should be included
in the restoration state.
read-onlyoverride
- hashCode → int
-
The hash code for this object.
read-onlyinherited
- hasListeners → bool
- Whether any listeners are currently registered.
- isPresent → bool
-
Whether the Route created by present is currently shown.
read-only
- isRegistered → bool
- Whether this property is currently registered with a RestorationMixin.
-
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.
final
-
onComplete
→ RouteCompletionCallback<
T> ? -
A callback that is invoked when the Route added via onPresent
completes.
final
- onPresent → RoutePresentationCallback
-
A callback that add a new Route to the provided navigator.
final
-
route
→ Route<
T> ? -
The route that present added to the Navigator.
read-only
- runtimeType → Type
-
A representation of the runtime type of the object.
read-onlyinherited
-
state
→ State<
StatefulWidget> - The State object that this property is registered with.
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
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.
override
-
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).
override
-
fromPrimitives(
Object? data) → String -
Called by the RestorationMixin to convert the
data
previously retrieved from toPrimitives back into an object of typeT
that this property should wrap.override -
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.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a non-existent method or property is accessed.
inherited
-
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.
inherited
-
toPrimitives(
) → Object? -
Called by the RestorationMixin to retrieve the information that this
property wants to store in the restoration data.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited