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) {
  if (!kIsWeb) return;
  final document = webWindow.document;

  // Create a flex container for the row
  final rowContainer = document.createElement('div') as WebHTMLDivElement;
  rowContainer.style.display = 'flex';
  rowContainer.style.flexDirection = 'row';

  // Inject each child widget as HTML
  for (final child in children) {
    if (child is SeoInjectable) {
      final element = (child as SeoInjectable).createHtmlElement();
      if (element != null) {
        rowContainer.appendChild(element);
      }
    } else if (child is SeoInjectableLayout) {
      (child as SeoInjectableLayout).injectHtmlTo(rowContainer);
    }
  }

  // Append the row container to the parent
  parent.appendChild(rowContainer);
}