Err<T, E> class

An Err<T, E> is a Result that represents a failure.

You can create an Err using either the Err(E) constructor or the Result.err(E) factory constructor.

Inheritance

Constructors

Err(E err)
Create an Err result with the given error.

Properties

hashCode int
The hash code for this object.
no setterinherited
props List<Object?>
The list of properties that will be used to determine whether two instances are equal.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
stringify bool
If set to true, the toString method will be overridden to output this instance's props.
no setter

Methods

and(Result<T, E> res) Result<T, E>
Returns res if the result is Ok, otherwise returns this.
override
andThen(Result<T, E> op(T)) Result<T, E>
Calls op with the Ok value if the result is Ok, otherwise returns this.
override
err() Option<E>
Converts the Result into an Option containing the error, if any. Otherwise returns None if the result is a value.
override
expect(String msg) → T
Unwraps a result, yielding the content of an Ok.
override
expectErr(String msg) → E
Unwraps a result, yielding the content of an Err.
override
fold<U, F>(U ok(T), F err(E)) Result<U, F>
Invoke either the ok or the err function based on the result.
override
isErr() bool
Returns true if the option is a Err value.
override
isOk() bool
Returns true if the option is a Ok value.
override
map<U>(U op(T)) Result<U, E>
Maps a Result<T, E> to Result<U, E> by applying a function to a contained Ok value, leaving an Err value untouched.
override
mapErr<F>(F op(E)) Result<T, F>
Maps a Result<T, E> to Result<T, F> by applying a function to a contained Err value, leaving an Ok value untouched.
override
mapOr<U>(U op(T), U opt) → U
Applies a function to the contained value (if any), or returns the provided default (if not).
override
mapOrElse<U>(U op(T), U errOp(E)) → U
Maps a Result<T, E> to U by applying a function to a contained Ok value, or a fallback function to a contained Err value.
override
match<R>(R okop(T), R errop(E)) → R
Invokes either the okop or the errop depending on the result.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
ok() Option<T>
Converts the Result into an Option containing the value, if any. Otherwise returns None if the result is an error.
override
or(Result<T, E> res) Result<T, E>
Returns res if the result is an Err, otherwise returns this.
override
orElse(Result<T, E> op(E)) Result<T, E>
Calls op with the Err value if the result is Err, otherwise returns this.
override
toString() String
A string representation of this object.
inherited
unwrap() → T
Unwraps a result, yielding the content of an Ok.
override
unwrapErr() → E
Unwraps a result, yielding the content of an Err.
override
unwrapOr(T opt) → T
Unwraps a result, yielding the content of an Ok. Else, it returns opt.
override
unwrapOrElse(T op(E)) → T
Unwraps a result, yielding the content of an Ok. If the value is an Err then it calls op with its value.
override
when<R>({required R ok(T), required R err(E)}) → R
Invokes either ok or err depending on the result.
override

Operators

operator ==(Object other) bool
The equality operator.