Maybe<T> class sealed

Container that either holds a value or an exception that was raised while computing the value.

Implementers

Constructors

Maybe(T value)
Create a Maybe that holds a computed value.
const
factory
Maybe.error(Object error, [StackTrace? stackTrace])
Create a Maybe that holds the exception error.
const
factory
Maybe.wrap(T compute())
Compute a value using compute and wrap the result in a Maybe.
factory

Properties

error Object?
Exception thrown during the computation of value.
no setter
hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
unwrap → T
Get the wrapped value or throw error if this Maybe represents an error.
no setter
value → T?
The value or null if there was an error during computation
no setter

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

wrapAsync<T>(Future<T> compute()) Future<Maybe<T>>
Compute a Future value using compute and wrap the result in a Maybe.