writeJsonWithCode method
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);
}