toDocument method

String toDocument({
  1. String title = '',
  2. String lang = 'en',
  3. String? bodyClass,
})

The full HTML document.

Implementation

String toDocument({String title = '', String lang = 'en', String? bodyClass}) {
  final stateScript = state != null
      ? '<script id="__LARK_DATA__" type="application/json">$state</script>'
      : '';

  return '''<!DOCTYPE html>
<html lang="$lang">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
${title.isNotEmpty ? '<title>$title</title>' : ''}
$head
</head>
<body${bodyClass != null ? ' class="$bodyClass"' : ''}>
<div id="app">$html</div>
$stateScript
<script src="/main.dart.js" defer></script>
</body>
</html>''';
}