PresentOptional<T> class

Implementation of an Optional with a value.

Inheritance

Properties

hashCode → int
The hash code for this object.
no setteroverride
isAbsent → bool
Returns whether the value is absent.
no setteroverride
isPresent → bool
Returns whether the value is present.
no setteroverride
iterable → Iterable<T>
Returns an Iterable with the single present value, otherwise an empty iterable.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value → T
Returns the present value, otherwise throws a StateError.
final
valueOrNull → T?
Returns the present value if present, otherwise returns null.
no setteroverride

Methods

flatMap<R>(Map1<T, Optional<R>> function) → Optional<R>
Transforms the present value of this Optional with the provided mapping function, otherwise returns an absent Optional.
override
ifAbsent(Callback0 function) → void
Evaluates the callback function if the value is absent, otherwise does nothing.
override
ifPresent(Callback1<T> function) → void
Evaluates the callback function with the present value, otherwise does nothing.
override
map<R>(Map1<T, R> function) → Optional<R>
Transforms the present value of this Optional with the provided mapping function, otherwise returns an absent Optional.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
or(Map0<Optional<T>> function) → Optional<T>
Returns the current optional if present, otherwise evaluates the function callback and returns its optional.
override
orElse(T value) → T
Returns the current value if present, otherwise the argument value.
override
orElseGet(Map0<T> function) → T
Returns the current value if present, otherwise evaluates the callback function and returns its value.
override
orElseThrow([Object? error]) → T
Returns the current value if present, otherwise throws the provided error or a StateError.
override
toString() → String
A string representation of this object.
override
where(Predicate1<T> function) → Optional<T>
Returns this Optional if the provided predicate function evaluates to true, otherwise returns an absent Optional.
override
whereType<R>() → Optional<R>
Casts the present value of this Optional to R, otherwise returns an absent Optional.
override

Operators

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