value property
Completes with the returned value, or throws Cancelled with the cancellation stack trace, or throws the body's error.
Reading it marks the job observed, so nobody is asked to answer for a
Failed outcome; any read counts, a print or a debugger's watch on
the getter as well. Handle the error the future carries, or it becomes
an unhandled Future error instead.
Implementation
@override
Future<T> get value async {
_observed = true;
final outcome = await _done.future;
return switch (outcome) {
Done(:final value) => value,
Failed(:final error, :final stackTrace) => Error.throwWithStackTrace(
error,
stackTrace,
),
Cancelled() => Error.throwWithStackTrace(
outcome,
outcome.stackTrace ?? StackTrace.current,
),
};
}