Success<T> class final

The happy path. Carries the parsed response body.

Inheritance

Constructors

Success(T data, {int statusCode = 200, Map<String, String> headers = const {}})
const

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 true when this is a Failure.
no setterinherited
isSuccess bool
Returns true when 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 this unchanged.
inherited
onSuccess(void action(T value)) Result<T>
Run a side-effect on success, then return this unchanged.
inherited
toString() String
A string representation of this object.
override

Operators

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