Ok<T extends Object, E extends Object> class final

A Result representing a successful operation.

Inheritance

Constructors

Ok(T value)
Creates an Ok with the given value.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
isFailure bool
Returns true if this is an Err.
no setterinherited
isSuccess bool
Returns true if this is an Ok.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
The successful value.
final

Methods

fold<R>({required R onSuccess(T), required R onError(E)}) → R
Executes onSuccess if this is an Ok, or onError if this is an Err.
override
getOrElse(T fallback(E)) → T
Returns the value if this is an Ok.
inherited
map<R extends Object>(R fn(T)) Res<R, E>
Transforms the success value using fn.
inherited
mapError<R extends Object>(R fn(E)) Res<T, R>
Transforms the error value using fn.
inherited
next<R extends Object>(Res<R, E> fn(T)) Res<R, E>
Chains another Result operation when this result is Ok.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
or(Res<T, E> fn(E error)) Res<T, E>
Returns this result if it is Ok, or calls fn with the error.
inherited
toString() String
A string representation of this object.
override
when({required void onSuccess(T), required void onError(E)}) → void
Executes onSuccess if this is an Ok, or onError if this is an Err.
inherited

Operators

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