foldNotNull<R> method

  1. @override
R? foldNotNull<R>(
  1. R onSuccess(
    1. T value
    ), {
  2. required R onFailure(
    1. ErrorMessage errorMessage
    ),
})
override

Similar to fold, but ensures that the value is not null before calling onSuccess.

onSuccess is the function that transforms the value if the result is a success and not null. onNullOrFailure is the function that transforms the error message or provides a default value if the result is null or a failure.

Implementation

@override
R? foldNotNull<R>(
  R Function(T value) onSuccess, {
  required R Function(ErrorMessage errorMessage) onFailure,
}) =>
    onFailure(_error);