url_launcher 0.3.1 copy "url_launcher: ^0.3.1" to clipboard
url_launcher: ^0.3.1 copied to clipboard

outdatedDart 1 only

Flutter plugin for launching a URL

url_launcher #

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:

  • http:
  • mailto:
  • tel:
  • sms:

More details can be found here for iOS and Android