fromPredicate<R> static method
Constructs a Result by testing a condition. If the condition is true, the Result is a success with a certain value. If the condition is false, the Result is an error with a certain error.
Implementation
static Result<R> fromPredicate<R>(
bool Function() predicate,
R Function() onSuccess,
BaseError Function() onError,
) {
if (predicate()) {
return successResult(onSuccess());
} else {
return errorResult(onError());
}
}