url_launcher 0.4.2+4

url_launcher

pub package

A Flutter plugin for launching a URL in the mobile platform. Supports iOS and Android.

Usage

To use this plugin, add url_launcher as a dependency in your pubspec.yaml file.

Example

import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';

void main() {
  runApp(new Scaffold(
    body: new Center(
      child: new RaisedButton(
        onPressed: _launchURL,
        child: new Text('Show Flutter homepage'),
      ),
    ),
  ));
}

_launchURL() async {
  const url = 'https://flutter.io';
  if (await canLaunch(url)) {
    await launch(url);
  } else {
    throw 'Could not launch $url';
  }
}

Supported URL schemes

The launch method takes a string argument containing a URL. This URL can be formatted using a number of different URL schemes. The supported URL schemes depend on the underlying platform and installed apps.

Common schemes supported by both iOS and Android:

SchemeAction
http:<URL> , https:<URL>, e.g. http://flutter.ioOpen URL in the default browser
mailto:<email address>?subject=<subject>&body=<body>, e.g. mailto:smith@example.org?subject=News&body=New%20pluginCreate email to <email address> in the default email app
tel:<phone number>, e.g. tel:+1 555 010 999Make a phone call to <phone number> using the default phone app
sms:<phone number>, e.g. sms:5550101234Send an SMS message to <phone number> using the default messaging app

More details can be found here for iOS and Android

Handling missing URL receivers

A particular mobile device may not be able to receive all supported URL schemes. For example, a tablet may not have a cellular radio and thus no support for launching a URL using the sms scheme, or a device may not have an email app and thus no support for launching a URL using the email scheme.

We recommend checking which URL schemes are supported using the canLaunch method prior to calling launch. If the canLaunch method returns false, as a best practice we suggest adjusting the application UI so that the unsupported URL is never triggered; for example, if the email scheme is not supported, a UI button that would have sent email can be changed to redirect the user to a web page using a URL following the http scheme.

[0.4.2+2], [0.4.2+3], [0.4.2+4] - 2017-08-16

  • Updated README

[0.4.2+1] - 2017-05-16

  • Updated README

[0.4.2] - 2017-05-15

  • Change to README.md.

[0.4.1] - 2017-05-09

  • Upgrade Android SDK Build Tools to 25.0.3.

[0.4.0] - 2017-05-09

  • Upgrade to new plugin registration.

[0.3.6] - 2017-05-09

  • Fix workaround for failing dynamic check in Xcode 7/sdk version 9.

[0.3.5] - 2017-05-08

  • Workaround for failing dynamic check in Xcode 7/sdk version 9.

[0.3.4] - 2017-05-08

  • Add test.

[0.3.3] - 2017-05-05

  • Change to buildToolsVersion

[0.3.2] - 2017-05-04

  • Change to README.md.

[0.3.1] - 2017-05-01

  • Change to README.md.

[0.3.0] - 2017-04-27

  • Add canLaunch method.

[0.2.0] - 2017-04-24

  • Change launch to a top-level method instead of a static method in a class.

[0.1.1] - 2017-04-21

  • Change to README.md

[0.1.0] - 2017-04-20

  • Initial Open Source release.

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  url_launcher: "^0.4.2+4"

2. Install it

You can install packages from the command line:

$ flutter packages get

Alternatively, your editor might support 'packages get'. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:url_launcher/url_launcher.dart';

About

A Flutter plugin for launching a URL.

Author

Email flutter-dev@googlegroups.com Flutter Team

Homepage

github.com/flutter/plugins/tree/master/packages/url_launcher

Documentation

www.dartdocs.org/documentation/url_launcher/0.4.2%2B4/

Source code (hyperlinked)

www.crossdart.info/p/url_launcher/0.4.2%2B4/

Uploader

zarah@google.com
goderbauer@google.com
jackson@google.com
mit@google.com

Published

Aug 16, 2017

Share