json function

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

Helper to create a JSON response

Implementation

Response json(dynamic data, {int statusCode = 200, Map<String, String>? headers}) {
  return Response(
    statusCode,
    body: jsonEncode(data),
    headers: {
      'Content-Type': 'application/json',
      ...?headers,
    },
  );
}