Result<T, E extends BaseException> class
sealed
Algebraic data type for success/failure flows that plays nicely with Bloc/Riverpod/Notifier state management.
Properties
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< next(T value)) → Future<U, E> >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<
Maps the success value using an async transformer, preserving errors.T, E> , provided by the ResultX extension -
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
okorerraccordingly. -
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
fallbackwhen 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