Ok<T, E extends Object> class
The success variant of Result.
Constructors
- Ok(T value)
-
const
Properties
- errOrNull → E?
-
Returns the error value if this is Err, otherwise
null.no setterinherited - hashCode → int
-
The hash code for this object.
no setteroverride
- isErr → bool
-
Whether this is an Err result.
no setterinherited
- isOk → bool
-
Whether this is an Ok result.
no setterinherited
- okOrNull → T?
-
Returns the success value if this is Ok, otherwise
null.no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value → T
-
final
Methods
-
fold<
R> (R onOk(T value), R onErr(E error)) → R -
Collapses the result with
onOkoronErr, producing a single value of typeR.inherited -
map<
R> (R f(T value)) → Result< R, E> -
Transforms the success value with
fif this is Ok.inherited -
mapErr<
F extends Object> (F f(E error)) → Result< T, F> -
Transforms the error value with
fif this is Err.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
orElse<
F extends Object> (Result< T, F> f(E error)) → Result<T, F> -
Returns the success value if this is Ok, otherwise the result of
calling
fon the error.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
unwrap(
) → T -
Returns the success value, or throws a ResultException if this is Err.
inherited
-
unwrapOr(
T defaultValue) → T -
Returns the success value if this is Ok, otherwise returns
defaultValue.inherited -
unwrapOrElse(
T onErr(E error)) → T -
Returns the success value if this is Ok, otherwise computes a fallback
using
onErr.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override