Response class

An HTTP response where the entire response body is known in advance.

Inheritance
Available extensions

Constructors

Response(String body, int statusCode, {BaseRequest? request, Map<String, String> headers = const {}, bool isRedirect = false, bool persistentConnection = true, String? reasonPhrase})
Creates a new HTTP response with a string body.
Response.bytes(List<int> bodyBytes, int statusCode, {BaseRequest? request, Map<String, String> headers = const {}, bool isRedirect = false, bool persistentConnection = true, String? reasonPhrase})
Create a new HTTP response with a byte array body.

Properties

body → String
The body of the response as a string.
no setter
bodyBytes → Uint8List
The bytes comprising the body of this response.
final
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
headersSplitValues → Map<String, List<String>>

Available on BaseResponse, provided by the HeadersWithSplitValues extension

The HTTP headers returned by the server.
no setter
isRedirect → bool
finalinherited
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
statusCode → int
The HTTP status code for this response.
finalinherited

Methods

copyWith({int? statusCode, BaseRequest? request, Map<String, String>? headers, bool? isRedirect, bool? persistentConnection, String? reasonPhrase, String? body, Stream<List<int>>? stream, int? contentLength}) → BaseResponse

Available on BaseResponse, provided by the BaseResponseCopyWith extension

Creates a new instance of BaseResponse based of on this. It copies all the properties and overrides the ones sent via parameters.
copyWith({String? body, int? statusCode, BaseRequest? request, Map<String, String>? headers, bool? isRedirect, bool? persistentConnection, String? reasonPhrase}) → Response

Available on Response, provided by the ResponseCopyWith extension

Creates a new instance of Response based of on this. It copies all the properties and overrides the ones sent via parameters.
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) → Future<Response>
Creates a new HTTP response by waiting for the full body to become available from a StreamedResponse.