injectNoscriptFallback method

void injectNoscriptFallback({
  1. required String title,
  2. String? description,
  3. String? bodyHtml,
  4. List<NoscriptLink>? links,
})

Inject

Implementation

void injectNoscriptFallback({
  required String title,
  String? description,
  String? bodyHtml,
  List<NoscriptLink>? links,
}) {
  final buffer = StringBuffer();
  buffer.writeln('<h1>${_sanitizeHtml(title)}</h1>');

  if (description != null) {
    buffer.writeln('<p>${_sanitizeHtml(description)}</p>');
  }

  if (links != null && links.isNotEmpty) {
    buffer.writeln('<nav><ul>');
    for (final link in links) {
      buffer.writeln(
        '<li><a href="${_sanitizeHtml(link.href)}">'
        '${_sanitizeHtml(link.text)}</a></li>',
      );
    }
    buffer.writeln('</ul></nav>');
  }

  if (bodyHtml != null) {
    buffer.writeln(bodyHtml);
  }

  _platform.injectNoscriptContent(buffer.toString());
}