Search code examples
flutterflutter-packageslinkify

Open the link in the browser in flutter_linkify package


I use this package to open links within the text, but this package opens the link inside the application, can I make it open the link in the browser?

This is the package link: https://pub.dev/packages/flutter_linkify


Solution

  • You can use the following example to open a link in a browser

    Linkify(
    onOpen: (link) async {
      if (await canLaunch(link.url)) {
        await launchUrl(Uri.parse(link.url),
            mode: LaunchMode.externalApplication);
      } else {
        throw 'Could not launch $link';
      }
    },
    text: "Made by https://cretezy.com",
    style: TextStyle(color: Colors.yellow),
    linkStyle: TextStyle(color: Colors.red),);