flatMapAsync<U> method

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

Flat maps the success value asynchronously

Implementation

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