launchUrl method

  1. @override
Future<void> launchUrl({
  1. required WebUri url,
  2. Map<String, String>? headers,
  3. List<WebUri>? otherLikelyURLs,
  4. WebUri? referrer,
})

Tells the browser to launch with url.

url - initial url.

headers - whitelisted cross-origin request headers. It is possible to attach non-whitelisted headers to cross-origin requests, when the server and client are related using a digital asset link.

otherLikelyURLs - Other likely destinations, sorted in decreasing likelihood order.

referrer - referrer header.

Officially Supported Platforms/Implementations:

  • Android Chrome Custom Tabs

Parameters - Officially Supported Platforms/Implementations:

  • url: all platforms
  • headers: all platforms
  • otherLikelyURLs: all platforms
  • referrer: all platforms

Use the PlatformChromeSafariBrowser.isMethodSupported method to check if this method is supported at runtime.

Implementation

@override
Future<void> launchUrl({
  required WebUri url,
  Map<String, String>? headers,
  List<WebUri>? otherLikelyURLs,
  WebUri? referrer,
}) async {
  Map<String, dynamic> args = <String, dynamic>{};
  args.putIfAbsent('url', () => url.toString());
  args.putIfAbsent('headers', () => headers);
  args.putIfAbsent(
    'otherLikelyURLs',
    () => otherLikelyURLs?.map((e) => e.toString()).toList(),
  );
  args.putIfAbsent('referrer', () => referrer?.toString());
  await channel?.invokeMethod("launchUrl", args);
}