Flutter : Launch Url

This Article is posted by shubham.narkhede8 at 11/26/2019 4:57:07 PM



In this tutorial, we’ll learn how we can launch a url in flutter mobile applications. For this we can use a flutter package called url_launcher

First we need to create a new Flutter Project and then we will add our plugin into the pubspec.yaml file.

dependencies: flutter: sdk: flutter url_launcher: ^5.2.7
First to open website url into your app you need to create a method with website url.

  myUrl() async {
    const url = 'https://www.google.com/maps/@18.8154265,76.7751435,7z';
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw 'Could not launch $url';
    }
  }

we’ve created a method named myUrl and inside this method we’ve written the code for opening the google map in the browser.
Call this method on onPress of button

 RaisedButton(
        child: Text('Launch Url'),
        onPressed: () {
          myUrl();
        },
);

And thats solve


Tags: flutter; dart; android; ios; appbar; flutterUi; Stateless, Stateful, widgets








1 Comments
Login to comment.
Recent Comments

walidja2009 at 12/9/2019

Thankx great easy cleary to understand usefull quickly bref amazing .....

Login to Reply.












© 2018 - Fluttercentral | Email to me - seven.srikanth@gmail.com