AsyncValue<T> constructor

AsyncValue<T>(
  1. Future<T> future
)

Implementation

AsyncValue(Future<T> future) {
  _future = future.then(
    _onLoad,
    onError: (Object error, StackTrace stackTrace) {
      _onError(error);
      // A nullable `T` completes with `null` on error (previous behaviour).
      if (null is T) return null as T;
      // A non-nullable `T` can't complete with `null`: propagate the error.
      Error.throwWithStackTrace(error, stackTrace);
    },
  );
}