Err<T, E> class
final
Failed operation result.
const result = Err<int, String>('invalid count');
- Inheritance
- Available extensions
Constructors
- Err(E error)
-
Creates one failed result.
const
Properties
- error → E
-
Error value.
final
- hashCode → int
-
The hash code for this object.
no setteroverride
- isErr → bool
-
Whether this result is Err.
no setterinherited
- isOk → bool
-
Whether this result is Ok.
no setteroverride
- orReject → T
-
Available on Result<
The extracted value, or a thrown Rejection.T, Rejection> , provided by the RejectOnFailure extensionno setter - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
and<
R> (Result< R, E> other) → Result<R, E> -
Available on Result<
ReturnsT, E> , provided by the ResultTransform extensionotherwhen this result succeeded, or this error otherwise. -
andThen<
R> (Result< R, E> next(T value)) → Result<R, E> -
Available on Result<
Chains another result-producing operation when this result is successful.T, E> , provided by the ResultChain extension -
err(
) → Option< E> -
Available on Result<
The error as Some, or None for an Ok.T, E> , provided by the ResultQuery extension -
expect(
String message) → T -
Available on Result<
Returns the successful value, or throwsT, E> , provided by the ResultQuery extensionmessagefor an Err. -
expectErr(
String message) → E -
Available on Result<
Returns the error, or throwsT, E> , provided by the ResultQuery extensionmessagefor an Ok. -
flatten(
) → Result< T, E> -
Available on Result<
TurnsResult< , provided by the ResultFlatten extensionT, E> , E>Ok(Ok(value))intoOk(value), and either error into Err. -
inspect(
void action(T value)) → Result< T, E> -
Available on Result<
CallsT, E> , provided by the ResultTransform extensionactionwith a successful value, and returns this result unchanged. -
inspectErr(
void action(E error)) → Result< T, E> -
Available on Result<
CallsT, E> , provided by the ResultTransform extensionactionwith the error, and returns this result unchanged. -
isErrAnd(
bool predicate(E error)) → bool -
Available on Result<
Whether the result failed and its error satisfiesT, E> , provided by the ResultQuery extensionpredicate. -
isOkAnd(
bool predicate(T value)) → bool -
Available on Result<
Whether the result succeeded and its value satisfiesT, E> , provided by the ResultQuery extensionpredicate. -
map<
R> (R mapper(T value)) → Result< R, E> -
Maps a successful value and leaves errors unchanged.
override
-
mapErr<
F> (F mapper(E error)) → Result< T, F> -
Maps an error value and leaves successful values unchanged.
override
-
mapOr<
R> (R fallback, R mapper(T value)) → R -
Available on Result<
Maps a successful value, or returnsT, E> , provided by the ResultTransform extensionfallbackfor an Err. -
mapOrElse<
R> (R fallback(E error), R mapper(T value)) → R -
Available on Result<
Maps a successful value, or computes a fallback from the error.T, E> , provided by the ResultTransform extension -
match<
R> ({required R ok(T value), required R err(E error)}) → R -
Pattern matches this result.
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
ok(
) → Option< T> -
Available on Result<
The successful value as Some, or None for an Err.T, E> , provided by the ResultQuery extension -
or<
F> (Result< T, F> other) → Result<T, F> -
Available on Result<
Returns this result when it succeeded, orT, E> , provided by the ResultTransform extensionotherotherwise. -
orElse<
F> (Result< T, F> next(E error)) → Result<T, F> -
Available on Result<
Chains another result-producing operation when this result failed.T, E> , provided by the ResultChain extension -
toString(
) → String -
A string representation of this object.
override
-
transpose(
) → Option< Result< T, E> > -
Available on Result<
Turns a result of an option into an optional result.Option< , provided by the ResultTranspose extensionT> , E> -
unwrap(
) → T -
Available on Result<
Returns the successful value, or throws for an Err.T, E> , provided by the ResultQuery extension -
unwrapErr(
) → E -
Available on Result<
Returns the error, or throws for an Ok.T, E> , provided by the ResultQuery extension -
unwrapOr(
T fallback) → T -
Available on Result<
Returns the successful value, orT, E> , provided by the ResultChain extensionfallbackwhen this result failed. -
unwrapOrElse(
T fallback(E error)) → T -
Available on Result<
Returns the successful value, or computes one from the error.T, E> , provided by the ResultChain extension
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override