Ok<T extends Object, E extends Object> class
final
A Result representing a successful operation.
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- isFailure → bool
-
Returns
trueif this is an Err.no setterinherited - isSuccess → bool
-
Returns
trueif 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
onSuccessif this is an Ok, oronErrorif 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
fnwith the error.inherited -
toString(
) → String -
A string representation of this object.
override
-
when(
{required void onSuccess(T), required void onError(E)}) → void -
Executes
onSuccessif this is an Ok, oronErrorif this is an Err.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override