ItsSaed
ItsSaed

Reputation: 67

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

Upvotes: 0

Views: 425

Answers (1)

Nikunj Ramani
Nikunj Ramani

Reputation: 446

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

Upvotes: 1

Related Questions