Response.json constructor
Implementation
factory Response.json(
Object? data, {
int? status,
String? statusText,
Object? headers,
}) {
final body = utf8.encode(jsonCodec.encode(data));
final response = Response._(
Stream<Uint8List>.value(body),
headers: headers,
status: status,
statusText: statusText,
type: ResponseType.basic,
);
// Set headers
response.headers.set('Content-Type', 'application/json; charset=utf-8');
response.headers.set('Content-Length', body.length.toString());
return response;
}