Open the link in the browser in flutter_linkify package

352 Views Asked by At

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

1

There are 1 best solutions below

1
Nikunj Ramani On BEST ANSWER

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),);