writeJsonWithCode method

void writeJsonWithCode(
  1. int code,
  2. Object? object
)

Write json with pretty output and set code

Implementation

void writeJsonWithCode(int code, Object? object) {
  final json = jsonPrettyEncode(object);
  response
    ..statusCode = code
    ..headers.contentType = ContentType.json
    ..contentLength = utf8.encode(json).length
    ..write(json);
}