Option<T extends Object> class sealed

A Monad that represents an optional value: every Option is either Some and contains a value, or None and does not.

Inheritance
Implemented types
Available extensions

Constructors

Option.from(T? value)
Creates an Option from a nullable value.
factory
Option.fromNullable(T? value)
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool?
If set to true, the toString method will be overridden to output this instance's props.
no setterinherited
value FutureOr<Object>
finalinherited

Methods

asOption() Option<T>
Returns this as a base Option type.
end() → void
Suppresses the linter error must_use_monad.
override
filter(bool noFutures(T value)) Option<T>
Returns None if the predicate noFutures returns false. Otherwise, returns the original Option.
flatMap<R extends Object>(Option<R> noFutures(T value)) Option<R>
Maps an Option<T> to Option<R> by applying a function that returns another Option.
flatten() Option<T>

Available on Option<Option<Option<Option<Option<Option<Option<Option<Option<T>>>>>>>>>, provided by the FlattenOptionExt9 extension

flatten() Option<T>

Available on Option<Option<T>>, provided by the FlattenOptionExt2 extension

flatten() Option<T>

Available on Option<Option<Option<T>>>, provided by the FlattenOptionExt3 extension

flatten() Option<T>

Available on Option<Option<Option<Option<T>>>>, provided by the FlattenOptionExt4 extension

flatten() Option<T>

Available on Option<Option<Option<Option<Option<T>>>>>, provided by the FlattenOptionExt5 extension

flatten() Option<T>

Available on Option<Option<Option<Option<Option<Option<T>>>>>>, provided by the FlattenOptionExt6 extension

flatten() Option<T>

Available on Option<Option<Option<Option<Option<Option<Option<T>>>>>>>, provided by the FlattenOptionExt7 extension

flatten() Option<T>

Available on Option<Option<Option<Option<Option<Option<Option<Option<T>>>>>>>>, provided by the FlattenOptionExt8 extension

flatten2() Option<T>

Available on Option<Option<T>>, provided by the FlattenOptionExt2 extension

flatten3() Option<T>

Available on Option<Option<Option<T>>>, provided by the FlattenOptionExt3 extension

flatten4() Option<T>

Available on Option<Option<Option<Option<T>>>>, provided by the FlattenOptionExt4 extension

flatten5() Option<T>

Available on Option<Option<Option<Option<Option<T>>>>>, provided by the FlattenOptionExt5 extension

flatten6() Option<T>

Available on Option<Option<Option<Option<Option<Option<T>>>>>>, provided by the FlattenOptionExt6 extension

flatten7() Option<T>

Available on Option<Option<Option<Option<Option<Option<Option<T>>>>>>>, provided by the FlattenOptionExt7 extension

flatten8() Option<T>

Available on Option<Option<Option<Option<Option<Option<Option<Option<T>>>>>>>>, provided by the FlattenOptionExt8 extension

flatten9() Option<T>

Available on Option<Option<Option<Option<Option<Option<Option<Option<Option<T>>>>>>>>>, provided by the FlattenOptionExt9 extension

fold(Option<Object>? onSome(Some<T> some), Option<Object>? onNone(None<T> none)) Result<Option<Object>>
Folds the two cases of this Option into a single Result.
ifNone(void noFutures(Option<T> self, None<T> none)) Result<Option<T>>
Performs a side-effect if this is a None.
ifSome(void noFutures(Option<T> self, Some<T> some)) Result<Option<T>>
Performs a side-effect with the contained value if this is a Some.
isNone() bool
Returns true if this Option is a None.
isSome() bool
Returns true if this Option is a Some.
map<R extends Object>(R noFutures(T value)) Option<R>
Transforms the contained value using the mapper function noFutures while preserving the Monad's structure.
override
map10<R extends Object>(R mapper(T)) TResolvableOption<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>>, provided by the MapMonadExt10 extension

map2<R extends Object>(R mapper(T)) TResolvableOption<Object>

Available on Monad<Monad<Object>>, provided by the MapMonadExt2 extension

map3<R extends Object>(R mapper(T)) TResolvableOption<Object>

Available on Monad<Monad<Monad<Object>>>, provided by the MapMonadExt3 extension

map4<R extends Object>(R mapper(T)) TResolvableOption<Object>

Available on Monad<Monad<Monad<Monad<Object>>>>, provided by the MapMonadExt4 extension

map5<R extends Object>(R mapper(T)) TResolvableOption<Object>

Available on Monad<Monad<Monad<Monad<Monad<Object>>>>>, provided by the MapMonadExt5 extension

map6<R extends Object>(R mapper(T)) TResolvableOption<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>, provided by the MapMonadExt6 extension

map7<R extends Object>(R mapper(T)) TResolvableOption<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>, provided by the MapMonadExt7 extension

map8<R extends Object>(R mapper(T)) TResolvableOption<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>, provided by the MapMonadExt8 extension

map9<R extends Object>(R mapper(T)) TResolvableOption<Object>

