Ok<T> class final

A successful Result carrying a value.

Inheritance
Available extensions

Constructors

Ok(T value)
Creates a success carrying value.
const

Properties

error → ResultError?
The error, or null for an Ok.
no setteroverride
errorMessage → String
The error message, or '' for an Ok.
no setterinherited
hashCode → int
The hash code for this object.
no setteroverride
isFail → bool
True for Err.
no setterinherited
isSuccess → bool
True for Ok.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
value → T
The success value. Non-null when T is non-nullable (the common case); for a nullable T it may be null.
final
valueOrNull → T?
The success value, or null for an Err. Prefer pattern matching or ResultCombinators.valueOr/ResultCombinators.getOrElse; a convenience for migration and display.
no setteroverride

Methods

flatMap<R>(Result<R> next(T value)) → Result<R>

Available on Result<T>, provided by the ResultCombinators extension

Chain a success into another Result; pass an Err through unchanged.
flatMapAsync<R>(Future<Result<R>> next(T value)) → Future<Result<R>>

Available on Result<T>, provided by the ResultCombinators extension

Async flatMap.
fold<R>(R onOk(T value), R onErr(ResultError error)) → R

Available on Result<T>, provided by the ResultCombinators extension

Collapse into a single value by handling both branches.
getOrElse(T orElse(ResultError error)) → T

Available on Result<T>, provided by the ResultCombinators extension

The success value, or the result of orElse on an Err.
map<R>(R transform(T value)) → Result<R>

Available on Result<T>, provided by the ResultCombinators extension

Transform a success value; pass an Err through unchanged.
mapError(ResultError transform(ResultError error)) → Result<T>

Available on Result<T>, provided by the ResultCombinators extension

Transform the error of an Err; a no-op on an Ok.
match<R>({required R onOk(T value), required R onErr(ResultError error)}) → R

Available on Result<T>, provided by the ResultCombinators extension

Named-parameter form of fold.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
recover(T recovery(ResultError error)) → Result<T>

Available on Result<T>, provided by the ResultCombinators extension

Turn an Err into an Ok via recovery; a no-op on an Ok.
toString() → String
A string representation of this object.
inherited
valueOr(T fallback) → T

Available on Result<T>, provided by the ResultCombinators extension

The success value, or fallback on an Err.

Operators

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