asyncMapResult<T> method

Future<Result<T>> asyncMapResult<T>(
  1. Future<T> mapSuccess(
    1. E
    ), {
  2. String? tag,
})

Map the current Result to a new Result one, which could be from a different type.

Implementation

Future<Result<T>> asyncMapResult<T>(
  Future<T> Function(E) mapSuccess, {
  String? tag,
}) async {
  final that = this;

  if (that is ResultSuccess<E>) {
    return Result<T>.success(
      await mapSuccess(that.data),
      tag: tag ?? that.tag,
    );
  }

  return _mapResultToErrorOrLoading<T>(tag: tag);
}