Res class

Response object to handle response to the client.

Constructors

Res(String _localKey, HttpResponse _res)

Properties

app App?
Reference to the App instance that use this response.
no setter
closed bool
Checks if this response has been closed.
getter/setter pair
contentType ContentType?
Response Content-Type header.
no setter
cookies List<Cookie>
Contents of Set-Cookie header of this response
no setter
hashCode int
The hash code for this object.
no setterinherited
hasValidResult bool
Check if this response has a valid result from previous middleware.
no setter
headers HttpHeaders
Returns the response headers.
no setter
isContentText bool
Check if content type of response is text/plain
no setter
log Log
Logger attached to this response
getter/setter pair
open bool
Check if this response is still open to send data
no setter
renderer ↔ (FutureOr Function(String view, Map<String, dynamic> data)?)
getter/setter pair
response HttpResponse
HttpResponse object attached to this response
no setter
result ↔ dynamic
Result from a previous middleware.
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
secureCookie ↔ Cookies?
SecureCookie object to be used to set secure cookies.
getter/setter pair
statusCode int
The status code of the response.
no setter

Methods

add(List<int> data) → void
Adds byte data to the target consumer, ignoring encoding.
addStream(Stream<List<int>> stream) Future
Adds all elements of the given stream.
back() Future
Redirect back to previous path, based on Referer from request header.
clearCookie(String name) → void
Clear a cookie by name.
clearCookies() → void
Clear all cookies.
close() Future
Close the target consumer.
Add or edit a response cookie.
download(dynamic file, [String? filename]) Future
Send a file to download with optional filename.
end() FutureOr
Ends the response by sending empty string to the client, and close the connection
get(String name) String?
Get the HTTP response header associated with the specified field.
Can be used for both set or get the headers value.
json(Object data) FutureOr
Sends a JSON response.
local<T>(String key, [dynamic value]) → T?
Get a value from local data associated with the specified key
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
redirect(dynamic path, [String? fallback]) Future
Redirects to the URL derived from the specified path, with specified status, a positive integer that corresponds to an HTTP status code.
remove(String name) → void
removeLocal<T>(String key) → T?
Remove value in local data associated with the specified key
render(String view, Map<String, dynamic> data) FutureOr
Render a template view
send(Object data) Future
Sends the HTTP response.
sendFile(dynamic file, [String? filename]) Future
Send a file to the response with optional filename.
sendStatus(int statusCode) Future
Set the response status code and send a message containing the associated status string.
set(dynamic name, [String? value]) → void
Sets the HTTP response header field to value.
setContentType(ContentType? contentType) → void
Set response content type.
setContentTypeFromExtension(String extension) → void
Set the content type from the extension ie. 'pdf'
setContentTypeFromFile(File file) → void
Set response content type from file.
status(int statusCode) Res
Set the response status code.
to(dynamic path, [String? fallback]) Future
toString() String
A string representation of this object.
inherited
type(String type) → void
Update the response content type associated with the specified type.
view(String view, Map<String, dynamic> data) FutureOr

Operators

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