when<R> method
R
when<R>({})
Implementation
R when<R>({
required R Function(Success<T>) success,
required R Function(Failure<T>) failure,
required R Function(Loading<T>) loading,
}) {
if (this is Success<T>) {
return success(this as Success<T>);
}
if (this is Failure<T>) {
return failure(this as Failure<T>);
}
if (this is Loading<T>) {
return loading(this as Loading<T>);
}
throw new Exception('Should never get here');
}