mapAsync<U> method

Future<Result<U, E>> mapAsync<U>(
  1. Future<U> mapper(
    1. T
    )
)

Maps the success value asynchronously

Implementation

Future<Result<U, E>> mapAsync<U>(Future<U> Function(T) mapper) async {
  final result = await this;
  return switch (result) {
    Success(value: final value) => Result.success(await mapper(value)),
    Failure(error: final error) => Result.failure(error),
  };
}