Some<T> class final

Option state for a present value.

Match this state to read the present value.

const option = Some<String?>('John');

final label = switch (option) {
  None<String?>() => 'Anonymous',
  Some<String?>(:final value) => value ?? 'No nickname',
};
Inheritance

Constructors

Some(T value)
Creates a present option state.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
isNone bool
Whether this option is None.
no setterinherited
isSome bool
Whether this option is Some.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
Replacement value, including null for nullable fields.
final

Methods

andThen<R>(Option<R> next(T value)) Option<R>
Chains another option-producing operation when a value is present.
override
map<R>(R mapper(T value)) Option<R>
Maps a present value and leaves absent values unchanged.
override
match<R>({required R some(T value), required R none()}) → R
Pattern matches this option.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
unwrapOr(T fallback) → T
Returns the present value, or fallback when this option is absent.
override
unwrapOrElse(T fallback()) → T
Returns the present value, or computes one when this option is absent.
override

Operators

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