Search code examples
flutterurl-launcher

Launch url in flutter_widget_from_html


Using flutter_widget_from_html, my html is rendering, but the links are not launching. I am using th url_launcher package and my code is below.

Am i doing something wrong?

 HtmlWidget('<p>This is a <a href="https://bbc.co.uk">link</a></p>', 
                onTapUrl: (url) => canLaunchUrl(Uri.parse(url)),
                renderMode: RenderMode.column,
                textStyle: TextStyle(fontSize: 20),
              )

Solution

  • canLaunchUrl is a function to check if the specified URL can be launched, and returns a boolean. To actually launch the URL, use launchUrl.

    onTapUrl: (url) => launchUrl(Uri.parse(url)),