fold<R> method

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

Allows handling the success and failure cases of a Result separately and returns a value of type R.

onSuccess is the function that transforms the value if the result is a success. onFailure is the function that transforms the error message if the result is a failure.

Implementation

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