json method

Response json(
  1. Object? body, {
  2. int statusCode = 200,
  3. Map<String, Object>? headers,
})

Returns a JSON response.

Implementation

Response json(
  Object? body, {
  int statusCode = 200,
  Map<String, Object>? headers,
}) {
  // TODO: Implement JSON serialization
  return Response(
    statusCode,
    body: body.toString(),
    headers: {'content-type': 'application/json', ...?headers},
  );
}