json method

Future<void> json(
  1. Object data, {
  2. int? statusCode,
})

Implementation

Future<void> json(
  Object data, {
  int? statusCode,
}) async {
  /// set the Response contentType to Json
  response.headers.contentType = ContentType.json;

  /// set the default status code
  response.statusCode = statusCode ?? defStatusCode;

  /// append the data to the response
  await write(toJson(data));
}