Response<BodyType> class
base
A http.BaseResponse
wrapper representing a response of a Chopper network call.
@Get(path: '/something')
Future<Response> fetchSomething();
@Get(path: '/items/{id}')
Future<Response<Item>> fetchItem();
- Implementers
- Annotations
-
- @immutable
Constructors
Properties
- base → BaseResponse
-
The
http.BaseResponse
frompackage:http
that this Response wraps.final - body → BodyType?
-
The body of the response after conversion by Chopper
See Converter for more on body conversion.
final
- bodyBytes → Uint8List
-
Returns the response body as bytes (Uint8List) provided the network
call was successful, else this will be
null
.no setter - bodyOrThrow → BodyType
-
Returns the response body if Response isSuccessful and body is not null.
Otherwise it throws an
HttpException
with the response status code and error object. If the error object is an Exception, it will be thrown instead.no setter - bodyString → String
-
Returns the response body as a String provided the network
call was successful, else this will be
null
.no setter - error → Object?
-
The body of the response if isSuccessful is false.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, String> -
HTTP headers of the response.
no setter
- isSuccessful → bool
-
Whether the network call was successful or not.
no setter
-
props
→ List<
Object?> -
The list of properties that will be used to determine whether
two instances are equal.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- statusCode → int
-
The HTTP status code of the response.
no setter
- stringify → bool?
-
If set to
true
, the toString method will be overridden to output this instance's props.no setterinherited
Methods
-
copyWith<
NewBodyType> ({BaseResponse? base, NewBodyType? body, Object? bodyError}) → Response< NewBodyType> - Makes a copy of this Response, replacing original values with the given ones. This method can also alter the type of the response body.
-
errorWhereType<
ErrorType> () → ErrorType? -
Check if the response is an error and if the error is of type
ErrorType
and casts the error toErrorType
. Otherwise it returns null. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited