blob: df738046b96b1020f5e962462ac256fcc0d46c15 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'package:flutter/services.dart';
import 'link.dart';
import 'url_launcher_platform_interface.dart';
const MethodChannel _channel = MethodChannel('');
/// An implementation of [UrlLauncherPlatform] that uses method channels.
class MethodChannelUrlLauncher extends UrlLauncherPlatform {
final LinkDelegate? linkDelegate = null;
Future<bool> canLaunch(String url) {
return _channel.invokeMethod<bool>(
<String, Object>{'url': url},
).then((bool? value) => value ?? false);
Future<void> closeWebView() {
return _channel.invokeMethod<void>('closeWebView');
Future<bool> launch(
String url, {
required bool useSafariVC,
required bool useWebView,
required bool enableJavaScript,
required bool enableDomStorage,
required bool universalLinksOnly,
required Map<String, String> headers,
String? webOnlyWindowName,
}) {
return _channel.invokeMethod<bool>(
<String, Object>{
'url': url,
'useSafariVC': useSafariVC,
'useWebView': useWebView,
'enableJavaScript': enableJavaScript,
'enableDomStorage': enableDomStorage,
'universalLinksOnly': universalLinksOnly,
'headers': headers,
).then((bool? value) => value ?? false);