extractHtmlTitle function
Extracts and decodes the <title> of an HTML document, or null when
absent or empty.
Implementation
String? extractHtmlTitle(String html) {
final match = RegExp(
r'<title\b[^>]*>([\s\S]*?)</title>',
caseSensitive: false,
).firstMatch(html);
if (match == null) return null;
final title = stripHtmlTags(match.group(1)!);
return title.isEmpty ? null : title;
}