Response class

An HTTP response for the Ruta framework.

Constructors

Response({int statusCode = 200, String? body, Map<String, Object>? headers, Encoding? encoding})
Create a Response with a string body.
Response.bytes({int statusCode = 200, List<int>? body, Map<String, Object>? headers})
Create a Response with a byte array body.
Response.json({int statusCode = 200, Object? body = const <String, dynamic>{}, Map<String, Object> headers = const <String, Object>{}})
Create a Response with a JSON-encoded body.
Response.movedPermanently({required String location, String? body, Map<String, Object> headers = const <String, Object>{}, Encoding? encoding})
Create a Response Moved Permanently (301).
Response.stream({int statusCode = 200, Stream<List<int>>? body, Map<String, Object>? headers, bool bufferOutput = true})
Create a Response with a stream of bytes.

Properties

context Map<String, Object>
Extra context that can be used by middleware and handlers. The value is immutable.
no setter
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
The HTTP headers with case-insensitive keys. The returned map is unmodifiable.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
The HTTP status code of the response.
no setter

Methods

body() Future<String>
Returns a Future containing the body as a String.
bytes() Stream<List<int>>
Returns a Stream representing the body.
copyWith({Map<String, Object?>? headers, Object? body}) Response
Creates a new Response by copying existing values and applying specified changes.
formData() Future<FormData>
Returns a Future containing the form data as a Map.
json() Future
Returns a Future containing the body text parsed as a JSON object. This object could be anything that can be represented by JSON (e.g., a map, a list, a string, a number, a bool).
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

Constants

shelfBufferOutputContextKey → const String
A shelf.Response.context key used to determine if the HttpResponse.bufferOutput should be enabled or disabled.