renderView method

Future<String> renderView({
  1. required String path,
  2. int status = 200,
  3. bool isFile = true,
  4. bool toData = false,
  5. Map<String, dynamic> data = const {},
})

after this function everything will be stop and send to client

Implementation

Future<String> renderView({
  required String path,
  int status = 200,
  bool isFile = true,
  bool toData = false,
  Map<String, dynamic> data = const {},
}) async {
  if (isClosed) return '';

  if (toData) {
    return renderDataParam(status: status, data: data);
  }

  try {
    response.statusCode = status;
    response.headers.contentType = ContentType.html;
  } catch (e) {
    Console.i(e);
  }
  var renderString = await render(path: path, isFile: isFile);
  await writeAndClose(renderString);
  return renderString;
}