From 4abf5423aa627539798987f2d07985b53da1f5ab Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Fri, 28 Apr 2017 09:02:03 +0200 Subject: [PATCH 1/3] Add doc to canLaunch --- packages/url-launcher/lib/url_launcher.dart | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/packages/url-launcher/lib/url_launcher.dart b/packages/url-launcher/lib/url_launcher.dart index 999ee0c28a87..3103b113a3f1 100644 --- a/packages/url-launcher/lib/url_launcher.dart +++ b/packages/url-launcher/lib/url_launcher.dart @@ -16,7 +16,8 @@ Future launch(String urlString) { urlString, ); } - +/// Checks whether the specified URL can be handled by some app installed on +/// the device. Future canLaunch(String urlString) { return _channel.invokeMethod( 'canLaunch', From 5e1f6793c779eb566127f86e99434c72f68706b6 Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Fri, 28 Apr 2017 13:36:32 +0200 Subject: [PATCH 2/3] Add more doc --- packages/url-launcher/lib/url_launcher.dart | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/url-launcher/lib/url_launcher.dart b/packages/url-launcher/lib/url_launcher.dart index 3103b113a3f1..dccc29ebe124 100644 --- a/packages/url-launcher/lib/url_launcher.dart +++ b/packages/url-launcher/lib/url_launcher.dart @@ -8,17 +8,24 @@ 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', urlString, ); } -/// Checks whether the specified URL can be handled by some app installed on -/// the device. + +/// Checks whether the specified URL can be handled by some app installed on the +/// device. Future canLaunch(String urlString) { + if (urlString == null) + return false; return _channel.invokeMethod( 'canLaunch', urlString, From 924c2a91d69c89d19245c97ade8053f6b4ba912f Mon Sep 17 00:00:00 2001 From: Sarah Zakarias Date: Fri, 28 Apr 2017 13:38:51 +0200 Subject: [PATCH 3/3] add async to canLaunch --- packages/url-launcher/lib/url_launcher.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/url-launcher/lib/url_launcher.dart b/packages/url-launcher/lib/url_launcher.dart index dccc29ebe124..9cf5136644ee 100644 --- a/packages/url-launcher/lib/url_launcher.dart +++ b/packages/url-launcher/lib/url_launcher.dart @@ -23,10 +23,10 @@ Future launch(String urlString) { /// Checks whether the specified URL can be handled by some app installed on the /// device. -Future canLaunch(String urlString) { +Future canLaunch(String urlString) async { if (urlString == null) return false; - return _channel.invokeMethod( + return await _channel.invokeMethod( 'canLaunch', urlString, );