Error<S, E> class
Represents a failed result containing an error of type E.
This is one of the two concrete implementations of Result, used when an operation fails and produces an error instead of a successful value.
Example:
final result = Error('Something went wrong');
print(result.error); // 'Something went wrong'
Properties
- error → E
-
The error data wrapped by this result.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isError → bool
-
Returns true if this result represents a failed operation.
no setterinherited
- isSuccess → bool
-
Returns true if this result represents a successful operation.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
execute(
) → void -
Forces evaluation of this result without returning any value.
inherited
-
flat(
) → (S?, E) -
Flattens this error result into a tuple.
override
-
getOrNull(
) → S? -
Extracts the success value or returns null if this result is an error.
inherited
-
getOrThrow(
) → S -
Extracts the success value or throws an exception if this result is an error.
inherited
-
map<
X extends Result> (X errorMapper(E error)) → X - Transforms this error using a mapper function.
-
mapError<
E2> (E2 mapper(E err)) → Result< S, E2> -
Transforms the error value using a mapper function.
inherited
-
mapOnError<
E2> (Result< S, E2> mapper(E err)) → Result<S, E2> -
Transforms the error value using a mapper that returns a Result.
inherited
-
mapOnSuccess<
S2> (Result< S2, E> mapper(S data)) → Result<S2, E> -
Transforms the success value using a mapper that returns a Result.
inherited
-
mapSuccess<
S2> (S2 mapper(S data)) → Result< S2, E> -
Transforms the success value using a mapper function.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
nullable(
) → Result< S?, E> -
Converts this result to allow nullable success values.
inherited
-
onError(
void onError(E error)) → Result< S, E> -
Executes a side effect if this result is an error.
inherited
-
onSuccess(
void onSuccess(S data)) → Result< S, E> -
Executes a side effect if this result is successful.
inherited
-
resolve(
{required S onError(E error)}) → Success< S, E> -
Converts any error result into a successful result using a recovery function.
inherited
-
toString(
) → String -
Returns a string representation of this error result.
override
-
when<
T> ({required T success(S data), required T error(E error)}) → T -
Pattern matches on this result and executes the appropriate callback.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited