FutureOr<T> classabstract
A type representing values that are eitherFuture<T> orT.
This class declaration is a public stand-in for an internalfuture-or-value generic type, which is not a class type.References to this class are resolved to the internal type.
It is a compile-time error for any class to extend, mix in or implementFutureOr.
Examples
// The `Future<T>.then` function takes a callback [f] that returns either// an `S` or a `Future<S>`.Future<S> then<S>(FutureOr<S> f(T x), ...);// `Completer<T>.complete` takes either a `T` or `Future<T>`.void complete(FutureOr<T> value);Advanced
TheFutureOr<int> type is actually the "type union" of the typesint andFuture<int>. This type union is defined in such a way thatFutureOr<Object> is both a super- and sub-type ofObject (sub-typebecauseObject is one of the types of the union, super-type becauseObject is a super-type of both of the types of the union). Together itmeans thatFutureOr<Object> is equivalent toObject.
As a corollary,FutureOr<Object> is equivalent toFutureOr<FutureOr<Object>>,FutureOr<Future<Object>> is equivalent toFuture<Object>.
Properties
- hashCode→int
- The hash code for this object.no setterinherited
- runtimeType→Type
- A representation of the runtime type of the object.no setterinherited
Methods
- noSuchMethod(
Invocationinvocation)→ dynamic - Invoked when a nonexistent method or property is accessed.inherited
- toString(
)→String - A string representation of this object.inherited
Operators
- operator ==(
Objectother)→bool - The equality operator.inherited