Result<T, E> class
Result
is a type that represents either success (`ok`
) or failure (`error`
).
- Annotations
-
- @immutable
Properties
- hashCode → int
-
The hash code for this object.
no setteroverride
- rawValue → dynamic
-
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- type → ResultType
-
final
Methods
-
and<
U> (Result< U, E> res) → Result<U, E> -
Returns
res
if the result is ok, otherwise returns the error value of class. -
andThen<
U> (Result< U, E> op(T val)) → Result<U, E> -
Calls
op
if the result is`Ok`
, otherwise returns the`Err`
value ofself
. -
contains(
T val) → bool -
Returns
true
if the result is an`ok`
value containing the given value. -
containsError(
E err) → bool -
Returns
true
if the result is an`error`
value containing the given value. -
isError(
) → bool -
Returns
true
if the result is error. -
isOk(
) → bool -
Returns
true
if the result is ok. -
map<
U> (U op(T val)) → Result< U, E> -
Maps a
Result<T, E>
toResult<U, E>
by applying a function to a contained ok value, leaving an error value untouched. -
mapError<
F> (F op(E err)) → Result< T, F> -
Maps a
Result<T, E>
toResult<T, F>
by applying a function to a contained error value, leaving an ok value untouched. -
mapOr<
U> (U defaultt, U op(T val)) → U - Returns the provided default (if error), or applies a function to the contained value (if ok),
-
mapOrElse<
U> (U defaultt(E err), U op(T val)) → U -
Maps a
Result<T, E>
toU
by applying a fallback function to a contained error value, or a default function to a contained ok value. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
or<
F> (Result< T, F> res) → Result<T, F> -
Returns
res
if the result is error, otherwise returns the ok value of class. -
orElse<
F> (Result< T, F> op(E err)) → Result<T, F> -
Calls
op
if the result is error, otherwise returns the ok value of class`. -
toString(
) → String -
A string representation of this object.
override
-
unwrap(
) → T - Returns the contained ok value.
-
unwrapError(
) → E - Returns the contained error value.
-
unwrapOr(
T instance) → T - Returns the contained ok value or a provided default.
-
unwrapOrElse(
T op(E err)) → T - Returns the contained ok value or computes it from a closure.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override