url_launcher 5.2.7
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(Scaffold(
body: Center(
child: RaisedButton(
onPressed: _launchURL,
child: Text('Show Flutter homepage'),
),
),
));
}
_launchURL() async {
const url = 'https://flutter.dev';
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.dev | 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.
Browser vs In-app Handling #
By default, Android opens up a browser when handling URLs. You can pass forceWebView: true parameter to tell the plugin to open a WebView instead. On iOS, the default behavior is to open all web URLs within the app. Everything else is redirected to the app handler.
5.2.7 #
- Minor unit test changes and added a lint for public DartDocs.
5.2.6 #
- Remove AndroidX warnings.
5.2.5 #
- Include lifecycle dependency as a compileOnly one on Android to resolve potential version conflicts with other transitive libraries.
5.2.4 #
- Use
package:url_launcher_platform_interface
to get the platform-specific implementation.
5.2.3 #
Android: Use android.arch.lifecycle instead of androidx.lifecycle:lifecycle in build.gradle
to support apps that has not been migrated to AndroidX.
5.2.2 #
- Re-land embedder v2 support with correct Flutter SDK constraints.
5.2.1 #
- Revert the migration since the Flutter dependency was too low.
5.2.0 #
- Migrate the plugin to use the V2 Android engine embedding. This shouldn't affect existing functionality. Plugin authors who use the V2 embedding can now instantiate the plugin and expect that it correctly responds to app lifecycle changes.
5.1.7 #
- Define clang module for iOS.
5.1.6 #
- Fixes bug where androidx app won't build with this plugin by enabling androidx and jetifier in the android
gradle.properties
.
5.1.5 #
- Update homepage url after moving to federated directory.
5.1.4 #
- Update and migrate iOS example project.
5.1.3 #
- Always launch url from the top most UIViewController in iOS.
5.1.2 #
- Update AGP and gradle.
- Split plugin and WebViewActivity class files.
5.1.1 #
- Suppress a handled deprecation warning on iOS
5.1.0 #
- Add
headers
field to enable headers in the Android implementation.
5.0.5 #
- Add
enableDomStorage
field tolaunch
to enable DOM storage in Android WebView.
5.0.4 #
- Update Dart code to conform to current Dart formatter.
5.0.3 #
- Add missing template type parameter to
invokeMethod
calls. - Bump minimum Flutter version to 1.5.0.
- Replace invokeMethod with invokeMapMethod wherever necessary.
5.0.2 #
- Fixes
closeWebView
failure on iOS.
5.0.1 #
- Log a more detailed warning at build time about the previous AndroidX migration.
5.0.0 #
-
Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.
This was originally incorrectly pushed in the
4.2.0
update.
4.2.0+3 #
- Revert the breaking 4.2.0 update. 4.2.0 was known to be breaking and
should have incremented the major version number instead of the minor. This
revert is in and of itself breaking for anyone that has already migrated
however. Anyone who has already migrated their app to AndroidX should
immediately update to
5.0.0
instead. That's the correctly versioned new push of4.2.0
.
4.2.0+2 #
- Updated
launch
to use async and await, fixed the incorrect return value bylaunch
method.
4.2.0+1 #
- Refactored the Java and Objective-C code. Replaced instance variables with properties in Objective-C.
4.2.0 #
-
BAD. This was a breaking change that was incorrectly published on a minor version upgrade, should never have happened. Reverted by 4.2.0+3.
-
Breaking change. Migrate from the deprecated original Android Support Library to AndroidX. This shouldn't result in any functional changes, but it requires any Android apps using this plugin to also migrate if they're using the original support library.
4.1.0+1 #
- This is just a version bump to republish as 4.1.0 was published with some dirty local state.
4.1.0 #
- Added
universalLinksOnly
setting. - Updated
launch
to returnFuture<bool>
.
4.0.3 #
- Fixed launch url fail for Android:
launch
now assert activity not null and using activity to startActivity. - Fixed
WebViewActivity has leaked IntentReceiver
for Android.
4.0.2 #
- Added
closeWebView
function to programmatically close the current WebView.
4.0.1 #
- Added enableJavaScript field to
launch
to enable javascript in Android WebView.
4.0.0 #
- Breaking change Now requires a minimum Flutter version of 0.5.6.
- Update to statusBarBrightness field so that the logic runs on the Flutter side.
- Breaking change statusBarBrightness no longer has a default value.
3.0.3 #
- Added statusBarBrightness field to
launch
to set iOS status bar brightness.
3.0.2 #
- Updated Gradle tooling to match Android Studio 3.1.2.
3.0.1 #
- Fix a crash during Safari view controller dismiss.
3.0.0 #
- Breaking change. Set SDK constraints to match the Flutter beta release.
2.0.2 #
- Fixed Dart 2 issue:
launch
now returnsFuture<void>
instead ofFuture<Null>
.
2.0.1 #
- Simplified and upgraded Android project template to Android SDK 27.
- Updated package description.
2.0.0 #
- Breaking change. Upgraded to Gradle 4.1 and Android Studio Gradle plugin 3.0.1. Older Flutter projects need to upgrade their Gradle setup as well in order to use this version of the plugin. Instructions can be found here.
1.0.3 #
- Add FLT prefix to iOS types.
1.0.2 #
- Fix handling of URLs in Android WebView.
1.0.1 #
- Support option to launch default browser in iOS.
- Parse incoming url and decide on what to open based on scheme.
- Support WebView on Android.
1.0.0 #
- iOS plugin presents a Safari view controller instead of switching to the Safari app.
0.4.2+5 #
- Aligned author name with rest of repo.
0.4.2+2, 0.4.2+3, 0.4.2+4 #
- Updated README.
0.4.2+1 #
- Updated README.
0.4.2 #
- Change to README.md.
0.4.1 #
- Upgrade Android SDK Build Tools to 25.0.3.
0.4.0 #
- Upgrade to new plugin registration.
0.3.6 #
- Fix workaround for failing dynamic check in Xcode 7/sdk version 9.
0.3.5 #
- Workaround for failing dynamic check in Xcode 7/sdk version 9.
0.3.4 #
- Add test.
0.3.3 #
- Change to buildToolsVersion.
0.3.2 #
- Change to README.md.
0.3.1 #
- Change to README.md.
0.3.0 #
- Add
canLaunch
method.
0.2.0 #
- Change
launch
to a top-level method instead of a static method in a class.
0.1.1 #
- Change to README.md.
0.1.0 #
- Initial Open Source release.
url_launcher_example #
Demonstrates how to use the url_launcher plugin.
Getting Started #
For help getting started with Flutter, view our online documentation.
Use this package as a library
1. Depend on it
Add this to your package's pubspec.yaml file:
dependencies:
url_launcher: ^5.2.7
2. Install it
You can install packages from the command line:
with Flutter:
$ flutter pub get
Alternatively, your editor might support flutter pub 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';
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
100
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
100
|
We analyzed this package on Dec 5, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
- Dart: 2.6.1
- pana: 0.12.21
- Flutter: 1.9.1+hotfix.6
Platforms
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Dependencies
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0-dev.28.0 <3.0.0 | ||
flutter | 0.0.0 | ||
url_launcher_platform_interface | ^1.0.1 | 1.0.1 | |
Transitive dependencies | |||
collection | 1.14.11 | 1.14.12 | |
meta | 1.1.7 | 1.1.8 | |
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 | ||
Dev dependencies | |||
flutter_test | |||
mockito | ^4.1.1 | ||
test | ^1.3.0 |