updated macos docs, added getContentWidth WebView method

This commit is contained in:
Lorenzo Pichilli 2022-10-18 18:12:33 +02:00
parent 3e3ba55a30
commit 652ee52c75
67 changed files with 3941 additions and 1171 deletions

View File

@ -1,3 +1,14 @@
## 6.0.0-beta.3
- Added MacOS support
- Added `PrintJobInfo.printer`
- Added `getContentWidth` WebView method
### BREAKING CHANGES
- Removed `PrintJobInfo.printerId`
- All `InAppWebViewSettings`, `InAppBrowserSettings` properties are optionals
## 6.0.0-beta.2
- Fixed web example

View File

@ -95,6 +95,7 @@ public class InAppBrowserSettings implements ISettings<InAppBrowserActivity> {
@Override
public Map<String, Object> getRealSettings(@NonNull InAppBrowserActivity inAppBrowserActivity) {
Map<String, Object> realSettings = toMap();
realSettings.put("hidden", inAppBrowserActivity.isHidden);
realSettings.put("hideToolbarTop", inAppBrowserActivity.actionBar == null || !inAppBrowserActivity.actionBar.isShowing());
realSettings.put("hideUrlBar", inAppBrowserActivity.menu == null || !inAppBrowserActivity.menu.findItem(R.id.menu_search).isVisible());
realSettings.put("hideProgressBar", inAppBrowserActivity.progressBar == null || inAppBrowserActivity.progressBar.getMax() == 0);

View File

@ -69,6 +69,7 @@ public interface InAppWebViewInterface {
String printCurrentPage(@Nullable PrintJobSettings settings);
int getContentHeight();
void getContentHeight(ValueCallback<Integer> callback);
void getContentWidth(ValueCallback<Integer> callback);
void zoomBy(float zoomFactor);
String getOriginalUrl();
void getSelectedText(ValueCallback<String> callback);

View File

@ -263,6 +263,14 @@ public class WebViewChannelDelegate extends ChannelDelegateImpl {
result.notImplemented();
}
break;
case isHidden:
if (webView != null && webView.getInAppBrowserDelegate() instanceof InAppBrowserActivity) {
InAppBrowserActivity inAppBrowserActivity = (InAppBrowserActivity) webView.getInAppBrowserDelegate();
result.success(inAppBrowserActivity.isHidden);
} else {
result.notImplemented();
}
break;
case getCopyBackForwardList:
result.success((webView != null) ? webView.getCopyBackForwardList() : null);
break;
@ -370,6 +378,18 @@ public class WebViewChannelDelegate extends ChannelDelegateImpl {
result.success(null);
}
break;
case getContentWidth:
if (webView instanceof InAppWebView) {
webView.getContentWidth(new ValueCallback<Integer>() {
@Override
public void onReceiveValue(@Nullable Integer contentWidth) {
result.success(contentWidth);
}
});
} else {
result.success(null);
}
break;
case zoomBy:
if (webView != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
double zoomFactor = (double) call.argument("zoomFactor");

View File

@ -27,6 +27,7 @@ public enum WebViewChannelDelegateMethods {
close,
show,
hide,
isHidden,
getCopyBackForwardList,
startSafeBrowsing,
clearCache,
@ -46,6 +47,7 @@ public enum WebViewChannelDelegateMethods {
resumeTimers,
printCurrentPage,
getContentHeight,
getContentWidth,
zoomBy,
getOriginalUrl,
getZoomScale,

View File

@ -1910,6 +1910,19 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie
callback.onReceiveValue(getContentHeight());
}
public void getContentWidth(final ValueCallback<Integer> callback) {
evaluateJavascript("document.documentElement.scrollWidth;", new ValueCallback<String>() {
@Override
public void onReceiveValue(@Nullable String value) {
Integer contentWidth = null;
if (value != null && !value.equalsIgnoreCase("null")) {
contentWidth = Integer.parseInt(value);
}
callback.onReceiveValue(contentWidth);
}
});
}
@Override
public void getHitTestResult(ValueCallback<com.pichillilorenzo.flutter_inappwebview.types.HitTestResult> callback) {
callback.onReceiveValue(com.pichillilorenzo.flutter_inappwebview.types.HitTestResult.fromWebViewHitTestResult(getHitTestResult()));

View File

@ -1,3 +1,7 @@
## 1.1.0
- Added `ExchangeableObject.copyMethod`.
## 1.0.0
Initial release.

View File

@ -4,6 +4,7 @@ class ExchangeableObject {
final bool fromMapFactory;
final bool nullableFromMapFactory;
final bool toStringMethod;
final bool copyMethod;
const ExchangeableObject({
this.toMapMethod = true,
@ -11,5 +12,6 @@ class ExchangeableObject {
this.fromMapFactory = true,
this.nullableFromMapFactory = true,
this.toStringMethod = true,
this.copyMethod = false
});
}

View File

@ -1,6 +1,6 @@
name: flutter_inappwebview_internal_annotations
description: Internal annotations used by the generator of flutter_inappwebview plugin
version: 1.0.0
version: 1.1.0
homepage: https://github.com/pichillilorenzo/flutter_inappwebview
environment:

View File

@ -443,6 +443,14 @@ class ExchangeableObjectGenerator
classBuffer.writeln('}');
}
if (annotation.read("copyMethod").boolValue && (!visitor.methods.containsKey("copy") ||
Util.methodHasIgnore(visitor.methods['copy']!))) {
classBuffer.writeln('///Returns a copy of $extClassName.');
classBuffer.writeln('$extClassName copy() {');
classBuffer.writeln('return $extClassName.fromMap(toMap()) ?? $extClassName();');
classBuffer.writeln('}');
}
if (annotation.read("toStringMethod").boolValue && (!visitor.methods.containsKey("toString") ||
Util.methodHasIgnore(visitor.methods['toString']!))) {
classBuffer.writeln('@override');

View File

@ -187,7 +187,7 @@ packages:
name: flutter_inappwebview_internal_annotations
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
version: "1.1.0"
frontend_server_client:
dependency: transitive
description:

View File

@ -12,7 +12,7 @@ dependencies:
sdk: flutter
build: ^2.3.1
source_gen: ^1.2.5
flutter_inappwebview_internal_annotations: ^1.0.0
flutter_inappwebview_internal_annotations: ^1.1.0
dev_dependencies:
build_runner: ^2.2.1

View File

@ -0,0 +1,32 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:flutter_test/flutter_test.dart';
import '../constants.dart';
import '../util.dart';
void hideAndShow() {
final shouldSkip = kIsWeb
? true
: ![
TargetPlatform.android,
TargetPlatform.iOS,
TargetPlatform.macOS,
].contains(defaultTargetPlatform);
test('hide and show', () async {
var inAppBrowser = new MyInAppBrowser();
await inAppBrowser.openUrlRequest(
urlRequest: URLRequest(url: TEST_URL_1),
settings: InAppBrowserClassSettings(
browserSettings: InAppBrowserSettings(hidden: true)));
await inAppBrowser.browserCreated.future;
await inAppBrowser.firstPageLoaded.future;
expect(await inAppBrowser.isHidden(), true);
await expectLater(inAppBrowser.show(), completes);
expect(await inAppBrowser.isHidden(), false);
await expectLater(inAppBrowser.hide(), completes);
expect(await inAppBrowser.isHidden(), true);
}, skip: shouldSkip);
}

View File

@ -5,6 +5,7 @@ import 'open_data_and_close.dart';
import 'open_file_and_close.dart';
import 'open_url_and_close.dart';
import 'set_get_settings.dart';
import 'hide_and_show.dart';
void main() {
final shouldSkip = kIsWeb;
@ -14,5 +15,6 @@ void main() {
openFileAndClose();
openDataAndClose();
setGetSettings();
hideAndShow();
}, skip: shouldSkip);
}

View File

@ -3,11 +3,12 @@
export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4"
export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_TARGET=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.dart_tool/package_config.json"
export "PACKAGE_CONFIG=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/.dart_tool/package_config.json"

View File

@ -106,7 +106,6 @@ class _InAppBrowserExampleScreenState extends State<InAppBrowserExampleScreen> {
URLRequest(url: Uri.parse("https://flutter.dev")),
settings: InAppBrowserClassSettings(
browserSettings: InAppBrowserSettings(
hidden: false,
toolbarTopBackgroundColor: Colors.blue,
presentationStyle: ModalPresentationStyle.POPOVER
),

View File

@ -56,6 +56,7 @@ public class InAppBrowserManager: ChannelDelegate {
let webViewController = InAppBrowserWebViewController()
webViewController.browserSettings = browserSettings
webViewController.isHidden = browserSettings.hidden
webViewController.webViewSettings = webViewSettings
webViewController.previousStatusBarStyle = previousStatusBarStyle
return webViewController

View File

@ -35,6 +35,7 @@ public class InAppBrowserSettings: ISettings<InAppBrowserWebViewController> {
override func getRealSettings(obj: InAppBrowserWebViewController?) -> [String: Any?] {
var realOptions: [String: Any?] = toMap()
if let inAppBrowserWebViewController = obj {
realOptions["hidden"] = inAppBrowserWebViewController.isHidden
realOptions["hideUrlBar"] = inAppBrowserWebViewController.searchBar.isHidden
realOptions["progressBar"] = inAppBrowserWebViewController.progressBar.isHidden
realOptions["closeButtonCaption"] = inAppBrowserWebViewController.closeButton.title

View File

@ -38,6 +38,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
var previousStatusBarStyle = -1
var initialUserScripts: [[String: Any]] = []
var pullToRefreshInitialSettings: [String: Any?] = [:]
var isHidden = false
public override func loadView() {
let channel = FlutterMethodChannel(name: InAppBrowserWebViewController.METHOD_CHANNEL_NAME_PREFIX + id, binaryMessenger: SwiftFlutterPlugin.instance!.registrar!.messenger())
@ -363,6 +364,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
public func show(completion: (() -> Void)? = nil) {
if let navController = navigationController as? InAppBrowserNavigationController, let window = navController.tmpWindow {
isHidden = false
window.alpha = 0.0
window.isHidden = false
window.makeKeyAndVisible()
@ -375,6 +377,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
public func hide(completion: (() -> Void)? = nil) {
if let navController = navigationController as? InAppBrowserNavigationController, let window = navController.tmpWindow {
isHidden = true
window.alpha = 1.0
UIView.animate(withDuration: 0.2) {
window.alpha = 0.0

View File

@ -1562,8 +1562,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
}
@available(iOS 15.0, *)
@available(macOS 12.0, *)
@available(macCatalyst 15.0, *)
public func webView(_ webView: WKWebView,
requestMediaCapturePermissionFor origin: WKSecurityOrigin,
initiatedByFrame frame: WKFrameInfo,
@ -1605,8 +1603,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate,
}
@available(iOS 15.0, *)
@available(macOS 12.0, *)
@available(macCatalyst 15.0, *)
public func webView(_ webView: WKWebView,
requestDeviceOrientationAndMotionPermissionFor origin: WKSecurityOrigin,
initiatedByFrame frame: WKFrameInfo,
@ -2848,6 +2844,10 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
return Int64(scrollView.contentSize.height)
}
public func getContentWidth() -> Int64 {
return Int64(scrollView.contentSize.width)
}
public func zoomBy(zoomFactor: Float, animated: Bool) {
let currentZoomScale = scrollView.zoomScale
scrollView.setZoomScale(currentZoomScale * CGFloat(zoomFactor), animated: animated)

View File

@ -119,7 +119,7 @@ public class InAppWebViewSettings: ISettings<InAppWebView> {
} else {
realSettings["mediaPlaybackRequiresUserGesture"] = configuration.mediaPlaybackRequiresUserAction
}
realSettings["minimumFontSize"] = configuration.preferences.minimumFontSize
realSettings["minimumFontSize"] = Int(configuration.preferences.minimumFontSize)
realSettings["suppressesIncrementalRendering"] = configuration.suppressesIncrementalRendering
realSettings["allowsBackForwardNavigationGestures"] = webView.allowsBackForwardNavigationGestures
realSettings["allowsInlineMediaPlayback"] = configuration.allowsInlineMediaPlayback

View File

@ -206,6 +206,13 @@ public class WebViewChannelDelegate : ChannelDelegate {
result(FlutterMethodNotImplemented)
}
break
case .isHidden:
if let iabController = webView?.inAppBrowserDelegate as? InAppBrowserWebViewController {
result(iabController.isHidden)
} else {
result(FlutterMethodNotImplemented)
}
break
case .getCopyBackForwardList:
result(webView?.getCopyBackForwardList())
break
@ -290,6 +297,9 @@ public class WebViewChannelDelegate : ChannelDelegate {
case .getContentHeight:
result(webView?.getContentHeight())
break
case .getContentWidth:
result(webView?.getContentWidth())
break
case .zoomBy:
let zoomFactor = (arguments!["zoomFactor"] as! NSNumber).floatValue
let animated = arguments!["animated"] as! Bool
@ -572,8 +582,14 @@ public class WebViewChannelDelegate : ChannelDelegate {
if let webView = self.webView, #available(iOS 14.5, *) {
// closeAllMediaPresentations with completionHandler v15.0 makes the app crash
// with error EXC_BAD_ACCESS, so use closeAllMediaPresentations v14.5
webView.closeAllMediaPresentations()
result(true)
if #available(iOS 16.0, *) {
webView.closeAllMediaPresentations {
result(true)
}
} else {
webView.closeAllMediaPresentations()
result(true)
}
} else {
result(false)
}

View File

@ -34,6 +34,7 @@ public enum WebViewChannelDelegateMethods: String {
case close = "close"
case show = "show"
case hide = "hide"
case isHidden = "isHidden"
case getCopyBackForwardList = "getCopyBackForwardList"
@available(*, deprecated, message: "Use FindInteractionController.findAll instead.")
case findAll = "findAll"
@ -48,6 +49,7 @@ public enum WebViewChannelDelegateMethods: String {
case resumeTimers = "resumeTimers"
case printCurrentPage = "printCurrentPage"
case getContentHeight = "getContentHeight"
case getContentWidth = "getContentWidth"
case zoomBy = "zoomBy"
case reloadFromOrigin = "reloadFromOrigin"
case getOriginalUrl = "getOriginalUrl"

View File

@ -2,7 +2,7 @@ import 'types/main.dart';
///Class that represents a set of rules to use block content in the browser window.
///
///On iOS, it uses [WKContentRuleListStore](https://developer.apple.com/documentation/webkit/wkcontentruleliststore).
///On iOS and MacOS, it uses [WKContentRuleListStore](https://developer.apple.com/documentation/webkit/wkcontentruleliststore).
///On Android, it uses a custom implementation because such functionality doesn't exist.
///
///In general, this [article](https://developer.apple.com/documentation/safariservices/creating_a_content_blocker) can be used to get an overview about this functionality
@ -27,6 +27,11 @@ class ContentBlocker {
action: ContentBlockerAction.fromMap(
Map<String, dynamic>.from(map["action"]!)));
}
@override
String toString() {
return 'ContentBlocker{trigger: $trigger, action: $action}';
}
}
///Trigger of the content blocker. The trigger tells to the WebView when to perform the corresponding action.
@ -39,40 +44,76 @@ class ContentBlockerTrigger {
///A list of regular expressions to match iframes URL against.
///
///*NOTE*: available only on iOS.
///**Supported Platforms/Implementations**:
///- iOS
///- MacOS
List<String> ifFrameUrl;
///A Boolean value. The default value is `false`.
///
///*NOTE*: available only on iOS.
///**Supported Platforms/Implementations**:
///- iOS
///- MacOS
bool urlFilterIsCaseSensitive;
///A list of [ContentBlockerTriggerResourceType] representing the resource types (how the browser intends to use the resource) that the rule should match.
///If not specified, the rule matches all resource types.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
List<ContentBlockerTriggerResourceType> resourceType;
///A list of strings matched to a URL's domain; limits action to a list of specific domains.
///Values must be lowercase ASCII, or punycode for non-ASCII. Add * in front to match domain and subdomains. Can't be used with [ContentBlockerTrigger.unlessDomain].
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
List<String> ifDomain;
///A list of strings matched to a URL's domain; acts on any site except domains in a provided list.
///Values must be lowercase ASCII, or punycode for non-ASCII. Add * in front to match domain and subdomains. Can't be used with [ContentBlockerTrigger.ifDomain].
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
List<String> unlessDomain;
///A list of [ContentBlockerTriggerLoadType] that can include one of two mutually exclusive values. If not specified, the rule matches all load types.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
List<ContentBlockerTriggerLoadType> loadType;
///A list of strings matched to the entire main document URL; limits the action to a specific list of URL patterns.
///Values must be lowercase ASCII, or punycode for non-ASCII. Can't be used with [ContentBlockerTrigger.unlessTopUrl].
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
List<String> ifTopUrl;
///An array of strings matched to the entire main document URL; acts on any site except URL patterns in provided list.
///Values must be lowercase ASCII, or punycode for non-ASCII. Can't be used with [ContentBlockerTrigger.ifTopUrl].
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
List<String> unlessTopUrl;
///An array of strings that specify loading contexts.
///
///*NOTE*: available only on iOS.
///**Supported Platforms/Implementations**:
///- iOS
///- MacOS
List<ContentBlockerTriggerLoadContext> loadContext;
ContentBlockerTrigger(
@ -161,7 +202,7 @@ class ContentBlockerTrigger {
return ContentBlockerTrigger(
urlFilter: map["url-filter"],
ifFrameUrl: map["if-frame-url"],
ifFrameUrl: List<String>.from(map["if-frame-url"] ?? []),
urlFilterIsCaseSensitive: map["url-filter-is-case-sensitive"],
ifDomain: List<String>.from(map["if-domain"] ?? []),
unlessDomain: List<String>.from(map["unless-domain"] ?? []),
@ -171,6 +212,11 @@ class ContentBlockerTrigger {
unlessTopUrl: List<String>.from(map["unless-top-url"] ?? []),
loadContext: loadContext);
}
@override
String toString() {
return 'ContentBlockerTrigger{urlFilter: $urlFilter, ifFrameUrl: $ifFrameUrl, urlFilterIsCaseSensitive: $urlFilterIsCaseSensitive, resourceType: $resourceType, ifDomain: $ifDomain, unlessDomain: $unlessDomain, loadType: $loadType, ifTopUrl: $ifTopUrl, unlessTopUrl: $unlessTopUrl, loadContext: $loadContext}';
}
}
///Action associated to the trigger. The action tells to the WebView what to do when the trigger is matched.
@ -213,4 +259,9 @@ class ContentBlockerAction {
type: ContentBlockerActionType.fromNativeValue(map["type"])!,
selector: map["selector"]);
}
@override
String toString() {
return 'ContentBlockerAction{type: $type, selector: $selector}';
}
}

View File

@ -4,7 +4,6 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'in_app_webview/in_app_webview_controller.dart';
import 'in_app_webview/in_app_webview_settings.dart';
import 'in_app_webview/headless_in_app_webview.dart';
import 'platform_util.dart';
@ -21,13 +20,13 @@ import 'types/main.dart';
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
class CookieManager {
static CookieManager? _instance;
static const MethodChannel _channel = const MethodChannel(
'com.pichillilorenzo/flutter_inappwebview_cookiemanager');
///Contains only iOS-specific methods of [CookieManager].
///Use [CookieManager] instead.
@Deprecated("Use CookieManager instead")
late IOSCookieManager ios;
@ -60,9 +59,9 @@ class CookieManager {
///The default value of [path] is `"/"`.
///
///[webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies)
///on the current URL of the [WebView] managed by that controller when you need to target iOS below 11 and Web platform. In this case the [url] parameter is ignored.
///on the current URL of the [WebView] managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. In this case the [url] parameter is ignored.
///
///**NOTE for iOS below 11.0**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView]
///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView]
///to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]).
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
@ -72,6 +71,7 @@ class CookieManager {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - CookieManager.setCookie](https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)))
///- iOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie))
///- MacOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie))
///- Web
Future<void> setCookie(
{required Uri url,
@ -94,27 +94,19 @@ class CookieManager {
assert(value.isNotEmpty);
assert(path.isNotEmpty);
if (defaultTargetPlatform == TargetPlatform.iOS || kIsWeb) {
var shouldUseJavascript = kIsWeb;
if (defaultTargetPlatform == TargetPlatform.iOS && !kIsWeb) {
var platformUtil = PlatformUtil.instance();
var version = double.tryParse(await platformUtil.getSystemVersion());
shouldUseJavascript = version != null && version < 11.0;
}
if (shouldUseJavascript) {
await _setCookieWithJavaScript(
url: url,
name: name,
value: value,
domain: domain,
path: path,
expiresDate: expiresDate,
maxAge: maxAge,
isSecure: isSecure,
sameSite: sameSite,
webViewController: webViewController);
return;
}
if (await _shouldUseJavascript()) {
await _setCookieWithJavaScript(
url: url,
name: name,
value: value,
domain: domain,
path: path,
expiresDate: expiresDate,
maxAge: maxAge,
isSecure: isSecure,
sameSite: sameSite,
webViewController: webViewController);
return;
}
Map<String, dynamic> args = <String, dynamic>{};
@ -160,16 +152,17 @@ class CookieManager {
cookieValue += ";";
if (webViewController != null) {
InAppWebViewSettings? settings = await webViewController.getSettings();
if (settings != null && settings.javaScriptEnabled) {
final javaScriptEnabled =
(await webViewController.getSettings())?.javaScriptEnabled ?? false;
if (javaScriptEnabled) {
await webViewController.evaluateJavascript(
source: 'document.cookie="$cookieValue"');
return;
}
}
var setCookieCompleter = Completer<void>();
var headlessWebView = new HeadlessInAppWebView(
final setCookieCompleter = Completer<void>();
final headlessWebView = new HeadlessInAppWebView(
initialUrlRequest: URLRequest(url: url),
onLoadStop: (controller, url) async {
await controller.evaluateJavascript(
@ -185,10 +178,10 @@ class CookieManager {
///Gets all the cookies for the given [url].
///
///[webViewController] is used for getting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies)
///from the current context of the [WebView] managed by that controller when you need to target iOS below 11 and Web platform. JavaScript must be enabled in order to work.
///from the current context of the [WebView] managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work.
///In this case the [url] parameter is ignored.
///
///**NOTE for iOS below 11.0**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value].
///**NOTE for iOS below 11.0 and MacOS below 10.13**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value].
///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView]
///to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!).
///
@ -199,6 +192,7 @@ class CookieManager {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - CookieManager.getCookie](https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)))
///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
///- Web
Future<List<Cookie>> getCookies(
{required Uri url,
@ -209,17 +203,9 @@ class CookieManager {
webViewController = webViewController ?? iosBelow11WebViewController;
if (defaultTargetPlatform == TargetPlatform.iOS || kIsWeb) {
var shouldUseJavascript = kIsWeb;
if (defaultTargetPlatform == TargetPlatform.iOS && !kIsWeb) {
var platformUtil = PlatformUtil.instance();
var version = double.tryParse(await platformUtil.getSystemVersion());
shouldUseJavascript = version != null && version < 11.0;
}
if (shouldUseJavascript) {
return await _getCookiesWithJavaScript(
url: url, webViewController: webViewController);
}
if (await _shouldUseJavascript()) {
return await _getCookiesWithJavaScript(
url: url, webViewController: webViewController);
}
List<Cookie> cookies = [];
@ -253,8 +239,9 @@ class CookieManager {
List<Cookie> cookies = [];
if (webViewController != null) {
InAppWebViewSettings? settings = await webViewController.getSettings();
if (settings != null && settings.javaScriptEnabled) {
final javaScriptEnabled =
(await webViewController.getSettings())?.javaScriptEnabled ?? false;
if (javaScriptEnabled) {
List<String> documentCookies = (await webViewController
.evaluateJavascript(source: 'document.cookie') as String)
.split(';')
@ -273,8 +260,8 @@ class CookieManager {
}
}
var pageLoaded = Completer<void>();
var headlessWebView = new HeadlessInAppWebView(
final pageLoaded = Completer<void>();
final headlessWebView = new HeadlessInAppWebView(
initialUrlRequest: URLRequest(url: url),
onLoadStop: (controller, url) async {
pageLoaded.complete();
@ -304,10 +291,10 @@ class CookieManager {
///Gets a cookie by its [name] for the given [url].
///
///[webViewController] is used for getting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies)
///from the current context of the [WebView] managed by that controller when you need to target iOS below 11 and Web platform. JavaScript must be enabled in order to work.
///from the current context of the [WebView] managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work.
///In this case the [url] parameter is ignored.
///
///**NOTE for iOS below 11.0**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value].
///**NOTE for iOS below 11.0 and MacOS below 10.13**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value].
///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView]
///to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!).
///
@ -318,6 +305,7 @@ class CookieManager {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<Cookie?> getCookie(
{required Uri url,
@ -330,20 +318,12 @@ class CookieManager {
webViewController = webViewController ?? iosBelow11WebViewController;
if (defaultTargetPlatform == TargetPlatform.iOS || kIsWeb) {
var shouldUseJavascript = kIsWeb;
if (defaultTargetPlatform == TargetPlatform.iOS && !kIsWeb) {
var platformUtil = PlatformUtil.instance();
var version = double.tryParse(await platformUtil.getSystemVersion());
shouldUseJavascript = version != null && version < 11.0;
}
if (shouldUseJavascript) {
List<Cookie> cookies = await _getCookiesWithJavaScript(
url: url, webViewController: webViewController);
return cookies
.cast<Cookie?>()
.firstWhere((cookie) => cookie!.name == name, orElse: () => null);
}
if (await _shouldUseJavascript()) {
List<Cookie> cookies = await _getCookiesWithJavaScript(
url: url, webViewController: webViewController);
return cookies
.cast<Cookie?>()
.firstWhere((cookie) => cookie!.name == name, orElse: () => null);
}
Map<String, dynamic> args = <String, dynamic>{};
@ -373,10 +353,10 @@ class CookieManager {
///The default value of [path] is `"/"`.
///
///[webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies)
///from the current context of the [WebView] managed by that controller when you need to target iOS below 11 and Web platform. JavaScript must be enabled in order to work.
///from the current context of the [WebView] managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work.
///In this case the [url] parameter is ignored.
///
///**NOTE for iOS below 11.0**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView]
///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView]
///to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!).
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
@ -386,6 +366,7 @@ class CookieManager {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)
///- MacOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)
///- Web
Future<void> deleteCookie(
{required Uri url,
@ -400,24 +381,16 @@ class CookieManager {
webViewController = webViewController ?? iosBelow11WebViewController;
if (defaultTargetPlatform == TargetPlatform.iOS || kIsWeb) {
var shouldUseJavascript = kIsWeb;
if (defaultTargetPlatform == TargetPlatform.iOS && !kIsWeb) {
var platformUtil = PlatformUtil.instance();
var version = double.tryParse(await platformUtil.getSystemVersion());
shouldUseJavascript = version != null && version < 11.0;
}
if (shouldUseJavascript) {
await _setCookieWithJavaScript(
url: url,
name: name,
value: "",
path: path,
domain: domain,
maxAge: -1,
webViewController: webViewController);
return;
}
if (await _shouldUseJavascript()) {
await _setCookieWithJavaScript(
url: url,
name: name,
value: "",
path: path,
domain: domain,
maxAge: -1,
webViewController: webViewController);
return;
}
Map<String, dynamic> args = <String, dynamic>{};
@ -433,10 +406,10 @@ class CookieManager {
///The default value of [path] is `"/"`.
///
///[webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies)
///from the current context of the [WebView] managed by that controller when you need to target iOS below 11 and Web platform. JavaScript must be enabled in order to work.
///from the current context of the [WebView] managed by that controller when you need to target iOS below 11, MacOS below 10.13 and Web platform. JavaScript must be enabled in order to work.
///In this case the [url] parameter is ignored.
///
///**NOTE for iOS below 11.0**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView]
///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView]
///to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!).
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
@ -446,6 +419,7 @@ class CookieManager {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<void> deleteCookies(
{required Uri url,
@ -458,28 +432,20 @@ class CookieManager {
webViewController = webViewController ?? iosBelow11WebViewController;
if (defaultTargetPlatform == TargetPlatform.iOS || kIsWeb) {
var shouldUseJavascript = kIsWeb;
if (defaultTargetPlatform == TargetPlatform.iOS && !kIsWeb) {
var platformUtil = PlatformUtil.instance();
var version = double.tryParse(await platformUtil.getSystemVersion());
shouldUseJavascript = version != null && version < 11.0;
}
if (shouldUseJavascript) {
List<Cookie> cookies = await _getCookiesWithJavaScript(
url: url, webViewController: webViewController);
for (var i = 0; i < cookies.length; i++) {
await _setCookieWithJavaScript(
url: url,
name: cookies[i].name,
value: "",
path: path,
domain: domain,
maxAge: -1,
webViewController: webViewController);
}
return;
if (await _shouldUseJavascript()) {
List<Cookie> cookies = await _getCookiesWithJavaScript(
url: url, webViewController: webViewController);
for (var i = 0; i < cookies.length; i++) {
await _setCookieWithJavaScript(
url: url,
name: cookies[i].name,
value: "",
path: path,
domain: domain,
maxAge: -1,
webViewController: webViewController);
}
return;
}
Map<String, dynamic> args = <String, dynamic>{};
@ -493,9 +459,12 @@ class CookieManager {
///
///**NOTE for iOS**: available from iOS 11.0+.
///
///**NOTE for MacOS**: available from iOS 10.13+.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - CookieManager.removeAllCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)))
///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
Future<void> deleteAllCookies() async {
Map<String, dynamic> args = <String, dynamic>{};
await _channel.invokeMethod('deleteAllCookies', args);
@ -503,10 +472,13 @@ class CookieManager {
///Fetches all stored cookies.
///
///**NOTE**: available on iOS 11.0+.
///**NOTE for iOS**: available on iOS 11.0+.
///
///**NOTE for MacOS**: available from iOS 10.13+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies))
Future<List<Cookie>> getAllCookies() async {
List<Cookie> cookies = [];
@ -542,6 +514,21 @@ class CookieManager {
timezone: 'GMT')
: await platformUtil.getWebCookieExpirationDate(date: dateTime);
}
Future<bool> _shouldUseJavascript() async {
if (kIsWeb) {
return true;
}
if (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform == TargetPlatform.macOS) {
final platformUtil = PlatformUtil.instance();
final systemVersion = await platformUtil.getSystemVersion();
return defaultTargetPlatform == TargetPlatform.iOS
? systemVersion.compareTo("11") == -1
: systemVersion.compareTo("10.13") == -1;
}
return false;
}
}
///Class that contains only iOS-specific methods of [CookieManager].

View File

@ -9,6 +9,7 @@ import '../types/main.dart';
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
class FindInteractionController {
MethodChannel? _channel;
@ -29,6 +30,7 @@ class FindInteractionController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.FindListener.onFindResultReceived](https://developer.android.com/reference/android/webkit/WebView.FindListener#onFindResultReceived(int,%20int,%20boolean)))
///- iOS
///- MacOS
final void Function(
FindInteractionController controller,
int activeMatchOrdinal,
@ -108,6 +110,7 @@ class FindInteractionController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.findAllAsync](https://developer.android.com/reference/android/webkit/WebView#findAllAsync(java.lang.String)))
///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2) with [Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2))
///- MacOS
Future<void> findAll({String? find}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('find', () => find);
@ -125,6 +128,7 @@ class FindInteractionController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.findNext](https://developer.android.com/reference/android/webkit/WebView#findNext(boolean)))
///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.findNext](https://developer.apple.com/documentation/uikit/uifindinteraction/3975829-findnext?changes=_2) and ([Official API - UIFindInteraction.findPrevious](https://developer.apple.com/documentation/uikit/uifindinteraction/3975830-findprevious?changes=_2)))
///- MacOS
Future<void> findNext({bool forward = true}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('forward', () => forward);
@ -140,6 +144,7 @@ class FindInteractionController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.clearMatches](https://developer.android.com/reference/android/webkit/WebView#clearMatches()))
///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2))
///- MacOS
Future<void> clearMatches() async {
Map<String, dynamic> args = <String, dynamic>{};
await _channel?.invokeMethod('clearMatches', args);
@ -153,6 +158,7 @@ class FindInteractionController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2))
///- MacOS
Future<void> setSearchText(String? searchText) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('searchText', () => searchText);
@ -167,6 +173,7 @@ class FindInteractionController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2))
///- MacOS
Future<String?> getSearchText() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel?.invokeMethod('getSearchText', args);
@ -221,6 +228,7 @@ class FindInteractionController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - UIFindInteraction.activeFindSession](https://developer.apple.com/documentation/uikit/uifindinteraction/3975825-activefindsession?changes=_7____4_8&language=objc))
///- MacOS
Future<FindSession?> getActiveFindSession() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic>? result =

View File

@ -4,7 +4,7 @@ import 'types/main.dart';
import 'package:flutter/services.dart';
///Class that implements a singleton object (shared instance) which manages the shared HTTP auth credentials cache.
///On iOS, this class uses the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.
///On iOS and MacOS, this class uses the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.
///On Android, this class has a custom implementation using `android.database.sqlite.SQLiteDatabase` because
///[WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase)
///doesn't offer the same functionalities as iOS `URLCredentialStorage`.
@ -12,6 +12,7 @@ import 'package:flutter/services.dart';
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
class HttpAuthCredentialDatabase {
static HttpAuthCredentialDatabase? _instance;
static const MethodChannel _channel = const MethodChannel(
@ -44,6 +45,7 @@ class HttpAuthCredentialDatabase {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - URLCredentialStorage.allCredentials](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials))
///- MacOS ([Official API - URLCredentialStorage.allCredentials](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials))
Future<List<URLProtectionSpaceHttpAuthCredentials>>
getAllAuthCredentials() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -67,6 +69,7 @@ class HttpAuthCredentialDatabase {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<List<URLCredential>> getHttpAuthCredentials(
{required URLProtectionSpace protectionSpace}) async {
Map<String, dynamic> args = <String, dynamic>{};
@ -91,6 +94,7 @@ class HttpAuthCredentialDatabase {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - URLCredentialStorage.set](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set))
///- MacOS ([Official API - URLCredentialStorage.set](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set))
Future<void> setHttpAuthCredential(
{required URLProtectionSpace protectionSpace,
required URLCredential credential}) async {
@ -109,6 +113,7 @@ class HttpAuthCredentialDatabase {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - URLCredentialStorage.remove](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove))
///- MacOS ([Official API - URLCredentialStorage.remove](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove))
Future<void> removeHttpAuthCredential(
{required URLProtectionSpace protectionSpace,
required URLCredential credential}) async {
@ -127,6 +132,7 @@ class HttpAuthCredentialDatabase {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> removeHttpAuthCredentials(
{required URLProtectionSpace protectionSpace}) async {
Map<String, dynamic> args = <String, dynamic>{};
@ -142,6 +148,7 @@ class HttpAuthCredentialDatabase {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> clearAllAuthCredentials() async {
Map<String, dynamic> args = <String, dynamic>{};
await _channel.invokeMethod('clearAllAuthCredentials', args);

View File

@ -48,6 +48,7 @@ class InAppBrowserNotOpenedException implements Exception {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
class InAppBrowser {
///Debug settings.
static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings();
@ -152,6 +153,11 @@ class InAppBrowser {
///[options]: Options for the [InAppBrowser].
///
///[settings]: Settings for the [InAppBrowser].
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> openUrlRequest(
{required URLRequest urlRequest,
// ignore: deprecated_member_use_from_same_package
@ -220,6 +226,11 @@ class InAppBrowser {
///[options]: Options for the [InAppBrowser].
///
///[settings]: Settings for the [InAppBrowser].
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> openFile(
{required String assetFilePath,
// ignore: deprecated_member_use_from_same_package
@ -262,6 +273,11 @@ class InAppBrowser {
///The [options] parameter specifies the options for the [InAppBrowser].
///
///[settings]: Settings for the [InAppBrowser].
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> openData(
{required String data,
String mimeType = "text/html",
@ -303,6 +319,11 @@ class InAppBrowser {
}
///This is a static method that opens an [url] in the system browser. You wont be able to use the [InAppBrowser] methods here!
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
static Future<void> openWithSystemBrowser({required Uri url}) async {
assert(url.toString().isNotEmpty);
Map<String, dynamic> args = <String, dynamic>{};
@ -311,6 +332,11 @@ class InAppBrowser {
}
///Displays an [InAppBrowser] window that was opened hidden. Calling this has no effect if the [InAppBrowser] was already visible.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> show() async {
this.throwIfNotOpened();
Map<String, dynamic> args = <String, dynamic>{};
@ -318,6 +344,11 @@ class InAppBrowser {
}
///Hides the [InAppBrowser] window. Calling this has no effect if the [InAppBrowser] was already hidden.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> hide() async {
this.throwIfNotOpened();
Map<String, dynamic> args = <String, dynamic>{};
@ -325,6 +356,11 @@ class InAppBrowser {
}
///Closes the [InAppBrowser] window.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> close() async {
this.throwIfNotOpened();
Map<String, dynamic> args = <String, dynamic>{};
@ -332,6 +368,11 @@ class InAppBrowser {
}
///Check if the Web View of the [InAppBrowser] instance is hidden.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<bool> isHidden() async {
this.throwIfNotOpened();
Map<String, dynamic> args = <String, dynamic>{};
@ -365,6 +406,11 @@ class InAppBrowser {
}
///Sets the [InAppBrowser] settings with the new [settings] and evaluates them.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> setSettings(
{required InAppBrowserClassSettings settings}) async {
this.throwIfNotOpened();
@ -375,6 +421,11 @@ class InAppBrowser {
}
///Gets the current [InAppBrowser] settings. Returns `null` if it wasn't able to get them.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<InAppBrowserClassSettings?> getSettings() async {
this.throwIfNotOpened();
Map<String, dynamic> args = <String, dynamic>{};
@ -391,14 +442,29 @@ class InAppBrowser {
}
///Returns `true` if the [InAppBrowser] instance is opened, otherwise `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
bool isOpened() {
return this._isOpened;
}
///Event fired when the [InAppBrowser] is created.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
void onBrowserCreated() {}
///Event fired when the [InAppBrowser] window is closed.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
void onExit() {}
///Event fired when the [InAppBrowser] starts to load an [url].
@ -406,6 +472,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onPageStarted](https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
void onLoadStart(Uri? url) {}
///Event fired when the [InAppBrowser] finishes loading an [url].
@ -413,6 +480,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onPageFinished](https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
void onLoadStop(Uri? url) {}
///Use [onReceivedError] instead.
@ -424,6 +492,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview))
void onReceivedError(WebResourceRequest request, WebResourceError error) {}
///Use [onReceivedHttpError] instead.
@ -441,6 +510,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedHttpError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
void onReceivedHttpError(
WebResourceRequest request, WebResourceResponse errorResponse) {}
@ -449,6 +519,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onProgressChanged](https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int)))
///- iOS
///- MacOS
void onProgressChanged(int progress) {}
///Event fired when the [InAppBrowser] webview receives a [ConsoleMessage].
@ -456,23 +527,25 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onConsoleMessage](https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)))
///- iOS
///- MacOS
void onConsoleMessage(ConsoleMessage consoleMessage) {}
///Give the host application a chance to take control when a URL is about to be loaded in the current WebView. This event is not called on the initial load of the WebView.
///
///Note that on Android there isn't any way to load an URL for a frame that is not the main frame, so if the request is not for the main frame, the navigation is allowed by default.
///However, if you want to cancel requests for subframes, you can use the [InAppWebViewSettings.regexToCancelSubFramesLoading] option
///However, if you want to cancel requests for subframes, you can use the [InAppWebViewSettings.regexToCancelSubFramesLoading] setting
///to write a Regular Expression that, if the url request of a subframe matches, then the request of that subframe is canceled.
///
///Also, on Android, this method is not called for POST requests.
///
///[navigationAction] represents an object that contains information about an action that causes navigation to occur.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldOverrideUrlLoading] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldOverrideUrlLoading] setting to `true`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.shouldOverrideUrlLoading](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview))
Future<NavigationActionPolicy?>? shouldOverrideUrlLoading(
NavigationAction navigationAction) {
return null;
@ -480,11 +553,12 @@ class InAppBrowser {
///Event fired when the [InAppBrowser] webview loads a resource.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnLoadResource] and [InAppWebViewSettings.javaScriptEnabled] options to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnLoadResource] and [InAppWebViewSettings.javaScriptEnabled] setting to `true`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
void onLoadResource(LoadedResource resource) {}
///Event fired when the [InAppBrowser] webview scrolls.
@ -493,9 +567,12 @@ class InAppBrowser {
///
///[y] represents the current vertical scroll origin in pixels.
///
///**NOTE for MacOS**: this method is implemented with using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.onScrollChanged](https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int)))
///- iOS ([Official API - UIScrollViewDelegate.scrollViewDidScroll](https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll))
///- MacOS
void onScrollChanged(int x, int y) {}
///Use [onDownloadStartRequest] instead
@ -507,11 +584,12 @@ class InAppBrowser {
///
///[downloadStartRequest] represents the request of the file to download.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnDownloadStart] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnDownloadStart] setting to `true`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.setDownloadListener](https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)))
///- iOS
///- MacOS
void onDownloadStartRequest(DownloadStartRequest downloadStartRequest) {}
///Use [onLoadResourceWithCustomScheme] instead.
@ -526,6 +604,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler))
///- MacOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler))
Future<CustomSchemeResponse?>? onLoadResourceWithCustomScheme(
WebResourceRequest request) {
return null;
@ -539,11 +618,11 @@ class InAppBrowser {
///
///[createWindowAction] represents the request.
///
///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically] option to `true`.
///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically] setting to `true`.
///
///**NOTE**: on Android you need to set [InAppWebViewSettings.supportMultipleWindows] option to `true`.
///**NOTE**: on Android you need to set [InAppWebViewSettings.supportMultipleWindows] setting to `true`.
///
///**NOTE**: on iOS, setting these initial options: [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest],
///**NOTE**: on iOS and MacOS, setting these initial settings: [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest],
///[InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically],
///[InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito],
///[InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture],
@ -562,6 +641,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onCreateWindow](https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)))
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview))
///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview))
Future<bool?>? onCreateWindow(CreateWindowAction createWindowAction) {
return null;
}
@ -572,6 +652,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onCloseWindow](https://developer.android.com/reference/android/webkit/WebChromeClient#onCloseWindow(android.webkit.WebView)))
///- iOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose))
///- MacOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose))
void onCloseWindow() {}
///Event fired when the JavaScript `window` object of the WebView has received focus.
@ -580,6 +661,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
void onWindowFocus() {}
///Event fired when the JavaScript `window` object of the WebView has lost focus.
@ -588,6 +670,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
void onWindowBlur() {}
///Event fired when javascript calls the `alert()` method to display an alert dialog.
@ -598,6 +681,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onJsAlert](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)))
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview))
///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview))
Future<JsAlertResponse?>? onJsAlert(JsAlertRequest jsAlertRequest) {
return null;
}
@ -610,6 +694,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onJsConfirm](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsConfirm(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)))
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview))
///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview))
Future<JsConfirmResponse?>? onJsConfirm(JsConfirmRequest jsConfirmRequest) {
return null;
}
@ -622,6 +707,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onJsPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult)))
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview))
///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview))
Future<JsPromptResponse?>? onJsPrompt(JsPromptRequest jsPromptRequest) {
return null;
}
@ -633,6 +719,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedHttpAuthRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
Future<HttpAuthResponse?>? onReceivedHttpAuthRequest(
URLAuthenticationChallenge challenge) {
return null;
@ -646,6 +733,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedSslError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
Future<ServerTrustAuthResponse?>? onReceivedServerTrustAuthRequest(
URLAuthenticationChallenge challenge) {
return null;
@ -661,6 +749,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedClientCertRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedClientCertRequest(android.webkit.WebView,%20android.webkit.ClientCertRequest)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
Future<ClientCertResponse?>? onReceivedClientCertRequest(
URLAuthenticationChallenge challenge) {
return null;
@ -676,7 +765,7 @@ class InAppBrowser {
///
///[ajaxRequest] represents the `XMLHttpRequest`.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting to `true`.
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
@ -685,6 +774,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<AjaxRequest?>? shouldInterceptAjaxRequest(AjaxRequest ajaxRequest) {
return null;
}
@ -694,7 +784,7 @@ class InAppBrowser {
///
///[ajaxRequest] represents the [XMLHttpRequest].
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting to `true`.
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
@ -703,6 +793,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<AjaxRequestAction?>? onAjaxReadyStateChange(AjaxRequest ajaxRequest) {
return null;
}
@ -712,7 +803,7 @@ class InAppBrowser {
///
///[ajaxRequest] represents the [XMLHttpRequest].
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting to `true`.
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
@ -721,6 +812,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<AjaxRequestAction?>? onAjaxProgress(AjaxRequest ajaxRequest) {
return null;
}
@ -730,7 +822,7 @@ class InAppBrowser {
///
///[fetchRequest] represents a resource request.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptFetchRequest] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptFetchRequest] setting to `true`.
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
///used to intercept fetch requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
@ -739,6 +831,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<FetchRequest?>? shouldInterceptFetchRequest(
FetchRequest fetchRequest) {
return null;
@ -756,6 +849,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.doUpdateVisitedHistory](https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean)))
///- iOS
///- MacOS
void onUpdateVisitedHistory(Uri? url, bool? isReload) {}
///Use [onPrintRequest] instead
@ -773,6 +867,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<bool?>? onPrintRequest(
Uri? url, PrintJobController? printJobController) {
return null;
@ -792,6 +887,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onShowCustomView](https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)))
///- iOS ([Official API - UIWindow.didBecomeVisibleNotification](https://developer.apple.com/documentation/uikit/uiwindow/1621621-didbecomevisiblenotification))
///- MacOS ([Official API - NSWindow.didEnterFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419651-didenterfullscreennotification))
void onEnterFullscreen() {}
///Event fired when the current page has exited full screen mode.
@ -799,6 +895,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onHideCustomView](https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()))
///- iOS ([Official API - UIWindow.didBecomeHiddenNotification](https://developer.apple.com/documentation/uikit/uiwindow/1621617-didbecomehiddennotification))
///- MacOS ([Official API - NSWindow.didExitFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419177-didexitfullscreennotification))
void onExitFullscreen() {}
///Called when the web view begins to receive web content.
@ -811,6 +908,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onPageCommitVisible](https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview))
void onPageCommitVisible(Uri? url) {}
///Event fired when a change in the document title occurred.
@ -820,6 +918,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onReceivedTitle](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)))
///- iOS
///- MacOS
void onTitleChanged(String? title) {}
///Event fired to respond to the results of an over-scroll operation.
@ -888,9 +987,12 @@ class InAppBrowser {
///
///**NOTE for iOS**: available only on iOS 15.0+. The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].
///
///**NOTE for MacOS**: available only on iOS 12.0+. The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onPermissionRequest](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)))
///- iOS
///- MacOS
Future<PermissionResponse?>? onPermissionRequest(
PermissionRequest permissionRequest) {
return null;
@ -1112,6 +1214,7 @@ class InAppBrowser {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi))
///- MacOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi))
void onWebContentProcessDidTerminate() {}
///Use [onDidReceiveServerRedirectForProvisionalNavigation] instead.
@ -1122,6 +1225,7 @@ class InAppBrowser {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview))
void onDidReceiveServerRedirectForProvisionalNavigation() {}
///Use [onNavigationResponse] instead.
@ -1135,10 +1239,11 @@ class InAppBrowser {
///
///[navigationResponse] represents the navigation response.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnNavigationResponse] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnNavigationResponse] setting to `true`.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
Future<NavigationResponseAction?>? onNavigationResponse(
NavigationResponse navigationResponse) {
return null;
@ -1155,10 +1260,13 @@ class InAppBrowser {
///
///[challenge] represents the authentication challenge.
///
///**NOTE**: available only on iOS 14.0+.
///**NOTE for iOS**: available only on iOS 14.0+.
///
///**NOTE for MacOS**: available only on MacOS 11.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview))
Future<ShouldAllowDeprecatedTLSAction?>? shouldAllowDeprecatedTLS(
URLAuthenticationChallenge challenge) {
return null;
@ -1166,10 +1274,13 @@ class InAppBrowser {
///Event fired when a change in the camera capture state occurred.
///
///**NOTE**: available only on iOS 15.0+.
///**NOTE for iOS**: available only on iOS 15.0+.
///
///**NOTE for MacOS**: available only on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS
///- MacOS
void onCameraCaptureStateChanged(
MediaCaptureState? oldState,
MediaCaptureState? newState,
@ -1177,10 +1288,13 @@ class InAppBrowser {
///Event fired when a change in the microphone capture state occurred.
///
///**NOTE**: available only on iOS 15.0+.
///**NOTE for iOS**: available only on iOS 15.0+.
///
///**NOTE for MacOS**: available only on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS
///- MacOS
void onMicrophoneCaptureStateChanged(
MediaCaptureState? oldState,
MediaCaptureState? newState,

View File

@ -2,7 +2,10 @@ import 'dart:ui';
import 'package:flutter/foundation.dart';
import 'package:flutter_inappwebview/src/types/main.dart';
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import '../types/modal_presentation_style.dart';
import '../types/modal_transition_style.dart';
import '../util.dart';
import '../in_app_webview/in_app_webview_settings.dart';
@ -13,6 +16,8 @@ import '../in_app_webview/android/in_app_webview_options.dart';
import 'apple/in_app_browser_options.dart';
import '../in_app_webview/apple/in_app_webview_options.dart';
part 'in_app_browser_settings.g.dart';
///Class that represents the settings that can be used for an [InAppBrowser] instance.
class InAppBrowserClassSettings {
///Browser settings.
@ -50,8 +55,8 @@ class InAppBrowserClassSettings {
if (instance == null) {
instance = InAppBrowserClassSettings();
}
instance.browserSettings = InAppBrowserSettings.fromMap(options);
instance.webViewSettings = InAppWebViewSettings.fromMap(options);
instance.browserSettings = InAppBrowserSettings.fromMap(options) ?? InAppBrowserSettings();
instance.webViewSettings = InAppWebViewSettings.fromMap(options) ?? InAppWebViewSettings();
return instance;
}
@ -84,7 +89,8 @@ class BrowserOptions {
}
///This class represents all [InAppBrowser] settings available.
class InAppBrowserSettings
@ExchangeableObject(copyMethod: true)
class InAppBrowserSettings_
implements BrowserOptions, AndroidOptions, IosOptions {
///Set to `true` to create the browser and load the page, but not show it. Omit or set to `false` to have the browser open and load normally.
///The default value is `false`.
@ -92,20 +98,23 @@ class InAppBrowserSettings
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
bool hidden;
///- MacOS
bool? hidden;
///Set to `true` to hide the toolbar at the top of the WebView. The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
bool hideToolbarTop;
///- MacOS
bool? hideToolbarTop;
///Set the custom background color of the toolbar at the top.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Color? toolbarTopBackgroundColor;
///Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`.
@ -113,50 +122,53 @@ class InAppBrowserSettings
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
bool hideUrlBar;
///- MacOS
bool? hideUrlBar;
///Set to `true` to hide the progress bar when the WebView is loading a page. The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
bool hideProgressBar;
///- MacOS
bool? hideProgressBar;
///Set to `true` if you want the title should be displayed. The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
bool hideTitleBar;
bool? hideTitleBar;
///Set the action bar's title.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- MacOS
String? toolbarTopFixedTitle;
///Set to `false` to not close the InAppBrowser when the user click on the Android back button and the WebView cannot go back to the history. The default value is `true`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
bool closeOnCannotGoBack;
bool? closeOnCannotGoBack;
///Set to `false` to block the InAppBrowser WebView going back when the user click on the Android back button. The default value is `true`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
bool allowGoBackWithBackButton;
bool? allowGoBackWithBackButton;
///Set to `true` to close the InAppBrowser when the user click on the Android back button. The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
bool shouldCloseOnBackButtonPressed;
bool? shouldCloseOnBackButtonPressed;
///Set to `true` to set the toolbar at the top translucent. The default value is `true`.
///
///**Supported Platforms/Implementations**:
///- iOS
bool toolbarTopTranslucent;
bool? toolbarTopTranslucent;
///Set the tint color to apply to the navigation bar background.
///
@ -174,7 +186,7 @@ class InAppBrowserSettings
///
///**Supported Platforms/Implementations**:
///- iOS
bool hideToolbarBottom;
bool? hideToolbarBottom;
///Set the custom background color of the toolbar at the bottom.
///
@ -192,7 +204,7 @@ class InAppBrowserSettings
///
///**Supported Platforms/Implementations**:
///- iOS
bool toolbarBottomTranslucent;
bool? toolbarBottomTranslucent;
///Set the custom text for the close button.
///
@ -210,15 +222,15 @@ class InAppBrowserSettings
///
///**Supported Platforms/Implementations**:
///- iOS
ModalPresentationStyle presentationStyle;
ModalPresentationStyle_? presentationStyle;
///Set to the custom transition style when presenting the WebView. The default value is [ModalTransitionStyle.COVER_VERTICAL].
///
///**Supported Platforms/Implementations**:
///- iOS
ModalTransitionStyle transitionStyle;
ModalTransitionStyle_? transitionStyle;
InAppBrowserSettings(
InAppBrowserSettings_(
{this.hidden = false,
this.hideToolbarTop = false,
this.toolbarTopBackgroundColor,
@ -232,8 +244,8 @@ class InAppBrowserSettings
this.toolbarBottomTranslucent = true,
this.closeButtonCaption,
this.closeButtonColor,
this.presentationStyle = ModalPresentationStyle.FULL_SCREEN,
this.transitionStyle = ModalTransitionStyle.COVER_VERTICAL,
this.presentationStyle = ModalPresentationStyle_.FULL_SCREEN,
this.transitionStyle = ModalTransitionStyle_.COVER_VERTICAL,
this.hideTitleBar = false,
this.toolbarTopFixedTitle,
this.closeOnCannotGoBack = true,
@ -241,81 +253,21 @@ class InAppBrowserSettings
this.shouldCloseOnBackButtonPressed = false});
@override
Map<String, dynamic> toMap() {
return {
"hidden": hidden,
"hideToolbarTop": hideToolbarTop,
"toolbarTopBackgroundColor": toolbarTopBackgroundColor?.toHex(),
"hideUrlBar": hideUrlBar,
"hideProgressBar": hideProgressBar,
"hideTitleBar": hideTitleBar,
"toolbarTopFixedTitle": toolbarTopFixedTitle,
"closeOnCannotGoBack": closeOnCannotGoBack,
"allowGoBackWithBackButton": allowGoBackWithBackButton,
"shouldCloseOnBackButtonPressed": shouldCloseOnBackButtonPressed,
"toolbarTopTranslucent": toolbarTopTranslucent,
"toolbarTopTintColor": toolbarTopTintColor?.toHex(),
"hideToolbarBottom": hideToolbarBottom,
"toolbarBottomBackgroundColor": toolbarBottomBackgroundColor?.toHex(),
"toolbarBottomTintColor": toolbarBottomTintColor?.toHex(),
"toolbarBottomTranslucent": toolbarBottomTranslucent,
"closeButtonCaption": closeButtonCaption,
"closeButtonColor": closeButtonColor?.toHex(),
"presentationStyle": presentationStyle.toNativeValue(),
"transitionStyle": transitionStyle.toNativeValue(),
};
}
static InAppBrowserSettings fromMap(Map<String, dynamic> map) {
var settings = InAppBrowserSettings();
settings.hidden = map["hidden"];
settings.hideToolbarTop = map["hideToolbarTop"];
settings.toolbarTopBackgroundColor =
UtilColor.fromHex(map["toolbarTopBackgroundColor"]);
settings.hideUrlBar = map["hideUrlBar"];
settings.hideProgressBar = map["hideProgressBar"];
if (defaultTargetPlatform == TargetPlatform.android) {
settings.hideTitleBar = map["hideTitleBar"];
settings.toolbarTopFixedTitle = map["toolbarTopFixedTitle"];
settings.closeOnCannotGoBack = map["closeOnCannotGoBack"];
settings.allowGoBackWithBackButton = map["allowGoBackWithBackButton"];
settings.shouldCloseOnBackButtonPressed =
map["shouldCloseOnBackButtonPressed"];
}
if (defaultTargetPlatform == TargetPlatform.iOS ||
defaultTargetPlatform == TargetPlatform.macOS) {
settings.toolbarTopTranslucent = map["toolbarTopTranslucent"];
settings.toolbarTopTintColor =
UtilColor.fromHex(map["toolbarTopTintColor"]);
settings.hideToolbarBottom = map["hideToolbarBottom"];
settings.toolbarBottomBackgroundColor =
UtilColor.fromHex(map["toolbarBottomBackgroundColor"]);
settings.toolbarBottomTintColor =
UtilColor.fromHex(map["toolbarBottomTintColor"]);
settings.toolbarBottomTranslucent = map["toolbarBottomTranslucent"];
settings.closeButtonCaption = map["closeButtonCaption"];
settings.closeButtonColor = UtilColor.fromHex(map["closeButtonColor"]);
settings.presentationStyle =
ModalPresentationStyle.fromNativeValue(map["presentationStyle"])!;
settings.transitionStyle =
ModalTransitionStyle.fromNativeValue(map["transitionStyle"])!;
}
return settings;
@ExchangeableObjectMethod(ignore: true)
InAppBrowserSettings_ copy() {
throw UnimplementedError();
}
@override
@ExchangeableObjectMethod(ignore: true)
Map<String, dynamic> toJson() {
return this.toMap();
throw UnimplementedError();
}
@override
String toString() {
return toMap().toString();
}
@override
InAppBrowserSettings copy() {
return InAppBrowserSettings.fromMap(this.toMap());
@ExchangeableObjectMethod(ignore: true)
Map<String, dynamic> toMap() {
throw UnimplementedError();
}
}

View File

@ -0,0 +1,259 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'in_app_browser_settings.dart';
// **************************************************************************
// ExchangeableObjectGenerator
// **************************************************************************
///This class represents all [InAppBrowser] settings available.
class InAppBrowserSettings
implements BrowserOptions, AndroidOptions, IosOptions {
///Set to `true` to create the browser and load the page, but not show it. Omit or set to `false` to have the browser open and load normally.
///The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
bool? hidden;
///Set to `true` to hide the toolbar at the top of the WebView. The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
bool? hideToolbarTop;
///Set the custom background color of the toolbar at the top.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Color? toolbarTopBackgroundColor;
///Set to `true` to hide the url bar on the toolbar at the top. The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
bool? hideUrlBar;
///Set to `true` to hide the progress bar when the WebView is loading a page. The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
bool? hideProgressBar;
///Set to `true` if you want the title should be displayed. The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
bool? hideTitleBar;
///Set the action bar's title.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- MacOS
String? toolbarTopFixedTitle;
///Set to `false` to not close the InAppBrowser when the user click on the Android back button and the WebView cannot go back to the history. The default value is `true`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
bool? closeOnCannotGoBack;
///Set to `false` to block the InAppBrowser WebView going back when the user click on the Android back button. The default value is `true`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
bool? allowGoBackWithBackButton;
///Set to `true` to close the InAppBrowser when the user click on the Android back button. The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
bool? shouldCloseOnBackButtonPressed;
///Set to `true` to set the toolbar at the top translucent. The default value is `true`.
///
///**Supported Platforms/Implementations**:
///- iOS
bool? toolbarTopTranslucent;
///Set the tint color to apply to the navigation bar background.
///
///**Supported Platforms/Implementations**:
///- iOS
Color? toolbarTopBarTintColor;
///Set the tint color to apply to the navigation items and bar button items.
///
///**Supported Platforms/Implementations**:
///- iOS
Color? toolbarTopTintColor;
///Set to `true` to hide the toolbar at the bottom of the WebView. The default value is `false`.
///
///**Supported Platforms/Implementations**:
///- iOS
bool? hideToolbarBottom;
///Set the custom background color of the toolbar at the bottom.
///
///**Supported Platforms/Implementations**:
///- iOS
Color? toolbarBottomBackgroundColor;
///Set the tint color to apply to the bar button items.
///
///**Supported Platforms/Implementations**:
///- iOS
Color? toolbarBottomTintColor;
///Set to `true` to set the toolbar at the bottom translucent. The default value is `true`.
///
///**Supported Platforms/Implementations**:
///- iOS
bool? toolbarBottomTranslucent;
///Set the custom text for the close button.
///
///**Supported Platforms/Implementations**:
///- iOS
String? closeButtonCaption;
///Set the custom color for the close button.
///
///**Supported Platforms/Implementations**:
///- iOS
Color? closeButtonColor;
///Set the custom modal presentation style when presenting the WebView. The default value is [ModalPresentationStyle.FULL_SCREEN].
///
///**Supported Platforms/Implementations**:
///- iOS
ModalPresentationStyle? presentationStyle;
///Set to the custom transition style when presenting the WebView. The default value is [ModalTransitionStyle.COVER_VERTICAL].
///
///**Supported Platforms/Implementations**:
///- iOS
ModalTransitionStyle? transitionStyle;
InAppBrowserSettings(
{this.hidden = false,
this.hideToolbarTop = false,
this.toolbarTopBackgroundColor,
this.hideUrlBar = false,
this.hideProgressBar = false,
this.hideTitleBar = false,
this.toolbarTopFixedTitle,
this.closeOnCannotGoBack = true,
this.allowGoBackWithBackButton = true,
this.shouldCloseOnBackButtonPressed = false,
this.toolbarTopTranslucent = true,
this.toolbarTopTintColor,
this.hideToolbarBottom = false,
this.toolbarBottomBackgroundColor,
this.toolbarBottomTintColor,
this.toolbarBottomTranslucent = true,
this.closeButtonCaption,
this.closeButtonColor,
this.presentationStyle = ModalPresentationStyle.FULL_SCREEN,
this.transitionStyle = ModalTransitionStyle.COVER_VERTICAL});
///Gets a possible [InAppBrowserSettings] instance from a [Map] value.
static InAppBrowserSettings? fromMap(Map<String, dynamic>? map) {
if (map == null) {
return null;
}
final instance = InAppBrowserSettings(
toolbarTopBackgroundColor: map['toolbarTopBackgroundColor'] != null
? UtilColor.fromStringRepresentation(map['toolbarTopBackgroundColor'])
: null,
toolbarTopFixedTitle: map['toolbarTopFixedTitle'],
toolbarTopTintColor: map['toolbarTopTintColor'] != null
? UtilColor.fromStringRepresentation(map['toolbarTopTintColor'])
: null,
toolbarBottomBackgroundColor: map['toolbarBottomBackgroundColor'] != null
? UtilColor.fromStringRepresentation(
map['toolbarBottomBackgroundColor'])
: null,
toolbarBottomTintColor: map['toolbarBottomTintColor'] != null
? UtilColor.fromStringRepresentation(map['toolbarBottomTintColor'])
: null,
closeButtonCaption: map['closeButtonCaption'],
closeButtonColor: map['closeButtonColor'] != null
? UtilColor.fromStringRepresentation(map['closeButtonColor'])
: null,
);
instance.hidden = map['hidden'];
instance.hideToolbarTop = map['hideToolbarTop'];
instance.hideUrlBar = map['hideUrlBar'];
instance.hideProgressBar = map['hideProgressBar'];
instance.hideTitleBar = map['hideTitleBar'];
instance.closeOnCannotGoBack = map['closeOnCannotGoBack'];
instance.allowGoBackWithBackButton = map['allowGoBackWithBackButton'];
instance.shouldCloseOnBackButtonPressed =
map['shouldCloseOnBackButtonPressed'];
instance.toolbarTopTranslucent = map['toolbarTopTranslucent'];
instance.toolbarTopBarTintColor = map['toolbarTopBarTintColor'] != null
? UtilColor.fromStringRepresentation(map['toolbarTopBarTintColor'])
: null;
instance.hideToolbarBottom = map['hideToolbarBottom'];
instance.toolbarBottomTranslucent = map['toolbarBottomTranslucent'];
instance.presentationStyle =
ModalPresentationStyle.fromNativeValue(map['presentationStyle']);
instance.transitionStyle =
ModalTransitionStyle.fromNativeValue(map['transitionStyle']);
return instance;
}
///Converts instance to a map.
Map<String, dynamic> toMap() {
return {
"hidden": hidden,
"hideToolbarTop": hideToolbarTop,
"toolbarTopBackgroundColor": toolbarTopBackgroundColor?.toHex(),
"hideUrlBar": hideUrlBar,
"hideProgressBar": hideProgressBar,
"hideTitleBar": hideTitleBar,
"toolbarTopFixedTitle": toolbarTopFixedTitle,
"closeOnCannotGoBack": closeOnCannotGoBack,
"allowGoBackWithBackButton": allowGoBackWithBackButton,
"shouldCloseOnBackButtonPressed": shouldCloseOnBackButtonPressed,
"toolbarTopTranslucent": toolbarTopTranslucent,
"toolbarTopBarTintColor": toolbarTopBarTintColor?.toHex(),
"toolbarTopTintColor": toolbarTopTintColor?.toHex(),
"hideToolbarBottom": hideToolbarBottom,
"toolbarBottomBackgroundColor": toolbarBottomBackgroundColor?.toHex(),
"toolbarBottomTintColor": toolbarBottomTintColor?.toHex(),
"toolbarBottomTranslucent": toolbarBottomTranslucent,
"closeButtonCaption": closeButtonCaption,
"closeButtonColor": closeButtonColor?.toHex(),
"presentationStyle": presentationStyle?.toNativeValue(),
"transitionStyle": transitionStyle?.toNativeValue(),
};
}
///Converts instance to a map.
Map<String, dynamic> toJson() {
return toMap();
}
///Returns a copy of InAppBrowserSettings.
InAppBrowserSettings copy() {
return InAppBrowserSettings.fromMap(toMap()) ?? InAppBrowserSettings();
}
@override
String toString() {
return 'InAppBrowserSettings{hidden: $hidden, hideToolbarTop: $hideToolbarTop, toolbarTopBackgroundColor: $toolbarTopBackgroundColor, hideUrlBar: $hideUrlBar, hideProgressBar: $hideProgressBar, hideTitleBar: $hideTitleBar, toolbarTopFixedTitle: $toolbarTopFixedTitle, closeOnCannotGoBack: $closeOnCannotGoBack, allowGoBackWithBackButton: $allowGoBackWithBackButton, shouldCloseOnBackButtonPressed: $shouldCloseOnBackButtonPressed, toolbarTopTranslucent: $toolbarTopTranslucent, toolbarTopBarTintColor: $toolbarTopBarTintColor, toolbarTopTintColor: $toolbarTopTintColor, hideToolbarBottom: $hideToolbarBottom, toolbarBottomBackgroundColor: $toolbarBottomBackgroundColor, toolbarBottomTintColor: $toolbarBottomTintColor, toolbarBottomTranslucent: $toolbarBottomTranslucent, closeButtonCaption: $closeButtonCaption, closeButtonColor: $closeButtonColor, presentationStyle: $presentationStyle, transitionStyle: $transitionStyle}';
}
}

View File

@ -1,4 +1,10 @@
export 'in_app_browser.dart';
export 'in_app_browser_settings.dart';
export 'in_app_browser_settings.dart'
show
InAppBrowserClassSettings,
BrowserOptions,
InAppBrowserSettings,
InAppBrowserClassOptions,
InAppBrowserOptions;
export 'android/main.dart';
export 'apple/main.dart';

View File

@ -12,6 +12,7 @@ import 'mime_type_resolver.dart';
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
class InAppLocalhostServer {
bool _started = false;
HttpServer? _server;

View File

@ -23,6 +23,7 @@ import '../types/disposable.dart';
///- Android native WebView
///- iOS
///- Web
///- MacOS
class HeadlessInAppWebView implements WebView, Disposable {
///View ID.
late final String id;
@ -192,6 +193,7 @@ class HeadlessInAppWebView implements WebView, Disposable {
///- Android native WebView
///- iOS
///- Web
///- MacOS
Future<void> run() async {
if (_started) {
return;
@ -236,6 +238,7 @@ class HeadlessInAppWebView implements WebView, Disposable {
///- Android native WebView
///- iOS
///- Web
///- MacOS
@override
Future<void> dispose() async {
if (!_running) {
@ -253,6 +256,7 @@ class HeadlessInAppWebView implements WebView, Disposable {
///- Android native WebView
///- iOS
///- Web
///- MacOS
bool isRunning() {
return _running;
}
@ -270,6 +274,7 @@ class HeadlessInAppWebView implements WebView, Disposable {
///- Android native WebView
///- iOS
///- Web
///- MacOS
Future<void> setSize(Size size) async {
if (!_running) {
return;
@ -288,6 +293,7 @@ class HeadlessInAppWebView implements WebView, Disposable {
///- Android native WebView
///- iOS
///- Web
///- MacOS
Future<Size?> getSize() async {
if (!_running) {
return null;

View File

@ -1343,6 +1343,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.getUrl](https://developer.android.com/reference/android/webkit/WebView#getUrl()))
///- iOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url))
///- MacOS ([Official API - WKWebView.url](https://developer.apple.com/documentation/webkit/wkwebview/1415005-url))
///- Web
Future<Uri?> getUrl() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -1357,6 +1358,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.getTitle](https://developer.android.com/reference/android/webkit/WebView#getTitle()))
///- iOS ([Official API - WKWebView.title](https://developer.apple.com/documentation/webkit/wkwebview/1415015-title))
///- MacOS ([Official API - WKWebView.title](https://developer.apple.com/documentation/webkit/wkwebview/1415015-title))
///- Web
Future<String?> getTitle() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -1368,6 +1370,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.getProgress](https://developer.android.com/reference/android/webkit/WebView#getProgress()))
///- iOS ([Official API - WKWebView.estimatedProgress](https://developer.apple.com/documentation/webkit/wkwebview/1415007-estimatedprogress))
///- MacOS ([Official API - WKWebView.estimatedProgress](https://developer.apple.com/documentation/webkit/wkwebview/1415007-estimatedprogress))
Future<int?> getProgress() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel.invokeMethod('getProgress', args);
@ -1383,6 +1386,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<String?> getHtml() async {
String? html;
@ -1427,6 +1431,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<List<Favicon>> getFavicons() async {
List<Favicon> favicons = [];
@ -1611,6 +1616,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.loadUrl](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String))). If method is "POST", [Official API - WebView.postUrl](https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[]))
///- iOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load). If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl))
///- MacOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load). If [allowingReadAccessTo] is used, [Official API - WKWebView.loadFileURL](https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl))
///- Web
Future<void> loadUrl(
{required URLRequest urlRequest,
@ -1646,6 +1652,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.postUrl](https://developer.android.com/reference/android/webkit/WebView#postUrl(java.lang.String,%20byte[])))
///- iOS
///- MacOS
///- Web
Future<void> postUrl({required Uri url, required Uint8List postData}) async {
assert(url.toString().isNotEmpty);
@ -1672,6 +1679,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.loadDataWithBaseURL](https://developer.android.com/reference/android/webkit/WebView#loadDataWithBaseURL(java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20java.lang.String)))
///- iOS ([Official API - WKWebView.loadHTMLString](https://developer.apple.com/documentation/webkit/wkwebview/1415004-loadhtmlstring) or [Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1415011-load))
///- MacOS ([Official API - WKWebView.loadHTMLString](https://developer.apple.com/documentation/webkit/wkwebview/1415004-loadhtmlstring) or [Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1415011-load))
///- Web
Future<void> loadData(
{required String data,
@ -1741,6 +1749,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.loadUrl](https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String)))
///- iOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load))
///- MacOS ([Official API - WKWebView.load](https://developer.apple.com/documentation/webkit/wkwebview/1414954-load))
///- Web
Future<void> loadFile({required String assetFilePath}) async {
assert(assetFilePath.isNotEmpty);
@ -1756,6 +1765,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.reload](https://developer.android.com/reference/android/webkit/WebView#reload()))
///- iOS ([Official API - WKWebView.reload](https://developer.apple.com/documentation/webkit/wkwebview/1414969-reload))
///- MacOS ([Official API - WKWebView.reload](https://developer.apple.com/documentation/webkit/wkwebview/1414969-reload))
///- Web ([Official API - Location.reload](https://developer.mozilla.org/en-US/docs/Web/API/Location/reload))
Future<void> reload() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -1769,6 +1779,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.goBack](https://developer.android.com/reference/android/webkit/WebView#goBack()))
///- iOS ([Official API - WKWebView.goBack](https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback))
///- MacOS ([Official API - WKWebView.goBack](https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback))
///- Web ([Official API - History.back](https://developer.mozilla.org/en-US/docs/Web/API/History/back))
Future<void> goBack() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -1780,6 +1791,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.canGoBack](https://developer.android.com/reference/android/webkit/WebView#canGoBack()))
///- iOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback))
///- MacOS ([Official API - WKWebView.canGoBack](https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback))
Future<bool> canGoBack() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel.invokeMethod('canGoBack', args);
@ -1792,6 +1804,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.goForward](https://developer.android.com/reference/android/webkit/WebView#goForward()))
///- iOS ([Official API - WKWebView.goForward](https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward))
///- MacOS ([Official API - WKWebView.goForward](https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward))
///- Web ([Official API - History.forward](https://developer.mozilla.org/en-US/docs/Web/API/History/forward))
Future<void> goForward() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -1803,6 +1816,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.canGoForward](https://developer.android.com/reference/android/webkit/WebView#canGoForward()))
///- iOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward))
///- MacOS ([Official API - WKWebView.canGoForward](https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward))
Future<bool> canGoForward() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel.invokeMethod('canGoForward', args);
@ -1815,6 +1829,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.goBackOrForward](https://developer.android.com/reference/android/webkit/WebView#goBackOrForward(int)))
///- iOS ([Official API - WKWebView.go](https://developer.apple.com/documentation/webkit/wkwebview/1414991-go))
///- MacOS ([Official API - WKWebView.go](https://developer.apple.com/documentation/webkit/wkwebview/1414991-go))
///- Web ([Official API - History.go](https://developer.mozilla.org/en-US/docs/Web/API/History/go))
Future<void> goBackOrForward({required int steps}) async {
Map<String, dynamic> args = <String, dynamic>{};
@ -1827,6 +1842,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.canGoBackOrForward](https://developer.android.com/reference/android/webkit/WebView#canGoBackOrForward(int)))
///- iOS
///- MacOS
Future<bool> canGoBackOrForward({required int steps}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('steps', () => steps);
@ -1840,6 +1856,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<void> goTo({required WebHistoryItem historyItem}) async {
var steps = historyItem.offset;
@ -1853,6 +1870,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<bool> isLoading() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -1866,6 +1884,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.stopLoading](https://developer.android.com/reference/android/webkit/WebView#stopLoading()))
///- iOS ([Official API - WKWebView.stopLoading](https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading))
///- MacOS ([Official API - WKWebView.stopLoading](https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading))
///- Web ([Official API - Window.stop](https://developer.mozilla.org/en-US/docs/Web/API/Window/stop))
Future<void> stopLoading() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -1879,7 +1898,7 @@ class InAppWebViewController {
///This parameter doesnt apply to changes you make to the underlying web content, such as the documents DOM structure.
///Those changes remain visible to all scripts, regardless of which content world you specify.
///For more information about content worlds, see [ContentWorld].
///Available on iOS 14.0+.
///Available on iOS 14.0+ and MacOS 11.0+.
///**NOTE**: not used on Web.
///
///**NOTE**: This method shouldn't be called in the [WebView.onWebViewCreated] or [WebView.onLoadStart] events,
@ -1892,6 +1911,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.evaluateJavascript](https://developer.android.com/reference/android/webkit/WebView#evaluateJavascript(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.String%3E)))
///- iOS ([Official API - WKWebView.evaluateJavascript](https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript))
///- MacOS ([Official API - WKWebView.evaluateJavascript](https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript))
///- Web ([Official API - Window.eval](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval?retiredLocale=it))
Future<dynamic> evaluateJavascript(
{required String source, ContentWorld? contentWorld}) async {
@ -1924,6 +1944,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<void> injectJavascriptFileFromUrl(
{required Uri urlFile,
@ -1952,6 +1973,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<dynamic> injectJavascriptFileFromAsset(
{required String assetFilePath}) async {
@ -1971,6 +1993,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<void> injectCSSCode({required String source}) async {
Map<String, dynamic> args = <String, dynamic>{};
@ -1992,6 +2015,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<void> injectCSSFileFromUrl(
{required Uri urlFile,
@ -2016,6 +2040,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<void> injectCSSFileFromAsset({required String assetFilePath}) async {
String source = await rootBundle.loadString(assetFilePath);
@ -2076,6 +2101,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
void addJavaScriptHandler(
{required String handlerName,
required JavaScriptHandlerCallback callback}) {
@ -2091,6 +2117,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
JavaScriptHandlerCallback? removeJavaScriptHandler(
{required String handlerName}) {
return this.javaScriptHandlersMap.remove(handlerName);
@ -2102,9 +2129,12 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available on iOS 11.0+.
///
///**NOTE for MacOS**: available on MacOS 10.13+.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot))
///- MacOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot))
Future<Uint8List?> takeScreenshot(
{ScreenshotConfiguration? screenshotConfiguration}) async {
Map<String, dynamic> args = <String, dynamic>{};
@ -2117,7 +2147,7 @@ class InAppWebViewController {
@Deprecated('Use setSettings instead')
Future<void> setOptions({required InAppWebViewGroupOptions options}) async {
InAppWebViewSettings settings =
InAppWebViewSettings.fromMap(options.toMap());
InAppWebViewSettings.fromMap(options.toMap()) ?? InAppWebViewSettings();
await setSettings(settings: settings);
}
@ -2140,6 +2170,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<void> setSettings({required InAppWebViewSettings settings}) async {
Map<String, dynamic> args = <String, dynamic>{};
@ -2153,6 +2184,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<InAppWebViewSettings?> getSettings() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -2175,6 +2207,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.copyBackForwardList](https://developer.android.com/reference/android/webkit/WebView#copyBackForwardList()))
///- iOS ([Official API - WKWebView.backForwardList](https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist))
///- MacOS ([Official API - WKWebView.backForwardList](https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist))
Future<WebHistory?> getCopyBackForwardList() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic>? result =
@ -2188,6 +2221,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> clearCache() async {
Map<String, dynamic> args = <String, dynamic>{};
await _channel.invokeMethod('clearCache', args);
@ -2238,9 +2272,12 @@ class InAppWebViewController {
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
///
///**NOTE for MacOS**: this method is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - View.scrollTo](https://developer.android.com/reference/android/view/View#scrollTo(int,%20int)))
///- iOS ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset))
///- MacOS
///- Web ([Official API - Window.scrollTo](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo))
Future<void> scrollTo(
{required int x, required int y, bool animated = false}) async {
@ -2261,9 +2298,12 @@ class InAppWebViewController {
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
///
///**NOTE for MacOS**: this method is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - View.scrollBy](https://developer.android.com/reference/android/view/View#scrollBy(int,%20int)))
///- iOS ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset))
///- MacOS
///- Web ([Official API - Window.scrollBy](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy))
Future<void> scrollBy(
{required int x, required int y, bool animated = false}) async {
@ -2277,11 +2317,14 @@ class InAppWebViewController {
///On Android native WebView, it pauses all layout, parsing, and JavaScript timers for all WebViews.
///This is a global requests, not restricted to just this WebView. This can be useful if the application has been paused.
///
///On iOS, it is implemented using JavaScript and it is restricted to just this WebView.
///**NOTE for iOS**: it is implemented using JavaScript and it is restricted to just this WebView.
///
///**NOTE for MacOS**: it is implemented using JavaScript and it is restricted to just this WebView.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.pauseTimers](https://developer.android.com/reference/android/webkit/WebView#pauseTimers()))
///- iOS
///- MacOS
Future<void> pauseTimers() async {
Map<String, dynamic> args = <String, dynamic>{};
await _channel.invokeMethod('pauseTimers', args);
@ -2289,11 +2332,14 @@ class InAppWebViewController {
///On Android, it resumes all layout, parsing, and JavaScript timers for all WebViews. This will resume dispatching all timers.
///
///On iOS, it is implemented using JavaScript and it resumes all layout, parsing, and JavaScript timers to just this WebView.
///**NOTE for iOS**: it is implemented using JavaScript and it is restricted to just this WebView.
///
///**NOTE for MacOS**: it is implemented using JavaScript and it is restricted to just this WebView.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.resumeTimers](https://developer.android.com/reference/android/webkit/WebView#resumeTimers()))
///- iOS
///- MacOS
Future<void> resumeTimers() async {
Map<String, dynamic> args = <String, dynamic>{};
await _channel.invokeMethod('resumeTimers', args);
@ -2304,13 +2350,16 @@ class InAppWebViewController {
///To obtain the [PrintJobController], use [settings] argument with [PrintJobSettings.handledByClient] to `true`.
///Otherwise this method will return `null` and the [PrintJobController] will be handled and disposed automatically by the system.
///
///**NOTE**: available on Android 19+.
///**NOTE for Android**: available on Android 19+.
///
///**NOTE for MacOS**: [PrintJobController] is available on MacOS 11.0+.
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin. Also, [PrintJobController] is always `null`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - PrintManager.print](https://developer.android.com/reference/android/print/PrintManager#print(java.lang.String,%20android.print.PrintDocumentAdapter,%20android.print.PrintAttributes)))
///- iOS ([Official API - UIPrintInteractionController.present](https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/1618149-present))
///- MacOS (if 11.0+, [Official API - WKWebView.printOperation](https://developer.apple.com/documentation/webkit/wkwebview/3516861-printoperation), else [Official API - NSView.printView](https://developer.apple.com/documentation/appkit/nsview/1483705-printview))
///- Web ([Official API - Window.print](https://developer.mozilla.org/en-US/docs/Web/API/Window/print))
Future<PrintJobController?> printCurrentPage(
{PrintJobSettings? settings}) async {
@ -2327,9 +2376,12 @@ class InAppWebViewController {
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
///
///**NOTE for MacOS**: it is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.getContentHeight](https://developer.android.com/reference/android/webkit/WebView#getContentHeight()))
///- iOS ([Official API - UIScrollView.contentSize](https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize))
///- MacOS
///- Web ([Official API - Document.documentElement.scrollHeight](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight))
Future<int?> getContentHeight() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -2345,6 +2397,33 @@ class InAppWebViewController {
return height;
}
///Gets the width of the HTML content.
///
///**NOTE for Android**: it is implemented using JavaScript.
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
///
///**NOTE for MacOS**: it is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - UIScrollView.contentSize](https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize))
///- MacOS
///- Web ([Official API - Document.documentElement.scrollWidth](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth))
Future<int?> getContentWidth() async {
Map<String, dynamic> args = <String, dynamic>{};
var height = await _channel.invokeMethod('getContentWidth', args);
if (height == null || height == 0) {
// try to use javascript
var scrollHeight = await evaluateJavascript(
source: "document.documentElement.scrollWidth;");
if (scrollHeight != null && scrollHeight is num) {
height = scrollHeight.toInt();
}
}
return height;
}
///Performs a zoom operation in this WebView.
///
///[zoomFactor] represents the zoom factor to apply. On Android, the zoom factor will be clamped to the Webview's zoom limits and, also, this value must be in the range 0.01 (excluded) to 100.0 (included).
@ -2381,6 +2460,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.getOriginalUrl](https://developer.android.com/reference/android/webkit/WebView#getOriginalUrl()))
///- iOS
///- MacOS
///- Web
Future<Uri?> getOriginalUrl() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -2415,6 +2495,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<String?> getSelectedText() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -2515,6 +2596,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<List<MetaTag>> getMetaTags() async {
List<MetaTag> metaTags = [];
@ -2578,13 +2660,14 @@ class InAppWebViewController {
///Returns an instance of [Color] representing the `content` value of the
///`<meta name="theme-color" content="">` tag of the current WebView, if available, otherwise `null`.
///
///**NOTE**: on Android, Web and iOS < 15.0, it is implemented using JavaScript.
///**NOTE**: on Android, Web, iOS < 15.0 and MacOS < 12.0, it is implemented using JavaScript.
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - WKWebView.themeColor](https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor))
///- MacOS ([Official API - WKWebView.themeColor](https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor))
///- Web
Future<Color?> getMetaThemeColor() async {
Color? themeColor;
@ -2626,9 +2709,12 @@ class InAppWebViewController {
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
///
///**NOTE for MacOS**: it is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - View.getScrollX](https://developer.android.com/reference/android/view/View#getScrollX()))
///- iOS ([Official API - UIScrollView.contentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset))
///- MacOS
///- Web ([Official API - Window.scrollX](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX))
Future<int?> getScrollX() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -2639,9 +2725,12 @@ class InAppWebViewController {
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
///
///**NOTE for MacOS**: it is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - View.getScrollY](https://developer.android.com/reference/android/view/View#getScrollY()))
///- iOS ([Official API - UIScrollView.contentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset))
///- MacOS
///- Web ([Official API - Window.scrollY](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY))
Future<int?> getScrollY() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -2653,6 +2742,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.getCertificate](https://developer.android.com/reference/android/webkit/WebView#getCertificate()))
///- iOS
///- MacOS
Future<SslCertificate?> getCertificate() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic>? sslCertificateMap =
@ -2663,13 +2753,14 @@ class InAppWebViewController {
///Injects the specified [userScript] into the webpages content.
///
///**NOTE for iOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to iOS window WebViews.
///This is a limitation of the native iOS WebKit APIs.
///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to window WebViews.
///This is a limitation of the native WebKit APIs.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript))
///- MacOS ([Official API - WKUserContentController.addUserScript](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript))
Future<void> addUserScript({required UserScript userScript}) async {
assert(_webview?.windowId == null ||
defaultTargetPlatform != TargetPlatform.iOS);
@ -2684,13 +2775,14 @@ class InAppWebViewController {
///Injects the [userScripts] into the webpages content.
///
///**NOTE for iOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to iOS window WebViews.
///This is a limitation of the native iOS WebKit APIs.
///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to window WebViews.
///This is a limitation of the native WebKit APIs.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> addUserScripts({required List<UserScript> userScripts}) async {
assert(_webview?.windowId == null ||
defaultTargetPlatform != TargetPlatform.iOS);
@ -2704,13 +2796,14 @@ class InAppWebViewController {
///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load.
///Returns `true` if [userScript] was in the list, `false` otherwise.
///
///**NOTE for iOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to iOS window WebViews.
///This is a limitation of the native iOS WebKit APIs.
///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to window WebViews.
///This is a limitation of the native WebKit APIs.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<bool> removeUserScript({required UserScript userScript}) async {
assert(_webview?.windowId == null ||
defaultTargetPlatform != TargetPlatform.iOS);
@ -2732,13 +2825,14 @@ class InAppWebViewController {
///Removes all the [UserScript]s with [groupName] as group name from the webpages content.
///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load.
///
///**NOTE for iOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to iOS window WebViews.
///This is a limitation of the native iOS WebKit APIs.
///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to window WebViews.
///This is a limitation of the native WebKit APIs.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> removeUserScriptsByGroupName({required String groupName}) async {
assert(_webview?.windowId == null ||
defaultTargetPlatform != TargetPlatform.iOS);
@ -2751,13 +2845,14 @@ class InAppWebViewController {
///Removes the [userScripts] from the webpages content.
///User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load.
///
///**NOTE for iOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to iOS window WebViews.
///This is a limitation of the native iOS WebKit APIs.
///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to window WebViews.
///This is a limitation of the native WebKit APIs.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<void> removeUserScripts(
{required List<UserScript> userScripts}) async {
assert(_webview?.windowId == null ||
@ -2770,13 +2865,14 @@ class InAppWebViewController {
///Removes all the user scripts from the webpages content.
///
///**NOTE for iOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to iOS window WebViews.
///This is a limitation of the native iOS WebKit APIs.
///**NOTE for iOS and MacOS**: this method will throw an error if the [WebView.windowId] has been set.
///There isn't any way to add/remove user scripts specific to window WebViews.
///This is a limitation of the native WebKit APIs.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts))
///- MacOS ([Official API - WKUserContentController.removeAllUserScripts](https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts))
Future<void> removeAllUserScripts() async {
assert(_webview?.windowId == null ||
defaultTargetPlatform != TargetPlatform.iOS);
@ -2818,6 +2914,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - WKWebView.callAsyncJavaScript](https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript))
///- MacOS ([Official API - WKWebView.callAsyncJavaScript](https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript))
Future<CallAsyncJavaScriptResult?> callAsyncJavaScript(
{required String functionBody,
Map<String, dynamic> arguments = const <String, dynamic>{},
@ -2847,11 +2944,14 @@ class InAppWebViewController {
///
///**NOTE for iOS**: Available on iOS 14.0+. If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension.
///
///**NOTE for MacOS**: Available on MacOS 11.0+. If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension.
///
///**NOTE for Android**: if [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.saveWebArchive](https://developer.android.com/reference/android/webkit/WebView#saveWebArchive(java.lang.String,%20boolean,%20android.webkit.ValueCallback%3Cjava.lang.String%3E)))
///- iOS
///- MacOS
Future<String?> saveWebArchive(
{required String filePath, bool autoname = false}) async {
if (!autoname) {
@ -2879,6 +2979,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web ([Official API - Window.isSecureContext](https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext))
Future<bool> isSecureContext() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -2894,11 +2995,14 @@ class InAppWebViewController {
///
///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL].
///
///**NOTE**: On iOS, it is implemented using JavaScript.
///**NOTE for iOS**: it is implemented using JavaScript.
///
///**NOTE for MacOS**: it is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewCompat.createWebMessageChannel](https://developer.android.com/reference/androidx/webkit/WebViewCompat#createWebMessageChannel(android.webkit.WebView)))
///- iOS
///- MacOS
Future<WebMessageChannel?> createWebMessageChannel() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic>? result =
@ -2914,11 +3018,14 @@ class InAppWebViewController {
///
///**NOTE for Android native WebView**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.POST_WEB_MESSAGE].
///
///**NOTE**: On iOS, it is implemented using JavaScript.
///**NOTE for iOS**: it is implemented using JavaScript.
///
///**NOTE for MacOS**: it is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewCompat.postWebMessage](https://developer.android.com/reference/androidx/webkit/WebViewCompat#postWebMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri)))
///- iOS
///- MacOS
Future<void> postWebMessage(
{required WebMessage message, Uri? targetOrigin}) async {
if (targetOrigin == null) {
@ -3086,11 +3193,14 @@ class InAppWebViewController {
///
///**NOTE for Android**: This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.WEB_MESSAGE_LISTENER].
///
///**NOTE for iOS**: This is implemented using Javascript.
///**NOTE for iOS**: it is implemented using JavaScript.
///
///**NOTE for MacOS**: it is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewCompat.WebMessageListener](https://developer.android.com/reference/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,%20java.lang.String,%20java.util.Set%3Cjava.lang.String%3E,%20androidx.webkit.WebViewCompat.WebMessageListener)))
///- iOS
///- MacOS
Future<void> addWebMessageListener(
WebMessageListener webMessageListener) async {
assert(
@ -3107,9 +3217,12 @@ class InAppWebViewController {
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
///
///**NOTE for MacOS**: it is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<bool> canScrollVertically() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -3120,9 +3233,12 @@ class InAppWebViewController {
///
///**NOTE for Web**: this method will have effect only if the iframe has the same origin.
///
///**NOTE for MacOS**: it is implemented using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
Future<bool> canScrollHorizontally() async {
Map<String, dynamic> args = <String, dynamic>{};
@ -3233,6 +3349,7 @@ class InAppWebViewController {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.reloadFromOrigin](https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin))
///- MacOS ([Official API - WKWebView.reloadFromOrigin](https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin))
Future<void> reloadFromOrigin() async {
Map<String, dynamic> args = <String, dynamic>{};
await _channel.invokeMethod('reloadFromOrigin', args);
@ -3245,8 +3362,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available only on iOS 14.0+.
///
///**NOTE for MacOS**: available only on MacOS 11.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.createPdf](https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf))
///- MacOS ([Official API - WKWebView.createPdf](https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf))
Future<Uint8List?> createPdf(
{@Deprecated("Use pdfConfiguration instead")
// ignore: deprecated_member_use_from_same_package
@ -3263,8 +3383,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available only on iOS 14.0+.
///
///**NOTE for MacOS**: available only on MacOS 11.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.createWebArchiveData](https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata))
///- MacOS ([Official API - WKWebView.createWebArchiveData](https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata))
Future<Uint8List?> createWebArchiveData() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel.invokeMethod('createWebArchiveData', args);
@ -3274,6 +3397,7 @@ class InAppWebViewController {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.hasOnlySecureContent](https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent))
///- MacOS ([Official API - WKWebView.hasOnlySecureContent](https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent))
Future<bool> hasOnlySecureContent() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel.invokeMethod('hasOnlySecureContent', args);
@ -3283,8 +3407,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available on iOS 15.0+.
///
///**NOTE for MacOS**: available on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.pauseAllMediaPlayback](https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback)).
///- MacOS ([Official API - WKWebView.pauseAllMediaPlayback](https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback)).
Future<void> pauseAllMediaPlayback() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel.invokeMethod('pauseAllMediaPlayback', args);
@ -3297,8 +3424,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available on iOS 15.0+.
///
///**NOTE for MacOS**: available on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.setAllMediaPlaybackSuspended](https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended)).
///- MacOS ([Official API - WKWebView.setAllMediaPlaybackSuspended](https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended)).
Future<void> setAllMediaPlaybackSuspended({required bool suspended}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("suspended", () => suspended);
@ -3309,8 +3439,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available on iOS 14.5+.
///
///**NOTE for MacOS**: available on MacOS 11.3+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.closeAllMediaPresentations](https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations)).
///- MacOS ([Official API - WKWebView.closeAllMediaPresentations](https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations)).
Future<void> closeAllMediaPresentations() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel.invokeMethod('closeAllMediaPresentations', args);
@ -3322,8 +3455,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available on iOS 15.0+.
///
///**NOTE for MacOS**: available on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.requestMediaPlaybackState](https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate)).
///- MacOS ([Official API - WKWebView.requestMediaPlaybackState](https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate)).
Future<MediaPlaybackState?> requestMediaPlaybackState() async {
Map<String, dynamic> args = <String, dynamic>{};
return MediaPlaybackState.fromNativeValue(
@ -3335,6 +3471,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
Future<bool> isInFullscreen() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _channel.invokeMethod('isInFullscreen', args);
@ -3344,8 +3481,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available on iOS 15.0+.
///
///**NOTE for MacOS**: available on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.cameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate)).
///- MacOS ([Official API - WKWebView.cameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate)).
Future<MediaCaptureState?> getCameraCaptureState() async {
Map<String, dynamic> args = <String, dynamic>{};
return MediaCaptureState.fromNativeValue(
@ -3356,8 +3496,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available on iOS 15.0+.
///
///**NOTE for MacOS**: available on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.setCameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate)).
///- MacOS ([Official API - WKWebView.setCameraCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate)).
Future<void> setCameraCaptureState({required MediaCaptureState state}) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('state', () => state.toNativeValue());
@ -3368,8 +3511,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available on iOS 15.0+.
///
///**NOTE for MacOS**: available on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.microphoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate)).
///- MacOS ([Official API - WKWebView.microphoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate)).
Future<MediaCaptureState?> getMicrophoneCaptureState() async {
Map<String, dynamic> args = <String, dynamic>{};
return MediaCaptureState.fromNativeValue(
@ -3380,8 +3526,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available on iOS 15.0+.
///
///**NOTE for MacOS**: available on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.setMicrophoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate)).
///- MacOS ([Official API - WKWebView.setMicrophoneCaptureState](https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate)).
Future<void> setMicrophoneCaptureState(
{required MediaCaptureState state}) async {
Map<String, dynamic> args = <String, dynamic>{};
@ -3409,8 +3558,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available on iOS 15.0+.
///
///**NOTE for MacOS**: available on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.loadSimulatedRequest(_:response:responseData:)](https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest) and [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)).
///- MacOS ([Official API - WKWebView.loadSimulatedRequest(_:response:responseData:)](https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest) and [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)).
Future<void> loadSimulatedRequest(
{required URLRequest urlRequest,
required Uint8List data,
@ -3436,6 +3588,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebSettings.getDefaultUserAgent](https://developer.android.com/reference/android/webkit/WebSettings#getDefaultUserAgent(android.content.Context)))
///- iOS
///- MacOS
static Future<String> getDefaultUserAgent() async {
Map<String, dynamic> args = <String, dynamic>{};
return await _staticChannel.invokeMethod('getDefaultUserAgent', args);
@ -3545,8 +3698,11 @@ class InAppWebViewController {
///
///**NOTE for iOS**: available only on iOS 11.0+.
///
///**NOTE for MacOS**: available only on MacOS 10.13+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.handlesURLScheme](https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme))
///- MacOS ([Official API - WKWebView.handlesURLScheme](https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme))
static Future<bool> handlesURLScheme(String urlScheme) async {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('urlScheme', () => urlScheme);
@ -3558,6 +3714,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
static Future<String> get tRexRunnerHtml async => await rootBundle.loadString(
'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.html');
@ -3566,6 +3723,7 @@ class InAppWebViewController {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
static Future<String> get tRexRunnerCss async => await rootBundle.loadString(
'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.css');

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@ -1,7 +1,12 @@
export 'webview.dart';
export 'in_app_webview.dart';
export 'in_app_webview_controller.dart';
export 'in_app_webview_settings.dart';
export 'in_app_webview_settings.dart'
show
InAppWebViewSettings,
InAppWebViewGroupOptions,
WebViewOptions,
InAppWebViewOptions;
export 'headless_in_app_webview.dart';
export 'android/main.dart';
export 'apple/main.dart';

View File

@ -36,6 +36,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
final void Function(InAppWebViewController controller)? onWebViewCreated;
@ -49,6 +50,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onPageStarted](https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
///- Web
final void Function(InAppWebViewController controller, Uri? url)? onLoadStart;
@ -60,6 +62,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onPageFinished](https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
///- Web ([Official API - Window.onload](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event))
final void Function(InAppWebViewController controller, Uri? url)? onLoadStop;
@ -73,6 +76,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview))
final void Function(InAppWebViewController controller,
WebResourceRequest request, WebResourceError error)? onReceivedError;
@ -92,6 +96,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedHttpError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
final void Function(
InAppWebViewController controller,
WebResourceRequest request,
@ -102,6 +107,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onProgressChanged](https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int)))
///- iOS
///- MacOS
final void Function(InAppWebViewController controller, int progress)?
onProgressChanged;
@ -112,6 +118,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onConsoleMessage](https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)))
///- iOS
///- MacOS
///- Web
final void Function(
InAppWebViewController controller, ConsoleMessage consoleMessage)?
@ -120,30 +127,32 @@ abstract class WebView {
///Give the host application a chance to take control when a URL is about to be loaded in the current WebView. This event is not called on the initial load of the WebView.
///
///Note that on Android there isn't any way to load an URL for a frame that is not the main frame, so if the request is not for the main frame, the navigation is allowed by default.
///However, if you want to cancel requests for subframes, you can use the [InAppWebViewSettings.regexToCancelSubFramesLoading] option
///However, if you want to cancel requests for subframes, you can use the [InAppWebViewSettings.regexToCancelSubFramesLoading] setting
///to write a Regular Expression that, if the url request of a subframe matches, then the request of that subframe is canceled.
///
///Also, on Android, this method is not called for POST requests.
///
///[navigationAction] represents an object that contains information about an action that causes navigation to occur.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldOverrideUrlLoading] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldOverrideUrlLoading] setting to `true`.
///Also, on Android this event is not called on the first page load.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.shouldOverrideUrlLoading](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview))
final Future<NavigationActionPolicy?> Function(
InAppWebViewController controller, NavigationAction navigationAction)?
shouldOverrideUrlLoading;
///Event fired when the [WebView] loads a resource.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnLoadResource] and [InAppWebViewSettings.javaScriptEnabled] options to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnLoadResource] and [InAppWebViewSettings.javaScriptEnabled] setting to `true`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
final void Function(
InAppWebViewController controller, LoadedResource resource)?
onLoadResource;
@ -156,10 +165,13 @@ abstract class WebView {
///
///**NOTE for Web**: this event will be called only if the iframe has the same origin.
///
///**NOTE for MacOS**: this method is implemented with using JavaScript.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.onScrollChanged](https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int)))
///- iOS ([Official API - UIScrollViewDelegate.scrollViewDidScroll](https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll))
///- Web ([Official API - Window.onscroll](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onscroll))
///- MacOS
final void Function(InAppWebViewController controller, int x, int y)?
onScrollChanged;
@ -173,11 +185,12 @@ abstract class WebView {
///
///[downloadStartRequest] represents the request of the file to download.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnDownloadStart] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnDownloadStart] setting to `true`.
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebView.setDownloadListener](https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)))
///- iOS
///- MacOS
final void Function(InAppWebViewController controller,
DownloadStartRequest downloadStartRequest)? onDownloadStartRequest;
@ -192,6 +205,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler))
///- MacOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler))
final Future<CustomSchemeResponse?> Function(
InAppWebViewController controller, WebResourceRequest request)?
onLoadResourceWithCustomScheme;
@ -204,12 +218,12 @@ abstract class WebView {
///
///- [createWindowAction] represents the request.
///
///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically] option to `true`.
///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically] setting to `true`.
///
///**NOTE for Android**: you need to set [InAppWebViewSettings.supportMultipleWindows] option to `true`.
///**NOTE for Android**: you need to set [InAppWebViewSettings.supportMultipleWindows] setting to `true`.
///Also, if the request has been created using JavaScript (`window.open()`), then there are some limitation: check the [NavigationAction] class.
///
///**NOTE for iOS**: setting these initial options: [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest],
///**NOTE for iOS and MacOS**: setting these initial options: [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest],
///[InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically],
///[InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito],
///[InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture],
@ -231,6 +245,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onCreateWindow](https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)))
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview))
///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview))
///- Web
final Future<bool?> Function(InAppWebViewController controller,
CreateWindowAction createWindowAction)? onCreateWindow;
@ -241,6 +256,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onCloseWindow](https://developer.android.com/reference/android/webkit/WebChromeClient#onCloseWindow(android.webkit.WebView)))
///- iOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose))
///- MacOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose))
final void Function(InAppWebViewController controller)? onCloseWindow;
///Event fired when the JavaScript `window` object of the WebView has received focus.
@ -251,6 +267,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web ([Official API - Window.onfocus](https://developer.mozilla.org/en-US/docs/Web/API/Window/focus_event))
final void Function(InAppWebViewController controller)? onWindowFocus;
@ -262,6 +279,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web ([Official API - Window.onblur](https://developer.mozilla.org/en-US/docs/Web/API/Window/blur_event))
final void Function(InAppWebViewController controller)? onWindowBlur;
@ -273,6 +291,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onJsAlert](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)))
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview))
///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview))
final Future<JsAlertResponse?> Function(
InAppWebViewController controller, JsAlertRequest jsAlertRequest)?
onJsAlert;
@ -285,6 +304,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onJsConfirm](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsConfirm(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)))
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview))
///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview))
final Future<JsConfirmResponse?> Function(
InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)?
onJsConfirm;
@ -297,6 +317,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onJsPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult)))
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview))
///- MacOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview))
final Future<JsPromptResponse?> Function(
InAppWebViewController controller, JsPromptRequest jsPromptRequest)?
onJsPrompt;
@ -308,6 +329,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedHttpAuthRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
final Future<HttpAuthResponse?> Function(InAppWebViewController controller,
HttpAuthenticationChallenge challenge)? onReceivedHttpAuthRequest;
@ -319,6 +341,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedSslError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
final Future<ServerTrustAuthResponse?> Function(
InAppWebViewController controller, ServerTrustChallenge challenge)?
onReceivedServerTrustAuthRequest;
@ -333,6 +356,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedClientCertRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedClientCertRequest(android.webkit.WebView,%20android.webkit.ClientCertRequest)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
final Future<ClientCertResponse?> Function(
InAppWebViewController controller, ClientCertChallenge challenge)?
onReceivedClientCertRequest;
@ -347,7 +371,7 @@ abstract class WebView {
///
///[ajaxRequest] represents the `XMLHttpRequest`.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting to `true`.
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
@ -356,6 +380,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
final Future<AjaxRequest?> Function(
InAppWebViewController controller, AjaxRequest ajaxRequest)?
shouldInterceptAjaxRequest;
@ -365,7 +390,7 @@ abstract class WebView {
///
///[ajaxRequest] represents the [XMLHttpRequest].
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting to `true`.
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
@ -374,6 +399,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
final Future<AjaxRequestAction?> Function(
InAppWebViewController controller, AjaxRequest ajaxRequest)?
onAjaxReadyStateChange;
@ -383,7 +409,7 @@ abstract class WebView {
///
///[ajaxRequest] represents the [XMLHttpRequest].
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting to `true`.
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
@ -392,6 +418,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
final Future<AjaxRequestAction?> Function(
InAppWebViewController controller, AjaxRequest ajaxRequest)?
onAjaxProgress;
@ -401,7 +428,7 @@ abstract class WebView {
///
///[fetchRequest] represents a resource request.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptFetchRequest] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptFetchRequest] setting to `true`.
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
///used to intercept fetch requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
@ -410,6 +437,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
final Future<FetchRequest?> Function(
InAppWebViewController controller, FetchRequest fetchRequest)?
shouldInterceptFetchRequest;
@ -428,6 +456,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.doUpdateVisitedHistory](https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean)))
///- iOS
///- MacOS
///- Web
final void Function(
InAppWebViewController controller, Uri? url, bool? isReload)?
@ -451,6 +480,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
final Future<bool?> Function(InAppWebViewController controller, Uri? url,
PrintJobController? printJobController)? onPrintRequest;
@ -470,6 +500,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onShowCustomView](https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)))
///- iOS ([Official API - UIWindow.didBecomeVisibleNotification](https://developer.apple.com/documentation/uikit/uiwindow/1621621-didbecomevisiblenotification))
///- MacOS ([Official API - NSWindow.didEnterFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419651-didenterfullscreennotification))
///- Web ([Official API - Document.onfullscreenchange](https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event))
final void Function(InAppWebViewController controller)? onEnterFullscreen;
@ -482,6 +513,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onHideCustomView](https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()))
///- iOS ([Official API - UIWindow.didBecomeHiddenNotification](https://developer.apple.com/documentation/uikit/uiwindow/1621617-didbecomehiddennotification))
///- MacOS ([Official API - NSWindow.didExitFullScreenNotification](https://developer.apple.com/documentation/appkit/nswindow/1419177-didexitfullscreennotification))
///- Web ([Official API - Document.onfullscreenchange](https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event))
final void Function(InAppWebViewController controller)? onExitFullscreen;
@ -495,6 +527,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onPageCommitVisible](https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String)))
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview))
final void Function(InAppWebViewController controller, Uri? url)?
onPageCommitVisible;
@ -507,6 +540,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onReceivedTitle](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)))
///- iOS
///- MacOS
///- Web
final void Function(InAppWebViewController controller, String? title)?
onTitleChanged;
@ -583,9 +617,12 @@ abstract class WebView {
///
///**NOTE for iOS**: available only on iOS 15.0+. The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].
///
///**NOTE for MacOS**: available only on iOS 12.0+. The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].
///
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onPermissionRequest](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)))
///- iOS
///- MacOS
final Future<PermissionResponse?> Function(InAppWebViewController controller,
PermissionRequest permissionRequest)? onPermissionRequest;
@ -812,6 +849,7 @@ abstract class WebView {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi))
///- MacOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi))
final void Function(InAppWebViewController controller)?
onWebContentProcessDidTerminate;
@ -824,6 +862,7 @@ abstract class WebView {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview))
final void Function(InAppWebViewController controller)?
onDidReceiveServerRedirectForProvisionalNavigation;
@ -837,10 +876,11 @@ abstract class WebView {
///
///[navigationResponse] represents the navigation response.
///
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnNavigationResponse] option to `true`.
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnNavigationResponse] setting to `true`.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
final Future<NavigationResponseAction?> Function(
InAppWebViewController controller,
NavigationResponse navigationResponse)? onNavigationResponse;
@ -855,20 +895,26 @@ abstract class WebView {
///
///[challenge] represents the authentication challenge.
///
///**NOTE**: available only on iOS 14.0+.
///**NOTE for iOS**: available only on iOS 14.0+.
///
///**NOTE for MacOS**: available only on MacOS 11.0+.
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview))
///- MacOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview))
final Future<ShouldAllowDeprecatedTLSAction?> Function(
InAppWebViewController controller,
URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS;
///Event fired when a change in the camera capture state occurred.
///
///**NOTE**: available only on iOS 15.0+.
///**NOTE for iOS**: available only on iOS 15.0+.
///
///**NOTE for MacOS**: available only on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS
///- MacOS
final Future<void> Function(
InAppWebViewController controller,
MediaCaptureState? oldState,
@ -877,10 +923,13 @@ abstract class WebView {
///Event fired when a change in the microphone capture state occurred.
///
///**NOTE**: available only on iOS 15.0+.
///**NOTE for iOS**: available only on iOS 15.0+.
///
///**NOTE for MacOS**: available only on MacOS 12.0+.
///
///**Supported Platforms/Implementations**:
///- iOS
///- MacOS
final Future<void> Function(
InAppWebViewController controller,
MediaCaptureState? oldState,
@ -894,6 +943,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
final URLRequest? initialUrlRequest;
@ -902,6 +952,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
final String? initialFile;
@ -910,6 +961,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
final InAppWebViewInitialData? initialData;
@ -922,6 +974,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
final InAppWebViewSettings? initialSettings;
@ -943,6 +996,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
final UnmodifiableListView<UserScript>? initialUserScripts;
///Represents the pull-to-refresh feature controller.
@ -959,6 +1013,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
final FindInteractionController? findInteractionController;
///Represents the WebView native implementation to be used.

View File

@ -8,6 +8,11 @@ typedef PrintJobCompletionHandler = Future<void> Function(
bool completed, String? error)?;
///Class representing a print job eventually returned by [InAppWebViewController.printCurrentPage].
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
class PrintJobController implements Disposable {
///Print job ID.
final String id;
@ -18,6 +23,7 @@ class PrintJobController implements Disposable {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - UIPrintInteractionController.CompletionHandler](https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/completionhandler))
///- MacOS ([Official API - NSPrintOperation.runModal](https://developer.apple.com/documentation/appkit/nsprintoperation/1532065-runmodal))
PrintJobCompletionHandler onComplete;
PrintJobController({required this.id}) {
@ -91,6 +97,7 @@ class PrintJobController implements Disposable {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - PrintJob.getInfo](https://developer.android.com/reference/android/print/PrintJob#getInfo()))
///- iOS
///- MacOS
Future<PrintJobInfo?> getInfo() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic>? infoMap =
@ -103,6 +110,7 @@ class PrintJobController implements Disposable {
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
@override
Future<void> dispose() async {
Map<String, dynamic> args = <String, dynamic>{};

View File

@ -24,6 +24,12 @@ class PermissionResourceType_ {
apiName: 'WKMediaCaptureType.microphone',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone',
value: 1),
EnumMacOSPlatform(
available: "12.0",
apiName: 'WKMediaCaptureType.microphone',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone',
value: 1)
])
static const MICROPHONE = PermissionResourceType_._internal('MICROPHONE');
@ -63,6 +69,12 @@ class PermissionResourceType_ {
apiName: 'WKMediaCaptureType.camera',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera',
value: 0),
EnumMacOSPlatform(
available: "12.0",
apiName: 'WKMediaCaptureType.camera',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera',
value: 0)
])
static const CAMERA = PermissionResourceType_._internal('CAMERA');
@ -74,6 +86,12 @@ class PermissionResourceType_ {
apiName: 'WKMediaCaptureType.cameraAndMicrophone',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone',
value: 2),
EnumMacOSPlatform(
available: "12.0",
apiName: 'WKMediaCaptureType.cameraAndMicrophone',
apiUrl:
'https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone',
value: 2)
])
static const CAMERA_AND_MICROPHONE =
@ -81,7 +99,8 @@ class PermissionResourceType_ {
///Resource belongs to the devices orientation and motion.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(available: "15.0", value: 'deviceOrientationAndMotion')
EnumIOSPlatform(available: "15.0", value: 'deviceOrientationAndMotion'),
EnumMacOSPlatform(available: "12.0", value: 'deviceOrientationAndMotion')
])
static const DEVICE_ORIENTATION_AND_MOTION =
PermissionResourceType_._internal('DEVICE_ORIENTATION_AND_MOTION');

View File

@ -21,6 +21,7 @@ class PermissionResourceType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - PermissionRequest.RESOURCE_AUDIO_CAPTURE](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_AUDIO_CAPTURE))
///- iOS 15.0+ ([Official API - WKMediaCaptureType.microphone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone))
///- MacOS 12.0+ ([Official API - WKMediaCaptureType.microphone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone))
static final MICROPHONE =
PermissionResourceType._internalMultiPlatform('MICROPHONE', () {
switch (defaultTargetPlatform) {
@ -28,6 +29,8 @@ class PermissionResourceType {
return 'android.webkit.resource.AUDIO_CAPTURE';
case TargetPlatform.iOS:
return 1;
case TargetPlatform.macOS:
return 1;
default:
break;
}
@ -71,6 +74,7 @@ class PermissionResourceType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - PermissionRequest.RESOURCE_VIDEO_CAPTURE](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_VIDEO_CAPTURE))
///- iOS 15.0+ ([Official API - WKMediaCaptureType.camera](https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera))
///- MacOS 12.0+ ([Official API - WKMediaCaptureType.camera](https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera))
static final CAMERA =
PermissionResourceType._internalMultiPlatform('CAMERA', () {
switch (defaultTargetPlatform) {
@ -78,6 +82,8 @@ class PermissionResourceType {
return 'android.webkit.resource.VIDEO_CAPTURE';
case TargetPlatform.iOS:
return 0;
case TargetPlatform.macOS:
return 0;
default:
break;
}
@ -88,12 +94,15 @@ class PermissionResourceType {
///
///**Supported Platforms/Implementations**:
///- iOS 15.0+ ([Official API - WKMediaCaptureType.cameraAndMicrophone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone))
///- MacOS 12.0+ ([Official API - WKMediaCaptureType.cameraAndMicrophone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone))
static final CAMERA_AND_MICROPHONE =
PermissionResourceType._internalMultiPlatform('CAMERA_AND_MICROPHONE',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 2;
case TargetPlatform.macOS:
return 2;
default:
break;
}
@ -104,12 +113,15 @@ class PermissionResourceType {
///
///**Supported Platforms/Implementations**:
///- iOS 15.0+
///- MacOS 12.0+
static final DEVICE_ORIENTATION_AND_MOTION =
PermissionResourceType._internalMultiPlatform(
'DEVICE_ORIENTATION_AND_MOTION', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 'deviceOrientationAndMotion';
case TargetPlatform.macOS:
return 'deviceOrientationAndMotion';
default:
break;
}

View File

@ -1,4 +1,3 @@
import 'package:flutter/foundation.dart';
import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart';
import 'permission_response.dart';
@ -19,12 +18,6 @@ class PermissionResponseAction_ {
static const GRANT = const PermissionResponseAction_._internal(1);
///Prompt the user for permission for the requested resource.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
available: "15.0",
note: "On iOS < 15.0, it will fallback to [DENY]",
value: 2)
])
static const PROMPT = const PermissionResponseAction_._internal(2);
}

View File

@ -23,20 +23,7 @@ class PermissionResponseAction {
static const GRANT = PermissionResponseAction._internal(1, 1);
///Prompt the user for permission for the requested resource.
///
///**NOTE for iOS**: On iOS < 15.0, it will fallback to [DENY]
///
///**Supported Platforms/Implementations**:
///- iOS 15.0+
static final PROMPT = PermissionResponseAction._internalMultiPlatform(2, () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 2;
default:
break;
}
return null;
});
static const PROMPT = PermissionResponseAction._internal(2, 2);
///Set of all values of [PermissionResponseAction].
static final Set<PermissionResponseAction> values = [

View File

@ -74,6 +74,11 @@ class SslErrorType_ {
'https://developer.android.com/reference/android/net/http/SslError#SSL_INVALID',
value: 5),
EnumIOSPlatform(
apiName: 'SecTrustResultType.invalid',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/invalid',
value: 0),
EnumMacOSPlatform(
apiName: 'SecTrustResultType.invalid',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/invalid',
@ -89,6 +94,11 @@ class SslErrorType_ {
///The Keychain Access utility refers to this value as "Never Trust."
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'SecTrustResultType.deny',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/deny',
value: 3),
EnumMacOSPlatform(
apiName: 'SecTrustResultType.deny',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/deny',
@ -106,6 +116,11 @@ class SslErrorType_ {
///When receiving this value, most apps should trust the chain.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'SecTrustResultType.unspecified',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/unspecified',
value: 4),
EnumMacOSPlatform(
apiName: 'SecTrustResultType.unspecified',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/unspecified',
@ -124,6 +139,11 @@ class SslErrorType_ {
///you should check again using that date to see if the message was valid when you originally received it.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'SecTrustResultType.recoverableTrustFailure',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/recoverabletrustfailure',
value: 5),
EnumMacOSPlatform(
apiName: 'SecTrustResultType.recoverableTrustFailure',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/recoverabletrustfailure',
@ -140,6 +160,11 @@ class SslErrorType_ {
///Changing parameter values and reevaluating is unlikely to succeed unless you provide different certificates.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'SecTrustResultType.fatalTrustFailure',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/fataltrustfailure',
value: 6),
EnumMacOSPlatform(
apiName: 'SecTrustResultType.fatalTrustFailure',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/fataltrustfailure',
@ -154,6 +179,11 @@ class SslErrorType_ {
///This can be caused by either a revoked certificate or by OS-level errors that are unrelated to the certificates themselves.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'SecTrustResultType.otherError',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/othererror',
value: 7),
EnumMacOSPlatform(
apiName: 'SecTrustResultType.otherError',
apiUrl:
'https://developer.apple.com/documentation/security/sectrustresulttype/othererror',

View File

@ -95,12 +95,15 @@ class SslErrorType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - SslError.SSL_INVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_INVALID))
///- iOS ([Official API - SecTrustResultType.invalid](https://developer.apple.com/documentation/security/sectrustresulttype/invalid))
///- MacOS ([Official API - SecTrustResultType.invalid](https://developer.apple.com/documentation/security/sectrustresulttype/invalid))
static final INVALID = SslErrorType._internalMultiPlatform('INVALID', () {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
return 5;
case TargetPlatform.iOS:
return 0;
case TargetPlatform.macOS:
return 0;
default:
break;
}
@ -116,10 +119,13 @@ class SslErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - SecTrustResultType.deny](https://developer.apple.com/documentation/security/sectrustresulttype/deny))
///- MacOS ([Official API - SecTrustResultType.deny](https://developer.apple.com/documentation/security/sectrustresulttype/deny))
static final DENY = SslErrorType._internalMultiPlatform('DENY', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 3;
case TargetPlatform.macOS:
return 3;
default:
break;
}
@ -137,11 +143,14 @@ class SslErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - SecTrustResultType.unspecified](https://developer.apple.com/documentation/security/sectrustresulttype/unspecified))
///- MacOS ([Official API - SecTrustResultType.unspecified](https://developer.apple.com/documentation/security/sectrustresulttype/unspecified))
static final UNSPECIFIED =
SslErrorType._internalMultiPlatform('UNSPECIFIED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 4;
case TargetPlatform.macOS:
return 4;
default:
break;
}
@ -160,11 +169,14 @@ class SslErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - SecTrustResultType.recoverableTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/recoverabletrustfailure))
///- MacOS ([Official API - SecTrustResultType.recoverableTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/recoverabletrustfailure))
static final RECOVERABLE_TRUST_FAILURE =
SslErrorType._internalMultiPlatform('RECOVERABLE_TRUST_FAILURE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 5;
case TargetPlatform.macOS:
return 5;
default:
break;
}
@ -180,11 +192,14 @@ class SslErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - SecTrustResultType.fatalTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/fataltrustfailure))
///- MacOS ([Official API - SecTrustResultType.fatalTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/fataltrustfailure))
static final FATAL_TRUST_FAILURE =
SslErrorType._internalMultiPlatform('FATAL_TRUST_FAILURE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 6;
case TargetPlatform.macOS:
return 6;
default:
break;
}
@ -198,11 +213,14 @@ class SslErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - SecTrustResultType.otherError](https://developer.apple.com/documentation/security/sectrustresulttype/othererror))
///- MacOS ([Official API - SecTrustResultType.otherError](https://developer.apple.com/documentation/security/sectrustresulttype/othererror))
static final OTHER_ERROR =
SslErrorType._internalMultiPlatform('OTHER_ERROR', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return 7;
case TargetPlatform.macOS:
return 7;
default:
break;
}

View File

@ -32,6 +32,11 @@ class WebResourceErrorType_ {
'https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_BAD_URL',
value: -12),
EnumIOSPlatform(
apiName: 'URLError.badURL',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293516-badurl',
value: -1000),
EnumMacOSPlatform(
apiName: 'URLError.badURL',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293516-badurl',
@ -47,6 +52,11 @@ class WebResourceErrorType_ {
'https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_CONNECT',
value: -6),
EnumIOSPlatform(
apiName: 'URLError.cannotConnectToHost',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost',
value: -1004),
EnumMacOSPlatform(
apiName: 'URLError.cannotConnectToHost',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost',
@ -85,6 +95,11 @@ class WebResourceErrorType_ {
'https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FILE_NOT_FOUND',
value: -14),
EnumIOSPlatform(
apiName: 'URLError.fileDoesNotExist',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883074-filedoesnotexist',
value: -1100),
EnumMacOSPlatform(
apiName: 'URLError.fileDoesNotExist',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883074-filedoesnotexist',
@ -101,6 +116,11 @@ class WebResourceErrorType_ {
'https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_HOST_LOOKUP',
value: -2),
EnumIOSPlatform(
apiName: 'URLError.cannotFindHost',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost',
value: -1003),
EnumMacOSPlatform(
apiName: 'URLError.cannotFindHost',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost',
@ -137,6 +157,11 @@ class WebResourceErrorType_ {
'https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_REDIRECT_LOOP',
value: -9),
EnumIOSPlatform(
apiName: 'URLError.httpTooManyRedirects',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883099-httptoomanyredirects',
value: -1007),
EnumMacOSPlatform(
apiName: 'URLError.httpTooManyRedirects',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883099-httptoomanyredirects',
@ -153,6 +178,11 @@ class WebResourceErrorType_ {
'https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TIMEOUT',
value: -8),
EnumIOSPlatform(
apiName: 'URLError.timedOut',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout',
value: -1001),
EnumMacOSPlatform(
apiName: 'URLError.timedOut',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout',
@ -179,6 +209,11 @@ class WebResourceErrorType_ {
'https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNKNOWN',
value: -1),
EnumIOSPlatform(
apiName: 'URLError.unknown',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown',
value: -1),
EnumMacOSPlatform(
apiName: 'URLError.unknown',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown',
@ -217,6 +252,11 @@ class WebResourceErrorType_ {
'https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSUPPORTED_SCHEME',
value: -10),
EnumIOSPlatform(
apiName: 'URLError.unsupportedURL',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883043-unsupportedurl',
value: -1002),
EnumMacOSPlatform(
apiName: 'URLError.unsupportedURL',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883043-unsupportedurl',
@ -228,6 +268,11 @@ class WebResourceErrorType_ {
///An asynchronous load has been canceled.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cancelled',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled',
value: -999),
EnumMacOSPlatform(
apiName: 'URLError.cancelled',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled',
@ -238,6 +283,11 @@ class WebResourceErrorType_ {
///A client or server connection was severed in the middle of an in-progress load.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.networkConnectionLost',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost',
value: -1005),
EnumMacOSPlatform(
apiName: 'URLError.networkConnectionLost',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost',
@ -250,6 +300,11 @@ class WebResourceErrorType_ {
///This error can indicate a file-not-found situation, or decoding problems that prevent data from being processed correctly.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.resourceUnavailable',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293555-resourceunavailable',
value: -1008),
EnumMacOSPlatform(
apiName: 'URLError.resourceUnavailable',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293555-resourceunavailable',
@ -261,6 +316,11 @@ class WebResourceErrorType_ {
///A network resource was requested, but an internet connection hasnt been established and cant be established automatically.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.notConnectedToInternet',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293104-notconnectedtointernet',
value: -1009),
EnumMacOSPlatform(
apiName: 'URLError.notConnectedToInternet',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293104-notconnectedtointernet',
@ -272,6 +332,11 @@ class WebResourceErrorType_ {
///A redirect was specified by way of server response code, but the server didnt accompany this code with a redirect URL.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.redirectToNonExistentLocation',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293066-redirecttononexistentlocation',
value: -1010),
EnumMacOSPlatform(
apiName: 'URLError.redirectToNonExistentLocation',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293066-redirecttononexistentlocation',
@ -283,6 +348,11 @@ class WebResourceErrorType_ {
///The URL Loading System received bad data from the server.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.badServerResponse',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse',
value: -1011),
EnumMacOSPlatform(
apiName: 'URLError.badServerResponse',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse',
@ -295,6 +365,11 @@ class WebResourceErrorType_ {
///This error typically occurs when a user clicks a "Cancel" button in a username/password dialog, rather than attempting to authenticate.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.userCancelledAuthentication',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293330-usercancelledauthentication',
value: -1012),
EnumMacOSPlatform(
apiName: 'URLError.userCancelledAuthentication',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293330-usercancelledauthentication',
@ -306,6 +381,11 @@ class WebResourceErrorType_ {
///Authentication is required to access a resource.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.userAuthenticationRequired',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired',
value: -1013),
EnumMacOSPlatform(
apiName: 'URLError.userAuthenticationRequired',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired',
@ -317,6 +397,11 @@ class WebResourceErrorType_ {
///A server reported that a URL has a non-zero content length, but terminated the network connection gracefully without sending any data.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.zeroByteResource',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293773-zerobyteresource',
value: -1014),
EnumMacOSPlatform(
apiName: 'URLError.zeroByteResource',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293773-zerobyteresource',
@ -328,6 +413,11 @@ class WebResourceErrorType_ {
///Content data received during a connection request couldnt be decoded for a known content encoding.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cannotDecodeRawData',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293573-cannotdecoderawdata',
value: -1015),
EnumMacOSPlatform(
apiName: 'URLError.cannotDecodeRawData',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2293573-cannotdecoderawdata',
@ -339,6 +429,11 @@ class WebResourceErrorType_ {
///Content data received during a connection request couldnt be decoded for a known content encoding.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cannotDecodeContentData',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2292983-cannotdecodecontentdata',
value: -1016),
EnumMacOSPlatform(
apiName: 'URLError.cannotDecodeContentData',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/2292983-cannotdecodecontentdata',
@ -350,6 +445,11 @@ class WebResourceErrorType_ {
///A task could not parse a response.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cannotParseResponse',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882919-cannotparseresponse',
value: -1017),
EnumMacOSPlatform(
apiName: 'URLError.cannotParseResponse',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882919-cannotparseresponse',
@ -364,6 +464,11 @@ class WebResourceErrorType_ {
///- iOS ([Official API - URLError.appTransportSecurityRequiresSecureConnection](https://developer.apple.com/documentation/foundation/urlerror/code/2882980-apptransportsecurityrequiressecu))
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.appTransportSecurityRequiresSecureConnection',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882980-apptransportsecurityrequiressecu',
value: -1022),
EnumMacOSPlatform(
apiName: 'URLError.appTransportSecurityRequiresSecureConnection',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882980-apptransportsecurityrequiressecu',
@ -376,6 +481,11 @@ class WebResourceErrorType_ {
///A request for an FTP file resulted in the server responding that the file is not a plain file, but a directory.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.fileIsDirectory',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883220-fileisdirectory',
value: -1101),
EnumMacOSPlatform(
apiName: 'URLError.fileIsDirectory',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883220-fileisdirectory',
@ -387,6 +497,11 @@ class WebResourceErrorType_ {
///A resource couldnt be read because of insufficient permissions.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.noPermissionsToReadFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882941-nopermissionstoreadfile',
value: -1102),
EnumMacOSPlatform(
apiName: 'URLError.noPermissionsToReadFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882941-nopermissionstoreadfile',
@ -398,6 +513,11 @@ class WebResourceErrorType_ {
///The length of the resource data exceeds the maximum allowed.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.dataLengthExceedsMaximum',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882930-datalengthexceedsmaximum',
value: -1103),
EnumMacOSPlatform(
apiName: 'URLError.dataLengthExceedsMaximum',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882930-datalengthexceedsmaximum',
@ -409,6 +529,11 @@ class WebResourceErrorType_ {
///An attempt to establish a secure connection failed for reasons that cant be expressed more specifically.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.secureConnectionFailed',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883122-secureconnectionfailed',
value: -1200),
EnumMacOSPlatform(
apiName: 'URLError.secureConnectionFailed',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883122-secureconnectionfailed',
@ -420,6 +545,11 @@ class WebResourceErrorType_ {
///A server certificate had a date which indicates it has expired, or is not yet valid.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.serverCertificateHasBadDate',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883088-servercertificatehasbaddate',
value: -1201),
EnumMacOSPlatform(
apiName: 'URLError.serverCertificateHasBadDate',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883088-servercertificatehasbaddate',
@ -431,6 +561,11 @@ class WebResourceErrorType_ {
///A server certificate was signed by a root server that isnt trusted.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.serverCertificateUntrusted',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882976-servercertificateuntrusted',
value: -1202),
EnumMacOSPlatform(
apiName: 'URLError.serverCertificateUntrusted',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882976-servercertificateuntrusted',
@ -445,6 +580,11 @@ class WebResourceErrorType_ {
///- iOS ([Official API - URLError.serverCertificateHasUnknownRoot](https://developer.apple.com/documentation/foundation/urlerror/code/2883085-servercertificatehasunknownroot))
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.serverCertificateHasUnknownRoot',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883085-servercertificatehasunknownroot',
value: -1203),
EnumMacOSPlatform(
apiName: 'URLError.serverCertificateHasUnknownRoot',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883085-servercertificatehasunknownroot',
@ -459,6 +599,11 @@ class WebResourceErrorType_ {
///- iOS ([Official API - URLError.serverCertificateNotYetValid](https://developer.apple.com/documentation/foundation/urlerror/code/2882991-servercertificatenotyetvalid))
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.serverCertificateNotYetValid',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882991-servercertificatenotyetvalid',
value: -1204),
EnumMacOSPlatform(
apiName: 'URLError.serverCertificateNotYetValid',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882991-servercertificatenotyetvalid',
@ -470,6 +615,11 @@ class WebResourceErrorType_ {
///A server certificate was rejected.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.clientCertificateRejected',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883091-clientcertificaterejected',
value: -1205),
EnumMacOSPlatform(
apiName: 'URLError.clientCertificateRejected',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883091-clientcertificaterejected',
@ -481,6 +631,11 @@ class WebResourceErrorType_ {
///A client certificate was required to authenticate an SSL connection during a request.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.clientCertificateRequired',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883199-clientcertificaterequired',
value: -1206),
EnumMacOSPlatform(
apiName: 'URLError.clientCertificateRequired',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883199-clientcertificaterequired',
@ -492,6 +647,11 @@ class WebResourceErrorType_ {
///A request to load an item only from the cache could not be satisfied.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cannotLoadFromNetwork',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882968-cannotloadfromnetwork',
value: -2000),
EnumMacOSPlatform(
apiName: 'URLError.cannotLoadFromNetwork',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882968-cannotloadfromnetwork',
@ -503,6 +663,11 @@ class WebResourceErrorType_ {
///A download task couldnt create the downloaded file on disk because of an I/O failure.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cannotCreateFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883204-cannotcreatefile',
value: -3000),
EnumMacOSPlatform(
apiName: 'URLError.cannotCreateFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883204-cannotcreatefile',
@ -514,6 +679,11 @@ class WebResourceErrorType_ {
///A download task was unable to open the downloaded file on disk.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cannotOpenFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883034-cannotopenfile',
value: -3001),
EnumMacOSPlatform(
apiName: 'URLError.cannotOpenFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883034-cannotopenfile',
@ -525,6 +695,11 @@ class WebResourceErrorType_ {
///A download task couldnt close the downloaded file on disk.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cannotCloseFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883215-cannotclosefile',
value: -3002),
EnumMacOSPlatform(
apiName: 'URLError.cannotCloseFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883215-cannotclosefile',
@ -536,6 +711,11 @@ class WebResourceErrorType_ {
///A download task was unable to write to the downloaded file on disk.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cannotWriteToFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883098-cannotwritetofile',
value: -3003),
EnumMacOSPlatform(
apiName: 'URLError.cannotWriteToFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883098-cannotwritetofile',
@ -547,6 +727,11 @@ class WebResourceErrorType_ {
///A download task was unable to remove a downloaded file from disk.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cannotRemoveFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883202-cannotremovefile',
value: -3004),
EnumMacOSPlatform(
apiName: 'URLError.cannotRemoveFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883202-cannotremovefile',
@ -558,6 +743,11 @@ class WebResourceErrorType_ {
///A download task was unable to move a downloaded file on disk.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.cannotMoveFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883180-cannotmovefile',
value: -3005),
EnumMacOSPlatform(
apiName: 'URLError.cannotMoveFile',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883180-cannotmovefile',
@ -572,6 +762,11 @@ class WebResourceErrorType_ {
///- iOS ([Official API - URLError.downloadDecodingFailedMidStream](https://developer.apple.com/documentation/foundation/urlerror/code/2883224-downloaddecodingfailedmidstream))
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.downloadDecodingFailedMidStream',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883224-downloaddecodingfailedmidstream',
value: -3006),
EnumMacOSPlatform(
apiName: 'URLError.downloadDecodingFailedMidStream',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883224-downloaddecodingfailedmidstream',
@ -586,6 +781,11 @@ class WebResourceErrorType_ {
///- iOS ([Official API - URLError.downloadDecodingFailedToComplete](https://developer.apple.com/documentation/foundation/urlerror/code/2882936-downloaddecodingfailedtocomplete))
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.downloadDecodingFailedToComplete',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882936-downloaddecodingfailedtocomplete',
value: -3007),
EnumMacOSPlatform(
apiName: 'URLError.downloadDecodingFailedToComplete',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882936-downloaddecodingfailedtocomplete',
@ -597,6 +797,11 @@ class WebResourceErrorType_ {
///The attempted connection required activating a data context while roaming, but international roaming is disabled.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.internationalRoamingOff',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883134-internationalroamingoff',
value: -1018),
EnumMacOSPlatform(
apiName: 'URLError.internationalRoamingOff',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883134-internationalroamingoff',
@ -608,6 +813,11 @@ class WebResourceErrorType_ {
///A connection was attempted while a phone call is active on a network that does not support simultaneous phone and data communication (EDGE or GPRS).
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.callIsActive',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883170-callisactive',
value: -1019),
EnumMacOSPlatform(
apiName: 'URLError.callIsActive',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883170-callisactive',
@ -619,6 +829,11 @@ class WebResourceErrorType_ {
///The cellular network disallowed a connection.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.dataNotAllowed',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883217-datanotallowed',
value: -1020),
EnumMacOSPlatform(
apiName: 'URLError.dataNotAllowed',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883217-datanotallowed',
@ -630,6 +845,11 @@ class WebResourceErrorType_ {
///A body stream is needed but the client did not provide one.
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.requestBodyStreamExhausted',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883176-requestbodystreamexhausted',
value: -1021),
EnumMacOSPlatform(
apiName: 'URLError.requestBodyStreamExhausted',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883176-requestbodystreamexhausted',
@ -644,6 +864,11 @@ class WebResourceErrorType_ {
///- iOS ([Official API - URLError.backgroundSessionRequiresSharedContainer](https://developer.apple.com/documentation/foundation/urlerror/code/2883169-backgroundsessionrequiressharedc))
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.backgroundSessionRequiresSharedContainer',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883169-backgroundsessionrequiressharedc',
value: -995),
EnumMacOSPlatform(
apiName: 'URLError.backgroundSessionRequiresSharedContainer',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883169-backgroundsessionrequiressharedc',
@ -659,6 +884,11 @@ class WebResourceErrorType_ {
///- iOS ([Official API - URLError.backgroundSessionInUseByAnotherProcess](https://developer.apple.com/documentation/foundation/urlerror/code/2882923-backgroundsessioninusebyanotherp))
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.backgroundSessionInUseByAnotherProcess',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882923-backgroundsessioninusebyanotherp',
value: -996),
EnumMacOSPlatform(
apiName: 'URLError.backgroundSessionInUseByAnotherProcess',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2882923-backgroundsessioninusebyanotherp',
@ -674,6 +904,11 @@ class WebResourceErrorType_ {
///- iOS ([Official API - URLError.backgroundSessionWasDisconnected](https://developer.apple.com/documentation/foundation/urlerror/code/2883075-backgroundsessionwasdisconnected))
@EnumSupportedPlatforms(platforms: [
EnumIOSPlatform(
apiName: 'URLError.backgroundSessionWasDisconnected',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883075-backgroundsessionwasdisconnected',
value: -997),
EnumMacOSPlatform(
apiName: 'URLError.backgroundSessionWasDisconnected',
apiUrl:
'https://developer.apple.com/documentation/foundation/urlerror/code/2883075-backgroundsessionwasdisconnected',

View File

@ -37,6 +37,7 @@ class WebResourceErrorType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.ERROR_BAD_URL](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_BAD_URL))
///- iOS ([Official API - URLError.badURL](https://developer.apple.com/documentation/foundation/urlerror/2293516-badurl))
///- MacOS ([Official API - URLError.badURL](https://developer.apple.com/documentation/foundation/urlerror/2293516-badurl))
static final BAD_URL =
WebResourceErrorType._internalMultiPlatform('BAD_URL', () {
switch (defaultTargetPlatform) {
@ -44,6 +45,8 @@ class WebResourceErrorType {
return -12;
case TargetPlatform.iOS:
return -1000;
case TargetPlatform.macOS:
return -1000;
default:
break;
}
@ -55,6 +58,7 @@ class WebResourceErrorType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.ERROR_CONNECT](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_CONNECT))
///- iOS ([Official API - URLError.cannotConnectToHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost))
///- MacOS ([Official API - URLError.cannotConnectToHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost))
static final CANNOT_CONNECT_TO_HOST =
WebResourceErrorType._internalMultiPlatform('CANNOT_CONNECT_TO_HOST', () {
switch (defaultTargetPlatform) {
@ -62,6 +66,8 @@ class WebResourceErrorType {
return -6;
case TargetPlatform.iOS:
return -1004;
case TargetPlatform.macOS:
return -1004;
default:
break;
}
@ -103,6 +109,7 @@ class WebResourceErrorType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.ERROR_FILE_NOT_FOUND](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FILE_NOT_FOUND))
///- iOS ([Official API - URLError.fileDoesNotExist](https://developer.apple.com/documentation/foundation/urlerror/code/2883074-filedoesnotexist))
///- MacOS ([Official API - URLError.fileDoesNotExist](https://developer.apple.com/documentation/foundation/urlerror/code/2883074-filedoesnotexist))
static final FILE_NOT_FOUND =
WebResourceErrorType._internalMultiPlatform('FILE_NOT_FOUND', () {
switch (defaultTargetPlatform) {
@ -110,6 +117,8 @@ class WebResourceErrorType {
return -14;
case TargetPlatform.iOS:
return -1100;
case TargetPlatform.macOS:
return -1100;
default:
break;
}
@ -121,6 +130,7 @@ class WebResourceErrorType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.ERROR_HOST_LOOKUP](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_HOST_LOOKUP))
///- iOS ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost))
///- MacOS ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost))
static final HOST_LOOKUP =
WebResourceErrorType._internalMultiPlatform('HOST_LOOKUP', () {
switch (defaultTargetPlatform) {
@ -128,6 +138,8 @@ class WebResourceErrorType {
return -2;
case TargetPlatform.iOS:
return -1003;
case TargetPlatform.macOS:
return -1003;
default:
break;
}
@ -168,6 +180,7 @@ class WebResourceErrorType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.ERROR_REDIRECT_LOOP](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_REDIRECT_LOOP))
///- iOS ([Official API - URLError.httpTooManyRedirects](https://developer.apple.com/documentation/foundation/urlerror/code/2883099-httptoomanyredirects))
///- MacOS ([Official API - URLError.httpTooManyRedirects](https://developer.apple.com/documentation/foundation/urlerror/code/2883099-httptoomanyredirects))
static final TOO_MANY_REDIRECTS =
WebResourceErrorType._internalMultiPlatform('TOO_MANY_REDIRECTS', () {
switch (defaultTargetPlatform) {
@ -175,6 +188,8 @@ class WebResourceErrorType {
return -9;
case TargetPlatform.iOS:
return -1007;
case TargetPlatform.macOS:
return -1007;
default:
break;
}
@ -186,6 +201,7 @@ class WebResourceErrorType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.ERROR_TIMEOUT](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TIMEOUT))
///- iOS ([Official API - URLError.timedOut](https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout))
///- MacOS ([Official API - URLError.timedOut](https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout))
static final TIMEOUT =
WebResourceErrorType._internalMultiPlatform('TIMEOUT', () {
switch (defaultTargetPlatform) {
@ -193,6 +209,8 @@ class WebResourceErrorType {
return -8;
case TargetPlatform.iOS:
return -1001;
case TargetPlatform.macOS:
return -1001;
default:
break;
}
@ -219,6 +237,7 @@ class WebResourceErrorType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.ERROR_UNKNOWN](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNKNOWN))
///- iOS ([Official API - URLError.unknown](https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown))
///- MacOS ([Official API - URLError.unknown](https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown))
static final UNKNOWN =
WebResourceErrorType._internalMultiPlatform('UNKNOWN', () {
switch (defaultTargetPlatform) {
@ -226,6 +245,8 @@ class WebResourceErrorType {
return -1;
case TargetPlatform.iOS:
return -1;
case TargetPlatform.macOS:
return -1;
default:
break;
}
@ -269,6 +290,7 @@ class WebResourceErrorType {
///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.ERROR_UNSUPPORTED_SCHEME](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSUPPORTED_SCHEME))
///- iOS ([Official API - URLError.unsupportedURL](https://developer.apple.com/documentation/foundation/urlerror/code/2883043-unsupportedurl))
///- MacOS ([Official API - URLError.unsupportedURL](https://developer.apple.com/documentation/foundation/urlerror/code/2883043-unsupportedurl))
static final UNSUPPORTED_SCHEME =
WebResourceErrorType._internalMultiPlatform('UNSUPPORTED_SCHEME', () {
switch (defaultTargetPlatform) {
@ -276,6 +298,8 @@ class WebResourceErrorType {
return -10;
case TargetPlatform.iOS:
return -1002;
case TargetPlatform.macOS:
return -1002;
default:
break;
}
@ -286,11 +310,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cancelled](https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled))
///- MacOS ([Official API - URLError.cancelled](https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled))
static final CANCELLED =
WebResourceErrorType._internalMultiPlatform('CANCELLED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -999;
case TargetPlatform.macOS:
return -999;
default:
break;
}
@ -301,12 +328,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.networkConnectionLost](https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost))
///- MacOS ([Official API - URLError.networkConnectionLost](https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost))
static final NETWORK_CONNECTION_LOST =
WebResourceErrorType._internalMultiPlatform('NETWORK_CONNECTION_LOST',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1005;
case TargetPlatform.macOS:
return -1005;
default:
break;
}
@ -318,11 +348,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.resourceUnavailable](https://developer.apple.com/documentation/foundation/urlerror/2293555-resourceunavailable))
///- MacOS ([Official API - URLError.resourceUnavailable](https://developer.apple.com/documentation/foundation/urlerror/2293555-resourceunavailable))
static final RESOURCE_UNAVAILABLE =
WebResourceErrorType._internalMultiPlatform('RESOURCE_UNAVAILABLE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1008;
case TargetPlatform.macOS:
return -1008;
default:
break;
}
@ -333,12 +366,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.notConnectedToInternet](https://developer.apple.com/documentation/foundation/urlerror/2293104-notconnectedtointernet))
///- MacOS ([Official API - URLError.notConnectedToInternet](https://developer.apple.com/documentation/foundation/urlerror/2293104-notconnectedtointernet))
static final NOT_CONNECTED_TO_INTERNET =
WebResourceErrorType._internalMultiPlatform('NOT_CONNECTED_TO_INTERNET',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1009;
case TargetPlatform.macOS:
return -1009;
default:
break;
}
@ -349,12 +385,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.redirectToNonExistentLocation](https://developer.apple.com/documentation/foundation/urlerror/2293066-redirecttononexistentlocation))
///- MacOS ([Official API - URLError.redirectToNonExistentLocation](https://developer.apple.com/documentation/foundation/urlerror/2293066-redirecttononexistentlocation))
static final REDIRECT_TO_NON_EXISTENT_LOCATION =
WebResourceErrorType._internalMultiPlatform(
'REDIRECT_TO_NON_EXISTENT_LOCATION', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1010;
case TargetPlatform.macOS:
return -1010;
default:
break;
}
@ -365,11 +404,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.badServerResponse](https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse))
///- MacOS ([Official API - URLError.badServerResponse](https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse))
static final BAD_SERVER_RESPONSE =
WebResourceErrorType._internalMultiPlatform('BAD_SERVER_RESPONSE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1011;
case TargetPlatform.macOS:
return -1011;
default:
break;
}
@ -381,12 +423,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.userCancelledAuthentication](https://developer.apple.com/documentation/foundation/urlerror/2293330-usercancelledauthentication))
///- MacOS ([Official API - URLError.userCancelledAuthentication](https://developer.apple.com/documentation/foundation/urlerror/2293330-usercancelledauthentication))
static final USER_CANCELLED_AUTHENTICATION =
WebResourceErrorType._internalMultiPlatform(
'USER_CANCELLED_AUTHENTICATION', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1012;
case TargetPlatform.macOS:
return -1012;
default:
break;
}
@ -397,12 +442,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.userAuthenticationRequired](https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired))
///- MacOS ([Official API - URLError.userAuthenticationRequired](https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired))
static final USER_AUTHENTICATION_REQUIRED =
WebResourceErrorType._internalMultiPlatform(
'USER_AUTHENTICATION_REQUIRED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1013;
case TargetPlatform.macOS:
return -1013;
default:
break;
}
@ -413,11 +461,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.zeroByteResource](https://developer.apple.com/documentation/foundation/urlerror/2293773-zerobyteresource))
///- MacOS ([Official API - URLError.zeroByteResource](https://developer.apple.com/documentation/foundation/urlerror/2293773-zerobyteresource))
static final ZERO_BYTE_RESOURCE =
WebResourceErrorType._internalMultiPlatform('ZERO_BYTE_RESOURCE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1014;
case TargetPlatform.macOS:
return -1014;
default:
break;
}
@ -428,11 +479,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cannotDecodeRawData](https://developer.apple.com/documentation/foundation/urlerror/2293573-cannotdecoderawdata))
///- MacOS ([Official API - URLError.cannotDecodeRawData](https://developer.apple.com/documentation/foundation/urlerror/2293573-cannotdecoderawdata))
static final CANNOT_DECODE_RAW_DATA =
WebResourceErrorType._internalMultiPlatform('CANNOT_DECODE_RAW_DATA', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1015;
case TargetPlatform.macOS:
return -1015;
default:
break;
}
@ -443,12 +497,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cannotDecodeContentData](https://developer.apple.com/documentation/foundation/urlerror/2292983-cannotdecodecontentdata))
///- MacOS ([Official API - URLError.cannotDecodeContentData](https://developer.apple.com/documentation/foundation/urlerror/2292983-cannotdecodecontentdata))
static final CANNOT_DECODE_CONTENT_DATA =
WebResourceErrorType._internalMultiPlatform('CANNOT_DECODE_CONTENT_DATA',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1016;
case TargetPlatform.macOS:
return -1016;
default:
break;
}
@ -459,11 +516,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cannotParseResponse](https://developer.apple.com/documentation/foundation/urlerror/code/2882919-cannotparseresponse))
///- MacOS ([Official API - URLError.cannotParseResponse](https://developer.apple.com/documentation/foundation/urlerror/code/2882919-cannotparseresponse))
static final CANNOT_PARSE_RESPONSE =
WebResourceErrorType._internalMultiPlatform('CANNOT_PARSE_RESPONSE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1017;
case TargetPlatform.macOS:
return -1017;
default:
break;
}
@ -477,12 +537,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.appTransportSecurityRequiresSecureConnection](https://developer.apple.com/documentation/foundation/urlerror/code/2882980-apptransportsecurityrequiressecu))
///- MacOS ([Official API - URLError.appTransportSecurityRequiresSecureConnection](https://developer.apple.com/documentation/foundation/urlerror/code/2882980-apptransportsecurityrequiressecu))
static final APP_TRANSPORT_SECURITY_REQUIRES_SECURE_CONNECTION =
WebResourceErrorType._internalMultiPlatform(
'APP_TRANSPORT_SECURITY_REQUIRES_SECURE_CONNECTION', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1022;
case TargetPlatform.macOS:
return -1022;
default:
break;
}
@ -493,11 +556,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.fileIsDirectory](https://developer.apple.com/documentation/foundation/urlerror/code/2883220-fileisdirectory))
///- MacOS ([Official API - URLError.fileIsDirectory](https://developer.apple.com/documentation/foundation/urlerror/code/2883220-fileisdirectory))
static final FILE_IS_DIRECTORY =
WebResourceErrorType._internalMultiPlatform('FILE_IS_DIRECTORY', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1101;
case TargetPlatform.macOS:
return -1101;
default:
break;
}
@ -508,12 +574,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.noPermissionsToReadFile](https://developer.apple.com/documentation/foundation/urlerror/code/2882941-nopermissionstoreadfile))
///- MacOS ([Official API - URLError.noPermissionsToReadFile](https://developer.apple.com/documentation/foundation/urlerror/code/2882941-nopermissionstoreadfile))
static final NO_PERMISSIONS_TO_READ_FILE =
WebResourceErrorType._internalMultiPlatform('NO_PERMISSIONS_TO_READ_FILE',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1102;
case TargetPlatform.macOS:
return -1102;
default:
break;
}
@ -524,12 +593,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.dataLengthExceedsMaximum](https://developer.apple.com/documentation/foundation/urlerror/code/2882930-datalengthexceedsmaximum))
///- MacOS ([Official API - URLError.dataLengthExceedsMaximum](https://developer.apple.com/documentation/foundation/urlerror/code/2882930-datalengthexceedsmaximum))
static final DATA_LENGTH_EXCEEDS_MAXIMUM =
WebResourceErrorType._internalMultiPlatform('DATA_LENGTH_EXCEEDS_MAXIMUM',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1103;
case TargetPlatform.macOS:
return -1103;
default:
break;
}
@ -540,12 +612,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.secureConnectionFailed](https://developer.apple.com/documentation/foundation/urlerror/code/2883122-secureconnectionfailed))
///- MacOS ([Official API - URLError.secureConnectionFailed](https://developer.apple.com/documentation/foundation/urlerror/code/2883122-secureconnectionfailed))
static final SECURE_CONNECTION_FAILED =
WebResourceErrorType._internalMultiPlatform('SECURE_CONNECTION_FAILED',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1200;
case TargetPlatform.macOS:
return -1200;
default:
break;
}
@ -556,12 +631,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.serverCertificateHasBadDate](https://developer.apple.com/documentation/foundation/urlerror/code/2883088-servercertificatehasbaddate))
///- MacOS ([Official API - URLError.serverCertificateHasBadDate](https://developer.apple.com/documentation/foundation/urlerror/code/2883088-servercertificatehasbaddate))
static final SERVER_CERTIFICATE_HAS_BAD_DATE =
WebResourceErrorType._internalMultiPlatform(
'SERVER_CERTIFICATE_HAS_BAD_DATE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1201;
case TargetPlatform.macOS:
return -1201;
default:
break;
}
@ -572,12 +650,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.serverCertificateUntrusted](https://developer.apple.com/documentation/foundation/urlerror/code/2882976-servercertificateuntrusted))
///- MacOS ([Official API - URLError.serverCertificateUntrusted](https://developer.apple.com/documentation/foundation/urlerror/code/2882976-servercertificateuntrusted))
static final SERVER_CERTIFICATE_UNTRUSTED =
WebResourceErrorType._internalMultiPlatform(
'SERVER_CERTIFICATE_UNTRUSTED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1202;
case TargetPlatform.macOS:
return -1202;
default:
break;
}
@ -591,12 +672,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.serverCertificateHasUnknownRoot](https://developer.apple.com/documentation/foundation/urlerror/code/2883085-servercertificatehasunknownroot))
///- MacOS ([Official API - URLError.serverCertificateHasUnknownRoot](https://developer.apple.com/documentation/foundation/urlerror/code/2883085-servercertificatehasunknownroot))
static final SERVER_CERTIFICATE_HAS_UNKNOWN_ROOT =
WebResourceErrorType._internalMultiPlatform(
'SERVER_CERTIFICATE_HAS_UNKNOWN_ROOT', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1203;
case TargetPlatform.macOS:
return -1203;
default:
break;
}
@ -610,12 +694,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.serverCertificateNotYetValid](https://developer.apple.com/documentation/foundation/urlerror/code/2882991-servercertificatenotyetvalid))
///- MacOS ([Official API - URLError.serverCertificateNotYetValid](https://developer.apple.com/documentation/foundation/urlerror/code/2882991-servercertificatenotyetvalid))
static final SERVER_CERTIFICATE_NOT_YET_VALID =
WebResourceErrorType._internalMultiPlatform(
'SERVER_CERTIFICATE_NOT_YET_VALID', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1204;
case TargetPlatform.macOS:
return -1204;
default:
break;
}
@ -626,12 +713,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.clientCertificateRejected](https://developer.apple.com/documentation/foundation/urlerror/code/2883091-clientcertificaterejected))
///- MacOS ([Official API - URLError.clientCertificateRejected](https://developer.apple.com/documentation/foundation/urlerror/code/2883091-clientcertificaterejected))
static final CLIENT_CERTIFICATE_REJECTED =
WebResourceErrorType._internalMultiPlatform('CLIENT_CERTIFICATE_REJECTED',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1205;
case TargetPlatform.macOS:
return -1205;
default:
break;
}
@ -642,12 +732,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.clientCertificateRequired](https://developer.apple.com/documentation/foundation/urlerror/code/2883199-clientcertificaterequired))
///- MacOS ([Official API - URLError.clientCertificateRequired](https://developer.apple.com/documentation/foundation/urlerror/code/2883199-clientcertificaterequired))
static final CLIENT_CERTIFICATE_REQUIRED =
WebResourceErrorType._internalMultiPlatform('CLIENT_CERTIFICATE_REQUIRED',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1206;
case TargetPlatform.macOS:
return -1206;
default:
break;
}
@ -658,12 +751,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cannotLoadFromNetwork](https://developer.apple.com/documentation/foundation/urlerror/code/2882968-cannotloadfromnetwork))
///- MacOS ([Official API - URLError.cannotLoadFromNetwork](https://developer.apple.com/documentation/foundation/urlerror/code/2882968-cannotloadfromnetwork))
static final CANNOT_LOAD_FROM_NETWORK =
WebResourceErrorType._internalMultiPlatform('CANNOT_LOAD_FROM_NETWORK',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -2000;
case TargetPlatform.macOS:
return -2000;
default:
break;
}
@ -674,11 +770,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cannotCreateFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883204-cannotcreatefile))
///- MacOS ([Official API - URLError.cannotCreateFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883204-cannotcreatefile))
static final CANNOT_CREATE_FILE =
WebResourceErrorType._internalMultiPlatform('CANNOT_CREATE_FILE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -3000;
case TargetPlatform.macOS:
return -3000;
default:
break;
}
@ -689,11 +788,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cannotOpenFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883034-cannotopenfile))
///- MacOS ([Official API - URLError.cannotOpenFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883034-cannotopenfile))
static final CANNOT_OPEN_FILE =
WebResourceErrorType._internalMultiPlatform('CANNOT_OPEN_FILE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -3001;
case TargetPlatform.macOS:
return -3001;
default:
break;
}
@ -704,11 +806,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cannotCloseFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883215-cannotclosefile))
///- MacOS ([Official API - URLError.cannotCloseFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883215-cannotclosefile))
static final CANNOT_CLOSE_FILE =
WebResourceErrorType._internalMultiPlatform('CANNOT_CLOSE_FILE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -3002;
case TargetPlatform.macOS:
return -3002;
default:
break;
}
@ -719,11 +824,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cannotWriteToFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883098-cannotwritetofile))
///- MacOS ([Official API - URLError.cannotWriteToFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883098-cannotwritetofile))
static final CANNOT_WRITE_TO_FILE =
WebResourceErrorType._internalMultiPlatform('CANNOT_WRITE_TO_FILE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -3003;
case TargetPlatform.macOS:
return -3003;
default:
break;
}
@ -734,11 +842,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cannotRemoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883202-cannotremovefile))
///- MacOS ([Official API - URLError.cannotRemoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883202-cannotremovefile))
static final CANNOT_REMOVE_FILE =
WebResourceErrorType._internalMultiPlatform('CANNOT_REMOVE_FILE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -3004;
case TargetPlatform.macOS:
return -3004;
default:
break;
}
@ -749,11 +860,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.cannotMoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883180-cannotmovefile))
///- MacOS ([Official API - URLError.cannotMoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883180-cannotmovefile))
static final CANNOT_MOVE_FILE =
WebResourceErrorType._internalMultiPlatform('CANNOT_MOVE_FILE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -3005;
case TargetPlatform.macOS:
return -3005;
default:
break;
}
@ -767,12 +881,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.downloadDecodingFailedMidStream](https://developer.apple.com/documentation/foundation/urlerror/code/2883224-downloaddecodingfailedmidstream))
///- MacOS ([Official API - URLError.downloadDecodingFailedMidStream](https://developer.apple.com/documentation/foundation/urlerror/code/2883224-downloaddecodingfailedmidstream))
static final DOWNLOAD_DECODING_FAILED_MID_STREAM =
WebResourceErrorType._internalMultiPlatform(
'DOWNLOAD_DECODING_FAILED_MID_STREAM', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -3006;
case TargetPlatform.macOS:
return -3006;
default:
break;
}
@ -786,12 +903,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.downloadDecodingFailedToComplete](https://developer.apple.com/documentation/foundation/urlerror/code/2882936-downloaddecodingfailedtocomplete))
///- MacOS ([Official API - URLError.downloadDecodingFailedToComplete](https://developer.apple.com/documentation/foundation/urlerror/code/2882936-downloaddecodingfailedtocomplete))
static final DOWNLOAD_DECODING_FAILED_TO_COMPLETE =
WebResourceErrorType._internalMultiPlatform(
'DOWNLOAD_DECODING_FAILED_TO_COMPLETE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -3007;
case TargetPlatform.macOS:
return -3007;
default:
break;
}
@ -802,12 +922,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.internationalRoamingOff](https://developer.apple.com/documentation/foundation/urlerror/code/2883134-internationalroamingoff))
///- MacOS ([Official API - URLError.internationalRoamingOff](https://developer.apple.com/documentation/foundation/urlerror/code/2883134-internationalroamingoff))
static final INTERNATIONAL_ROAMING_OFF =
WebResourceErrorType._internalMultiPlatform('INTERNATIONAL_ROAMING_OFF',
() {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1018;
case TargetPlatform.macOS:
return -1018;
default:
break;
}
@ -818,11 +941,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.callIsActive](https://developer.apple.com/documentation/foundation/urlerror/code/2883170-callisactive))
///- MacOS ([Official API - URLError.callIsActive](https://developer.apple.com/documentation/foundation/urlerror/code/2883170-callisactive))
static final CALL_IS_ACTIVE =
WebResourceErrorType._internalMultiPlatform('CALL_IS_ACTIVE', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1019;
case TargetPlatform.macOS:
return -1019;
default:
break;
}
@ -833,11 +959,14 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.dataNotAllowed](https://developer.apple.com/documentation/foundation/urlerror/code/2883217-datanotallowed))
///- MacOS ([Official API - URLError.dataNotAllowed](https://developer.apple.com/documentation/foundation/urlerror/code/2883217-datanotallowed))
static final DATA_NOT_ALLOWED =
WebResourceErrorType._internalMultiPlatform('DATA_NOT_ALLOWED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1020;
case TargetPlatform.macOS:
return -1020;
default:
break;
}
@ -848,12 +977,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.requestBodyStreamExhausted](https://developer.apple.com/documentation/foundation/urlerror/code/2883176-requestbodystreamexhausted))
///- MacOS ([Official API - URLError.requestBodyStreamExhausted](https://developer.apple.com/documentation/foundation/urlerror/code/2883176-requestbodystreamexhausted))
static final REQUEST_BODY_STREAM_EXHAUSTED =
WebResourceErrorType._internalMultiPlatform(
'REQUEST_BODY_STREAM_EXHAUSTED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -1021;
case TargetPlatform.macOS:
return -1021;
default:
break;
}
@ -867,12 +999,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.backgroundSessionRequiresSharedContainer](https://developer.apple.com/documentation/foundation/urlerror/code/2883169-backgroundsessionrequiressharedc))
///- MacOS ([Official API - URLError.backgroundSessionRequiresSharedContainer](https://developer.apple.com/documentation/foundation/urlerror/code/2883169-backgroundsessionrequiressharedc))
static final BACKGROUND_SESSION_REQUIRES_SHARED_CONTAINER =
WebResourceErrorType._internalMultiPlatform(
'BACKGROUND_SESSION_REQUIRES_SHARED_CONTAINER', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -995;
case TargetPlatform.macOS:
return -995;
default:
break;
}
@ -886,12 +1021,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.backgroundSessionInUseByAnotherProcess](https://developer.apple.com/documentation/foundation/urlerror/code/2882923-backgroundsessioninusebyanotherp))
///- MacOS ([Official API - URLError.backgroundSessionInUseByAnotherProcess](https://developer.apple.com/documentation/foundation/urlerror/code/2882923-backgroundsessioninusebyanotherp))
static final BACKGROUND_SESSION_IN_USE_BY_ANOTHER_PROCESS =
WebResourceErrorType._internalMultiPlatform(
'BACKGROUND_SESSION_IN_USE_BY_ANOTHER_PROCESS', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -996;
case TargetPlatform.macOS:
return -996;
default:
break;
}
@ -905,12 +1043,15 @@ class WebResourceErrorType {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - URLError.backgroundSessionWasDisconnected](https://developer.apple.com/documentation/foundation/urlerror/code/2883075-backgroundsessionwasdisconnected))
///- MacOS ([Official API - URLError.backgroundSessionWasDisconnected](https://developer.apple.com/documentation/foundation/urlerror/code/2883075-backgroundsessionwasdisconnected))
static final BACKGROUND_SESSION_WAS_DISCONNECTED =
WebResourceErrorType._internalMultiPlatform(
'BACKGROUND_SESSION_WAS_DISCONNECTED', () {
switch (defaultTargetPlatform) {
case TargetPlatform.iOS:
return -997;
case TargetPlatform.macOS:
return -997;
default:
break;
}

View File

@ -97,7 +97,7 @@ class InAppWebViewWebElement implements Disposable {
return await getSettings();
case "setSettings":
InAppWebViewSettings newSettings = InAppWebViewSettings.fromMap(
call.arguments["settings"].cast<String, dynamic>());
call.arguments["settings"].cast<String, dynamic>()) ?? InAppWebViewSettings();
await setSettings(newSettings);
break;
case "getUrl":
@ -176,7 +176,7 @@ class InAppWebViewWebElement implements Disposable {
Set<Sandbox> sandbox = Set.from(Sandbox.values);
if (!settings.javaScriptEnabled) {
if (settings.javaScriptEnabled != null && !settings.javaScriptEnabled!) {
sandbox.remove(Sandbox.ALLOW_SCRIPTS);
}
@ -403,8 +403,8 @@ class InAppWebViewWebElement implements Disposable {
Future<void> setSettings(InAppWebViewSettings newSettings) async {
Set<Sandbox> sandbox = getSandbox();
if (settings.javaScriptEnabled != newSettings.javaScriptEnabled) {
if (!newSettings.javaScriptEnabled) {
if (newSettings.javaScriptEnabled != null && settings.javaScriptEnabled != newSettings.javaScriptEnabled) {
if (!newSettings.javaScriptEnabled!) {
sandbox.remove(Sandbox.ALLOW_SCRIPTS);
} else {
sandbox.add(Sandbox.ALLOW_SCRIPTS);

View File

@ -16,7 +16,7 @@ typedef WebAuthenticationSessionCompletionHandler = Future<void> Function(
///A session that an app uses to authenticate a user through a web service.
///
///It is implemented using [ASWebAuthenticationSession](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession) on iOS 12.0+
///It is implemented using [ASWebAuthenticationSession](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession) on iOS 12.0+ and MacOS 10.15+
///and [SFAuthenticationSession](https://developer.apple.com/documentation/safariservices/sfauthenticationsession) on iOS 11.0.
///
///Use an [WebAuthenticationSession] instance to authenticate a user through a web service, including one run by a third party.
@ -32,8 +32,11 @@ typedef WebAuthenticationSessionCompletionHandler = Future<void> Function(
///
///**NOTE for iOS**: Available only on iOS 11.0+.
///
///**NOTE for MacOS**: Available only on MacOS 10.15+.
///
///**Supported Platforms/Implementations**:
///- iOS
///- MacOS
class WebAuthenticationSession implements Disposable {
///Debug settings.
static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings();

View File

@ -16,8 +16,11 @@ class WebAuthenticationSessionSettings {
///
///**NOTE for iOS**: Available only on iOS 13.0+.
///
///**NOTE for MacOS**: Available only on iOS 10.15+.
///
///**Supported Platforms/Implementations**:
///- iOS
///- MacOS
bool prefersEphemeralWebBrowserSession;
WebAuthenticationSessionSettings(

View File

@ -3,6 +3,11 @@ import '../types/main.dart';
import '../in_app_webview/in_app_webview_controller.dart';
///The representation of the [HTML5 message channels](https://html.spec.whatwg.org/multipage/web-messaging.html#message-channels).
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
class WebMessageChannel {
///Message Channel ID used internally.
final String id;

View File

@ -3,6 +3,11 @@ import '../in_app_webview/in_app_webview_controller.dart';
import '../types/main.dart';
///This listener receives messages sent on the JavaScript object which was injected by [InAppWebViewController.addWebMessageListener].
///
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
class WebMessageListener {
///The name for the injected JavaScript object.
final String jsObjectName;

View File

@ -9,6 +9,7 @@ import '../types/main.dart';
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
///- Web
class WebStorage {
///Represents `window.localStorage`.

View File

@ -17,6 +17,7 @@ import '../types/main.dart';
///**Supported Platforms/Implementations**:
///- Android native WebView
///- iOS
///- MacOS
class WebStorageManager {
static WebStorageManager? _instance;
static const MethodChannel _staticChannel = WEB_STORAGE_STATIC_CHANNEL;
@ -121,6 +122,7 @@ class WebStorageManager {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebsiteDataStore.fetchDataRecords](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords))
///- MacOS ([Official API - WKWebsiteDataStore.fetchDataRecords](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords))
Future<List<WebsiteDataRecord>> fetchDataRecords(
{required Set<WebsiteDataType> dataTypes}) async {
List<WebsiteDataRecord> recordList = [];
@ -156,6 +158,7 @@ class WebStorageManager {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata))
///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata))
Future<void> removeDataFor(
{required Set<WebsiteDataType> dataTypes,
required List<WebsiteDataRecord> dataRecords}) async {
@ -183,6 +186,7 @@ class WebStorageManager {
///
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
Future<void> removeDataModifiedSince(
{required Set<WebsiteDataType> dataTypes, required DateTime date}) async {
List<String> dataTypesList = [];

View File

@ -71,9 +71,9 @@ public class InAppBrowserManager: ChannelDelegate {
webViewController.initialMimeType = mimeType
webViewController.initialEncoding = encoding
webViewController.initialBaseUrl = baseUrl
webViewController.contextMenu = contextMenu
webViewController.windowId = windowId
webViewController.initialUserScripts = initialUserScripts ?? []
webViewController.isHidden = browserSettings.hidden
let window = InAppBrowserWindow(contentViewController: webViewController)
window.browserSettings = browserSettings

View File

@ -15,18 +15,7 @@ public class InAppBrowserSettings: ISettings<InAppBrowserWebViewController> {
var toolbarTopBackgroundColor: String?
var hideUrlBar = false
var hideProgressBar = false
var toolbarTopTranslucent = true
var toolbarTopBarTintColor: String?
var toolbarTopTintColor: String?
var hideToolbarBottom = true
var toolbarBottomBackgroundColor: String?
var toolbarBottomTintColor: String?
var toolbarBottomTranslucent = true
var closeButtonCaption: String?
var closeButtonColor: String?
var presentationStyle = 0 //fullscreen
var transitionStyle = 0 //crossDissolve
var toolbarTopFixedTitle: String?
override init(){
super.init()
@ -35,10 +24,11 @@ public class InAppBrowserSettings: ISettings<InAppBrowserWebViewController> {
override func getRealSettings(obj: InAppBrowserWebViewController?) -> [String: Any?] {
var realOptions: [String: Any?] = toMap()
if let inAppBrowserWebViewController = obj {
realOptions["hidden"] = inAppBrowserWebViewController.isHidden
realOptions["hideUrlBar"] = inAppBrowserWebViewController.window?.searchBar?.isHidden
realOptions["progressBar"] = inAppBrowserWebViewController.progressBar.isHidden
realOptions["hideToolbarTop"] = !(inAppBrowserWebViewController.window?.toolbar?.isVisible ?? true)
realOptions["toolbarTopBackgroundColor"] = inAppBrowserWebViewController.window?.backgroundColor
realOptions["toolbarTopBackgroundColor"] = inAppBrowserWebViewController.window?.backgroundColor.hexString
}
return realOptions
}

View File

@ -22,7 +22,6 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega
var channelDelegate: InAppBrowserChannelDelegate?
var initialUrlRequest: URLRequest?
var initialFile: String?
var contextMenu: [String: Any]?
var browserSettings: InAppBrowserSettings?
var webViewSettings: InAppWebViewSettings?
var initialData: String?
@ -30,6 +29,7 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega
var initialEncoding: String?
var initialBaseUrl: String?
var initialUserScripts: [[String: Any]] = []
var isHidden = false
public override func loadView() {
let channel = FlutterMethodChannel(name: InAppBrowserWebViewController.METHOD_CHANNEL_NAME_PREFIX + id, binaryMessenger: SwiftFlutterPlugin.instance!.registrar!.messenger)
@ -43,14 +43,12 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega
let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(settings: webViewSettings)
if let wId = windowId, let webViewTransport = InAppWebView.windowWebViews[wId] {
webView = webViewTransport.webView
webView!.contextMenu = contextMenu
webView!.initialUserScripts = userScripts
} else {
webView = InAppWebView(id: nil,
registrar: nil,
frame: .zero,
configuration: preWebviewConfiguration,
contextMenu: contextMenu,
userScripts: userScripts)
}
@ -184,7 +182,12 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega
guard let title = title else {
return
}
window?.title = title
if let browserSettings = browserSettings,
let toolbarTopFixedTitle = browserSettings.toolbarTopFixedTitle {
window?.title = toolbarTopFixedTitle
} else {
window?.title = title
}
window?.update()
}
@ -281,10 +284,12 @@ public class InAppBrowserWebViewController: NSViewController, InAppBrowserDelega
}
public func hide() {
isHidden = true
window?.hide()
}
public func show() {
isHidden = false
window?.show()
}

View File

@ -123,6 +123,9 @@ public class InAppBrowserWindow : NSWindow, NSWindowDelegate, NSToolbarDelegate,
backButton?.isEnabled = false
if let browserSettings = browserSettings {
if let toolbarTopFixedTitle = browserSettings.toolbarTopFixedTitle {
title = toolbarTopFixedTitle
}
if !browserSettings.hideToolbarTop {
toolbar?.isVisible = true
if browserSettings.hideUrlBar {

View File

@ -19,7 +19,6 @@ public class FlutterWebViewController: NSObject, /*FlutterPlatformView,*/ Dispos
myView = NSView(frame: frame)
let initialSettings = params["initialSettings"] as! [String: Any?]
let contextMenu = params["contextMenu"] as? [String: Any]
let windowId = params["windowId"] as? Int64
let initialUserScripts = params["initialUserScripts"] as? [[String: Any]]
@ -43,14 +42,12 @@ public class FlutterWebViewController: NSObject, /*FlutterPlatformView,*/ Dispos
binaryMessenger: registrar.messenger)
webView!.channelDelegate = WebViewChannelDelegate(webView: webView!, channel: channel)
webView!.frame = myView!.bounds
webView!.contextMenu = contextMenu
webView!.initialUserScripts = userScripts
} else {
webView = InAppWebView(id: viewId,
registrar: registrar,
frame: myView!.bounds,
configuration: preWebviewConfiguration,
contextMenu: contextMenu,
userScripts: userScripts)
}

View File

@ -38,18 +38,8 @@ public class InAppWebView: WKWebView, WKUIDelegate,
var isPausedTimers = false
var isPausedTimersCompletionHandler: (() -> Void)?
var contextMenu: [String: Any]?
var initialUserScripts: [UserScript] = []
var lastLongPressTouchPoint: CGPoint?
var lastTouchPoint: CGPoint?
var lastTouchPointTimestamp = Int64(Date().timeIntervalSince1970 * 1000)
var contextMenuIsShowing = false
// flag used for the workaround to trigger onCreateContextMenu event as the same on Android
var onCreateContextMenuEventTriggeredWhenMenuDisabled = false
var customIMPs: [IMP] = []
static var windowWebViews: [Int64:WebViewTransport] = [:]
@ -57,10 +47,8 @@ public class InAppWebView: WKWebView, WKUIDelegate,
var callAsyncJavaScriptBelowIOS14Results: [String:((Any?) -> Void)] = [:]
var oldZoomScale = Float(1.0)
init(id: Any?, registrar: FlutterPluginRegistrar?, frame: CGRect, configuration: WKWebViewConfiguration,
contextMenu: [String: Any]?, userScripts: [UserScript] = []) {
userScripts: [UserScript] = []) {
super.init(frame: frame, configuration: configuration)
self.id = id
if let id = id, let registrar = registrar {
@ -68,7 +56,6 @@ public class InAppWebView: WKWebView, WKUIDelegate,
binaryMessenger: registrar.messenger)
self.channelDelegate = WebViewChannelDelegate(webView: self, channel: channel)
}
self.contextMenu = contextMenu
self.initialUserScripts = userScripts
uiDelegate = self
navigationDelegate = self
@ -133,11 +120,9 @@ public class InAppWebView: WKWebView, WKUIDelegate,
}
allowsBackForwardNavigationGestures = settings.allowsBackForwardNavigationGestures
if #available(iOS 9.0, *) {
allowsLinkPreview = settings.allowsLinkPreview
if !settings.userAgent.isEmpty {
customUserAgent = settings.userAgent
}
allowsLinkPreview = settings.allowsLinkPreview
if !settings.userAgent.isEmpty {
customUserAgent = settings.userAgent
}
if #available(macOS 11.0, *) {
@ -216,7 +201,6 @@ public class InAppWebView: WKWebView, WKUIDelegate,
configuration.userContentController.addPluginScript(ON_WINDOW_BLUR_EVENT_JS_PLUGIN_SCRIPT)
configuration.userContentController.addPluginScript(ON_WINDOW_FOCUS_EVENT_JS_PLUGIN_SCRIPT)
configuration.userContentController.addPluginScript(FIND_ELEMENTS_AT_POINT_JS_PLUGIN_SCRIPT)
configuration.userContentController.addPluginScript(LAST_TOUCHED_ANCHOR_OR_IMAGE_JS_PLUGIN_SCRIPT)
configuration.userContentController.addPluginScript(FIND_TEXT_HIGHLIGHT_JS_PLUGIN_SCRIPT)
configuration.userContentController.addPluginScript(ORIGINAL_VIEWPORT_METATAG_CONTENT_JS_PLUGIN_SCRIPT)
configuration.userContentController.addPluginScript(ON_SCROLL_CHANGED_EVENT_JS_PLUGIN_SCRIPT)
@ -308,43 +292,6 @@ public class InAppWebView: WKWebView, WKUIDelegate,
return configuration
}
@objc func onCreateContextMenu() {
let mapSorted = SharedLastTouchPointTimestamp.sorted { $0.value > $1.value }
if (mapSorted.first?.key != self) {
return
}
contextMenuIsShowing = true
let hitTestResult = HitTestResult(type: .unknownType, extra: nil)
if let lastLongPressTouhLocation = lastLongPressTouchPoint {
if configuration.preferences.javaScriptEnabled {
self.evaluateJavaScript("window.\(JAVASCRIPT_BRIDGE_NAME)._findElementsAtPoint(\(lastLongPressTouhLocation.x),\(lastLongPressTouhLocation.y))", completionHandler: {(value, error) in
if error != nil {
print("Long press gesture recognizer error: \(error?.localizedDescription ?? "")")
} else if let value = value as? [String: Any?] {
self.channelDelegate?.onCreateContextMenu(hitTestResult: HitTestResult.fromMap(map: value) ?? hitTestResult)
} else {
self.channelDelegate?.onCreateContextMenu(hitTestResult: hitTestResult)
}
})
} else {
channelDelegate?.onCreateContextMenu(hitTestResult: hitTestResult)
}
} else {
channelDelegate?.onCreateContextMenu(hitTestResult: hitTestResult)
}
}
@objc func onHideContextMenu() {
if contextMenuIsShowing == false {
return
}
contextMenuIsShowing = false
channelDelegate?.onHideContextMenu()
}
override public func observeValue(forKeyPath keyPath: String?, of object: Any?,
change: [NSKeyValueChangeKey : Any]?, context: UnsafeMutableRawPointer?) {
if keyPath == #keyPath(WKWebView.estimatedProgress) {
@ -546,7 +493,7 @@ public class InAppWebView: WKWebView, WKUIDelegate,
public func loadUrl(urlRequest: URLRequest, allowingReadAccessTo: URL?) {
let url = urlRequest.url!
if #available(iOS 9.0, *), let allowingReadAccessTo = allowingReadAccessTo, url.scheme == "file", allowingReadAccessTo.scheme == "file" {
if let allowingReadAccessTo = allowingReadAccessTo, url.scheme == "file", allowingReadAccessTo.scheme == "file" {
loadFileURL(url, allowingReadAccessTo: allowingReadAccessTo)
} else {
load(urlRequest)
@ -563,15 +510,10 @@ public class InAppWebView: WKWebView, WKUIDelegate,
}
public func loadData(data: String, mimeType: String, encoding: String, baseUrl: URL, allowingReadAccessTo: URL?) {
if #available(iOS 9.0, *), let allowingReadAccessTo = allowingReadAccessTo, baseUrl.scheme == "file", allowingReadAccessTo.scheme == "file" {
if let allowingReadAccessTo = allowingReadAccessTo, baseUrl.scheme == "file", allowingReadAccessTo.scheme == "file" {
loadFileURL(baseUrl, allowingReadAccessTo: allowingReadAccessTo)
}
if #available(iOS 9.0, *) {
load(data.data(using: .utf8)!, mimeType: mimeType, characterEncodingName: encoding, baseURL: baseUrl)
} else {
loadHTMLString(data, baseURL: baseUrl)
}
load(data.data(using: .utf8)!, mimeType: mimeType, characterEncodingName: encoding, baseURL: baseUrl)
}
public func loadFile(assetFilePath: String) throws {
@ -583,17 +525,15 @@ public class InAppWebView: WKWebView, WKUIDelegate,
func setSettings(newSettings: InAppWebViewSettings, newSettingsMap: [String: Any]) {
// MUST be the first! In this way, all the settings that uses evaluateJavaScript can be applied/blocked!
if #available(iOS 13.0, *) {
if newSettingsMap["applePayAPIEnabled"] != nil && settings?.applePayAPIEnabled != newSettings.applePayAPIEnabled {
if let settings = settings {
settings.applePayAPIEnabled = newSettings.applePayAPIEnabled
}
if !newSettings.applePayAPIEnabled {
// re-add WKUserScripts for the next page load
prepareAndAddUserScripts()
} else {
configuration.userContentController.removeAllUserScripts()
}
if newSettingsMap["applePayAPIEnabled"] != nil && settings?.applePayAPIEnabled != newSettings.applePayAPIEnabled {
if let settings = settings {
settings.applePayAPIEnabled = newSettings.applePayAPIEnabled
}
if !newSettings.applePayAPIEnabled {
// re-add WKUserScripts for the next page load
prepareAndAddUserScripts()
} else {
configuration.userContentController.removeAllUserScripts()
}
}
@ -1122,9 +1062,7 @@ public class InAppWebView: WKWebView, WKUIDelegate,
return result;
}
@available(iOS 15.0, *)
@available(macOS 12.0, *)
@available(macCatalyst 15.0, *)
public func webView(_ webView: WKWebView,
requestMediaCapturePermissionFor origin: WKSecurityOrigin,
initiatedByFrame frame: WKFrameInfo,
@ -1301,7 +1239,6 @@ public class InAppWebView: WKWebView, WKUIDelegate,
public func webView(_ webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
currentOriginalUrl = url
lastTouchPoint = nil
disposeWebMessageChannels()
initializeWindowIdJS()
@ -1585,9 +1522,7 @@ public class InAppWebView: WKWebView, WKUIDelegate,
}
} else {
print("Security Error: " + securityError.description)
if #available(iOS 11.3, *) {
print(SecCopyErrorMessageString(securityError,nil) ?? "")
}
print(SecCopyErrorMessageString(securityError,nil) ?? "")
}
return identityAndTrust;
}
@ -1762,7 +1697,7 @@ public class InAppWebView: WKWebView, WKUIDelegate,
InAppWebView.windowAutoincrementId += 1
let windowId = InAppWebView.windowAutoincrementId
let windowWebView = InAppWebView(id: nil, registrar: nil, frame: CGRect.zero, configuration: configuration, contextMenu: nil)
let windowWebView = InAppWebView(id: nil, registrar: nil, frame: CGRect.zero, configuration: configuration)
windowWebView.windowId = windowId
let webViewTransport = WebViewTransport(
@ -1950,20 +1885,10 @@ public class InAppWebView: WKWebView, WKUIDelegate,
// https://stackoverflow.com/a/42840541/4637638
public func isVideoPlayerWindow(_ notificationObject: AnyObject?) -> Bool {
let nonVideoClasses = ["_UIAlertControllerShimPresenterWindow",
"UITextEffectsWindow",
"UIRemoteKeyboardWindow",
"PGHostedWindow"]
var isVideo = true
if let obj = notificationObject {
for nonVideoClass in nonVideoClasses {
if let clazz = NSClassFromString(nonVideoClass) {
isVideo = isVideo && !(obj.isKind(of: clazz))
}
}
if let obj = notificationObject, let clazz = NSClassFromString("WebCoreFullScreenWindow") {
return obj.isKind(of: clazz)
}
return isVideo
return false
}
@objc func onEnterFullscreen(_ notification: Notification) {
@ -2152,27 +2077,18 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
if let webMessageListener = webMessageListeners.first(where: ({($0.jsObjectName == jsObjectName)})) {
let isMainFrame = message.frameInfo.isMainFrame
var scheme: String? = nil
var host: String? = nil
var port: Int? = nil
if #available(iOS 9.0, *) {
let sourceOrigin = message.frameInfo.securityOrigin
scheme = sourceOrigin.protocol
host = sourceOrigin.host
port = sourceOrigin.port
} else if let url = message.frameInfo.request.url {
scheme = url.scheme
host = url.host
port = url.port
}
let securityOrigin = message.frameInfo.securityOrigin
let scheme = securityOrigin.protocol
let host = securityOrigin.host
let port = securityOrigin.port
if !webMessageListener.isOriginAllowed(scheme: scheme, host: host, port: port) {
return
}
var sourceOrigin: URL? = nil
if let scheme = scheme, !scheme.isEmpty, let host = host, !host.isEmpty {
sourceOrigin = URL(string: "\(scheme)://\(host)\(port != nil && port != 0 ? ":" + String(port!) : "")")
if !scheme.isEmpty, !host.isEmpty {
sourceOrigin = URL(string: "\(scheme)://\(host)\(port != 0 ? ":" + String(port) : "")")
}
webMessageListener.channelDelegate?.onPostMessage(message: messageData, sourceOrigin: sourceOrigin, isMainFrame: isMainFrame)
}
@ -2372,6 +2288,16 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
}
}
public func getContentWidth(completionHandler: @escaping ((Int64?, Error?) -> Void)) {
evaluateJavaScript("document.body.scrollWidth") { scrollWidth, error in
if let error = error {
completionHandler(nil, error)
} else {
completionHandler(Int64(scrollWidth as? Double ?? 0.0), nil)
}
}
}
public func getOriginalUrl() -> URL? {
return currentOriginalUrl
}
@ -2384,56 +2310,6 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
}
}
public func getHitTestResult(completionHandler: @escaping (HitTestResult) -> Void) {
if configuration.preferences.javaScriptEnabled, let lastTouchLocation = lastTouchPoint {
self.evaluateJavaScript("window.\(JAVASCRIPT_BRIDGE_NAME)._findElementsAtPoint(\(lastTouchLocation.x),\(lastTouchLocation.y))", completionHandler: {(value, error) in
if error != nil {
print("getHitTestResult error: \(error?.localizedDescription ?? "")")
completionHandler(HitTestResult(type: .unknownType, extra: nil))
} else if let value = value as? [String: Any?] {
let hitTestResult = HitTestResult.fromMap(map: value)!
completionHandler(hitTestResult)
} else {
completionHandler(HitTestResult(type: .unknownType, extra: nil))
}
})
} else {
completionHandler(HitTestResult(type: .unknownType, extra: nil))
}
}
public func requestFocusNodeHref(completionHandler: @escaping ([String: Any?]?, Error?) -> Void) {
if configuration.preferences.javaScriptEnabled {
// add some delay to make it sure _lastAnchorOrImageTouched is updated
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
self.evaluateJavaScript("window.\(JAVASCRIPT_BRIDGE_NAME)._lastAnchorOrImageTouched", completionHandler: {(value, error) in
let lastAnchorOrImageTouched = value as? [String: Any?]
completionHandler(lastAnchorOrImageTouched, error)
})
}
} else {
completionHandler(nil, nil)
}
}
public func requestImageRef(completionHandler: @escaping ([String: Any?]?, Error?) -> Void) {
if configuration.preferences.javaScriptEnabled {
// add some delay to make it sure _lastImageTouched is updated
DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {
self.evaluateJavaScript("window.\(JAVASCRIPT_BRIDGE_NAME)._lastImageTouched", completionHandler: {(value, error) in
let lastImageTouched = value as? [String: Any?]
completionHandler(lastImageTouched, error)
})
}
} else {
completionHandler(nil, nil)
}
}
public func clearFocus() {
self.enclosingScrollView?.subviews.first?.resignFirstResponder()
}
public func getCertificate() -> SslCertificate? {
guard let scheme = url?.scheme,
scheme == "https",
@ -2454,12 +2330,24 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
}
}
public func canScrollVertically() -> Bool {
return enclosingScrollView?.contentSize.height ?? 0 > self.frame.height
public func canScrollVertically(completionHandler: @escaping ((Bool, Error?) -> Void)) {
getContentHeight { contentHeight, error in
if let error = error {
completionHandler(false, error)
} else {
completionHandler(CGFloat(contentHeight ?? 0) > self.frame.height, nil)
}
}
}
public func canScrollHorizontally() -> Bool {
return enclosingScrollView?.contentSize.width ?? 0 > self.frame.width
public func canScrollHorizontally(completionHandler: @escaping ((Bool, Error?) -> Void)) {
getContentWidth { contentWidth, error in
if let error = error {
completionHandler(false, error)
} else {
completionHandler(CGFloat(contentWidth ?? 0) > self.frame.width, nil)
}
}
}
public func createWebMessageChannel(completionHandler: ((WebMessageChannel) -> Void)? = nil) -> WebMessageChannel {
@ -2578,7 +2466,6 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) {
uiDelegate = nil
navigationDelegate = nil
isPausedTimersCompletionHandler = nil
SharedLastTouchPointTimestamp.removeValue(forKey: self)
callAsyncJavaScriptBelowIOS14Results.removeAll()
super.removeFromSuperview()
}

View File

@ -20,8 +20,6 @@ public class InAppWebViewSettings: ISettings<InAppWebView> {
var javaScriptEnabled = true
var javaScriptCanOpenWindowsAutomatically = false
var mediaPlaybackRequiresUserGesture = true
var verticalScrollBarEnabled = true
var horizontalScrollBarEnabled = true
var resourceCustomSchemes: [String] = []
var contentBlockers: [[String: [String : Any]]] = []
var minimumFontSize = 0
@ -30,54 +28,29 @@ public class InAppWebViewSettings: ISettings<InAppWebView> {
var incognito = false
var cacheEnabled = true
var transparentBackground = false
var disableVerticalScroll = false
var disableHorizontalScroll = false
var disableContextMenu = false
var supportZoom = true
var allowUniversalAccessFromFileURLs = false
var allowFileAccessFromFileURLs = false
var disallowOverScroll = false
var enableViewportScale = false
var suppressesIncrementalRendering = false
var allowsAirPlayForMediaPlayback = true
var allowsBackForwardNavigationGestures = true
var allowsLinkPreview = true
var ignoresViewportScaleLimits = false
var allowsInlineMediaPlayback = false
var allowsPictureInPictureMediaPlayback = true
var isFraudulentWebsiteWarningEnabled = true
var selectionGranularity = 0
var dataDetectorTypes: [String] = ["NONE"] // WKDataDetectorTypeNone
var preferredContentMode = 0
var sharedCookiesEnabled = false
var automaticallyAdjustsScrollIndicatorInsets = false
var accessibilityIgnoresInvertColors = false
var decelerationRate = "NORMAL" // UIScrollView.DecelerationRate.normal
var alwaysBounceVertical = false
var alwaysBounceHorizontal = false
var scrollsToTop = true
var isPagingEnabled = false
var maximumZoomScale = 1.0
var minimumZoomScale = 1.0
var contentInsetAdjustmentBehavior = 2 // UIScrollView.ContentInsetAdjustmentBehavior.never
var isDirectionalLockEnabled = false
var mediaType: String? = nil
var pageZoom = 1.0
var limitsNavigationsToAppBoundDomains = false
var useOnNavigationResponse = false
var applePayAPIEnabled = false
var allowingReadAccessTo: String? = nil
var disableLongPressContextMenuOnLinks = false
var disableInputAccessoryView = false
var underPageBackgroundColor: String?
var isTextInteractionEnabled = true
var isSiteSpecificQuirksModeEnabled = true
var upgradeKnownHostsToHTTPS = true
var isElementFullscreenEnabled = true
var isFindInteractionEnabled = false
var minimumViewportInset: NSEdgeInsets? = nil
var maximumViewportInset: NSEdgeInsets? = nil
override init(){
super.init()
@ -105,7 +78,7 @@ public class InAppWebViewSettings: ISettings<InAppWebView> {
if #available(macOS 10.12, *) {
realSettings["mediaPlaybackRequiresUserGesture"] = configuration.mediaTypesRequiringUserActionForPlayback == .all
}
realSettings["minimumFontSize"] = configuration.preferences.minimumFontSize
realSettings["minimumFontSize"] = Int(configuration.preferences.minimumFontSize)
realSettings["suppressesIncrementalRendering"] = configuration.suppressesIncrementalRendering
realSettings["allowsBackForwardNavigationGestures"] = webView.allowsBackForwardNavigationGestures
if #available(macOS 10.15, *) {

View File

@ -204,6 +204,13 @@ public class WebViewChannelDelegate : ChannelDelegate {
result(FlutterMethodNotImplemented)
}
break
case .isHidden:
if let iabController = webView?.inAppBrowserDelegate as? InAppBrowserWebViewController {
result(iabController.isHidden)
} else {
result(FlutterMethodNotImplemented)
}
break
case .getCopyBackForwardList:
result(webView?.getCopyBackForwardList())
break
@ -295,11 +302,15 @@ public class WebViewChannelDelegate : ChannelDelegate {
result(contentHeight)
}
break
case .zoomBy:
// let zoomFactor = (arguments!["zoomFactor"] as! NSNumber).floatValue
// let animated = arguments!["animated"] as! Bool
// webView?.zoomBy(zoomFactor: zoomFactor, animated: animated)
result(true)
case .getContentWidth:
webView?.getContentWidth { contentWidth, error in
if let error = error {
print(error)
result(nil)
return
}
result(contentWidth)
}
break
case .reloadFromOrigin:
webView?.reloadFromOrigin()
@ -329,57 +340,6 @@ public class WebViewChannelDelegate : ChannelDelegate {
result(nil)
}
break
case .getHitTestResult:
if let webView = webView {
webView.getHitTestResult { (hitTestResult) in
result(hitTestResult.toMap())
}
}
else {
result(nil)
}
break
case .clearFocus:
webView?.clearFocus()
result(true)
break
case .setContextMenu:
if let webView = webView {
let contextMenu = arguments!["contextMenu"] as? [String: Any]
webView.contextMenu = contextMenu
result(true)
} else {
result(false)
}
break
case .requestFocusNodeHref:
if let webView = webView {
webView.requestFocusNodeHref { (value, error) in
if let err = error {
print(err.localizedDescription)
result(nil)
return
}
result(value)
}
} else {
result(nil)
}
break
case .requestImageRef:
if let webView = webView {
webView.requestImageRef { (value, error) in
if let err = error {
print(err.localizedDescription)
result(nil)
return
}
result(value)
}
} else {
result(nil)
}
break
case .getScrollX:
if let webView = webView {
webView.getScrollX { scrollX, error in
@ -558,14 +518,28 @@ public class WebViewChannelDelegate : ChannelDelegate {
break
case .canScrollVertically:
if let webView = webView {
result(webView.canScrollVertically())
webView.canScrollVertically { canScrollVertically, error in
if let error = error {
print(error)
result(false)
return
}
result(canScrollVertically)
}
} else {
result(false)
}
break
case .canScrollHorizontally:
if let webView = webView {
result(webView.canScrollHorizontally())
webView.canScrollHorizontally { canScrollHorizontally, error in
if let error = error {
print(error)
result(false)
return
}
result(canScrollHorizontally)
}
} else {
result(false)
}
@ -591,10 +565,14 @@ public class WebViewChannelDelegate : ChannelDelegate {
break
case .closeAllMediaPresentations:
if let webView = self.webView, #available(macOS 11.3, *) {
// closeAllMediaPresentations with completionHandler v15.0 makes the app crash
// with error EXC_BAD_ACCESS, so use closeAllMediaPresentations v14.5
webView.closeAllMediaPresentations()
result(true)
if #available(macOS 12.0, *) {
webView.closeAllMediaPresentations {
result(true)
}
} else {
webView.closeAllMediaPresentations()
result(true)
}
} else {
result(false)
}

View File

@ -34,6 +34,7 @@ public enum WebViewChannelDelegateMethods: String {
case close = "close"
case show = "show"
case hide = "hide"
case isHidden = "isHidden"
case getCopyBackForwardList = "getCopyBackForwardList"
@available(*, deprecated, message: "Use FindInteractionController.findAll instead.")
case findAll = "findAll"
@ -48,17 +49,12 @@ public enum WebViewChannelDelegateMethods: String {
case resumeTimers = "resumeTimers"
case printCurrentPage = "printCurrentPage"
case getContentHeight = "getContentHeight"
case zoomBy = "zoomBy"
case getContentWidth = "getContentWidth"
case reloadFromOrigin = "reloadFromOrigin"
case getOriginalUrl = "getOriginalUrl"
case getZoomScale = "getZoomScale"
case hasOnlySecureContent = "hasOnlySecureContent"
case getSelectedText = "getSelectedText"
case getHitTestResult = "getHitTestResult"
case clearFocus = "clearFocus"
case setContextMenu = "setContextMenu"
case requestFocusNodeHref = "requestFocusNodeHref"
case requestImageRef = "requestImageRef"
case getScrollX = "getScrollX"
case getScrollY = "getScrollY"
case getCertificate = "getCertificate"

View File

@ -22,7 +22,8 @@ public class PlatformUtil: ChannelDelegate {
switch call.method {
case "getSystemVersion":
result(ProcessInfo.processInfo.operatingSystemVersionString)
let version = ProcessInfo.processInfo.operatingSystemVersion
result("\(version.majorVersion).\(version.minorVersion).\(version.patchVersion)")
break
case "formatDate":
let date = arguments!["date"] as! Int64

View File

@ -1,62 +0,0 @@
//
// LastTouchedAnchorOrImageJS.swift
// flutter_inappwebview
//
// Created by Lorenzo Pichilli on 16/02/21.
//
import Foundation
let LAST_TOUCHED_ANCHOR_OR_IMAGE_JS_PLUGIN_SCRIPT_GROUP_NAME = "IN_APP_WEBVIEW_LAST_TOUCHED_ANCHOR_OR_IMAGE_JS_PLUGIN_SCRIPT"
let LAST_TOUCHED_ANCHOR_OR_IMAGE_JS_PLUGIN_SCRIPT = PluginScript(
groupName: LAST_TOUCHED_ANCHOR_OR_IMAGE_JS_PLUGIN_SCRIPT_GROUP_NAME,
source: LAST_TOUCHED_ANCHOR_OR_IMAGE_JS_SOURCE,
injectionTime: .atDocumentStart,
forMainFrameOnly: true,
requiredInAllContentWorlds: false,
messageHandlerNames: [])
let LAST_TOUCHED_ANCHOR_OR_IMAGE_JS_SOURCE = """
window.\(JAVASCRIPT_BRIDGE_NAME)._lastAnchorOrImageTouched = null;
window.\(JAVASCRIPT_BRIDGE_NAME)._lastImageTouched = null;
(function() {
document.addEventListener('touchstart', function(event) {
var target = event.target;
while (target) {
if (target.tagName === 'IMG') {
var img = target;
window.\(JAVASCRIPT_BRIDGE_NAME)._lastImageTouched = {
url: img.src
};
var parent = img.parentNode;
while (parent) {
if (parent.tagName === 'A') {
window.\(JAVASCRIPT_BRIDGE_NAME)._lastAnchorOrImageTouched = {
title: parent.textContent,
url: parent.href,
src: img.src
};
break;
}
parent = parent.parentNode;
}
return;
} else if (target.tagName === 'A') {
var link = target;
var images = link.getElementsByTagName('img');
var img = (images.length > 0) ? images[0] : null;
var imgSrc = (img != null) ? img.src : null;
window.\(JAVASCRIPT_BRIDGE_NAME)._lastImageTouched = (img != null) ? {url: imgSrc} : window.\(JAVASCRIPT_BRIDGE_NAME)._lastImageTouched;
window.\(JAVASCRIPT_BRIDGE_NAME)._lastAnchorOrImageTouched = {
title: link.textContent,
url: link.href,
src: imgSrc
};
return;
}
target = target.parentNode;
}
});
})();
"""

View File

@ -9,8 +9,6 @@ import Foundation
import WebKit
import FlutterMacOS
var SharedLastTouchPointTimestamp: [InAppWebView: Int64] = [:]
public class Util {
public static func getUrlAsset(assetFilePath: String) throws -> URL {
// let key = SwiftFlutterPlugin.instance?.registrar?.lookupKey(forAsset: assetFilePath)

View File

@ -15,7 +15,7 @@ dependencies:
flutter_web_plugins:
sdk: flutter
js: ^0.6.4
flutter_inappwebview_internal_annotations: ^1.0.0
flutter_inappwebview_internal_annotations: ^1.1.0
dev_dependencies:
flutter_test: