Response class
An HTTP response.
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.
-
Response.stream({int statusCode = 200, Stream<
List< ? body, Map<int> >String, Object> ? headers}) - Create a Response with a stream of bytes.
Properties
- 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