Response class

The response returned by a Handler.

Constructors

Response.new(int statusCode, {Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs an HTTP response with the given statusCode.
Response.badRequest({Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs a 400 Bad Request response.
Response.forbidden({Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs a 403 Forbidden response.
Response.found(Uri location, {Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs a 302 Found response.
Response.internalServerError({Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs a 500 Internal Server Error response.
Response.movedPermanently(Uri location, {Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs a 301 Moved Permanently response.
Response.noContent({Headers? headers, Map<String, Object>? context})
Constructs a 204 No Content response.
Response.notFound({Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs a 404 Not Found response.
Response.notImplemented({Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs a 501 Not Implemented response.
Response.notModified({Headers? headers, Map<String, Object>? context})
Constructs a 304 Not Modified response.
Response.ok({Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs a 200 OK response.
Response.seeOther(Uri location, {Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs a 303 See Other response.
Response.unauthorized({Body? body, Headers? headers, Encoding? encoding, Map<String, Object>? context})
Constructs a 401 Unauthorized response.

Properties

body Body
The streaming body of the message.
getter/setter pairinherited
context Map<String, Object>
Extra context for middleware and handlers.
finalinherited
encoding Encoding?
Returns the encoding specified in the Body-Type (Content-Type header), or null if not specified.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
headers Headers
The HTTP headers associated with this message.
finalinherited
isEmpty bool
Determines if the body is empty by checking the content length.
no setterinherited
mimeType MimeType?
Returns the MIME type from the Body-Type (Content-Type header), if available.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
The HTTP status code of the response.
final

Methods

copyWith({Headers? headers, Map<String, Object?>? context, Body? body}) Response
Creates a new Response by copying existing values and applying specified changes.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read() Stream<Uint8List>
Reads the body as a stream of bytes. Can only be called once.
inherited
readAsString([Encoding? encoding]) Future<String>
Reads the body as a string, decoding it using the specified or detected encoding. Defaults to utf8 if no encoding is provided or detected.
inherited
toString() String
A string representation of this object.
inherited
writeHttpResponse(HttpResponse httpResponse) Future<void>
Writes the response to an HttpResponse.

Operators

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