Open Link URL Hyperlink in Flutter App to Default Browser

Hello friends, This is our another tutorial on url_launcher 6.0.20 pub package of Flutter. This tutorial is so much helpful in my other project, So I thought why not make more tutorials on it. As we all know Hyperlinking is one of the most usable thing in web development and no website can make without hyperlinking. So in flutter application sometimes we need to open a Link from our flutter app to mobile device default browser, Same as hyperlink. This can be possible via url_launcher package of flutter. So in this tutorial we would learn about Open Link URL Hyperlink in Flutter App to Default Browser.

Contents in this project Open Link URL Hyperlink in Flutter App to Default Browser :-

1. First of all we have to install the url_launcher package in our flutter application. So open your flutter project Root directory in CMD or Terminal and execute below command to install it.

Screenshot Before Installing :-

Screenshot after done installation :-

2. Now we have add https Web intent in our AndroidManifest.xml file. So open Your_Flutter_Project -> android -> app -> src -> main -> AndroidManifest.xml file. and put below Intent code inside it.

Source Code of my AndroidManifest.xml file after adding above code :-

3. Open your project’s main.dart file and import material.dart, url_launcher.dart and gestures.dart package.

4. Creating void main runApp() method and here we would call our main MyApp class.

5. Creating a Constant String variable named as _url. We would assing our HTTPS URL here.

6. Creating our main class MyApp extends StatelessWidget.

7. Creating a ASYNC type of function named as _launchURL(). In this function we would simply open the given string URL in device default web browser.

8. Creating Widget Build area -> SafeArea -> Center -> RichText -> TextSpan widget to make text looks like Hyperlink text in flutter.

9. Complete source code for main.dart file :-

Screenshots :-

Open Link URL Hyperlink in Flutter App to Default Browser

Leave a Reply

Your email address will not be published. Required fields are marked *