isNoneOr method

bool isNoneOr(
  1. bool predicate(
    1. T value
    )
)

Whether the option is absent, or its value satisfies predicate.

predicate is not called when the option is absent.

final allowed = const None<int>().isNoneOr((age) => age >= 18); // true

Implementation

bool isNoneOr(bool Function(T value) predicate) {
  return switch (this) {
    Some<T>(:final value) => predicate(value),
    None<T>() => true,
  };
}