Result<T, E extends BaseException> class sealed

Algebraic data type for success/failure flows that plays nicely with Bloc/Riverpod/Notifier state management.

Implementers
Available extensions

Properties

hashCode → int
The hash code for this object.
no setterinherited
isErr → bool
Returns true when this result contains an error.
no setter
isOk → bool
Returns true when this result contains a value.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

andThen<U>(Result<U, E> next(T value)) → Result<U, E>
Chains another computation only when this result is successful.
andThenAsync<U>(Future<Result<U, E>> next(T value)) → Future<Result<U, E>>
Async variant of andThen for future-returning pipelines.
map<U>(U f(T value)) → Result<U, E>
Maps the inner value when successful, preserving errors.
mapAsync<U>(Future<U> f(T value)) → Future<Result<U, E>>

Available on Result<T, E>, provided by the ResultX extension

Maps the success value using an async transformer, preserving errors.
mapErr<F extends BaseException>(F f(E error)) → Result<T, F>
Maps the error type when present, preserving successes.
match<R>({required R ok(T value), required R err(E error)}) → R
Pattern matches on the result, invoking ok or err accordingly.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
unwrap() → T
Unwraps the result, throwing if it contains an error.
unwrapOr(T fallback) → T
Returns the inner value or fallback when this is an error.
unwrapOrElse(T f(E error)) → T
Returns the inner value or computes one via f.

Operators

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