Home > Net >  How can i get web site title in flutter?
How can i get web site title in flutter?

Time:03-21

I want to get the title of a given website address in flutter. Example a website title : <title>Some Value</title>. How can i get Some Value in title tag?

CodePudding user response:

Use the html package so that you can parse the HTML content of the website. Then you can use querySelector('title')!.text to get the text of the <title> element.

import 'package:html/parser.dart' as html_parser;

void main() {
    const html = '<title>Some Value</title>';
    var doc = html_parser.parse(html);
    final value = doc.querySelector('title');
    print(value!.text);
}
  • Related