OptionTransform<T> extension
Transforming and choosing between Option values.
final label = const Some<int>(3).mapOr('none', (count) => '$count items');
final chosen = const None<int>().or(const Some<int>(1)); // Some(1)
- on
-
- Option<
T>
- Option<
Methods
-
and<
R> (Option< R> other) → Option<R> -
Available on Option<
ReturnsT> , provided by the OptionTransform extensionotherwhen this option is present, and None otherwise. -
filter(
bool predicate(T value)) → Option< T> -
Available on Option<
Keeps a present value only when it satisfiesT> , provided by the OptionTransform extensionpredicate. -
inspect(
void action(T value)) → Option< T> -
Available on Option<
CallsT> , provided by the OptionTransform extensionactionwith a present value, and returns this option unchanged. -
mapOr<
R> (R fallback, R mapper(T value)) → R -
Available on Option<
Maps a present value, or returnsT> , provided by the OptionTransform extensionfallbackwhen absent. -
mapOrElse<
R> (R fallback(), R mapper(T value)) → R -
Available on Option<
Maps a present value, or computes a fallback when absent.T> , provided by the OptionTransform extension -
or(
Option< T> other) → Option<T> -
Available on Option<
Returns this option when present, andT> , provided by the OptionTransform extensionotherotherwise. -
orElse(
Option< T> fallback()) → Option<T> -
Available on Option<
Returns this option when present, and computes one otherwise.T> , provided by the OptionTransform extension -
xor(
Option< T> other) → Option<T> -
Available on Option<
Returns whichever of the two options is present, when exactly one is.T> , provided by the OptionTransform extension