injectHtmlTo method

  1. @override
void injectHtmlTo(
  1. WebHTMLElement parent
)
override

Injects the HTML element into the given parent container.

Implementation

@override
void injectHtmlTo(WebHTMLElement parent) {
  // Only inject HTML if running on the web
  if (!kIsWeb) return;

  // Create a <div> container with column flex layout
  final colContainer =
      webWindow.document.createElement('div') as WebHTMLElement;
  colContainer.style.display = 'flex';
  colContainer.style.flexDirection = 'column';

  // Append each child's HTML representation
  for (final child in children) {
    if (child is SeoInjectable) {
      final element = (child as SeoInjectable).createHtmlElement();
      if (element != null) {
        colContainer.appendChild(element);
      }
    } else if (child is SeoInjectableLayout) {
      (child as SeoInjectableLayout).injectHtmlTo(colContainer);
    }
  }

  // Attach the column container to the parent element
  parent.appendChild(colContainer);
}