OptionQuery<T> extension
Reading an Option without matching on it.
const nickname = Some<String>('John');
final hasJohn = nickname.contains('John'); // true
final text = nickname.expect('a nickname was set'); // 'John'
- on
-
- Option<
T>
- Option<
Methods
-
contains(
T value) → bool -
Available on Option<
Whether this option holds a value equal toT> , provided by the OptionQuery extensionvalue. -
expect(
String message) → T -
Available on Option<
Returns the present value, or throwsT> , provided by the OptionQuery extensionmessagewhen absent. -
isNoneOr(
bool predicate(T value)) → bool -
Available on Option<
Whether the option is absent, or its value satisfiesT> , provided by the OptionQuery extensionpredicate. -
isSomeAnd(
bool predicate(T value)) → bool -
Available on Option<
Whether a value is present and satisfiesT> , provided by the OptionQuery extensionpredicate. -
toIterable(
) → Iterable< T> -
Available on Option<
Returns the present value as a one-element iterable, or an empty one.T> , provided by the OptionQuery extension -
toNullable(
) → T? -
Available on Option<
Returns the present value, orT> , provided by the OptionQuery extensionnullwhen absent. -
unwrap(
) → T -
Available on Option<
Returns the present value, or throws when absent.T> , provided by the OptionQuery extension