From 9bc9a59a436589c3501a1204cead3a5da732b625 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Mon, 1 May 2017 09:14:49 +0200 Subject: [PATCH] Add documentation (#9) --- packages/url-launcher/lib/url_launcher.dart | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/url-launcher/lib/url_launcher.dart b/packages/url-launcher/lib/url_launcher.dart index 999ee0c28a87..9cf5136644ee 100644 --- a/packages/url-launcher/lib/url_launcher.dart +++ b/packages/url-launcher/lib/url_launcher.dart @@ -8,8 +8,12 @@ import 'package:flutter/services.dart'; const _channel = const MethodChannel('plugins.flutter.io/url_launcher'); -/// Parse the specified URL string and delegate handling of the same to the +/// Parses the specified URL string and delegates handling of it to the /// underlying platform. +/// +/// The returned future completes with a [PlatformException] on invalid URLs and +/// schemes which cannot be handled, that is when [canLaunch] would complete +/// with false. Future launch(String urlString) { return _channel.invokeMethod( 'launch', @@ -17,8 +21,12 @@ Future launch(String urlString) { ); } -Future canLaunch(String urlString) { - return _channel.invokeMethod( +/// Checks whether the specified URL can be handled by some app installed on the +/// device. +Future canLaunch(String urlString) async { + if (urlString == null) + return false; + return await _channel.invokeMethod( 'canLaunch', urlString, );