processTitle function

void processTitle(
  1. Document document,
  2. SnapView view
)

Implementation

void processTitle(Document document, SnapView view) {
  if (view.title != 'Unknown') {
    return;
  }
  if (document.head != null) {
    final titles = document.head!.children
        .where((element) => element.localName == 'title')
        .toList();
    if (titles.isNotEmpty) {
      view.title = titles.first.innerHtml;
    }
  }
}