Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/url_launcher/url_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.4.12

* Web: Added support for tel scheme

## 5.4.11

* Add documentation in README suggesting how to properly encode urls with special characters.
Expand Down
4 changes: 2 additions & 2 deletions packages/url_launcher/url_launcher/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: url_launcher
description: Flutter plugin for launching a URL on Android and iOS. Supports
web, phone, SMS, and email schemes.
homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher
version: 5.4.11
version: 5.4.12

flutter:
plugin:
Expand All @@ -26,7 +26,7 @@ dependencies:
# validation, so we set a ^ constraint.
# TODO(amirh): Revisit this (either update this part in the design or the pub tool).
# https://github.com/flutter/flutter/issues/46264
url_launcher_web: ^0.1.0+1
url_launcher_web: ^0.1.2
url_launcher_macos: ^0.0.1

dev_dependencies:
Expand Down
4 changes: 4 additions & 0 deletions packages/url_launcher/url_launcher_web/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.1.2

- Added support for tel scheme

# 0.1.1+6

- Open "mailto" urls with target set as "\_top" on Safari browsers.
Expand Down
18 changes: 15 additions & 3 deletions packages/url_launcher/url_launcher_web/lib/url_launcher_web.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,28 @@ import 'package:url_launcher_platform_interface/url_launcher_platform_interface.

import 'package:platform_detect/platform_detect.dart' show browser;

const _mailtoScheme = 'mailto';

final _httpSchemes = {
'http',
'https',
};

final _mailtoScheme = {
'mailto',
};

final _phoneScheme = {
'tel',
};

final _validSchemes = _httpSchemes.union(_mailtoScheme).union(_phoneScheme);
/// The web implementation of [UrlLauncherPlatform].
///
/// This class implements the `package:url_launcher` functionality for the web.
class UrlLauncherPlugin extends UrlLauncherPlatform {
html.Window _window;

// The set of schemes that can be handled by the plugin
static final _supportedSchemes = {'http', 'https', _mailtoScheme};

/// A constructor that allows tests to override the window object used by the plugin.
UrlLauncherPlugin({@visibleForTesting html.Window window})
Expand Down Expand Up @@ -44,7 +56,7 @@ class UrlLauncherPlugin extends UrlLauncherPlatform {

@override
Future<bool> canLaunch(String url) {
return Future<bool>.value(_supportedSchemes.contains(_getUrlScheme(url)));
return Future<bool>.value(_validSchemes.contains(_getUrlScheme(url)));
}

@override
Expand Down
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher_web/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/u
# 0.1.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 0.1.1+6
version: 0.1.2

flutter:
plugin:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ void main() {
plugin.canLaunch('mailto:name@mydomain.com'), completion(isTrue));
});

test('"tel" URLs -> false', () {
expect(plugin.canLaunch('tel:5551234567'), completion(isFalse));
test('"tel" URLs -> true', () {
expect(plugin.canLaunch('tel:5551234567'), completion(isTrue));
});
});

Expand Down