Some<T> class

Type Some<T> is an Option that contains a value.

You can construct a Some using the Some() constructor or by calling the Option.some() factory constructor. The advantage of using the factory constructor on Option is that it will yield a None if the passed value is null, which can be helpful.

Inheritance

Constructors

Some(dynamic v)
Create a Some option with the given value.

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 setter
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 setter

Methods

and(Option<T> optb) Option<T>
Returns None if the option is None, otherwise returns optb.
override
andThen(Option<T> op(T)) Option<T>
Returns None if the option is None, otherwise calls op with the wrapped value and returns the result.
override
expect(String msg) → T
Unwraps an option, yielding the content of a Some.
override
filter(bool predicate(T)) Option<T>
Returns None if the option is None, otherwise calls predicate with the wrapped value and returns:
override
isNone() bool
Returns true if the option is a None value.
override
isSome() bool
Returns true if the option is a Some value.
override
map<U>(U op(T)) Option<U>
Maps an Option<T> to Option<U> by applying a function to a contained Some value. Otherwise returns a None.
override
mapOr<U>(U op(T), U opt) → U
Applies a function to the contained value (if any), or returns the provided default (if not).
override
mapOrElse<U>(U op(T), U def()) → U
Maps an Option<T> to U by applying a function to a contained T value, or computes a default (if not).
override
match<R>(R someop(T), R noneop()) → R
Invokes either the someop or the noneop depending on the option.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
okOr<E>(E err) Result<T, E>
Transforms the Option<T> into a Result<T, E>, mapping Some(v) to Ok(v) and None to Err(err).
override
okOrElse<E>(E err()) Result<T, E>
Transforms the Option<T> into a Result<T, E>, mapping Some(v) to Ok(v) and None to Err(err()).
override
or(Option<T> optb) Option<T>
Returns the option if it contains a value, otherwise returns optb.
override
orElse(Option<T> op()) Option<T>
Returns the option if it contains a value, otherwise calls op and returns the result.
override
toNullable() → T?
Returns an nullable that represents this optional value.
override
toString() String
A string representation of this object.
inherited
unwrap() → T
Unwraps an option, yielding the content of a Some.
override
unwrapOr(T opt) → T
Returns the contained value or a default.
override
unwrapOrElse(T op()) → T
Returns the contained value or computes it from a closure.
override
when<R>({required R some(T), required R none()}) → R
Invokes either some or none depending on the option.
override
xor(Option<T> optb) Option<T>
Returns Some if exactly one of this, optb is Some, otherwise returns None.
override

Operators

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