Available on Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Monad<Object>>>>>>>>>, provided by the MapMonadExt9 extension

mapSome(Some<T> noFutures(Some<T> some)) Option<T>
Transforms the inner Some instance if this is a Some.
none() Result<None<T>>
Safely gets the None instance. Returns an Ok on None, or an Err on Some.
noneOr(Option<T> other) Option<T>
Returns this if it's None, otherwise returns the other Option.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orNull() → T?
Returns the contained value or null.
raw({required FutureOr<Object> onErr(Err<Object> err), required FutureOr<Object> onNone()}) FutureOr<Object>
The low-level primitive for reducing a Monad chain. It recursively unwraps all Monad layers to return the innermost raw value, forcing the caller to handle terminal states via callbacks.
inherited
rawAsync() Async<Object>
Reduces any Monad chain to a single Async.
inherited
rawSync() Sync<Object>
Safely reduces any Monad chain to a single Sync.
inherited
reduce<R extends Object>() TResolvableOption<R>
Reduces any nested Monad structure into a single TResolvableOption.
inherited
some() Result<Some<T>>
Safely gets the Some instance. Returns an Ok on Some, or an Err on None.
someOr(Option<T> other) Option<T>
Returns this if it's Some, otherwise returns the other Option.
swap() Result<Option<T>>

Available on Option<Result<T>>, provided by the SwapOptionResultExt extension

swap() Sync<Option<T>>

Available on Option<Sync<T>>, provided by the SwapOptionSyncExt extension

swap() Resolvable<Option<T>>

Available on Option<Resolvable<T>>, provided by the SwapOptionResolvableExt extension

swap() Some<Option<T>>

Available on Option<Some<T>>, provided by the SwapOptionSomeExt extension

swap() Ok<Option<T>>

Available on Option<Ok<T>>, provided by the SwapOptionOkExt extension

swap() Err<Option<T>>

Available on Option<Err<T>>, provided by the SwapOptionErrExt extension

swap() None<Option<T>>

Available on Option<None<T>>, provided by the SwapOptionNoneExt extension

swap() Async<Option<T>>

Available on Option<Async<T>>, provided by the SwapOptionAsyncExt extension

toString() String
A string representation of this object.
inherited
toUnit() Monad<Unit>

Available on Monad<Object>, provided by the ToUnitOnObjectMonad extension

toUnit() Option<Unit>

Available on Option<Object>, provided by the ToUnitOnObjectOption extension

toVoid() Monad<void>

Available on Monad<T>, provided by the ToVoidOnMonadExt extension

toVoid() Option<void>

Available on Option<T>, provided by the ToVoidOnOptionExt extension

transf<R extends Object>([R noFutures(T e)?]) Result<Option<R>>
Transforms the Monad's generic type from T to R.
override
unwrap() → T
Strongly discouraged: Unsafely returns the contained value.
override
unwrapOr(T fallback) → T
Returns the contained value, or the fallback if the Monad is in an Err or None state.
override
wrapInAsync() Async<M>

Available on M, provided by the WrapOnMonadExt extension

wrapInOk() Ok<M>

Available on M, provided by the WrapOnMonadExt extension

wrapInResolvable() Resolvable<M>

Available on M, provided by the WrapOnMonadExt extension

wrapInSome() Some<M>

Available on M, provided by the WrapOnMonadExt extension

wrapInSync() Sync<M>

Available on M, provided by the WrapOnMonadExt extension

wrapValueInAsync() Monad<Async<T>>

Available on M, provided by the WrapOnMonadExt extension

wrapValueInAsync() Option<Async<T>>

Available on Option<T>, provided by the WrapOnOptionExt extension

wrapValueInOk() Monad<Ok<T>>

Available on M, provided by the WrapOnMonadExt extension

wrapValueInOk() Option<Ok<T>>

Available on Option<T>, provided by the WrapOnOptionExt extension

wrapValueInResolvable() Monad<Resolvable<T>>

Available on M, provided by the WrapOnMonadExt extension

wrapValueInResolvable() Option<Resolvable<T>>

Available on Option<T>, provided by the WrapOnOptionExt extension

wrapValueInSome() Monad<Some<T>>

Available on M, provided by the WrapOnMonadExt extension

wrapValueInSome() Option<Some<T>>

Available on Option<T>, provided by the WrapOnOptionExt extension

wrapValueInSync() Monad<Sync<T>>

Available on M, provided by the WrapOnMonadExt extension

wrapValueInSync() Option<Sync<T>>

Available on Option<T>, provided by the WrapOnOptionExt extension

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

combine2<T1 extends Object, T2 extends Object>(Option<T1> o1, Option<T2> o2) Option<(T1, T2)>
Combines 2 Option monads into 1 containing a tuple of their values if all are Some.
combine3<T1 extends Object, T2 extends Object, T3 extends Object>(Option<T1> o1, Option<T2> o2, Option<T3> o3) Option<(T1, T2, T3)>
Combines 3 Option monads into 1 containing a tuple of their values if all are Some.