url_launcher 0.4.2+5 copy "url_launcher: ^0.4.2+5" to clipboard
url_launcher: ^0.4.2+5 copied to clipboard

outdatedDart 1 only

A Flutter plugin for launching a URL.

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:

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

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.

7.7k
likes
0
points
3.36M
downloads

Publisher

verified publisherflutter.dev

Weekly Downloads

A Flutter plugin for launching a URL.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter

More

Packages that depend on url_launcher