Response<T> class

The response to a Request.

T is the type of the deserialized body.

Before using data check that the response hasData.

Annotations
  • @immutable

Constructors

Response({required Request<T> request, required Request httpRequest, required BaseResponse httpResponse, required String body, dynamic json, T? data})
Creates a new response.
const

Properties

body String
The as utf8 decoded body of the response.
final
data → T?
The deserialized body of the response.
final
hasData bool
Whether this response isOk and data is not null.
no setter
hashCode int
The hash code for this object.
no setteroverride
httpRequest → Request
The http.Request send to the server.
final
httpResponse → BaseResponse
The http.BaseResponse received from the server.
final
isOk bool
Whether statusCode is below 400.
no setter
json → dynamic
The as json decoded body of the response.
final
request Request<T>
The Request which created this response.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
The status code of httpResponse.
no setter

Methods

get() → T
Returns data if this request hasData. If the request has no data a StateError is thrown.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

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