mapResult<T> method

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

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

Implementation

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

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

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