mapBoth<R> method
Transforms both the contained success
and error
values
based on the results of the callback functions success
and error
respectively.
Implementation
Deferred<R> mapBoth<R>({
required R Function(T result) success,
required Object Function(Object error) error,
}) {
if (this is _InProgress) {
return Deferred.inProgress();
} else if (this is _Error) {
final e = this as _Error;
return Deferred.error(error(e.error), e.stackTrace);
} else if (this is _Success) {
final s = this as _Success<T>;
return Deferred.success(success(s.results));
} else {
return Deferred.idle();
}
}