TaskOption<R>.fromPredicate constructor

TaskOption<R>.fromPredicate(
  1. R value,
  2. bool predicate(
    1. R a
    )
)

When calling predicate with value returns true, then running TaskOption returns Some(value). Otherwise return None.

Implementation

factory TaskOption.fromPredicate(R value, bool Function(R a) predicate) =>
    TaskOption(
      () async => predicate(value) ? Option.of(value) : const Option.none(),
    );