Err<T, E> class final

Represents a failed result.

Inheritance

Constructors

Err(E error)
const

Properties

error → E
final
errOrNull → E?
Returns the Err value or null when Ok.
no setterinherited
hashCode int
The hash code for this object.
no setteroverride
isErr bool
Returns true when this result is Err.
no setterinherited
isOk bool
Returns true when this result is Ok.
no setterinherited
okOrNull → T?
Returns the Ok value or null when Err.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

andThen<U>(Result<U, E> op(T value)) Result<U, E>
Chains another Result-producing operation.
inherited
andThenAsync<U>(Future<Result<U, E>> op(T value)) Future<Result<U, E>>
Chains another async Result-producing operation.
inherited
expect(String message) → T
Returns the Ok value or throws an UnwrapException with a custom message.
inherited
expectErr(String message) → E
Returns the Err value or throws an UnwrapException with a custom message.
inherited
fold<R>(R onOk(T value), R onErr(E error)) → R
Converts this result into a value using the provided callbacks.
inherited
guard() → (T?, E?)
Returns a record (T?, E?) for safe extraction without exceptions. Similar to Go's (value, error) pattern.
inherited
inspect(void op(T value)) Result<T, E>
Runs a side-effect on Ok and returns the original result.
inherited
inspectErr(void op(E error)) Result<T, E>
Runs a side-effect on Err and returns the original result.
inherited
map<U>(U op(T value)) Result<U, E>
Maps an Ok value, leaving Err untouched.
inherited
mapErr<F>(F op(E error)) Result<T, F>
Maps an Err value, leaving Ok untouched.
inherited
mapError<F>(F op(E error)) Result<T, F>
Maps an Err value, leaving Ok untouched.
inherited
match<R>({required R ok(T value), required R err(E error)}) → R
Pattern match on the result.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
orElse(Result<T, E> op(E error)) Result<T, E>
Recovers from an Err with another Result.
inherited
tap(void op(T value)) Result<T, E>
Executes a function if this is Ok, returns the same Result.
inherited
tapAsync(Future<void> op(T value)) Future<Result<T, E>>
Executes an async function if this is Ok, returns the same Result.
inherited
toString() String
A string representation of this object.
override
unwrap([String? message]) → T
Returns the Ok value or throws an UnwrapException.
inherited
unwrapErr([String? message]) → E
Returns the Err value or throws an UnwrapException.
inherited
unwrapOr(T fallback) → T
Returns the Ok value or the provided fallback.
inherited
unwrapOrElse(T op(E error)) → T
Returns the Ok value or computes a fallback from Err.
inherited

Operators

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