fold<R> method
R
fold<R>({
- required R onFetchFailure(
- Object error,
- StackTrace stackTrace
- required R onFetchSuccess(
- Content data
- required R onRefreshFailure(
- Object error,
- StackTrace stackTrace
- required R onRefreshSuccess(
- Content data
Fold all cases into single value
Implementation
R fold<R>({
required R Function(Object error, StackTrace stackTrace) onFetchFailure,
required R Function(Content data) onFetchSuccess,
required R Function(Object error, StackTrace stackTrace) onRefreshFailure,
required R Function(Content data) onRefreshSuccess,
}) {
final self = this;
if (self is _FetchFailure<Content>) {
return onFetchFailure(self.error, self.stackTrace);
}
if (self is _FetchSuccess<Content>) {
return onFetchSuccess(self.content);
}
if (self is _RefreshFailure<Content>) {
return onRefreshFailure(self.error, self.stackTrace);
}
if (self is _RefreshSuccess<Content>) {
return onRefreshSuccess(self.content);
}
throw StateError('Unknown type $self');
}