Option<T> class sealed

Properties

hashCode int
The hash code for this object.
no setteroverride
isNone bool
no setter
isSome bool
no setter
none None<T>
Get the None value or throw an error if it's Some.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
some Some<T>
Get the Some value or throw an error if it's None.
no setter

Methods

andThen<U>(Option<U> fn(T value)) Option<U>
If it's Some, apply the function to the value, else return None.
filter(bool predicate(T value)) Option<T>
Applies the function only if the Option is Some, otherwise returns None.
fold<B>(B onSome(T value), B onNone()) → B
Fold is used to handle both Some and None cases.
getOrElse(T defaultValue()) → T
Transform the Option into a value using a default if None.
isSomeAnd(bool predicate(T value)) bool
Checks if the Option contains a value.
map<U>(U fn(T value)) Option<U>
Maps the value inside Some if it exists.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orElse(Option<T> alternative()) Option<T>
Returns Option if Some, or None otherwise.
toString() String
A string representation of this object.
inherited
unwrap() → T
Unwrap the value or throw an error if it's None.

Operators

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