Future<T>.value constructor

Future<T>.value(
  1. [FutureOr<T> value]
)

Creates a future completed with value.

If value is a future, the created future waits for the value future to complete, and then completes with the same result. Since a value future can complete with an error, so can the future created by Future.value, even if the name suggests otherwise.

If value is not a Future, the created future is completed with the value value, equivalently to new Future<T>.sync(() => value).

Use Completer to create a future and complete it later.

Implementation

@pragma("vm:entry-point")
factory Future.value([FutureOr<T> value]) {
  return new _Future<T>.immediate(value);
}