None<T> class
A type that represents the absence of a value.
Pattern matching is recommended for working with Option types.
Option<int> foo = None();
if (foo case None()) {
print('No value!');
}
- Inheritance
- Available extensions
Constructors
- None()
-
const
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
and<
U> (Option< U> other) → Option<U> -
Returns None<U> if this
Option
is None<T>, otherwise returnsother
.inherited -
andThen<
U> (Option< U> fn(T)) → Option<U> -
Returns None<U> if this
Option
is None<T>, otherwise callsfn
with the held value and returns the returnedOption
.inherited -
call(
) → T -
Shortcut to call Option.unwrap().
inherited
-
expect(
String message) → T -
Returns the held value of this
Option
if it is Some, or throws OptionError with the givenmessage
if thisOption
is None.inherited -
inspect(
void fn(T)) → Option< T> -
Calls the provided function with the contained value if this
Option
is Some.inherited -
isNone(
) → bool -
Returns whether or not this
Option
holds no value (None).inherited -
isSome(
) → bool -
Returns whether or not this
Option
holds a value (Some).inherited -
isSomeAnd(
bool predicate(T)) → bool -
Returns whether or not this
Option
holds a value (Some) and the held value matches the given predicate.inherited -
iter(
) → Iterable< T> -
Returns an Iterable of the held value.
inherited
-
map<
U> (U mapFn(T)) → Option< U> -
Maps this
Option<T>
to anOption<U>
using the given function with the held value.inherited -
mapOr<
U> (U orValue, U mapFn(T)) → Option< U> -
Maps this
Option<T>
to anOption<U>
using the given function with the held value if thisOption<T>
is Some. Otherwise returns the providedorValue
asSome(orValue)
.inherited -
mapOrElse<
U> (U orFn(), U mapFn(T)) → Option< U> -
Maps this
Option<T>
to anOption<U>
using the givenmapFn
function with the held value if thisOption
is Some. Otherwise returns the result oforFn
asSome(orFn())
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
okOr<
E> (E err) → Result< T, E> -
Converts this
Option<T>
into a Result<T, E> using the givenerr
if None.inherited -
okOrElse<
E> (E elseFn()) → Result< T, E> -
Converts this
Option<T>
into a Result<T, E> using the returned value fromelseFn
if None.inherited -
or(
Option< T> other) → Option<T> -
Returns this
Option
if thisOption
is Some<T>, otherwise returnsother
.inherited -
orElse(
Option< T> fn()) → Option<T> -
Returns this
Option
if thisOption
is Some<T>, otherwise callsfn
and returns the returnedOption
.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
unwrap(
) → T -
Returns the held value of this
Option
if it is Some.inherited -
unwrapOr(
T orValue) → T -
Returns the held value of this
Option
if it is Some, or the given value if thisOption
is None.inherited -
unwrapOrElse(
T elseFn()) → T -
Returns the held value of this
Option
if it is Some, or returns the returned value fromelseFn
if thisOption
is None.inherited -
where(
bool predicate(T)) → Option< T> -
Filters this
Option
based on the givenpredicate
function.inherited -
xor(
Option< T> other) → Option<T> -
Returns Some if exactly one of this
Option
andother
is Some, otherwise returns None.inherited -
zip<
U> (Option< U> other) → Option<(T, U)> -
Zips this
Option
with anotherOption
, returning a Record of their held values.inherited -
zipWith<
U, V> (Option< U> other, V zipFn(T, U)) → Option<V> -
Zips this
Option
with anotherOption
using the given function.inherited
Operators
-
operator ==(
Object other) → bool -
Compare equality between two
Option
values.inherited -
operator ~(
) → T -
Deprecated: Use
Option.call()
asvalue()
to easily unwrapOption
type values instead.inherited