complete method

void complete(
  1. FutureOr<T> value
)

Completes the operation with the provided value. If value is a Future, the CompleterOr will wait for it to complete. If value is synchronous, it will be stored directly.

This method can only be called once. Subsequent calls have no effect if the CompleterOr has already been completed.

Implementation

void complete(FutureOr<T> value) {
  if (isCompleted) return;
  if (value is Future<T>) {
    _completer.complete(value);
  } else {
    _value = value;
    _completer.complete(value);
  }
}