RestResponse class

A HTTP response for REST HTTP apis.

This will use only serializer, and JsonModelSerializer.common when deserializing a response body.

Constructors

RestResponse.bytes(List<int> bodyBytes, int statusCode, {BaseRequest? request, Map<String, String> headers = const {}, bool isRedirect = false, bool persistentConnection = true, String? reasonPhrase, JsonModelSerializer? serializer})
Create a new HTTP rest response with a byte array body.
RestResponse.fromResponse(Response response, [JsonModelSerializer? serializer])
Creates a new HTTP Rest response by waiting for the full body to become available from a Response.
factory

Properties

body String
The body of the response as a string.
no setterinherited
bodyBytes Uint8List
The bytes comprising the body of this response.
finalinherited
contentLength int?
The size of the response body, in bytes.
finalinherited
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
The HTTP headers returned by the server.
finalinherited
isRedirect bool
finalinherited
jsonBody Object?
Returns the Json object by parsing the response body string. The response is json decoded synchronously.
no setter
jsonBodyAsync FutureOr<Object?>
Returns the Json object by parsing the response body string. The response is json decoded asynchronously in an isolate.
no setter
persistentConnection bool
Whether the server requested that a persistent connection be maintained.
finalinherited
reasonPhrase String?
The reason phrase associated with the status code.
finalinherited
request → BaseRequest?
The (frozen) request that triggered this response.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serializer JsonModelSerializer
final
statusCode int
The HTTP status code for this response.
finalinherited

Methods

deserializeBody<T extends Object>() → T?
Returns T by deserializing the response body to it. The response is deserialized synchronously.
deserializeBodyAsync<T extends Object>() Future<T?>
Returns T by deserializing the response body to it. The response is deserialized asynchronously in an isolate.
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

Static Methods

fromStream(StreamedResponse response, [JsonModelSerializer? serializer]) Future<RestResponse>
Creates a new HTTP response by waiting for the full body to become available from a StreamedResponse.