Success<T> class
final
The happy path. Carries the parsed response body.
Properties
- data → T
-
Unwraps the value; throws StateError if this is a Failure.
final
- error → NetworkException
-
Unwraps the error; throws StateError if this is a Success.
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String> -
Raw response headers forwarded for callers that need them.
final
- 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
- statusCode → int
-
HTTP status code of the response, e.g. 200, 201.
final
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