url_launcher 0.3.0

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 50

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() {
  launch('https://flutter.io');
}

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:<URL> , https:<URL>
  • mailto:<email-address>
  • tel:<phone-number>
  • sms:<phone-number>

More details can be found here for iOS and Android

[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.

example/lib/main.dart

// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';

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

void main() {
  runApp(new MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'URL Launcher',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(title: 'URL Launcher'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  Future<Null> _launched;

  void _launchUrl() {
    setState(() {
      _launched = _launch('https://flutter.io');
    });
  }

  Future<Null> _launch(String url) async {
    if (await canLaunch(url)) {
      await launch(url);
    } else {
      throw "Could not launch $url";
    }
  }

  Widget _launchStatus(BuildContext context, AsyncSnapshot<Null> snapshot) {
    if (snapshot.hasError) {
      return new Text('Error: ${snapshot.error}');
    } else {
      return const Text('');
    }
  }

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      ),
      body: new Center(
        child: new Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            new Row(
              mainAxisSize: MainAxisSize.min,
              children: [
                new Padding(
                  padding: new EdgeInsets.all(16.0),
                  child: new Text("https://flutter.io"),
                ),
                new RaisedButton(
                  onPressed: _launchUrl,
                  child: new Text("Go"),
                ),
              ],
            ),
            new FutureBuilder<Null>(future: _launched, builder: _launchStatus),
          ],
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  url_launcher: ^0.3.0

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter 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';
  
Version Uploaded Documentation Archive
5.0.2 Mar 12, 2019 Go to the documentation of url_launcher 5.0.2 Download url_launcher 5.0.2 archive
5.0.1 Feb 8, 2019 Go to the documentation of url_launcher 5.0.1 Download url_launcher 5.0.1 archive
5.0.0 Jan 28, 2019 Go to the documentation of url_launcher 5.0.0 Download url_launcher 5.0.0 archive
4.2.0+3 Jan 28, 2019 Go to the documentation of url_launcher 4.2.0+3 Download url_launcher 4.2.0+3 archive
4.2.0+2 Jan 28, 2019 Go to the documentation of url_launcher 4.2.0+2 Download url_launcher 4.2.0+2 archive
4.2.0+1 Jan 25, 2019 Go to the documentation of url_launcher 4.2.0+1 Download url_launcher 4.2.0+1 archive
4.2.0 Jan 24, 2019 Go to the documentation of url_launcher 4.2.0 Download url_launcher 4.2.0 archive
4.1.0+1 Jan 23, 2019 Go to the documentation of url_launcher 4.1.0+1 Download url_launcher 4.1.0+1 archive
4.1.0 Jan 23, 2019 Go to the documentation of url_launcher 4.1.0 Download url_launcher 4.1.0 archive
4.0.3 Dec 21, 2018 Go to the documentation of url_launcher 4.0.3 Download url_launcher 4.0.3 archive

All 41 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
100
Health:
Code health derived from static analysis. [more]
--
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
--
Overall:
Weighted score of the above. [more]
50
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Maintenance issues and suggestions

Make sure dartdoc successfully runs on your package's source files. (-10 points)

Dependencies were not resolved.