Failure<T> class
final
The unhappy path. Carries a structured NetworkException.
Constructors
- Failure(NetworkException error)
-
const
Properties
- data → T
-
Unwraps the value; throws StateError if this is a Failure.
no setterinherited
- error → NetworkException
-
Unwraps the error; throws StateError if this is a Success.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isFailure → bool
-
Returns
truewhen this is a Failure.no setterinherited - isSuccess → bool
-
Returns
truewhen this is a Success.no setterinherited - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
fold<
R> ({required R onSuccess(T value), required R onFailure(NetworkException error)}) → R -
Fold into a single value regardless of variant.
inherited
-
map<
R> (R transform(T value)) → Result< R> -
Transforms a Success value; passes Failure through unchanged.
inherited
-
mapAsync<
R> (Future< R> transform(T value)) → Future<Result< R> > -
Async variant of map.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onFailure(
void action(NetworkException error)) → Result< T> -
Run a side-effect on failure, then return
thisunchanged.inherited -
onSuccess(
void action(T value)) → Result< T> -
Run a side-effect on success, then return
thisunchanged.inherited -
toString(
) → String -
A string representation of this object.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited