Option<T extends Object> class sealed

A Outcome 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 → Object
no setterinherited

Methods

asOption() → Option<T>
Returns this as a base Option type.
end() → void
Suppresses the linter error must_use_outcome. Returns void in every subtype — calling .end() is the "I am intentionally discarding this Outcome" marker, so the call site never needs to think about a Future. For Async this means the underlying future is detached internally via unawaited(...); if you actually need to await completion, use .value.
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<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

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

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 Outcome's structure.
override
map10<R extends Object>(R mapper(T)) → TResolvableOption<Object>

Available on Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Object>>>>>>>>>>, provided by the MapOutcomeExt10 extension

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

Available on Outcome<Outcome<Object>>, provided by the MapOutcomeExt2 extension

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

Available on Outcome<Outcome<Outcome<Object>>>, provided by the MapOutcomeExt3 extension

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

Available on Outcome<Outcome<Outcome<Outcome<Object>>>>, provided by the MapOutcomeExt4 extension

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

Available on Outcome<Outcome<Outcome<Outcome<Outcome<Object>>>>>, provided by the MapOutcomeExt5 extension

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

Available on Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Object>>>>>>, provided by the MapOutcomeExt6 extension

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

Available on Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Object>>>>>>>, provided by the MapOutcomeExt7 extension

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

Available on Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Object>>>>>>>>, provided by the MapOutcomeExt8 extension

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

Available on Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Outcome<Object>>>>>>>>>, provided by the MapOutcomeExt9 extension

mapNone(None<T> noFutures(None<T> none)) → Option<T>
Transforms the inner None instance if this is a None.
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 Outcome chain. It recursively unwraps all Outcome layers to return the innermost raw value, forcing the caller to handle terminal states via callbacks.
inherited
rawAsync() → Async<Object>
Reduces any Outcome chain to a single Async.
inherited
rawSync() → Sync<Object>
Safely reduces any Outcome chain to a single Sync.
inherited
reduce<R extends Object>() → TResolvableOption<R>
Reduces any nested Outcome 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() → Resolvable<Option<T>>

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

swap() → Sync<Option<T>>

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

swap() → Some<Option<T>>

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

swap() → Result<Option<T>>

Available on Option<Result<T>>, provided by the SwapOptionResultExt 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() → Option<Unit>

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

toUnit() → Outcome<Unit>

Available on Outcome<Object>, provided by the ToUnitOnObjectOutcome extension

toVoid() → Option<void>

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

toVoid() → Outcome<void>

Available on Outcome<T>, provided by the ToVoidOnOutcomeExt extension

transf<R extends Object>([R noFutures(T e)?]) → Result<Option<R>>
Transforms the Outcome'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 Outcome is in an Err or None state.
override
wrapInAsync() → Async<M>

Available on M, provided by the WrapOnOutcomeExt extension

wrapInOk() → Ok<M>

Available on M, provided by the WrapOnOutcomeExt extension

wrapInResolvable() → Resolvable<M>

Available on M, provided by the WrapOnOutcomeExt extension

wrapInSome() → Some<M>

Available on M, provided by the WrapOnOutcomeExt extension

wrapInSync() → Sync<M>

Available on M, provided by the WrapOnOutcomeExt extension

wrapValueInAsync() → Option<Async<T>>

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

wrapValueInAsync() → Outcome<Async<T>>

Available on M, provided by the WrapOnOutcomeExt extension

wrapValueInOk() → Option<Ok<T>>

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

wrapValueInOk() → Outcome<Ok<T>>

Available on M, provided by the WrapOnOutcomeExt extension

wrapValueInResolvable() → Option<Resolvable<T>>

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

wrapValueInResolvable() → Outcome<Resolvable<T>>

Available on M, provided by the WrapOnOutcomeExt extension

wrapValueInSome() → Option<Some<T>>

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

wrapValueInSome() → Outcome<Some<T>>

Available on M, provided by the WrapOnOutcomeExt extension

wrapValueInSync() → Option<Sync<T>>

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

wrapValueInSync() → Outcome<Sync<T>>

Available on M, provided by the WrapOnOutcomeExt 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 outcomes 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 outcomes into 1 containing a tuple of their values if all are Some.