diff --git a/CHANGELOG.md b/CHANGELOG.md index 53ed632d..6a245ce8 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserSettings.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserSettings.java index ff7ce54d..6e720949 100755 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserSettings.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/in_app_browser/InAppBrowserSettings.java @@ -95,6 +95,7 @@ public class InAppBrowserSettings implements ISettings { @Override public Map getRealSettings(@NonNull InAppBrowserActivity inAppBrowserActivity) { Map 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); diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewInterface.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewInterface.java index 5c55642d..60bf917d 100644 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewInterface.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/InAppWebViewInterface.java @@ -69,6 +69,7 @@ public interface InAppWebViewInterface { String printCurrentPage(@Nullable PrintJobSettings settings); int getContentHeight(); void getContentHeight(ValueCallback callback); + void getContentWidth(ValueCallback callback); void zoomBy(float zoomFactor); String getOriginalUrl(); void getSelectedText(ValueCallback callback); diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java index 5dddfb13..b161a194 100644 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegate.java @@ -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() { + @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"); diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegateMethods.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegateMethods.java index 445667bd..d87954f6 100644 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegateMethods.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/WebViewChannelDelegateMethods.java @@ -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, diff --git a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java index 881dc311..b7b022cc 100755 --- a/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java +++ b/android/src/main/java/com/pichillilorenzo/flutter_inappwebview/webview/in_app_webview/InAppWebView.java @@ -1910,6 +1910,19 @@ final public class InAppWebView extends InputAwareWebView implements InAppWebVie callback.onReceiveValue(getContentHeight()); } + public void getContentWidth(final ValueCallback callback) { + evaluateJavascript("document.documentElement.scrollWidth;", new ValueCallback() { + @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 callback) { callback.onReceiveValue(com.pichillilorenzo.flutter_inappwebview.types.HitTestResult.fromWebViewHitTestResult(getHitTestResult())); diff --git a/dev_packages/flutter_inappwebview_internal_annotations/CHANGELOG.md b/dev_packages/flutter_inappwebview_internal_annotations/CHANGELOG.md index 35771889..a05f94be 100755 --- a/dev_packages/flutter_inappwebview_internal_annotations/CHANGELOG.md +++ b/dev_packages/flutter_inappwebview_internal_annotations/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.0 + +- Added `ExchangeableObject.copyMethod`. + ## 1.0.0 Initial release. \ No newline at end of file diff --git a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_object.dart b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_object.dart index 6e1a9baf..1776e8fe 100644 --- a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_object.dart +++ b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/exchangeable_object.dart @@ -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 }); } diff --git a/dev_packages/flutter_inappwebview_internal_annotations/pubspec.yaml b/dev_packages/flutter_inappwebview_internal_annotations/pubspec.yaml index c074d9a6..01aae9a6 100755 --- a/dev_packages/flutter_inappwebview_internal_annotations/pubspec.yaml +++ b/dev_packages/flutter_inappwebview_internal_annotations/pubspec.yaml @@ -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: diff --git a/dev_packages/generators/lib/src/exchangeable_object_generator.dart b/dev_packages/generators/lib/src/exchangeable_object_generator.dart index cbde4c7d..d0f0a8e3 100644 --- a/dev_packages/generators/lib/src/exchangeable_object_generator.dart +++ b/dev_packages/generators/lib/src/exchangeable_object_generator.dart @@ -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'); diff --git a/dev_packages/generators/pubspec.lock b/dev_packages/generators/pubspec.lock index 3f1a113a..07f34add 100644 --- a/dev_packages/generators/pubspec.lock +++ b/dev_packages/generators/pubspec.lock @@ -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: diff --git a/dev_packages/generators/pubspec.yaml b/dev_packages/generators/pubspec.yaml index 80b666dd..47509f8f 100755 --- a/dev_packages/generators/pubspec.yaml +++ b/dev_packages/generators/pubspec.yaml @@ -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 diff --git a/example/integration_test/in_app_browser/hide_and_show.dart b/example/integration_test/in_app_browser/hide_and_show.dart new file mode 100644 index 00000000..1e1fa155 --- /dev/null +++ b/example/integration_test/in_app_browser/hide_and_show.dart @@ -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); +} diff --git a/example/integration_test/in_app_browser/main.dart b/example/integration_test/in_app_browser/main.dart index 13fc2bd1..4b20e930 100644 --- a/example/integration_test/in_app_browser/main.dart +++ b/example/integration_test/in_app_browser/main.dart @@ -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); } diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index fae63896..9e98dd5e 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -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" diff --git a/example/lib/in_app_browser_example.screen.dart b/example/lib/in_app_browser_example.screen.dart index 33c3a3a5..e9aa7d42 100755 --- a/example/lib/in_app_browser_example.screen.dart +++ b/example/lib/in_app_browser_example.screen.dart @@ -106,7 +106,6 @@ class _InAppBrowserExampleScreenState extends State { URLRequest(url: Uri.parse("https://flutter.dev")), settings: InAppBrowserClassSettings( browserSettings: InAppBrowserSettings( - hidden: false, toolbarTopBackgroundColor: Colors.blue, presentationStyle: ModalPresentationStyle.POPOVER ), diff --git a/ios/Classes/InAppBrowser/InAppBrowserManager.swift b/ios/Classes/InAppBrowser/InAppBrowserManager.swift index 233686be..ac621910 100755 --- a/ios/Classes/InAppBrowser/InAppBrowserManager.swift +++ b/ios/Classes/InAppBrowser/InAppBrowserManager.swift @@ -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 diff --git a/ios/Classes/InAppBrowser/InAppBrowserSettings.swift b/ios/Classes/InAppBrowser/InAppBrowserSettings.swift index 5bd51f8f..1449b312 100755 --- a/ios/Classes/InAppBrowser/InAppBrowserSettings.swift +++ b/ios/Classes/InAppBrowser/InAppBrowserSettings.swift @@ -35,6 +35,7 @@ public class InAppBrowserSettings: ISettings { 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 diff --git a/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift b/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift index 536eb049..ab6d8c35 100755 --- a/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift +++ b/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift @@ -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 diff --git a/ios/Classes/InAppWebView/InAppWebView.swift b/ios/Classes/InAppWebView/InAppWebView.swift index b8c02f74..a9057d20 100755 --- a/ios/Classes/InAppWebView/InAppWebView.swift +++ b/ios/Classes/InAppWebView/InAppWebView.swift @@ -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) diff --git a/ios/Classes/InAppWebView/InAppWebViewSettings.swift b/ios/Classes/InAppWebView/InAppWebViewSettings.swift index c024626c..98c7dd74 100755 --- a/ios/Classes/InAppWebView/InAppWebViewSettings.swift +++ b/ios/Classes/InAppWebView/InAppWebViewSettings.swift @@ -119,7 +119,7 @@ public class InAppWebViewSettings: ISettings { } 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 diff --git a/ios/Classes/InAppWebView/WebViewChannelDelegate.swift b/ios/Classes/InAppWebView/WebViewChannelDelegate.swift index ed33c497..4b5e6cae 100644 --- a/ios/Classes/InAppWebView/WebViewChannelDelegate.swift +++ b/ios/Classes/InAppWebView/WebViewChannelDelegate.swift @@ -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) } diff --git a/ios/Classes/InAppWebView/WebViewChannelDelegateMethods.swift b/ios/Classes/InAppWebView/WebViewChannelDelegateMethods.swift index 658c096f..d9e99ad1 100644 --- a/ios/Classes/InAppWebView/WebViewChannelDelegateMethods.swift +++ b/ios/Classes/InAppWebView/WebViewChannelDelegateMethods.swift @@ -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" diff --git a/lib/src/content_blocker.dart b/lib/src/content_blocker.dart index 9e6e448c..ae88732e 100755 --- a/lib/src/content_blocker.dart +++ b/lib/src/content_blocker.dart @@ -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.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 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 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 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 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 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 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 unlessTopUrl; ///An array of strings that specify loading contexts. /// - ///*NOTE*: available only on iOS. + ///**Supported Platforms/Implementations**: + ///- iOS + ///- MacOS List loadContext; ContentBlockerTrigger( @@ -161,7 +202,7 @@ class ContentBlockerTrigger { return ContentBlockerTrigger( urlFilter: map["url-filter"], - ifFrameUrl: map["if-frame-url"], + ifFrameUrl: List.from(map["if-frame-url"] ?? []), urlFilterIsCaseSensitive: map["url-filter-is-case-sensitive"], ifDomain: List.from(map["if-domain"] ?? []), unlessDomain: List.from(map["unless-domain"] ?? []), @@ -171,6 +212,11 @@ class ContentBlockerTrigger { unlessTopUrl: List.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}'; + } } diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index f419c1a9..a97b017f 100755 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -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 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 args = {}; @@ -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(); - var headlessWebView = new HeadlessInAppWebView( + final setCookieCompleter = Completer(); + 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> 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 cookies = []; @@ -253,8 +239,9 @@ class CookieManager { List cookies = []; if (webViewController != null) { - InAppWebViewSettings? settings = await webViewController.getSettings(); - if (settings != null && settings.javaScriptEnabled) { + final javaScriptEnabled = + (await webViewController.getSettings())?.javaScriptEnabled ?? false; + if (javaScriptEnabled) { List documentCookies = (await webViewController .evaluateJavascript(source: 'document.cookie') as String) .split(';') @@ -273,8 +260,8 @@ class CookieManager { } } - var pageLoaded = Completer(); - var headlessWebView = new HeadlessInAppWebView( + final pageLoaded = Completer(); + 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 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 cookies = await _getCookiesWithJavaScript( - url: url, webViewController: webViewController); - return cookies - .cast() - .firstWhere((cookie) => cookie!.name == name, orElse: () => null); - } + if (await _shouldUseJavascript()) { + List cookies = await _getCookiesWithJavaScript( + url: url, webViewController: webViewController); + return cookies + .cast() + .firstWhere((cookie) => cookie!.name == name, orElse: () => null); } Map args = {}; @@ -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 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 args = {}; @@ -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 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 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 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 args = {}; @@ -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 deleteAllCookies() async { Map args = {}; 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> getAllCookies() async { List cookies = []; @@ -542,6 +514,21 @@ class CookieManager { timezone: 'GMT') : await platformUtil.getWebCookieExpirationDate(date: dateTime); } + + Future _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]. diff --git a/lib/src/find_interaction/find_interaction_controller.dart b/lib/src/find_interaction/find_interaction_controller.dart index b63fe7a5..d6a24d3c 100644 --- a/lib/src/find_interaction/find_interaction_controller.dart +++ b/lib/src/find_interaction/find_interaction_controller.dart @@ -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 findAll({String? find}) async { Map args = {}; 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 findNext({bool forward = true}) async { Map args = {}; 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 clearMatches() async { Map args = {}; 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 setSearchText(String? searchText) async { Map args = {}; 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 getSearchText() async { Map args = {}; 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 getActiveFindSession() async { Map args = {}; Map? result = diff --git a/lib/src/http_auth_credentials_database.dart b/lib/src/http_auth_credentials_database.dart index 2650eb53..53027398 100755 --- a/lib/src/http_auth_credentials_database.dart +++ b/lib/src/http_auth_credentials_database.dart @@ -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> getAllAuthCredentials() async { Map args = {}; @@ -67,6 +69,7 @@ class HttpAuthCredentialDatabase { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS Future> getHttpAuthCredentials( {required URLProtectionSpace protectionSpace}) async { Map args = {}; @@ -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 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 removeHttpAuthCredential( {required URLProtectionSpace protectionSpace, required URLCredential credential}) async { @@ -127,6 +132,7 @@ class HttpAuthCredentialDatabase { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS Future removeHttpAuthCredentials( {required URLProtectionSpace protectionSpace}) async { Map args = {}; @@ -142,6 +148,7 @@ class HttpAuthCredentialDatabase { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS Future clearAllAuthCredentials() async { Map args = {}; await _channel.invokeMethod('clearAllAuthCredentials', args); diff --git a/lib/src/in_app_browser/in_app_browser.dart b/lib/src/in_app_browser/in_app_browser.dart index 8084ed82..a02ac2ed 100755 --- a/lib/src/in_app_browser/in_app_browser.dart +++ b/lib/src/in_app_browser/in_app_browser.dart @@ -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 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 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 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 openWithSystemBrowser({required Uri url}) async { assert(url.toString().isNotEmpty); Map args = {}; @@ -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 show() async { this.throwIfNotOpened(); Map args = {}; @@ -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 hide() async { this.throwIfNotOpened(); Map args = {}; @@ -325,6 +356,11 @@ class InAppBrowser { } ///Closes the [InAppBrowser] window. + /// + ///**Supported Platforms/Implementations**: + ///- Android native WebView + ///- iOS + ///- MacOS Future close() async { this.throwIfNotOpened(); Map args = {}; @@ -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 isHidden() async { this.throwIfNotOpened(); Map args = {}; @@ -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 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 getSettings() async { this.throwIfNotOpened(); Map args = {}; @@ -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? 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? 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? 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? 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? 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? 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? 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? 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? 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? 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? 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? 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? 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? 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? 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? 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? 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, diff --git a/lib/src/in_app_browser/in_app_browser_settings.dart b/lib/src/in_app_browser/in_app_browser_settings.dart index cd4e66d4..f0bfc15f 100755 --- a/lib/src/in_app_browser/in_app_browser_settings.dart +++ b/lib/src/in_app_browser/in_app_browser_settings.dart @@ -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 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 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 toJson() { - return this.toMap(); + throw UnimplementedError(); } @override - String toString() { - return toMap().toString(); - } - - @override - InAppBrowserSettings copy() { - return InAppBrowserSettings.fromMap(this.toMap()); + @ExchangeableObjectMethod(ignore: true) + Map toMap() { + throw UnimplementedError(); } } diff --git a/lib/src/in_app_browser/in_app_browser_settings.g.dart b/lib/src/in_app_browser/in_app_browser_settings.g.dart new file mode 100644 index 00000000..7d89a162 --- /dev/null +++ b/lib/src/in_app_browser/in_app_browser_settings.g.dart @@ -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? 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 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 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}'; + } +} diff --git a/lib/src/in_app_browser/main.dart b/lib/src/in_app_browser/main.dart index 069ebf66..0c541535 100644 --- a/lib/src/in_app_browser/main.dart +++ b/lib/src/in_app_browser/main.dart @@ -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'; diff --git a/lib/src/in_app_localhost_server.dart b/lib/src/in_app_localhost_server.dart index 57c74e49..452ddbb1 100755 --- a/lib/src/in_app_localhost_server.dart +++ b/lib/src/in_app_localhost_server.dart @@ -12,6 +12,7 @@ import 'mime_type_resolver.dart'; ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS +///- MacOS class InAppLocalhostServer { bool _started = false; HttpServer? _server; diff --git a/lib/src/in_app_webview/headless_in_app_webview.dart b/lib/src/in_app_webview/headless_in_app_webview.dart index 291b43b5..36400aeb 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -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 run() async { if (_started) { return; @@ -236,6 +238,7 @@ class HeadlessInAppWebView implements WebView, Disposable { ///- Android native WebView ///- iOS ///- Web + ///- MacOS @override Future 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 setSize(Size size) async { if (!_running) { return; @@ -288,6 +293,7 @@ class HeadlessInAppWebView implements WebView, Disposable { ///- Android native WebView ///- iOS ///- Web + ///- MacOS Future getSize() async { if (!_running) { return null; diff --git a/lib/src/in_app_webview/in_app_webview_controller.dart b/lib/src/in_app_webview/in_app_webview_controller.dart index eafba17b..214fbf2d 100644 --- a/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/in_app_webview_controller.dart @@ -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 getUrl() async { Map args = {}; @@ -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 getTitle() async { Map args = {}; @@ -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 getProgress() async { Map args = {}; return await _channel.invokeMethod('getProgress', args); @@ -1383,6 +1386,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future getHtml() async { String? html; @@ -1427,6 +1431,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future> getFavicons() async { List 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 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 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 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 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 reload() async { Map args = {}; @@ -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 goBack() async { Map args = {}; @@ -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 canGoBack() async { Map args = {}; 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 goForward() async { Map args = {}; @@ -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 canGoForward() async { Map args = {}; 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 goBackOrForward({required int steps}) async { Map args = {}; @@ -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 canGoBackOrForward({required int steps}) async { Map args = {}; args.putIfAbsent('steps', () => steps); @@ -1840,6 +1856,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future 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 isLoading() async { Map args = {}; @@ -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 stopLoading() async { Map args = {}; @@ -1879,7 +1898,7 @@ class InAppWebViewController { ///This parameter doesn’t apply to changes you make to the underlying web content, such as the document’s 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 evaluateJavascript( {required String source, ContentWorld? contentWorld}) async { @@ -1924,6 +1944,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future injectJavascriptFileFromUrl( {required Uri urlFile, @@ -1952,6 +1973,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future injectJavascriptFileFromAsset( {required String assetFilePath}) async { @@ -1971,6 +1993,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future injectCSSCode({required String source}) async { Map args = {}; @@ -1992,6 +2015,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future injectCSSFileFromUrl( {required Uri urlFile, @@ -2016,6 +2040,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future 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 takeScreenshot( {ScreenshotConfiguration? screenshotConfiguration}) async { Map args = {}; @@ -2117,7 +2147,7 @@ class InAppWebViewController { @Deprecated('Use setSettings instead') Future 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 setSettings({required InAppWebViewSettings settings}) async { Map args = {}; @@ -2153,6 +2184,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future getSettings() async { Map args = {}; @@ -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 getCopyBackForwardList() async { Map args = {}; Map? result = @@ -2188,6 +2221,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS Future clearCache() async { Map args = {}; 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 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 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 pauseTimers() async { Map args = {}; 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 resumeTimers() async { Map args = {}; 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 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 getContentHeight() async { Map args = {}; @@ -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 getContentWidth() async { + Map args = {}; + 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 getOriginalUrl() async { Map args = {}; @@ -2415,6 +2495,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future getSelectedText() async { Map args = {}; @@ -2515,6 +2596,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS ///- Web Future> getMetaTags() async { List metaTags = []; @@ -2578,13 +2660,14 @@ class InAppWebViewController { ///Returns an instance of [Color] representing the `content` value of the ///`` 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 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 getScrollX() async { Map args = {}; @@ -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 getScrollY() async { Map args = {}; @@ -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 getCertificate() async { Map args = {}; Map? sslCertificateMap = @@ -2663,13 +2753,14 @@ class InAppWebViewController { ///Injects the specified [userScript] into the webpage’s 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 addUserScript({required UserScript userScript}) async { assert(_webview?.windowId == null || defaultTargetPlatform != TargetPlatform.iOS); @@ -2684,13 +2775,14 @@ class InAppWebViewController { ///Injects the [userScripts] into the webpage’s 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 addUserScripts({required List 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 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 webpage’s 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 removeUserScriptsByGroupName({required String groupName}) async { assert(_webview?.windowId == null || defaultTargetPlatform != TargetPlatform.iOS); @@ -2751,13 +2845,14 @@ class InAppWebViewController { ///Removes the [userScripts] from the webpage’s 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 removeUserScripts( {required List userScripts}) async { assert(_webview?.windowId == null || @@ -2770,13 +2865,14 @@ class InAppWebViewController { ///Removes all the user scripts from the webpage’s 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 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 callAsyncJavaScript( {required String functionBody, Map arguments = const {}, @@ -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 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 isSecureContext() async { Map args = {}; @@ -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 createWebMessageChannel() async { Map args = {}; Map? 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 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 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 canScrollVertically() async { Map args = {}; @@ -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 canScrollHorizontally() async { Map args = {}; @@ -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 reloadFromOrigin() async { Map args = {}; 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 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 createWebArchiveData() async { Map args = {}; 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 hasOnlySecureContent() async { Map args = {}; 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 pauseAllMediaPlayback() async { Map args = {}; 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 setAllMediaPlaybackSuspended({required bool suspended}) async { Map args = {}; 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 closeAllMediaPresentations() async { Map args = {}; 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 requestMediaPlaybackState() async { Map args = {}; return MediaPlaybackState.fromNativeValue( @@ -3335,6 +3471,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS Future isInFullscreen() async { Map args = {}; 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 getCameraCaptureState() async { Map args = {}; 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 setCameraCaptureState({required MediaCaptureState state}) async { Map args = {}; 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 getMicrophoneCaptureState() async { Map args = {}; 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 setMicrophoneCaptureState( {required MediaCaptureState state}) async { Map args = {}; @@ -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 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 getDefaultUserAgent() async { Map args = {}; 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 handlesURLScheme(String urlScheme) async { Map args = {}; args.putIfAbsent('urlScheme', () => urlScheme); @@ -3558,6 +3714,7 @@ class InAppWebViewController { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS static Future 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 get tRexRunnerCss async => await rootBundle.loadString( 'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.css'); diff --git a/lib/src/in_app_webview/in_app_webview_settings.dart b/lib/src/in_app_webview/in_app_webview_settings.dart index 58e99250..c398fc6b 100755 --- a/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/lib/src/in_app_webview/in_app_webview_settings.dart @@ -1,6 +1,25 @@ import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_inappwebview/src/types/user_preferred_content_mode.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; +import '../types/action_mode_menu_item.dart'; +import '../types/cache_mode.dart'; +import '../types/data_detector_types.dart'; +import '../types/force_dark.dart'; +import '../types/force_dark_strategy.dart'; +import '../types/layout_algorithm.dart'; +import '../types/mixed_content_mode.dart'; +import '../types/over_scroll_mode.dart'; +import '../types/referrer_policy.dart'; +import '../types/renderer_priority_policy.dart'; +import '../types/requested_with_header_mode.dart'; +import '../types/sandbox.dart'; +import '../types/scrollbar_style.dart'; +import '../types/scrollview_content_inset_adjustment_behavior.dart'; +import '../types/scrollview_deceleration_rate.dart'; +import '../types/selection_granularity.dart'; +import '../types/vertical_scrollbar_position.dart'; import 'android/in_app_webview_options.dart'; import 'apple/in_app_webview_options.dart'; import '../content_blocker.dart'; @@ -12,35 +31,54 @@ import '../android/webview_feature.dart'; import '../in_app_webview/in_app_webview_controller.dart'; import '../context_menu.dart'; +part 'in_app_webview_settings.g.dart'; + +List _deserializeContentBlockers(List? contentBlockersMapList) { + List contentBlockers = []; + if (contentBlockersMapList != null) { + contentBlockersMapList.forEach((contentBlocker) { + contentBlockers.add(ContentBlocker.fromMap( + Map>.from( + Map.from(contentBlocker)))); + }); + } + return contentBlockers; +} + ///This class represents all the WebView settings available. -class InAppWebViewSettings { +@ExchangeableObject(copyMethod: true) +class InAppWebViewSettings_ { ///Set to `true` to be able to listen at the [WebView.shouldOverrideUrlLoading] event. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool useShouldOverrideUrlLoading; + ///- MacOS + bool? useShouldOverrideUrlLoading; ///Set to `true` to be able to listen at the [WebView.onLoadResource] event. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool useOnLoadResource; + ///- MacOS + bool? useOnLoadResource; ///Set to `true` to be able to listen at the [WebView.onDownloadStartRequest] event. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool useOnDownloadStart; + ///- MacOS + bool? useOnDownloadStart; ///Set to `true` to have all the browser's cache cleared before the new WebView is opened. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool clearCache; + ///- MacOS + bool? clearCache; ///Sets the user-agent for the WebView. /// @@ -49,7 +87,8 @@ class InAppWebViewSettings { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - String userAgent; + ///- MacOS + String? userAgent; ///Append to the existing user-agent. Setting userAgent will override this. /// @@ -58,7 +97,8 @@ class InAppWebViewSettings { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - String applicationNameForUserAgent; + ///- MacOS + String? applicationNameForUserAgent; ///Set to `true` to enable JavaScript. The default value is `true`. /// @@ -66,7 +106,8 @@ class InAppWebViewSettings { ///- Android native WebView ///- iOS ///- Web - bool javaScriptEnabled; + ///- MacOS + bool? javaScriptEnabled; ///Set to `true` to allow JavaScript open windows without user interaction. The default value is `false`. /// @@ -76,22 +117,27 @@ class InAppWebViewSettings { ///- Android native WebView ///- iOS ///- Web - bool javaScriptCanOpenWindowsAutomatically; + ///- MacOS + bool? javaScriptCanOpenWindowsAutomatically; ///Set to `true` to prevent HTML5 audio or video from autoplaying. The default value is `true`. /// - ///**NOTE**: available on iOS 10.0+. + ///**NOTE for iOS**: available on iOS 10.0+. + /// + ///**NOTE for MacOS**: available on MacOS 10.12+. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool mediaPlaybackRequiresUserGesture; + ///- MacOS + bool? mediaPlaybackRequiresUserGesture; ///Sets the minimum font size. The default value is `8` for Android, `0` for iOS. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS + ///- MacOS int? minimumFontSize; ///Define whether the vertical scrollbar should be drawn or not. The default value is `true`. @@ -103,7 +149,7 @@ class InAppWebViewSettings { ///- Android native WebView ///- iOS ///- Web - bool verticalScrollBarEnabled; + bool? verticalScrollBarEnabled; ///Define whether the horizontal scrollbar should be drawn or not. The default value is `true`. /// @@ -114,75 +160,93 @@ class InAppWebViewSettings { ///- Android native WebView ///- iOS ///- Web - bool horizontalScrollBarEnabled; + bool? horizontalScrollBarEnabled; ///List of custom schemes that the WebView must handle. Use the [WebView.onLoadResourceWithCustomScheme] event to intercept resource requests with custom scheme. /// - ///**NOTE**: available on iOS 11.0+. + ///**NOTE for iOS**: available on iOS 11.0+. + /// + ///**NOTE for MacOS**: available on MacOS 10.13+. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - List resourceCustomSchemes; + ///- MacOS + List? resourceCustomSchemes; ///List of [ContentBlocker] that are a set of rules used to block content in the browser window. /// - ///**NOTE**: available on iOS 11.0+. + ///**NOTE for iOS**: available on iOS 11.0+. + /// + ///**NOTE for MacOS**: available on MacOS 10.13+. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - List contentBlockers; + ///- MacOS + @ExchangeableObjectProperty(deserializer: _deserializeContentBlockers) + List? contentBlockers; ///Sets the content mode that the WebView needs to use when loading and rendering a webpage. The default value is [UserPreferredContentMode.RECOMMENDED]. /// - ///**NOTE**: available on iOS 13.0+. + ///**NOTE for iOS**: available on iOS 13.0+. + /// + ///**NOTE for MacOS**: available on MacOS 10.15+. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - UserPreferredContentMode? preferredContentMode; + ///- MacOS + UserPreferredContentMode_? preferredContentMode; ///Set to `true` to be able to listen at the [WebView.shouldInterceptAjaxRequest] event. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool useShouldInterceptAjaxRequest; + ///- MacOS + bool? useShouldInterceptAjaxRequest; ///Set to `true` to be able to listen at the [WebView.shouldInterceptFetchRequest] event. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool useShouldInterceptFetchRequest; + ///- MacOS + bool? useShouldInterceptFetchRequest; ///Set to `true` to open a browser window with incognito mode. The default value is `false`. /// - ///**NOTE**: available on iOS 9.0+. - ///On Android, by setting this option to `true`, it will clear all the cookies of all WebView instances, + ///**NOTE for iOS**: available on iOS 9.0+. + /// + ///**NOTE for Android**: setting this to `true`, it will clear all the cookies of all WebView instances, ///because there isn't any way to make the website data store non-persistent for the specific WebView instance such as on iOS. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool incognito; + ///- MacOS + bool? incognito; ///Sets whether WebView should use browser caching. The default value is `true`. /// - ///**NOTE**: available on iOS 9.0+. + ///**NOTE for iOS**: available on iOS 9.0+. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool cacheEnabled; + ///- MacOS + bool? cacheEnabled; ///Set to `true` to make the background of the WebView transparent. If your app has a dark theme, this can prevent a white flash on initialization. The default value is `false`. /// + ///**NOTE for MacOS**: available on MacOS 12.0+. + /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool transparentBackground; + ///- MacOS + bool? transparentBackground; ///Set to `true` to disable vertical scroll. The default value is `false`. /// @@ -192,7 +256,7 @@ class InAppWebViewSettings { ///- Android native WebView ///- iOS ///- Web - bool disableVerticalScroll; + bool? disableVerticalScroll; ///Set to `true` to disable horizontal scroll. The default value is `false`. /// @@ -202,7 +266,7 @@ class InAppWebViewSettings { ///- Android native WebView ///- iOS ///- Web - bool disableHorizontalScroll; + bool? disableHorizontalScroll; ///Set to `true` to disable context menu. The default value is `false`. /// @@ -212,14 +276,15 @@ class InAppWebViewSettings { ///- Android native WebView ///- iOS ///- Web - bool disableContextMenu; + bool? disableContextMenu; ///Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool supportZoom; + ///- MacOS + bool? supportZoom; ///Sets whether cross-origin requests in the context of a file scheme URL should be allowed to access content from other file scheme URLs. ///Note that some accesses such as image HTML elements don't follow same-origin rules and aren't affected by this setting. @@ -234,7 +299,8 @@ class InAppWebViewSettings { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool allowFileAccessFromFileURLs; + ///- MacOS + bool? allowFileAccessFromFileURLs; ///Sets whether cross-origin requests in the context of a file scheme URL should be allowed to access content from any origin. ///This includes access to content from other file scheme URLs or web contexts. @@ -249,43 +315,44 @@ class InAppWebViewSettings { ///**Supported Platforms/Implementations**: ///- Android native WebView ///- iOS - bool allowUniversalAccessFromFileURLs; + ///- MacOS + bool? allowUniversalAccessFromFileURLs; ///Sets the text zoom of the page in percent. The default value is `100`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - int textZoom; + int? textZoom; ///Set to `true` to have the session cookie cache cleared before the new window is opened. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool clearSessionCache; + bool? clearSessionCache; ///Set to `true` if the WebView should use its built-in zoom mechanisms. The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool builtInZoomControls; + bool? builtInZoomControls; ///Set to `true` if the WebView should display on-screen zoom controls when using the built-in zoom mechanisms. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool displayZoomControls; + bool? displayZoomControls; ///Set to `true` if you want the database storage API is enabled. The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool databaseEnabled; + bool? databaseEnabled; ///Set to `true` if you want the DOM storage API is enabled. The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool domStorageEnabled; + bool? domStorageEnabled; ///Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. ///When the value of the setting is false, the layout width is always set to the width of the WebView control in device-independent (CSS) pixels. @@ -294,7 +361,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool useWideViewPort; + bool? useWideViewPort; ///Sets whether Safe Browsing is enabled. Safe Browsing allows WebView to protect against malware and phishing attacks by verifying the links. ///Safe Browsing is enabled by default for devices which support it. @@ -303,7 +370,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool safeBrowsingEnabled; + bool? safeBrowsingEnabled; ///Configures the WebView's behavior when a secure origin attempts to load a resource from an insecure origin. /// @@ -311,20 +378,20 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - MixedContentMode? mixedContentMode; + MixedContentMode_? mixedContentMode; ///Enables or disables content URL access within WebView. Content URL access allows WebView to load content from a content provider installed in the system. The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool allowContentAccess; + bool? allowContentAccess; ///Enables or disables file access within WebView. Note that this enables or disables file system access only. ///Assets and resources are still accessible using `file:///android_asset` and `file:///android_res`. The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool allowFileAccess; + bool? allowFileAccess; ///Sets the path to the Application Caches files. In order for the Application Caches API to be enabled, this option must be set a path to which the application can write. ///This option is used one time: repeated calls are ignored. @@ -337,44 +404,44 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool blockNetworkImage; + bool? blockNetworkImage; ///Sets whether the WebView should not load resources from the network. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool blockNetworkLoads; + bool? blockNetworkLoads; ///Overrides the way the cache is used. The way the cache is used is based on the navigation type. For a normal page load, the cache is checked and content is re-validated as needed. ///When navigating back, content is not revalidated, instead the content is just retrieved from the cache. The default value is [CacheMode.LOAD_DEFAULT]. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - CacheMode? cacheMode; + CacheMode_? cacheMode; ///Sets the cursive font family name. The default value is `"cursive"`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - String cursiveFontFamily; + String? cursiveFontFamily; ///Sets the default fixed font size. The default value is `16`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - int defaultFixedFontSize; + int? defaultFixedFontSize; ///Sets the default font size. The default value is `16`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - int defaultFontSize; + int? defaultFontSize; ///Sets the default text encoding name to use when decoding html pages. The default value is `"UTF-8"`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - String defaultTextEncodingName; + String? defaultTextEncodingName; ///Disables the action mode menu items according to menuItems flag. /// @@ -382,19 +449,19 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - ActionModeMenuItem? disabledActionModeMenuItems; + ActionModeMenuItem_? disabledActionModeMenuItems; ///Sets the fantasy font family name. The default value is `"fantasy"`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - String fantasyFontFamily; + String? fantasyFontFamily; ///Sets the fixed font family name. The default value is `"monospace"`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - String fixedFontFamily; + String? fixedFontFamily; ///Set the force dark mode for this WebView. The default value is [ForceDark.OFF]. /// @@ -402,7 +469,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - ForceDark? forceDark; + ForceDark_? forceDark; ///Set how WebView content should be darkened. ///The default value is [ForceDarkStrategy.PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING]. @@ -411,19 +478,19 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - ForceDarkStrategy? forceDarkStrategy; + ForceDarkStrategy_? forceDarkStrategy; ///Sets whether Geolocation API is enabled. The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool geolocationEnabled; + bool? geolocationEnabled; ///Sets the underlying layout algorithm. This will cause a re-layout of the WebView. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - LayoutAlgorithm? layoutAlgorithm; + LayoutAlgorithm_? layoutAlgorithm; ///Sets whether the WebView loads pages in overview mode, that is, zooms out the content to fit on screen by width. ///This setting is taken into account when the content width is greater than the width of the WebView control, for example, when [useWideViewPort] is enabled. @@ -431,7 +498,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool loadWithOverviewMode; + bool? loadWithOverviewMode; ///Sets whether the WebView should load image resources. Note that this method controls loading of all images, including those embedded using the data URI scheme. ///Note that if the value of this setting is changed from false to true, all images resources referenced by content currently displayed by the WebView are loaded automatically. @@ -439,13 +506,13 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool loadsImagesAutomatically; + bool? loadsImagesAutomatically; ///Sets the minimum logical font size. The default is `8`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - int minimumLogicalFontSize; + int? minimumLogicalFontSize; ///Sets the initial scale for this WebView. 0 means default. The behavior for the default scale depends on the state of [useWideViewPort] and [loadWithOverviewMode]. ///If the content fits into the WebView control by width, then the zoom is set to 100%. For wide content, the behavior depends on the state of [loadWithOverviewMode]. @@ -456,13 +523,13 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - int initialScale; + int? initialScale; ///Tells the WebView whether it needs to set a node. The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool needInitialFocus; + bool? needInitialFocus; ///Sets whether this WebView should raster tiles when it is offscreen but attached to a window. ///Turning this on can avoid rendering artifacts when animating an offscreen WebView on-screen. @@ -472,25 +539,25 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool offscreenPreRaster; + bool? offscreenPreRaster; ///Sets the sans-serif font family name. The default value is `"sans-serif"`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - String sansSerifFontFamily; + String? sansSerifFontFamily; ///Sets the serif font family name. The default value is `"sans-serif"`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - String serifFontFamily; + String? serifFontFamily; ///Sets the standard font family name. The default value is `"sans-serif"`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - String standardFontFamily; + String? standardFontFamily; ///Sets whether the WebView should save form data. In Android O, the platform has implemented a fully functional Autofill feature to store form data. ///Therefore, the Webview form data save feature is disabled. Note that the feature will continue to be supported on older versions of Android as before. @@ -498,7 +565,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool saveFormData; + bool? saveFormData; ///Boolean value to enable third party cookies in the WebView. ///Used on Android Lollipop and above only as third party cookies are enabled by default on Android Kitkat and below and on iOS. @@ -508,21 +575,21 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool thirdPartyCookiesEnabled; + bool? thirdPartyCookiesEnabled; ///Boolean value to enable Hardware Acceleration in the WebView. ///The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool hardwareAcceleration; + bool? hardwareAcceleration; ///Sets whether the WebView supports multiple windows. ///If set to `true`, [WebView.onCreateWindow] event must be implemented by the host application. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool supportMultipleWindows; + bool? supportMultipleWindows; ///Regular expression used by [WebView.shouldOverrideUrlLoading] event to cancel navigation requests for frames that are not the main frame. ///If the url request of a subframe matches the regular expression, then the request of that subframe is canceled. @@ -539,19 +606,19 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool useHybridComposition; + bool? useHybridComposition; ///Set to `true` to be able to listen at the [WebView.shouldInterceptRequest] event. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool useShouldInterceptRequest; + bool? useShouldInterceptRequest; ///Set to `true` to be able to listen at the [WebView.onRenderProcessGone] event. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool useOnRenderProcessGone; + bool? useOnRenderProcessGone; ///Sets the WebView's over-scroll mode. ///Setting the over-scroll mode of a WebView will have an effect only if the WebView is capable of scrolling. @@ -559,7 +626,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - OverScrollMode? overScrollMode; + OverScrollMode_? overScrollMode; ///Informs WebView of the network state. ///This is used to set the JavaScript property `window.navigator.isOnline` and generates the online/offline event as specified in HTML5, sec. 5.7.7. @@ -577,14 +644,14 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - ScrollBarStyle? scrollBarStyle; + ScrollBarStyle_? scrollBarStyle; ///Sets the position of the vertical scroll bar. ///The default value is [VerticalScrollbarPosition.SCROLLBAR_POSITION_DEFAULT]. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - VerticalScrollbarPosition? verticalScrollbarPosition; + VerticalScrollbarPosition_? verticalScrollbarPosition; ///Defines the delay in milliseconds that a scrollbar waits before fade out. /// @@ -597,7 +664,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool scrollbarFadingEnabled; + bool? scrollbarFadingEnabled; ///Defines the scrollbar fade duration in milliseconds. /// @@ -609,14 +676,14 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - RendererPriorityPolicy? rendererPriorityPolicy; + RendererPriorityPolicy_? rendererPriorityPolicy; ///Sets whether the default Android error page should be disabled. ///The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool disableDefaultErrorPage; + bool? disableDefaultErrorPage; ///Sets the vertical scrollbar thumb color. /// @@ -657,7 +724,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool willSuppressErrorPage; + bool? willSuppressErrorPage; ///Control whether algorithmic darkening is allowed. /// @@ -677,7 +744,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool algorithmicDarkeningAllowed; + bool? algorithmicDarkeningAllowed; ///Sets how the WebView will set the `X-Requested-With` header on requests. ///If you are calling this method, you may also want to call [ServiceWorkerWebSettingsCompat.setRequestedWithHeaderMode] @@ -688,7 +755,7 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - RequestedWithHeaderMode? requestedWithHeaderMode; + RequestedWithHeaderMode_? requestedWithHeaderMode; ///Sets whether EnterpriseAuthenticationAppLinkPolicy if set by admin is allowed to have any ///effect on WebView. @@ -703,37 +770,41 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- Android native WebView - bool enterpriseAuthenticationAppLinkPolicyEnabled; + bool? enterpriseAuthenticationAppLinkPolicyEnabled; ///Set to `true` to disable the bouncing of the WebView when the scrolling has reached an edge of the content. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- iOS - bool disallowOverScroll; + bool? disallowOverScroll; ///Set to `true` to allow a viewport meta tag to either disable or restrict the range of user scaling. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- iOS - bool enableViewportScale; + ///- MacOS + bool? enableViewportScale; ///Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- iOS - bool suppressesIncrementalRendering; + ///- MacOS + bool? suppressesIncrementalRendering; ///Set to `true` to allow AirPlay. The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- iOS - bool allowsAirPlayForMediaPlayback; + ///- MacOS + bool? allowsAirPlayForMediaPlayback; ///Set to `true` to allow the horizontal swipe gestures trigger back-forward list navigations. The default value is `true`. /// ///**Supported Platforms/Implementations**: ///- iOS - bool allowsBackForwardNavigationGestures; + ///- MacOS + bool? allowsBackForwardNavigationGestures; ///Set to `true` to allow that pressing on a link displays a preview of the destination for the link. The default value is `true`. /// @@ -741,21 +812,22 @@ class InAppWebViewSettings { /// ///**Supported Platforms/Implementations**: ///- iOS - bool allowsLinkPreview; + ///- MacOS + bool? allowsLinkPreview; ///Set to `true` if you want that the WebView should always allow scaling of the webpage, regardless of the author's intent. ///The ignoresViewportScaleLimits property overrides the `user-scalable` HTML property in a webpage. The default value is `false`. /// ///**Supported Platforms/Implementations**: ///- iOS - bool ignoresViewportScaleLimits; + bool? ignoresViewportScaleLimits; ///Set to `true` to allow HTML5 media playback to appear inline within the screen layout, using browser-supplied controls rather than native controls. ///For this to work, add the `webkit-playsinline` attribute to any `