transformNullable<R> method
R?
transformNullable<R>({})
Implementation
R? transformNullable<R>({
R Function(Success<T> success)? whenSuccess,
R Function(Failure<T> failure)? whenFailure,
R Function(Cancelled<T> cancelled)? whenCancelled,
R Function(Result<T> result)? whenElse,
}) {
if (this is Success) {
return (whenSuccess ?? whenElse)?.call(this as Success<T>);
} else if (this is Failure) {
return (whenFailure ?? whenElse)?.call(this as Failure<T>);
} else {
return (whenCancelled ?? whenElse)?.call(this as Cancelled<T>);
}
}