renderComponent function

Future<String> renderComponent(
  1. Component app, {
  2. bool standalone = false,
})

Directly renders the provided component into a html string.

When standalone is false (default), the html output will have a full document structure (html, head, body).

Implementation

Future<String> renderComponent(Component app, {bool standalone = false}) async {
  _checkInitialized('renderComponent');
  var fileHandler = staticFileHandler();
  return render(_createSetup(app), Uri.parse('https://0.0.0.0/'), (name) async {
    var response = await fileHandler(Request('get', Uri.parse('https://0.0.0.0/$name')));
    return response.statusCode == 200 ? response.readAsString() : null;
  }, standalone);
}