valueOrThrow property

Future<ValueT> valueOrThrow

Returns the value if it is a success. Else, throws the error as an Exception.

Thanks to this extension, instead of :

Future<Result<Value, Failure>> result;
final value = (await result).valueOrThrow;

You can do :

Future<Result<Value, Failure>> result;
final value = await result.valueOrThrow;

Implementation

Future<ValueT> get valueOrThrow async {
  return (await this).valueOrThrow;
}