Skip to content

Commit

Permalink
[url_launcher_web] Added support for mailto in url_launcher_web plugin (
Browse files Browse the repository at this point in the history
flutter#2490)

* Unit tests
* Updated version and CHANGELOG
  • Loading branch information
ianyon authored and Egor committed Nov 20, 2020
1 parent 2234113 commit 22b6ef3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/url_launcher/url_launcher_web/CHANGELOG.md
@@ -1,3 +1,7 @@
# 0.1.1

- Added support for mailto scheme

# 0.1.0+2

- Remove androidx references from the no-op android implemenation.
Expand Down
Expand Up @@ -27,8 +27,9 @@ class UrlLauncherPlugin extends UrlLauncherPlatform {
final Uri parsedUrl = Uri.tryParse(url);
if (parsedUrl == null) return Future<bool>.value(false);

return Future<bool>.value(
parsedUrl.isScheme('http') || parsedUrl.isScheme('https'));
return Future<bool>.value(parsedUrl.isScheme('http') ||
parsedUrl.isScheme('https') ||
parsedUrl.isScheme('mailto'));
}

@override
Expand Down
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher_web/pubspec.yaml
@@ -1,7 +1,7 @@
name: url_launcher_web
description: Web platform implementation of url_launcher
homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher_web
version: 0.1.0+2
version: 0.1.1

flutter:
plugin:
Expand Down
Expand Up @@ -29,6 +29,10 @@ void main() {
expect(canLaunch('https://google.com'), completion(isTrue));
});

test('can launch "mailto" URLs', () {
expect(canLaunch('mailto:name@mydomain.com'), completion(isTrue));
});

test('cannot launch "tel" URLs', () {
expect(canLaunch('tel:5551234567'), completion(isFalse));
});
Expand All @@ -37,6 +41,10 @@ void main() {
expect(launch('https://www.google.com'), completion(isTrue));
});

test('launching a "mailto" returns true', () {
expect(launch('mailto:name@mydomain.com'), completion(isTrue));
});

test('the window that is launched is a new window', () {
final UrlLauncherPlugin urlLauncherPlugin = UrlLauncherPlugin();
final html.WindowBase newWindow =
Expand Down

0 comments on commit 22b6ef3

Please sign in to comment.