Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 98e7634

Browse files
author
Chris Yang
authored
Updated launch to use async and await, fixed the incorrect return value by launch method. (#1124)
This is a fix for the comments flutter/flutter#25991 (comment) and flutter/flutter#25991 (comment) which mentioned that the launch api returns null instead of a boolean. flutter/flutter#25991
1 parent 3039a26 commit 98e7634

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

packages/url_launcher/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.2.0+2
2+
3+
* Updated `launch` to use async and await, fixed the incorrect return value by `launch` method.
4+
15
## 4.2.0+1
26

37
* Refactored the Java and Objective-C code. Replaced instance variables with properties in Objective-C.

packages/url_launcher/lib/url_launcher.dart

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Future<bool> launch(
5959
bool enableJavaScript,
6060
bool universalLinksOnly,
6161
Brightness statusBarBrightness,
62-
}) {
62+
}) async {
6363
assert(urlString != null);
6464
final Uri url = Uri.parse(urlString.trimLeft());
6565
final bool isWebURL = url.scheme == 'http' || url.scheme == 'https';
@@ -82,7 +82,7 @@ Future<bool> launch(
8282
// TODO(amirh): remove this on when the invokeMethod update makes it to stable Flutter.
8383
// https://github.com/flutter/flutter/issues/26431
8484
// ignore: strong_mode_implicit_dynamic_method
85-
return _channel.invokeMethod(
85+
final bool result = await _channel.invokeMethod(
8686
'launch',
8787
<String, Object>{
8888
'url': urlString,
@@ -91,12 +91,12 @@ Future<bool> launch(
9191
'enableJavaScript': enableJavaScript ?? false,
9292
'universalLinksOnly': universalLinksOnly ?? false,
9393
},
94-
).then((void _) {
95-
if (statusBarBrightness != null) {
96-
WidgetsBinding.instance.renderView.automaticSystemUiAdjustment =
97-
previousAutomaticSystemUiAdjustment;
98-
}
99-
});
94+
);
95+
if (statusBarBrightness != null) {
96+
WidgetsBinding.instance.renderView.automaticSystemUiAdjustment =
97+
previousAutomaticSystemUiAdjustment;
98+
}
99+
return result;
100100
}
101101

102102
/// Checks whether the specified URL can be handled by some app installed on the

packages/url_launcher/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for launching a URL on Android and iOS. Supports
33
web, phone, SMS, and email schemes.
44
author: Flutter Team <flutter-dev@googlegroups.com>
55
homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher
6-
version: 4.2.0+1
6+
version: 4.2.0+2
77

88
flutter:
99
plugin:

0 commit comments

Comments
 (0)