Maybe<T> class sealed

A value that is Present or Absent.

Unlike a nullable, it tells "not provided" apart from "provided as null", which is what a copyWith parameter needs.

Implementers

Properties

asNullable → T?
The value if present, otherwise null.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isAbsent → bool
Whether this is Absent.
no setter
isPresent → bool
Whether this is Present.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

convert<T2>(T2 converter(T value)) → Maybe<T2>
Maps the value with converter, if present.
filter(bool predicate(T value)) → Maybe<T>
Keeps the value only if it passes predicate, otherwise returns Absent.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
resolve<T2>({required T2 onPresent(T value), required T2 onAbsent()}) → T2
Folds both cases into one value: onPresent maps a present value, and onAbsent stands in for a missing one.
toString() → String
A string representation of this object.
inherited

Operators

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

Static Methods

from<T>(T? value) → Maybe<T>
Returns Absent for null, otherwise Present.