tree: bed214db34655be9fb6b246533166cdaa23d0103 [path history] [tgz]
  1. example/
  2. lib/
  3. test/
  4. AUTHORS
  5. CHANGELOG.md
  6. LICENSE
  7. pubspec.yaml
  8. README.md
packages/url_launcher/url_launcher_web/README.md

url_launcher_web

The web implementation of url_launcher.

Usage

This package is endorsed, which means you can simply use url_launcher normally. This package will be automatically included in your app when you do, so you do not need to add it to your pubspec.yaml.

However, if you import this package to use any of its APIs directly, you should add it to your pubspec.yaml as usual.

Limitations on the Web platform

A launch needs to be triggered by a user action

Web browsers prevent launching URLs in a new tab/window, unless triggered by a user action (e.g. a button click).

Even if a user triggers a launch through a button click, if there is a delay due to awaiting a Future before the launch, the browser may still block it. This is because the browser might perceive the launch as not being a direct result of user interaction, particularly if the Future takes too long to complete.

In such cases, you can use the webOnlyWindowName parameter, setting it to _self, to open the URL within the current tab. Another approach is to ensure that the uri is synchronously ready.

Read more: MDN > Transient activation.

Method launchUrl always returns true for allowed schemes

The launchUrl method always returns true on the web platform for allowed schemes. This is because URLs are opened in a new window using the noopener window feature. When the noopener feature is used, the browser does not return any information that can be used to determine if the link was successfully opened.

Read more: MDN > window.open.