Ok<T, E> class final

A successful Result.

Inheritance
Available Extensions

Constructors

Ok(T value)
Creates a successful Result with the given value.
const

Properties

err None<E>
The possibly contained error.
no setteroverride
errorOrNull Null
The contained error if this is an Err, or null otherwise.
no setteroverride
hashCode int
The hash code for this object.
no setteroverride
isErr bool
Whether this is an Err.
no setteroverride
isOk bool
Whether this is an Ok.
no setteroverride
iterable Iterable<T>
Returns an iterable over the possibly contained value.
no setteroverride
ok Some<T>
The possibly contained value.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
value → T
The contained value.
final
valueOrNull → T
The contained value if this is an Ok, or null otherwise.
no setteroverride

Methods

and<U>(Result<U, E> other) Result<U, E>
Returns other if this is an Ok, or an Err of the original error otherwise.
override
andThen<U>(Result<U, E> calculateOther(T value)) Result<U, E>
Returns the result of calculateOther if this is an Ok, or an Err of the original error otherwise.
override
contains(T value) bool
Returns true if this is an Ok with the given value.
override
containsErr(E error) bool
Returns true if this is an Err with the given error.
override
inspect(void inspect(T value)) Ok<T, E>
Calls inspect with the contained value if this is an Ok.
override
inspectErr(void inspect(E error)) Ok<T, E>
Calls inspect with the contained error if this is an Err.
override
isErrAnd(bool condition(E error)) bool
Returns true if this is an Err with a contained error that satisfies condition.
override
isOkAnd(bool condition(T value)) bool
Returns true if this is an Ok with a contained value that satisfies condition.
override
map<U>(U map(T value)) Ok<U, E>
Transforms the contained value, if any, by applying map to it.
override
mapErr<F>(F map(E error)) Ok<T, F>
Transforms the contained error, if any, by applying map to it.
override
mapErrOr<F>(F map(E error), F defaultError) → F
Returns the contained error, if any, with map applied to it, or defaultError otherwise.
override
mapErrOrElse<F>(F map(E error), F calculateDefaultError(T value)) → F
Returns the contained error, if any, with map applied to it, or the result of calculateDefaultError otherwise.
override
mapOr<U>(U map(T value), U defaultValue) → U
Returns the contained value, if any, with map applied to it, or defaultValue otherwise.
override
mapOrElse<U>(U map(T value), U calculateDefaultValue(E error)) → U
Returns the contained value, if any, with map applied to it, or the result of calculateDefaultValue otherwise.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
or<F>(Result<T, F> other) Ok<T, F>
Returns an Ok of the original value if this is an Ok, or other otherwise.
override
orElse<F>(Result<T, F> calculateOther(E error)) Ok<T, F>
Returns an Ok of the original value if this is an Ok, or the result of calculateOther otherwise.
override
toString() String
A string representation of this object.
override
unwrap({String? msg}) → T
Returns the contained value.
override
unwrapErr({String? msg}) → Never
Returns the contained error.
override
unwrapErrOr(E defaultError) → E
Returns the contained error, if any, or defaultError otherwise.
override
unwrapErrOrElse(E calculateDefaultError(T value)) → E
Returns the contained error, if any, or the result of calculateDefaultError otherwise.
override
unwrapOr(T defaultValue) → T
Returns the contained value, if any, or defaultValue otherwise.
override
unwrapOrElse(T calculateDefaultValue(E error)) → T
Returns the contained value, if any, or the result of calculateDefaultValue otherwise.
override

Operators

operator ==(covariant Result<T, E> other) bool
The equality operator.
override