fixed remaining classes and properties

This commit is contained in:
Lorenzo Pichilli 2022-04-20 03:05:46 +02:00
parent cdd2bdb09f
commit 0312d12859
33 changed files with 1378 additions and 1028 deletions

View File

@ -31,7 +31,7 @@ import com.pichillilorenzo.flutter_inappwebview.in_app_webview.InAppWebView;
import com.pichillilorenzo.flutter_inappwebview.in_app_webview.InAppWebViewChromeClient; import com.pichillilorenzo.flutter_inappwebview.in_app_webview.InAppWebViewChromeClient;
import com.pichillilorenzo.flutter_inappwebview.in_app_webview.InAppWebViewSettings; import com.pichillilorenzo.flutter_inappwebview.in_app_webview.InAppWebViewSettings;
import com.pichillilorenzo.flutter_inappwebview.pull_to_refresh.PullToRefreshLayout; import com.pichillilorenzo.flutter_inappwebview.pull_to_refresh.PullToRefreshLayout;
import com.pichillilorenzo.flutter_inappwebview.pull_to_refresh.PullToRefreshOptions; import com.pichillilorenzo.flutter_inappwebview.pull_to_refresh.PullToRefreshSettings;
import com.pichillilorenzo.flutter_inappwebview.types.URLRequest; import com.pichillilorenzo.flutter_inappwebview.types.URLRequest;
import com.pichillilorenzo.flutter_inappwebview.types.UserScript; import com.pichillilorenzo.flutter_inappwebview.types.UserScript;
@ -81,13 +81,13 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
setContentView(R.layout.activity_web_view); setContentView(R.layout.activity_web_view);
Map<String, Object> pullToRefreshInitialOptions = (Map<String, Object>) b.getSerializable("pullToRefreshInitialOptions"); Map<String, Object> pullToRefreshInitialSettings = (Map<String, Object>) b.getSerializable("pullToRefreshInitialSettings");
MethodChannel pullToRefreshLayoutChannel = new MethodChannel(manager.plugin.messenger, "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + id); MethodChannel pullToRefreshLayoutChannel = new MethodChannel(manager.plugin.messenger, "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + id);
PullToRefreshOptions pullToRefreshOptions = new PullToRefreshOptions(); PullToRefreshSettings pullToRefreshSettings = new PullToRefreshSettings();
pullToRefreshOptions.parse(pullToRefreshInitialOptions); pullToRefreshSettings.parse(pullToRefreshInitialSettings);
pullToRefreshLayout = findViewById(R.id.pullToRefresh); pullToRefreshLayout = findViewById(R.id.pullToRefresh);
pullToRefreshLayout.channel = pullToRefreshLayoutChannel; pullToRefreshLayout.channel = pullToRefreshLayoutChannel;
pullToRefreshLayout.options = pullToRefreshOptions; pullToRefreshLayout.options = pullToRefreshSettings;
pullToRefreshLayout.prepare(); pullToRefreshLayout.prepare();
webView = findViewById(R.id.webView); webView = findViewById(R.id.webView);

View File

@ -174,7 +174,7 @@ public class InAppBrowserManager implements MethodChannel.MethodCallHandler {
Map<String, Object> contextMenu = (Map<String, Object>) arguments.get("contextMenu"); Map<String, Object> contextMenu = (Map<String, Object>) arguments.get("contextMenu");
Integer windowId = (Integer) arguments.get("windowId"); Integer windowId = (Integer) arguments.get("windowId");
List<Map<String, Object>> initialUserScripts = (List<Map<String, Object>>) arguments.get("initialUserScripts"); List<Map<String, Object>> initialUserScripts = (List<Map<String, Object>>) arguments.get("initialUserScripts");
Map<String, Object> pullToRefreshInitialOptions = (Map<String, Object>) arguments.get("pullToRefreshOptions"); Map<String, Object> pullToRefreshInitialSettings = (Map<String, Object>) arguments.get("pullToRefreshSettings");
Bundle extras = new Bundle(); Bundle extras = new Bundle();
extras.putString("fromActivity", activity.getClass().getName()); extras.putString("fromActivity", activity.getClass().getName());
@ -191,7 +191,7 @@ public class InAppBrowserManager implements MethodChannel.MethodCallHandler {
extras.putSerializable("contextMenu", (Serializable) contextMenu); extras.putSerializable("contextMenu", (Serializable) contextMenu);
extras.putInt("windowId", windowId != null ? windowId : -1); extras.putInt("windowId", windowId != null ? windowId : -1);
extras.putSerializable("initialUserScripts", (Serializable) initialUserScripts); extras.putSerializable("initialUserScripts", (Serializable) initialUserScripts);
extras.putSerializable("pullToRefreshInitialOptions", (Serializable) pullToRefreshInitialOptions); extras.putSerializable("pullToRefreshInitialSettings", (Serializable) pullToRefreshInitialSettings);
startInAppBrowserActivity(activity, extras); startInAppBrowserActivity(activity, extras);
} }

View File

@ -21,7 +21,7 @@ import com.pichillilorenzo.flutter_inappwebview.InAppWebViewFlutterPlugin;
import com.pichillilorenzo.flutter_inappwebview.InAppWebViewMethodHandler; import com.pichillilorenzo.flutter_inappwebview.InAppWebViewMethodHandler;
import com.pichillilorenzo.flutter_inappwebview.plugin_scripts_js.JavaScriptBridgeJS; import com.pichillilorenzo.flutter_inappwebview.plugin_scripts_js.JavaScriptBridgeJS;
import com.pichillilorenzo.flutter_inappwebview.pull_to_refresh.PullToRefreshLayout; import com.pichillilorenzo.flutter_inappwebview.pull_to_refresh.PullToRefreshLayout;
import com.pichillilorenzo.flutter_inappwebview.pull_to_refresh.PullToRefreshOptions; import com.pichillilorenzo.flutter_inappwebview.pull_to_refresh.PullToRefreshSettings;
import com.pichillilorenzo.flutter_inappwebview.types.PlatformWebView; import com.pichillilorenzo.flutter_inappwebview.types.PlatformWebView;
import com.pichillilorenzo.flutter_inappwebview.types.URLRequest; import com.pichillilorenzo.flutter_inappwebview.types.URLRequest;
import com.pichillilorenzo.flutter_inappwebview.types.UserScript; import com.pichillilorenzo.flutter_inappwebview.types.UserScript;
@ -55,7 +55,7 @@ public class FlutterWebView implements PlatformWebView {
Map<String, Object> contextMenu = (Map<String, Object>) params.get("contextMenu"); Map<String, Object> contextMenu = (Map<String, Object>) params.get("contextMenu");
Integer windowId = (Integer) params.get("windowId"); Integer windowId = (Integer) params.get("windowId");
List<Map<String, Object>> initialUserScripts = (List<Map<String, Object>>) params.get("initialUserScripts"); List<Map<String, Object>> initialUserScripts = (List<Map<String, Object>>) params.get("initialUserScripts");
Map<String, Object> pullToRefreshInitialOptions = (Map<String, Object>) params.get("pullToRefreshOptions"); Map<String, Object> pullToRefreshInitialSettings = (Map<String, Object>) params.get("pullToRefreshSettings");
InAppWebViewSettings options = new InAppWebViewSettings(); InAppWebViewSettings options = new InAppWebViewSettings();
options.parse(initialSettings); options.parse(initialSettings);
@ -81,9 +81,9 @@ public class FlutterWebView implements PlatformWebView {
// set MATCH_PARENT layout params to the WebView, otherwise it won't take all the available space! // set MATCH_PARENT layout params to the WebView, otherwise it won't take all the available space!
webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); webView.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
MethodChannel pullToRefreshLayoutChannel = new MethodChannel(plugin.messenger, "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + id); MethodChannel pullToRefreshLayoutChannel = new MethodChannel(plugin.messenger, "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + id);
PullToRefreshOptions pullToRefreshOptions = new PullToRefreshOptions(); PullToRefreshSettings pullToRefreshSettings = new PullToRefreshSettings();
pullToRefreshOptions.parse(pullToRefreshInitialOptions); pullToRefreshSettings.parse(pullToRefreshInitialSettings);
pullToRefreshLayout = new PullToRefreshLayout(context, pullToRefreshLayoutChannel, pullToRefreshOptions); pullToRefreshLayout = new PullToRefreshLayout(context, pullToRefreshLayoutChannel, pullToRefreshSettings);
pullToRefreshLayout.addView(webView); pullToRefreshLayout.addView(webView);
pullToRefreshLayout.prepare(); pullToRefreshLayout.prepare();
} }

View File

@ -21,9 +21,9 @@ public class PullToRefreshLayout extends SwipeRefreshLayout implements MethodCha
static final String LOG_TAG = "PullToRefreshLayout"; static final String LOG_TAG = "PullToRefreshLayout";
public MethodChannel channel; public MethodChannel channel;
public PullToRefreshOptions options; public PullToRefreshSettings options;
public PullToRefreshLayout(@NonNull Context context, @NonNull MethodChannel channel, @NonNull PullToRefreshOptions options) { public PullToRefreshLayout(@NonNull Context context, @NonNull MethodChannel channel, @NonNull PullToRefreshSettings options) {
super(context); super(context);
this.channel = channel; this.channel = channel;
this.options = options; this.options = options;

View File

@ -7,8 +7,8 @@ import com.pichillilorenzo.flutter_inappwebview.IWebViewSettings;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
public class PullToRefreshOptions implements IWebViewSettings<PullToRefreshLayout> { public class PullToRefreshSettings implements IWebViewSettings<PullToRefreshLayout> {
public static final String LOG_TAG = "PullToRefreshOptions"; public static final String LOG_TAG = "PullToRefreshSettings";
public Boolean enabled = true; public Boolean enabled = true;
@Nullable @Nullable
@ -22,7 +22,7 @@ public class PullToRefreshOptions implements IWebViewSettings<PullToRefreshLayou
@Nullable @Nullable
public Integer size; public Integer size;
public PullToRefreshOptions parse(Map<String, Object> options) { public PullToRefreshSettings parse(Map<String, Object> options) {
for (Map.Entry<String, Object> pair : options.entrySet()) { for (Map.Entry<String, Object> pair : options.entrySet()) {
String key = pair.getKey(); String key = pair.getKey();
Object value = pair.getValue(); Object value = pair.getValue();
@ -56,20 +56,20 @@ public class PullToRefreshOptions implements IWebViewSettings<PullToRefreshLayou
} }
public Map<String, Object> toMap() { public Map<String, Object> toMap() {
Map<String, Object> options = new HashMap<>(); Map<String, Object> settings = new HashMap<>();
options.put("enabled", enabled); settings.put("enabled", enabled);
options.put("color", color); settings.put("color", color);
options.put("backgroundColor", backgroundColor); settings.put("backgroundColor", backgroundColor);
options.put("distanceToTriggerSync", distanceToTriggerSync); settings.put("distanceToTriggerSync", distanceToTriggerSync);
options.put("slingshotDistance", slingshotDistance); settings.put("slingshotDistance", slingshotDistance);
options.put("size", size); settings.put("size", size);
return options; return settings;
} }
@Override @Override
public Map<String, Object> getRealSettings(PullToRefreshLayout pullToRefreshLayout) { public Map<String, Object> getRealSettings(PullToRefreshLayout pullToRefreshLayout) {
Map<String, Object> realOptions = toMap(); Map<String, Object> realSettings = toMap();
return realOptions; return realSettings;
} }
} }

View File

@ -0,0 +1,18 @@
#
# NOTE: This podspec is NOT to be published. It is only used as a local source!
# This is a generated file; do not edit or check into version control.
#
Pod::Spec.new do |s|
s.name = 'Flutter'
s.version = '1.0.0'
s.summary = 'High-performance, high-fidelity mobile apps.'
s.homepage = 'https://flutter.io'
s.license = { :type => 'MIT' }
s.author = { 'Flutter Dev Team' => 'flutter-dev@googlegroups.com' }
s.source = { :git => 'https://github.com/flutter/engine', :tag => s.version.to_s }
s.ios.deployment_target = '9.0'
# Framework linking is handled by Flutter tooling, not CocoaPods.
# Add a placeholder to satisfy `s.dependency 'Flutter'` plugin podspecs.
s.vendored_frameworks = 'path/to/nothing'
end

View File

@ -3,11 +3,12 @@
export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4" export "FLUTTER_ROOT=/Users/lorenzopichilli/fvm/versions/2.10.4"
export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example" export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true" 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_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1" export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
export "DART_OBFUSCATION=false" export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false" export "TRACK_WIDGET_CREATION=true"
export "TREE_SHAKE_ICONS=false" export "TREE_SHAKE_ICONS=false"
export "PACKAGE_CONFIG=.packages" export "PACKAGE_CONFIG=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/.dart_tool/package_config.json"

View File

@ -80,7 +80,7 @@ public class InAppBrowserManager: NSObject, FlutterPlugin {
let contextMenu = arguments["contextMenu"] as! [String: Any] let contextMenu = arguments["contextMenu"] as! [String: Any]
let windowId = arguments["windowId"] as? Int64 let windowId = arguments["windowId"] as? Int64
let initialUserScripts = arguments["initialUserScripts"] as? [[String: Any]] let initialUserScripts = arguments["initialUserScripts"] as? [[String: Any]]
let pullToRefreshInitialOptions = arguments["pullToRefreshOptions"] as! [String: Any?] let pullToRefreshInitialSettings = arguments["pullToRefreshSettings"] as! [String: Any?]
let webViewController = prepareInAppBrowserWebViewController(settings: settings) let webViewController = prepareInAppBrowserWebViewController(settings: settings)
@ -94,7 +94,7 @@ public class InAppBrowserManager: NSObject, FlutterPlugin {
webViewController.contextMenu = contextMenu webViewController.contextMenu = contextMenu
webViewController.windowId = windowId webViewController.windowId = windowId
webViewController.initialUserScripts = initialUserScripts ?? [] webViewController.initialUserScripts = initialUserScripts ?? []
webViewController.pullToRefreshInitialOptions = pullToRefreshInitialOptions webViewController.pullToRefreshInitialSettings = pullToRefreshInitialSettings
presentViewController(webViewController: webViewController) presentViewController(webViewController: webViewController)
} }

View File

@ -36,7 +36,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
var initialBaseUrl: String? var initialBaseUrl: String?
var previousStatusBarStyle = -1 var previousStatusBarStyle = -1
var initialUserScripts: [[String: Any]] = [] var initialUserScripts: [[String: Any]] = []
var pullToRefreshInitialOptions: [String: Any?] = [:] var pullToRefreshInitialSettings: [String: Any?] = [:]
var methodCallDelegate: InAppWebViewMethodHandler? var methodCallDelegate: InAppWebViewMethodHandler?
public override func loadView() { public override func loadView() {
@ -47,7 +47,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
userScripts.append(UserScript.fromMap(map: intialUserScript, windowId: windowId)!) userScripts.append(UserScript.fromMap(map: intialUserScript, windowId: windowId)!)
} }
let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(options: webViewSettings) let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(settings: webViewSettings)
if let wId = windowId, let webViewTransport = InAppWebView.windowWebViews[wId] { if let wId = windowId, let webViewTransport = InAppWebView.windowWebViews[wId] {
webView = webViewTransport.webView webView = webViewTransport.webView
webView.contextMenu = contextMenu webView.contextMenu = contextMenu
@ -67,9 +67,9 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
let pullToRefreshLayoutChannel = FlutterMethodChannel(name: "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + id, let pullToRefreshLayoutChannel = FlutterMethodChannel(name: "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + id,
binaryMessenger: SwiftFlutterPlugin.instance!.registrar!.messenger()) binaryMessenger: SwiftFlutterPlugin.instance!.registrar!.messenger())
let pullToRefreshOptions = PullToRefreshSettings() let pullToRefreshSettings = PullToRefreshSettings()
let _ = pullToRefreshOptions.parse(options: pullToRefreshInitialOptions) let _ = pullToRefreshSettings.parse(settings: pullToRefreshInitialSettings)
let pullToRefreshControl = PullToRefreshControl(channel: pullToRefreshLayoutChannel, options: pullToRefreshOptions) let pullToRefreshControl = PullToRefreshControl(channel: pullToRefreshLayoutChannel, settings: pullToRefreshSettings)
webView.pullToRefreshControl = pullToRefreshControl webView.pullToRefreshControl = pullToRefreshControl
pullToRefreshControl.delegate = webView pullToRefreshControl.delegate = webView
pullToRefreshControl.prepare() pullToRefreshControl.prepare()
@ -429,8 +429,8 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
public func setSettings(newSettings: InAppBrowserSettings, newSettingsMap: [String: Any]) { public func setSettings(newSettings: InAppBrowserSettings, newSettingsMap: [String: Any]) {
let newInAppWebViewOptions = InAppWebViewSettings() let newInAppWebViewOptions = InAppWebViewSettings()
let _ = newInAppWebViewOptions.parse(options: newSettingsMap) let _ = newInAppWebViewOptions.parse(settings: newSettingsMap)
self.webView.setOptions(newSettings: newInAppWebViewOptions, newOptionsMap: newSettingsMap) self.webView.setSettings(newSettings: newInAppWebViewOptions, newSettingsMap: newSettingsMap)
if newSettingsMap["hidden"] != nil, browserSettings?.hidden != newSettings.hidden { if newSettingsMap["hidden"] != nil, browserSettings?.hidden != newSettings.hidden {
if newSettings.hidden { if newSettings.hidden {
@ -474,7 +474,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
} }
if newSettingsMap["hideToolbarBottom"] != nil, browserSettings?.hideToolbarBottom != newSettings.hideToolbarBottom { if newSettingsMap["hideToolbarBottom"] != nil, browserSettings?.hideToolbarBottom != newSettings.hideToolbarBottom {
navigationController?.isToolbarHidden = !newOptions.hideToolbarBottom navigationController?.isToolbarHidden = !newSettings.hideToolbarBottom
} }
if newSettingsMap["toolbarBottomBackgroundColor"] != nil, browserSettings?.toolbarBottomBackgroundColor != newSettings.toolbarBottomBackgroundColor { if newSettingsMap["toolbarBottomBackgroundColor"] != nil, browserSettings?.toolbarBottomBackgroundColor != newSettings.toolbarBottomBackgroundColor {

View File

@ -33,7 +33,7 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
let contextMenu = params["contextMenu"] as? [String: Any] let contextMenu = params["contextMenu"] as? [String: Any]
let windowId = params["windowId"] as? Int64 let windowId = params["windowId"] as? Int64
let initialUserScripts = params["initialUserScripts"] as? [[String: Any]] let initialUserScripts = params["initialUserScripts"] as? [[String: Any]]
let pullToRefreshInitialOptions = params["pullToRefreshOptions"] as! [String: Any?] let pullToRefreshInitialSettings = params["pullToRefreshSettings"] as! [String: Any?]
var userScripts: [UserScript] = [] var userScripts: [UserScript] = []
if let initialUserScripts = initialUserScripts { if let initialUserScripts = initialUserScripts {
@ -44,7 +44,7 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
let settings = InAppWebViewSettings() let settings = InAppWebViewSettings()
let _ = settings.parse(settings: initialSettings) let _ = settings.parse(settings: initialSettings)
let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(options: settings) let preWebviewConfiguration = InAppWebView.preWKWebViewConfiguration(settings: settings)
if let wId = windowId, let webViewTransport = InAppWebView.windowWebViews[wId] { if let wId = windowId, let webViewTransport = InAppWebView.windowWebViews[wId] {
webView = webViewTransport.webView webView = webViewTransport.webView
@ -65,9 +65,9 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
let pullToRefreshLayoutChannel = FlutterMethodChannel(name: "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + String(describing: viewId), let pullToRefreshLayoutChannel = FlutterMethodChannel(name: "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + String(describing: viewId),
binaryMessenger: registrar.messenger()) binaryMessenger: registrar.messenger())
let pullToRefreshOptions = PullToRefreshSettings() let pullToRefreshSettings = PullToRefreshSettings()
let _ = pullToRefreshOptions.parse(settings: pullToRefreshInitialOptions) let _ = pullToRefreshSettings.parse(settings: pullToRefreshInitialSettings)
let pullToRefreshControl = PullToRefreshControl(channel: pullToRefreshLayoutChannel, options: pullToRefreshOptions) let pullToRefreshControl = PullToRefreshControl(channel: pullToRefreshLayoutChannel, settings: pullToRefreshSettings)
webView!.pullToRefreshControl = pullToRefreshControl webView!.pullToRefreshControl = pullToRefreshControl
pullToRefreshControl.delegate = webView! pullToRefreshControl.delegate = webView!
pullToRefreshControl.prepare() pullToRefreshControl.prepare()

View File

@ -11,14 +11,14 @@ import Flutter
public class PullToRefreshControl : UIRefreshControl, FlutterPlugin { public class PullToRefreshControl : UIRefreshControl, FlutterPlugin {
var channel: FlutterMethodChannel? var channel: FlutterMethodChannel?
var options: PullToRefreshSettings? var settings: PullToRefreshSettings?
var shouldCallOnRefresh = false var shouldCallOnRefresh = false
var delegate: PullToRefreshDelegate? var delegate: PullToRefreshDelegate?
public init(channel: FlutterMethodChannel?, options: PullToRefreshSettings?) { public init(channel: FlutterMethodChannel?, settings: PullToRefreshSettings?) {
super.init() super.init()
self.channel = channel self.channel = channel
self.options = options self.settings = settings
} }
required init?(coder: NSCoder) { required init?(coder: NSCoder) {
@ -31,7 +31,7 @@ public class PullToRefreshControl : UIRefreshControl, FlutterPlugin {
public func prepare() { public func prepare() {
self.channel?.setMethodCallHandler(self.handle) self.channel?.setMethodCallHandler(self.handle)
if let options = options { if let options = settings {
if options.enabled { if options.enabled {
delegate?.enablePullToRefresh() delegate?.enablePullToRefresh()
} }

View File

@ -1,5 +1,5 @@
// //
// PullToRefreshOptions.swift // pullToRefreshSettings.swift
// flutter_inappwebview // flutter_inappwebview
// //
// Created by Lorenzo Pichilli on 03/03/21. // Created by Lorenzo Pichilli on 03/03/21.

View File

@ -28,17 +28,15 @@ class ServiceWorkerController {
} }
static Future<dynamic> _handleMethod(MethodCall call) async { static Future<dynamic> _handleMethod(MethodCall call) async {
ServiceWorkerController controller = ServiceWorkerController controller = ServiceWorkerController.instance();
ServiceWorkerController.instance(); ServiceWorkerClient? serviceWorkerClient = controller.serviceWorkerClient;
ServiceWorkerClient? serviceWorkerClient =
controller.serviceWorkerClient;
switch (call.method) { switch (call.method) {
case "shouldInterceptRequest": case "shouldInterceptRequest":
if (serviceWorkerClient != null && if (serviceWorkerClient != null &&
serviceWorkerClient.shouldInterceptRequest != null) { serviceWorkerClient.shouldInterceptRequest != null) {
Map<String, dynamic> arguments = Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>(); call.arguments.cast<String, dynamic>();
WebResourceRequest request = WebResourceRequest.fromMap(arguments)!; WebResourceRequest request = WebResourceRequest.fromMap(arguments)!;
return (await serviceWorkerClient.shouldInterceptRequest!(request)) return (await serviceWorkerClient.shouldInterceptRequest!(request))
@ -164,7 +162,7 @@ class ServiceWorkerClient {
/// ///
///**NOTE**: available on Android 24+. ///**NOTE**: available on Android 24+.
final Future<WebResourceResponse?> Function(WebResourceRequest request)? final Future<WebResourceResponse?> Function(WebResourceRequest request)?
shouldInterceptRequest; shouldInterceptRequest;
ServiceWorkerClient({this.shouldInterceptRequest}); ServiceWorkerClient({this.shouldInterceptRequest});
} }

View File

@ -72,174 +72,167 @@ class WebViewFeature {
/// ///
static const CREATE_WEB_MESSAGE_CHANNEL = static const CREATE_WEB_MESSAGE_CHANNEL =
const WebViewFeature._internal("CREATE_WEB_MESSAGE_CHANNEL"); const WebViewFeature._internal("CREATE_WEB_MESSAGE_CHANNEL");
/// ///
static const DISABLED_ACTION_MODE_MENU_ITEMS = static const DISABLED_ACTION_MODE_MENU_ITEMS =
const WebViewFeature._internal("DISABLED_ACTION_MODE_MENU_ITEMS"); const WebViewFeature._internal("DISABLED_ACTION_MODE_MENU_ITEMS");
/// ///
static const FORCE_DARK = const WebViewFeature._internal("FORCE_DARK"); static const FORCE_DARK = const WebViewFeature._internal("FORCE_DARK");
/// ///
static const FORCE_DARK_STRATEGY = static const FORCE_DARK_STRATEGY =
const WebViewFeature._internal("FORCE_DARK_STRATEGY"); const WebViewFeature._internal("FORCE_DARK_STRATEGY");
/// ///
static const GET_WEB_CHROME_CLIENT = static const GET_WEB_CHROME_CLIENT =
const WebViewFeature._internal("GET_WEB_CHROME_CLIENT"); const WebViewFeature._internal("GET_WEB_CHROME_CLIENT");
/// ///
static const GET_WEB_VIEW_CLIENT = static const GET_WEB_VIEW_CLIENT =
const WebViewFeature._internal("GET_WEB_VIEW_CLIENT"); const WebViewFeature._internal("GET_WEB_VIEW_CLIENT");
/// ///
static const GET_WEB_VIEW_RENDERER = static const GET_WEB_VIEW_RENDERER =
const WebViewFeature._internal("GET_WEB_VIEW_RENDERER"); const WebViewFeature._internal("GET_WEB_VIEW_RENDERER");
/// ///
static const MULTI_PROCESS = static const MULTI_PROCESS = const WebViewFeature._internal("MULTI_PROCESS");
const WebViewFeature._internal("MULTI_PROCESS");
/// ///
static const OFF_SCREEN_PRERASTER = static const OFF_SCREEN_PRERASTER =
const WebViewFeature._internal("OFF_SCREEN_PRERASTER"); const WebViewFeature._internal("OFF_SCREEN_PRERASTER");
/// ///
static const POST_WEB_MESSAGE = static const POST_WEB_MESSAGE =
const WebViewFeature._internal("POST_WEB_MESSAGE"); const WebViewFeature._internal("POST_WEB_MESSAGE");
/// ///
static const PROXY_OVERRIDE = static const PROXY_OVERRIDE =
const WebViewFeature._internal("PROXY_OVERRIDE"); const WebViewFeature._internal("PROXY_OVERRIDE");
/// ///
static const RECEIVE_HTTP_ERROR = static const RECEIVE_HTTP_ERROR =
const WebViewFeature._internal("RECEIVE_HTTP_ERROR"); const WebViewFeature._internal("RECEIVE_HTTP_ERROR");
/// ///
static const RECEIVE_WEB_RESOURCE_ERROR = static const RECEIVE_WEB_RESOURCE_ERROR =
const WebViewFeature._internal("RECEIVE_WEB_RESOURCE_ERROR"); const WebViewFeature._internal("RECEIVE_WEB_RESOURCE_ERROR");
/// ///
static const SAFE_BROWSING_ALLOWLIST = static const SAFE_BROWSING_ALLOWLIST =
const WebViewFeature._internal("SAFE_BROWSING_ALLOWLIST"); const WebViewFeature._internal("SAFE_BROWSING_ALLOWLIST");
/// ///
static const SAFE_BROWSING_ENABLE = static const SAFE_BROWSING_ENABLE =
const WebViewFeature._internal("SAFE_BROWSING_ENABLE"); const WebViewFeature._internal("SAFE_BROWSING_ENABLE");
/// ///
static const SAFE_BROWSING_HIT = static const SAFE_BROWSING_HIT =
const WebViewFeature._internal("SAFE_BROWSING_HIT"); const WebViewFeature._internal("SAFE_BROWSING_HIT");
/// ///
static const SAFE_BROWSING_PRIVACY_POLICY_URL = static const SAFE_BROWSING_PRIVACY_POLICY_URL =
const WebViewFeature._internal("SAFE_BROWSING_PRIVACY_POLICY_URL"); const WebViewFeature._internal("SAFE_BROWSING_PRIVACY_POLICY_URL");
/// ///
static const SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY = static const SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY =
const WebViewFeature._internal( const WebViewFeature._internal("SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY");
"SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY");
/// ///
static const SAFE_BROWSING_RESPONSE_PROCEED = static const SAFE_BROWSING_RESPONSE_PROCEED =
const WebViewFeature._internal("SAFE_BROWSING_RESPONSE_PROCEED"); const WebViewFeature._internal("SAFE_BROWSING_RESPONSE_PROCEED");
/// ///
static const SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL = static const SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL =
const WebViewFeature._internal( const WebViewFeature._internal(
"SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL"); "SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL");
///Use [SAFE_BROWSING_ALLOWLIST] instead. ///Use [SAFE_BROWSING_ALLOWLIST] instead.
@Deprecated('Use SAFE_BROWSING_ALLOWLIST instead') @Deprecated('Use SAFE_BROWSING_ALLOWLIST instead')
static const SAFE_BROWSING_WHITELIST = static const SAFE_BROWSING_WHITELIST =
const WebViewFeature._internal("SAFE_BROWSING_WHITELIST"); const WebViewFeature._internal("SAFE_BROWSING_WHITELIST");
/// ///
static const SERVICE_WORKER_BASIC_USAGE = static const SERVICE_WORKER_BASIC_USAGE =
const WebViewFeature._internal("SERVICE_WORKER_BASIC_USAGE"); const WebViewFeature._internal("SERVICE_WORKER_BASIC_USAGE");
/// ///
static const SERVICE_WORKER_BLOCK_NETWORK_LOADS = static const SERVICE_WORKER_BLOCK_NETWORK_LOADS =
const WebViewFeature._internal( const WebViewFeature._internal("SERVICE_WORKER_BLOCK_NETWORK_LOADS");
"SERVICE_WORKER_BLOCK_NETWORK_LOADS");
/// ///
static const SERVICE_WORKER_CACHE_MODE = static const SERVICE_WORKER_CACHE_MODE =
const WebViewFeature._internal("SERVICE_WORKER_CACHE_MODE"); const WebViewFeature._internal("SERVICE_WORKER_CACHE_MODE");
/// ///
static const SERVICE_WORKER_CONTENT_ACCESS = static const SERVICE_WORKER_CONTENT_ACCESS =
const WebViewFeature._internal("SERVICE_WORKER_CONTENT_ACCESS"); const WebViewFeature._internal("SERVICE_WORKER_CONTENT_ACCESS");
/// ///
static const SERVICE_WORKER_FILE_ACCESS = static const SERVICE_WORKER_FILE_ACCESS =
const WebViewFeature._internal("SERVICE_WORKER_FILE_ACCESS"); const WebViewFeature._internal("SERVICE_WORKER_FILE_ACCESS");
/// ///
static const SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST = static const SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST =
const WebViewFeature._internal( const WebViewFeature._internal("SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST");
"SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST");
/// ///
static const SHOULD_OVERRIDE_WITH_REDIRECTS = static const SHOULD_OVERRIDE_WITH_REDIRECTS =
const WebViewFeature._internal("SHOULD_OVERRIDE_WITH_REDIRECTS"); const WebViewFeature._internal("SHOULD_OVERRIDE_WITH_REDIRECTS");
/// ///
static const START_SAFE_BROWSING = static const START_SAFE_BROWSING =
const WebViewFeature._internal("START_SAFE_BROWSING"); const WebViewFeature._internal("START_SAFE_BROWSING");
/// ///
static const TRACING_CONTROLLER_BASIC_USAGE = static const TRACING_CONTROLLER_BASIC_USAGE =
const WebViewFeature._internal("TRACING_CONTROLLER_BASIC_USAGE"); const WebViewFeature._internal("TRACING_CONTROLLER_BASIC_USAGE");
/// ///
static const VISUAL_STATE_CALLBACK = static const VISUAL_STATE_CALLBACK =
const WebViewFeature._internal("VISUAL_STATE_CALLBACK"); const WebViewFeature._internal("VISUAL_STATE_CALLBACK");
/// ///
static const WEB_MESSAGE_CALLBACK_ON_MESSAGE = static const WEB_MESSAGE_CALLBACK_ON_MESSAGE =
const WebViewFeature._internal("WEB_MESSAGE_CALLBACK_ON_MESSAGE"); const WebViewFeature._internal("WEB_MESSAGE_CALLBACK_ON_MESSAGE");
/// ///
static const WEB_MESSAGE_LISTENER = static const WEB_MESSAGE_LISTENER =
const WebViewFeature._internal("WEB_MESSAGE_LISTENER"); const WebViewFeature._internal("WEB_MESSAGE_LISTENER");
/// ///
static const WEB_MESSAGE_PORT_CLOSE = static const WEB_MESSAGE_PORT_CLOSE =
const WebViewFeature._internal("WEB_MESSAGE_PORT_CLOSE"); const WebViewFeature._internal("WEB_MESSAGE_PORT_CLOSE");
/// ///
static const WEB_MESSAGE_PORT_POST_MESSAGE = static const WEB_MESSAGE_PORT_POST_MESSAGE =
const WebViewFeature._internal("WEB_MESSAGE_PORT_POST_MESSAGE"); const WebViewFeature._internal("WEB_MESSAGE_PORT_POST_MESSAGE");
/// ///
static const WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK = static const WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK =
const WebViewFeature._internal( const WebViewFeature._internal("WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK");
"WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK");
/// ///
static const WEB_RESOURCE_ERROR_GET_CODE = static const WEB_RESOURCE_ERROR_GET_CODE =
const WebViewFeature._internal("WEB_RESOURCE_ERROR_GET_CODE"); const WebViewFeature._internal("WEB_RESOURCE_ERROR_GET_CODE");
/// ///
static const WEB_RESOURCE_ERROR_GET_DESCRIPTION = static const WEB_RESOURCE_ERROR_GET_DESCRIPTION =
const WebViewFeature._internal( const WebViewFeature._internal("WEB_RESOURCE_ERROR_GET_DESCRIPTION");
"WEB_RESOURCE_ERROR_GET_DESCRIPTION");
/// ///
static const WEB_RESOURCE_REQUEST_IS_REDIRECT = static const WEB_RESOURCE_REQUEST_IS_REDIRECT =
const WebViewFeature._internal("WEB_RESOURCE_REQUEST_IS_REDIRECT"); const WebViewFeature._internal("WEB_RESOURCE_REQUEST_IS_REDIRECT");
/// ///
static const WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE = static const WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE =
const WebViewFeature._internal( const WebViewFeature._internal("WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE");
"WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE");
/// ///
static const WEB_VIEW_RENDERER_TERMINATE = static const WEB_VIEW_RENDERER_TERMINATE =
const WebViewFeature._internal("WEB_VIEW_RENDERER_TERMINATE"); const WebViewFeature._internal("WEB_VIEW_RENDERER_TERMINATE");
bool operator ==(value) => value == _value; bool operator ==(value) => value == _value;
@ -258,7 +251,6 @@ class WebViewFeature {
} }
} }
///Class that represents an Android-specific utility class for checking which WebView Support Library features are supported on the device. ///Class that represents an Android-specific utility class for checking which WebView Support Library features are supported on the device.
///Use [WebViewFeature] instead. ///Use [WebViewFeature] instead.
@Deprecated("Use WebViewFeature instead") @Deprecated("Use WebViewFeature instead")

View File

@ -88,8 +88,9 @@ class ChromeSafariBrowser {
///[settings]: Settings for the [ChromeSafariBrowser]. ///[settings]: Settings for the [ChromeSafariBrowser].
Future<void> open( Future<void> open(
{required Uri url, {required Uri url,
// ignore: deprecated_member_use_from_same_package @Deprecated('Use settings instead')
@Deprecated('Use settings instead') ChromeSafariBrowserClassOptions? options, // ignore: deprecated_member_use_from_same_package
ChromeSafariBrowserClassOptions? options,
ChromeSafariBrowserSettings? settings}) async { ChromeSafariBrowserSettings? settings}) async {
assert(url.toString().isNotEmpty); assert(url.toString().isNotEmpty);
this.throwIsAlreadyOpened(message: 'Cannot open $url!'); this.throwIsAlreadyOpened(message: 'Cannot open $url!');
@ -99,7 +100,8 @@ class ChromeSafariBrowser {
menuItemList.add({"id": value.id, "label": value.label}); menuItemList.add({"id": value.id, "label": value.label});
}); });
var initialSettings = settings?.toMap() ?? options?.toMap() ?? var initialSettings = settings?.toMap() ??
options?.toMap() ??
ChromeSafariBrowserSettings().toMap(); ChromeSafariBrowserSettings().toMap();
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};

View File

@ -32,7 +32,6 @@ class ChromeSafariBrowserOptions {
///Class that represents the settings that can be used for an [ChromeSafariBrowser] window. ///Class that represents the settings that can be used for an [ChromeSafariBrowser] window.
class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions {
///The share state that should be applied to the custom tab. The default value is [CustomTabsShareState.SHARE_STATE_DEFAULT]. ///The share state that should be applied to the custom tab. The default value is [CustomTabsShareState.SHARE_STATE_DEFAULT].
/// ///
///**NOTE**: Not available in a Trusted Web Activity. ///**NOTE**: Not available in a Trusted Web Activity.
@ -179,25 +178,25 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions {
ChromeSafariBrowserSettings( ChromeSafariBrowserSettings(
{this.shareState = CustomTabsShareState.SHARE_STATE_DEFAULT, {this.shareState = CustomTabsShareState.SHARE_STATE_DEFAULT,
this.showTitle = true, this.showTitle = true,
this.toolbarBackgroundColor, this.toolbarBackgroundColor,
this.enableUrlBarHiding = false, this.enableUrlBarHiding = false,
this.instantAppsEnabled = false, this.instantAppsEnabled = false,
this.packageName, this.packageName,
this.keepAliveEnabled = false, this.keepAliveEnabled = false,
this.isSingleInstance = false, this.isSingleInstance = false,
this.noHistory = false, this.noHistory = false,
this.isTrustedWebActivity = false, this.isTrustedWebActivity = false,
this.additionalTrustedOrigins = const [], this.additionalTrustedOrigins = const [],
this.displayMode, this.displayMode,
this.screenOrientation = TrustedWebActivityScreenOrientation.DEFAULT, this.screenOrientation = TrustedWebActivityScreenOrientation.DEFAULT,
this.entersReaderIfAvailable = false, this.entersReaderIfAvailable = false,
this.barCollapsingEnabled = false, this.barCollapsingEnabled = false,
this.dismissButtonStyle = DismissButtonStyle.DONE, this.dismissButtonStyle = DismissButtonStyle.DONE,
this.preferredBarTintColor, this.preferredBarTintColor,
this.preferredControlTintColor, this.preferredControlTintColor,
this.presentationStyle = ModalPresentationStyle.FULL_SCREEN, this.presentationStyle = ModalPresentationStyle.FULL_SCREEN,
this.transitionStyle = ModalTransitionStyle.COVER_VERTICAL}); this.transitionStyle = ModalTransitionStyle.COVER_VERTICAL});
@override @override
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
@ -226,8 +225,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions {
} }
static ChromeSafariBrowserSettings fromMap(Map<String, dynamic> map) { static ChromeSafariBrowserSettings fromMap(Map<String, dynamic> map) {
ChromeSafariBrowserSettings options = ChromeSafariBrowserSettings options = new ChromeSafariBrowserSettings();
new ChromeSafariBrowserSettings();
options.shareState = map["shareState"]; options.shareState = map["shareState"];
options.showTitle = map["showTitle"]; options.showTitle = map["showTitle"];
options.toolbarBackgroundColor = options.toolbarBackgroundColor =

View File

@ -438,7 +438,7 @@ class CookieManager {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
List<dynamic> cookieListMap = List<dynamic> cookieListMap =
await CookieManager._channel.invokeMethod('getAllCookies', args); await CookieManager._channel.invokeMethod('getAllCookies', args);
cookieListMap = cookieListMap.cast<Map<dynamic, dynamic>>(); cookieListMap = cookieListMap.cast<Map<dynamic, dynamic>>();
cookieListMap.forEach((cookieMap) { cookieListMap.forEach((cookieMap) {

View File

@ -107,15 +107,22 @@ class InAppBrowser {
///[settings]: Settings for the [InAppBrowser]. ///[settings]: Settings for the [InAppBrowser].
Future<void> openUrlRequest( Future<void> openUrlRequest(
{required URLRequest urlRequest, {required URLRequest urlRequest,
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
@Deprecated('Use settings instead') InAppBrowserClassOptions? options, @Deprecated('Use settings instead') InAppBrowserClassOptions? options,
InAppBrowserClassSettings? settings}) async { InAppBrowserClassSettings? settings}) async {
this.throwIfAlreadyOpened(message: 'Cannot open $urlRequest!'); this.throwIfAlreadyOpened(message: 'Cannot open $urlRequest!');
assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty); assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty);
var initialSettings = settings?.toMap() ?? options?.toMap() ?? var initialSettings = settings?.toMap() ??
options?.toMap() ??
InAppBrowserClassSettings().toMap(); InAppBrowserClassSettings().toMap();
Map<String, dynamic> pullToRefreshSettings =
pullToRefreshController?.settings.toMap() ??
// ignore: deprecated_member_use_from_same_package
pullToRefreshController?.options.toMap() ??
PullToRefreshSettings(enabled: false).toMap();
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('id', () => id); args.putIfAbsent('id', () => id);
args.putIfAbsent('urlRequest', () => urlRequest.toMap()); args.putIfAbsent('urlRequest', () => urlRequest.toMap());
@ -125,11 +132,7 @@ class InAppBrowser {
args.putIfAbsent('implementation', () => implementation.toValue()); args.putIfAbsent('implementation', () => implementation.toValue());
args.putIfAbsent('initialUserScripts', args.putIfAbsent('initialUserScripts',
() => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []);
args.putIfAbsent( args.putIfAbsent('pullToRefreshSettings', () => pullToRefreshSettings);
'pullToRefreshOptions',
() =>
pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap());
await _sharedChannel.invokeMethod('open', args); await _sharedChannel.invokeMethod('open', args);
} }
@ -178,9 +181,16 @@ class InAppBrowser {
this.throwIfAlreadyOpened(message: 'Cannot open $assetFilePath!'); this.throwIfAlreadyOpened(message: 'Cannot open $assetFilePath!');
assert(assetFilePath.isNotEmpty); assert(assetFilePath.isNotEmpty);
var initialSettings = settings?.toMap() ?? options?.toMap() ?? var initialSettings = settings?.toMap() ??
options?.toMap() ??
InAppBrowserClassSettings().toMap(); InAppBrowserClassSettings().toMap();
Map<String, dynamic> pullToRefreshSettings =
pullToRefreshController?.settings.toMap() ??
// ignore: deprecated_member_use_from_same_package
pullToRefreshController?.options.toMap() ??
PullToRefreshSettings(enabled: false).toMap();
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('id', () => id); args.putIfAbsent('id', () => id);
args.putIfAbsent('assetFilePath', () => assetFilePath); args.putIfAbsent('assetFilePath', () => assetFilePath);
@ -190,11 +200,7 @@ class InAppBrowser {
args.putIfAbsent('implementation', () => implementation.toValue()); args.putIfAbsent('implementation', () => implementation.toValue());
args.putIfAbsent('initialUserScripts', args.putIfAbsent('initialUserScripts',
() => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []);
args.putIfAbsent( args.putIfAbsent('pullToRefreshSettings', () => pullToRefreshSettings);
'pullToRefreshOptions',
() =>
pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap());
await _sharedChannel.invokeMethod('open', args); await _sharedChannel.invokeMethod('open', args);
} }
@ -221,9 +227,16 @@ class InAppBrowser {
InAppBrowserClassSettings? settings}) async { InAppBrowserClassSettings? settings}) async {
this.throwIfAlreadyOpened(message: 'Cannot open data!'); this.throwIfAlreadyOpened(message: 'Cannot open data!');
var initialSettings = settings?.toMap() ?? options?.toMap() ?? var initialSettings = settings?.toMap() ??
options?.toMap() ??
InAppBrowserClassSettings().toMap(); InAppBrowserClassSettings().toMap();
Map<String, dynamic> pullToRefreshSettings =
pullToRefreshController?.settings.toMap() ??
// ignore: deprecated_member_use_from_same_package
pullToRefreshController?.options.toMap() ??
PullToRefreshSettings(enabled: false).toMap();
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('id', () => id); args.putIfAbsent('id', () => id);
args.putIfAbsent('settings', () => initialSettings); args.putIfAbsent('settings', () => initialSettings);
@ -231,18 +244,14 @@ class InAppBrowser {
args.putIfAbsent('mimeType', () => mimeType); args.putIfAbsent('mimeType', () => mimeType);
args.putIfAbsent('encoding', () => encoding); args.putIfAbsent('encoding', () => encoding);
args.putIfAbsent('baseUrl', () => baseUrl?.toString() ?? "about:blank"); args.putIfAbsent('baseUrl', () => baseUrl?.toString() ?? "about:blank");
args.putIfAbsent( args.putIfAbsent('historyUrl',
'historyUrl', () => (historyUrl ?? androidHistoryUrl)?.toString() ?? "about:blank"); () => (historyUrl ?? androidHistoryUrl)?.toString() ?? "about:blank");
args.putIfAbsent('contextMenu', () => contextMenu?.toMap() ?? {}); args.putIfAbsent('contextMenu', () => contextMenu?.toMap() ?? {});
args.putIfAbsent('windowId', () => windowId); args.putIfAbsent('windowId', () => windowId);
args.putIfAbsent('implementation', () => implementation.toValue()); args.putIfAbsent('implementation', () => implementation.toValue());
args.putIfAbsent('initialUserScripts', args.putIfAbsent('initialUserScripts',
() => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []);
args.putIfAbsent( args.putIfAbsent('pullToRefreshSettings', () => pullToRefreshSettings);
'pullToRefreshOptions',
() =>
pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap());
await _sharedChannel.invokeMethod('open', args); await _sharedChannel.invokeMethod('open', args);
} }
@ -309,7 +318,8 @@ class InAppBrowser {
} }
///Sets the [InAppBrowser] settings with the new [settings] and evaluates them. ///Sets the [InAppBrowser] settings with the new [settings] and evaluates them.
Future<void> setSettings({required InAppBrowserClassSettings settings}) async { Future<void> setSettings(
{required InAppBrowserClassSettings settings}) async {
this.throwIfNotOpened(); this.throwIfNotOpened();
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
@ -323,10 +333,11 @@ class InAppBrowser {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
Map<dynamic, dynamic>? settings = Map<dynamic, dynamic>? settings =
await _channel.invokeMethod('getSettings', args); await _channel.invokeMethod('getSettings', args);
if (settings != null) { if (settings != null) {
settings = settings.cast<String, dynamic>(); settings = settings.cast<String, dynamic>();
return InAppBrowserClassSettings.fromMap(settings as Map<String, dynamic>); return InAppBrowserClassSettings.fromMap(
settings as Map<String, dynamic>);
} }
return null; return null;
@ -802,7 +813,7 @@ class InAppBrowser {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsShowPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback))) ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsShowPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)))
Future<GeolocationPermissionShowPromptResponse?>? Future<GeolocationPermissionShowPromptResponse?>?
onGeolocationPermissionsShowPrompt(String origin) {} onGeolocationPermissionsShowPrompt(String origin) {}
///Use [onGeolocationPermissionsHidePrompt] instead. ///Use [onGeolocationPermissionsHidePrompt] instead.
@Deprecated("Use onGeolocationPermissionsHidePrompt instead") @Deprecated("Use onGeolocationPermissionsHidePrompt instead")
@ -863,8 +874,7 @@ class InAppBrowser {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)))
Future<WebViewRenderProcessAction?>? onRenderProcessUnresponsive( Future<WebViewRenderProcessAction?>? onRenderProcessUnresponsive(Uri? url) {}
Uri? url) {}
///Use [onRenderProcessResponsive] instead. ///Use [onRenderProcessResponsive] instead.
@Deprecated("Use onRenderProcessResponsive instead") @Deprecated("Use onRenderProcessResponsive instead")
@ -883,8 +893,7 @@ class InAppBrowser {
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)))
Future<WebViewRenderProcessAction?>? onRenderProcessResponsive( Future<WebViewRenderProcessAction?>? onRenderProcessResponsive(Uri? url) {}
Uri? url) {}
///Use [onRenderProcessGone] instead. ///Use [onRenderProcessGone] instead.
@Deprecated("Use onRenderProcessGone instead") @Deprecated("Use onRenderProcessGone instead")
@ -928,7 +937,6 @@ class InAppBrowser {
///- Android native WebView ([Official API - WebChromeClient.onReceivedIcon](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap))) ///- Android native WebView ([Official API - WebChromeClient.onReceivedIcon](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap)))
void onReceivedIcon(Uint8List icon) {} void onReceivedIcon(Uint8List icon) {}
///Use [onReceivedTouchIconUrl] instead. ///Use [onReceivedTouchIconUrl] instead.
@Deprecated('Use onReceivedTouchIconUrl instead') @Deprecated('Use onReceivedTouchIconUrl instead')
void androidOnReceivedTouchIconUrl(Uri url, bool precomposed) {} void androidOnReceivedTouchIconUrl(Uri url, bool precomposed) {}
@ -943,7 +951,6 @@ class InAppBrowser {
///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean))) ///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)))
void onReceivedTouchIconUrl(Uri url, bool precomposed) {} void onReceivedTouchIconUrl(Uri url, bool precomposed) {}
///Use [onJsBeforeUnload] instead. ///Use [onJsBeforeUnload] instead.
@Deprecated('Use onJsBeforeUnload instead') @Deprecated('Use onJsBeforeUnload instead')
Future<JsBeforeUnloadResponse?>? androidOnJsBeforeUnload( Future<JsBeforeUnloadResponse?>? androidOnJsBeforeUnload(

View File

@ -46,7 +46,7 @@ class InAppBrowserClassSettings {
InAppBrowserClassSettings( InAppBrowserClassSettings(
{InAppBrowserSettings? browserSettings, {InAppBrowserSettings? browserSettings,
InAppWebViewSettings? webViewSettings}) { InAppWebViewSettings? webViewSettings}) {
this.browserSettings = browserSettings ?? InAppBrowserSettings(); this.browserSettings = browserSettings ?? InAppBrowserSettings();
this.webViewSettings = webViewSettings ?? InAppWebViewSettings(); this.webViewSettings = webViewSettings ?? InAppWebViewSettings();
} }
@ -60,7 +60,8 @@ class InAppBrowserClassSettings {
return options; return options;
} }
static Map<String, dynamic> instanceToMap(InAppBrowserClassSettings settings) { static Map<String, dynamic> instanceToMap(
InAppBrowserClassSettings settings) {
return settings.toMap(); return settings.toMap();
} }
@ -73,7 +74,8 @@ class InAppBrowserClassSettings {
return toMap().toString(); return toMap().toString();
} }
static InAppBrowserClassSettings fromMap(Map<String, dynamic> options, {InAppBrowserClassSettings? instance}) { static InAppBrowserClassSettings fromMap(Map<String, dynamic> options,
{InAppBrowserClassSettings? instance}) {
if (instance == null) { if (instance == null) {
instance = InAppBrowserClassSettings(); instance = InAppBrowserClassSettings();
} }
@ -88,8 +90,8 @@ class InAppBrowserClassSettings {
} }
///This class represents all [InAppBrowser] settings available. ///This class represents all [InAppBrowser] settings available.
class InAppBrowserSettings implements BrowserOptions, AndroidOptions, IosOptions { 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. ///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`. ///The default value is `false`.
/// ///
@ -224,25 +226,25 @@ class InAppBrowserSettings implements BrowserOptions, AndroidOptions, IosOptions
InAppBrowserSettings( InAppBrowserSettings(
{this.hidden = false, {this.hidden = false,
this.hideToolbarTop = false, this.hideToolbarTop = false,
this.toolbarTopBackgroundColor, this.toolbarTopBackgroundColor,
this.hideUrlBar = false, this.hideUrlBar = false,
this.hideProgressBar = false, this.hideProgressBar = false,
this.toolbarTopTranslucent = true, this.toolbarTopTranslucent = true,
this.toolbarTopTintColor, this.toolbarTopTintColor,
this.hideToolbarBottom = false, this.hideToolbarBottom = false,
this.toolbarBottomBackgroundColor, this.toolbarBottomBackgroundColor,
this.toolbarBottomTintColor, this.toolbarBottomTintColor,
this.toolbarBottomTranslucent = true, this.toolbarBottomTranslucent = true,
this.closeButtonCaption, this.closeButtonCaption,
this.closeButtonColor, this.closeButtonColor,
this.presentationStyle = ModalPresentationStyle.FULL_SCREEN, this.presentationStyle = ModalPresentationStyle.FULL_SCREEN,
this.transitionStyle = ModalTransitionStyle.COVER_VERTICAL, this.transitionStyle = ModalTransitionStyle.COVER_VERTICAL,
this.hideTitleBar = false, this.hideTitleBar = false,
this.toolbarTopFixedTitle, this.toolbarTopFixedTitle,
this.closeOnCannotGoBack = true, this.closeOnCannotGoBack = true,
this.allowGoBackWithBackButton = true, this.allowGoBackWithBackButton = true,
this.shouldCloseOnBackButtonPressed = false}); this.shouldCloseOnBackButtonPressed = false});
@override @override
Map<String, dynamic> toMap() { Map<String, dynamic> toMap() {
@ -282,9 +284,11 @@ class InAppBrowserSettings implements BrowserOptions, AndroidOptions, IosOptions
instance.toolbarTopFixedTitle = map["toolbarTopFixedTitle"]; instance.toolbarTopFixedTitle = map["toolbarTopFixedTitle"];
instance.closeOnCannotGoBack = map["closeOnCannotGoBack"]; instance.closeOnCannotGoBack = map["closeOnCannotGoBack"];
instance.allowGoBackWithBackButton = map["allowGoBackWithBackButton"]; instance.allowGoBackWithBackButton = map["allowGoBackWithBackButton"];
instance.shouldCloseOnBackButtonPressed = map["shouldCloseOnBackButtonPressed"]; instance.shouldCloseOnBackButtonPressed =
map["shouldCloseOnBackButtonPressed"];
instance.toolbarTopTranslucent = map["toolbarTopTranslucent"]; instance.toolbarTopTranslucent = map["toolbarTopTranslucent"];
instance.toolbarTopTintColor = UtilColor.fromHex(map["toolbarTopTintColor"]); instance.toolbarTopTintColor =
UtilColor.fromHex(map["toolbarTopTintColor"]);
instance.hideToolbarBottom = map["hideToolbarBottom"]; instance.hideToolbarBottom = map["hideToolbarBottom"];
instance.toolbarBottomBackgroundColor = instance.toolbarBottomBackgroundColor =
UtilColor.fromHex(map["toolbarBottomBackgroundColor"]); UtilColor.fromHex(map["toolbarBottomBackgroundColor"]);
@ -294,9 +298,9 @@ class InAppBrowserSettings implements BrowserOptions, AndroidOptions, IosOptions
instance.closeButtonCaption = map["closeButtonCaption"]; instance.closeButtonCaption = map["closeButtonCaption"];
instance.closeButtonColor = UtilColor.fromHex(map["closeButtonColor"]); instance.closeButtonColor = UtilColor.fromHex(map["closeButtonColor"]);
instance.presentationStyle = instance.presentationStyle =
ModalPresentationStyle.fromValue(map["presentationStyle"])!; ModalPresentationStyle.fromValue(map["presentationStyle"])!;
instance.transitionStyle = instance.transitionStyle =
ModalTransitionStyle.fromValue(map["transitionStyle"])!; ModalTransitionStyle.fromValue(map["transitionStyle"])!;
return instance; return instance;
} }

View File

@ -76,7 +76,8 @@ class IOSInAppBrowserOptions implements BrowserOptions, IosOptions {
static IOSInAppBrowserOptions fromMap(Map<String, dynamic> map) { static IOSInAppBrowserOptions fromMap(Map<String, dynamic> map) {
var instance = IOSInAppBrowserOptions(); var instance = IOSInAppBrowserOptions();
instance.toolbarTopTranslucent = map["toolbarTopTranslucent"]; instance.toolbarTopTranslucent = map["toolbarTopTranslucent"];
instance.toolbarTopTintColor = UtilColor.fromHex(map["toolbarTopTintColor"]); instance.toolbarTopTintColor =
UtilColor.fromHex(map["toolbarTopTintColor"]);
instance.hideToolbarBottom = map["hideToolbarBottom"]; instance.hideToolbarBottom = map["hideToolbarBottom"];
instance.toolbarBottomBackgroundColor = instance.toolbarBottomBackgroundColor =
UtilColor.fromHex(map["toolbarBottomBackgroundColor"]); UtilColor.fromHex(map["toolbarBottomBackgroundColor"]);

View File

@ -127,7 +127,8 @@ class AndroidInAppWebViewController with AndroidInAppWebViewControllerMixin {
} }
///Use [InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl] instead. ///Use [InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl] instead.
@Deprecated("Use InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl instead") @Deprecated(
"Use InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl instead")
static Future<Uri?> getSafeBrowsingPrivacyPolicyUrl() async { static Future<Uri?> getSafeBrowsingPrivacyPolicyUrl() async {
return await InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl(); return await InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl();
} }
@ -142,15 +143,18 @@ class AndroidInAppWebViewController with AndroidInAppWebViewControllerMixin {
///Use [InAppWebViewController.getCurrentWebViewPackage] instead. ///Use [InAppWebViewController.getCurrentWebViewPackage] instead.
@Deprecated("Use InAppWebViewController.getCurrentWebViewPackage instead") @Deprecated("Use InAppWebViewController.getCurrentWebViewPackage instead")
static Future<AndroidWebViewPackageInfo?> getCurrentWebViewPackage() async { static Future<AndroidWebViewPackageInfo?> getCurrentWebViewPackage() async {
Map<String, dynamic>? packageInfo = (await InAppWebViewController.getCurrentWebViewPackage())?.toMap(); Map<String, dynamic>? packageInfo =
(await InAppWebViewController.getCurrentWebViewPackage())?.toMap();
return AndroidWebViewPackageInfo.fromMap(packageInfo); return AndroidWebViewPackageInfo.fromMap(packageInfo);
} }
///Use [InAppWebViewController.setWebContentsDebuggingEnabled] instead. ///Use [InAppWebViewController.setWebContentsDebuggingEnabled] instead.
@Deprecated("Use InAppWebViewController.setWebContentsDebuggingEnabled instead") @Deprecated(
"Use InAppWebViewController.setWebContentsDebuggingEnabled instead")
static Future<void> setWebContentsDebuggingEnabled( static Future<void> setWebContentsDebuggingEnabled(
bool debuggingEnabled) async { bool debuggingEnabled) async {
return await InAppWebViewController.setWebContentsDebuggingEnabled(debuggingEnabled); return await InAppWebViewController.setWebContentsDebuggingEnabled(
debuggingEnabled);
} }
///Use [InAppWebViewController.getOriginalUrl] instead. ///Use [InAppWebViewController.getOriginalUrl] instead.
@ -160,4 +164,4 @@ class AndroidInAppWebViewController with AndroidInAppWebViewControllerMixin {
String? url = await _channel.invokeMethod('getOriginalUrl', args); String? url = await _channel.invokeMethod('getOriginalUrl', args);
return url != null ? Uri.parse(url) : null; return url != null ? Uri.parse(url) : null;
} }
} }

View File

@ -11,7 +11,7 @@ import 'webview.dart';
import 'in_app_webview_controller.dart'; import 'in_app_webview_controller.dart';
import 'in_app_webview_settings.dart'; import 'in_app_webview_settings.dart';
import '../pull_to_refresh/pull_to_refresh_controller.dart'; import '../pull_to_refresh/pull_to_refresh_controller.dart';
import '../pull_to_refresh/pull_to_refresh_options.dart'; import '../pull_to_refresh/pull_to_refresh_settings.dart';
import '../util.dart'; import '../util.dart';
///Class that represents a WebView in headless mode. ///Class that represents a WebView in headless mode.
@ -43,90 +43,104 @@ class HeadlessInAppWebView implements WebView {
///**NOTE for Android**: `Size` width and height values will be converted to `int` values because they cannot have `double` values. ///**NOTE for Android**: `Size` width and height values will be converted to `int` values because they cannot have `double` values.
final Size initialSize; final Size initialSize;
HeadlessInAppWebView( HeadlessInAppWebView({
{this.initialSize = const Size(-1, -1), this.initialSize = const Size(-1, -1),
this.windowId, this.windowId,
this.initialUrlRequest, this.initialUrlRequest,
this.initialFile, this.initialFile,
this.initialData, this.initialData,
@Deprecated('Use initialSettings instead') this.initialOptions, @Deprecated('Use initialSettings instead') this.initialOptions,
this.initialSettings, this.initialSettings,
this.contextMenu, this.contextMenu,
this.initialUserScripts, this.initialUserScripts,
this.pullToRefreshController, this.pullToRefreshController,
this.implementation = WebViewImplementation.NATIVE, this.implementation = WebViewImplementation.NATIVE,
this.onWebViewCreated, this.onWebViewCreated,
this.onLoadStart, this.onLoadStart,
this.onLoadStop, this.onLoadStop,
this.onLoadError, this.onLoadError,
this.onLoadHttpError, this.onLoadHttpError,
this.onProgressChanged, this.onProgressChanged,
this.onConsoleMessage, this.onConsoleMessage,
this.shouldOverrideUrlLoading, this.shouldOverrideUrlLoading,
this.onLoadResource, this.onLoadResource,
this.onScrollChanged, this.onScrollChanged,
@Deprecated('Use onDownloadStartRequest instead') @Deprecated('Use onDownloadStartRequest instead') this.onDownloadStart,
this.onDownloadStart, this.onDownloadStartRequest,
this.onDownloadStartRequest, this.onLoadResourceCustomScheme,
this.onLoadResourceCustomScheme, this.onCreateWindow,
this.onCreateWindow, this.onCloseWindow,
this.onCloseWindow, this.onJsAlert,
this.onJsAlert, this.onJsConfirm,
this.onJsConfirm, this.onJsPrompt,
this.onJsPrompt, this.onReceivedHttpAuthRequest,
this.onReceivedHttpAuthRequest, this.onReceivedServerTrustAuthRequest,
this.onReceivedServerTrustAuthRequest, this.onReceivedClientCertRequest,
this.onReceivedClientCertRequest, this.onFindResultReceived,
this.onFindResultReceived, this.shouldInterceptAjaxRequest,
this.shouldInterceptAjaxRequest, this.onAjaxReadyStateChange,
this.onAjaxReadyStateChange, this.onAjaxProgress,
this.onAjaxProgress, this.shouldInterceptFetchRequest,
this.shouldInterceptFetchRequest, this.onUpdateVisitedHistory,
this.onUpdateVisitedHistory, this.onPrint,
this.onPrint, this.onLongPressHitTestResult,
this.onLongPressHitTestResult, this.onEnterFullscreen,
this.onEnterFullscreen, this.onExitFullscreen,
this.onExitFullscreen, this.onPageCommitVisible,
this.onPageCommitVisible, this.onTitleChanged,
this.onTitleChanged, this.onWindowFocus,
this.onWindowFocus, this.onWindowBlur,
this.onWindowBlur, this.onOverScrolled,
this.onOverScrolled, @Deprecated('Use onSafeBrowsingHit instead') this.androidOnSafeBrowsingHit,
@Deprecated('Use onSafeBrowsingHit instead') this.androidOnSafeBrowsingHit, this.onSafeBrowsingHit,
this.onSafeBrowsingHit, @Deprecated('Use onPermissionRequest instead')
@Deprecated('Use onPermissionRequest instead') this.androidOnPermissionRequest, this.androidOnPermissionRequest,
this.onPermissionRequest, this.onPermissionRequest,
@Deprecated('Use onGeolocationPermissionsShowPrompt instead') this.androidOnGeolocationPermissionsShowPrompt, @Deprecated('Use onGeolocationPermissionsShowPrompt instead')
this.onGeolocationPermissionsShowPrompt, this.androidOnGeolocationPermissionsShowPrompt,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead') this.androidOnGeolocationPermissionsHidePrompt, this.onGeolocationPermissionsShowPrompt,
this.onGeolocationPermissionsHidePrompt, @Deprecated('Use onGeolocationPermissionsHidePrompt instead')
@Deprecated('Use shouldInterceptRequest instead') this.androidShouldInterceptRequest, this.androidOnGeolocationPermissionsHidePrompt,
this.shouldInterceptRequest, this.onGeolocationPermissionsHidePrompt,
@Deprecated('Use onRenderProcessGone instead') this.androidOnRenderProcessGone, @Deprecated('Use shouldInterceptRequest instead')
this.onRenderProcessGone, this.androidShouldInterceptRequest,
@Deprecated('Use onRenderProcessResponsive instead') this.androidOnRenderProcessResponsive, this.shouldInterceptRequest,
this.onRenderProcessResponsive, @Deprecated('Use onRenderProcessGone instead')
@Deprecated('Use onRenderProcessUnresponsive instead') this.androidOnRenderProcessUnresponsive, this.androidOnRenderProcessGone,
this.onRenderProcessUnresponsive, this.onRenderProcessGone,
@Deprecated('Use onFormResubmission instead') this.androidOnFormResubmission, @Deprecated('Use onRenderProcessResponsive instead')
this.onFormResubmission, this.androidOnRenderProcessResponsive,
@Deprecated('Use onZoomScaleChanged instead') this.androidOnScaleChanged, this.onRenderProcessResponsive,
@Deprecated('Use onReceivedIcon instead') this.androidOnReceivedIcon, @Deprecated('Use onRenderProcessUnresponsive instead')
this.onReceivedIcon, this.androidOnRenderProcessUnresponsive,
@Deprecated('Use onReceivedTouchIconUrl instead') this.androidOnReceivedTouchIconUrl, this.onRenderProcessUnresponsive,
this.onReceivedTouchIconUrl, @Deprecated('Use onFormResubmission instead')
@Deprecated('Use onJsBeforeUnload instead') this.androidOnJsBeforeUnload, this.androidOnFormResubmission,
this.onJsBeforeUnload, this.onFormResubmission,
@Deprecated('Use onReceivedLoginRequest instead') this.androidOnReceivedLoginRequest, @Deprecated('Use onZoomScaleChanged instead') this.androidOnScaleChanged,
this.onReceivedLoginRequest, @Deprecated('Use onReceivedIcon instead') this.androidOnReceivedIcon,
@Deprecated('Use onWebContentProcessDidTerminate instead') this.iosOnWebContentProcessDidTerminate, this.onReceivedIcon,
this.onWebContentProcessDidTerminate, @Deprecated('Use onReceivedTouchIconUrl instead')
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead') this.iosOnDidReceiveServerRedirectForProvisionalNavigation, this.androidOnReceivedTouchIconUrl,
this.onDidReceiveServerRedirectForProvisionalNavigation, this.onReceivedTouchIconUrl,
@Deprecated('Use onNavigationResponse instead') this.iosOnNavigationResponse, @Deprecated('Use onJsBeforeUnload instead') this.androidOnJsBeforeUnload,
this.onNavigationResponse, this.onJsBeforeUnload,
@Deprecated('Use shouldAllowDeprecatedTLS instead') this.iosShouldAllowDeprecatedTLS, @Deprecated('Use onReceivedLoginRequest instead')
this.shouldAllowDeprecatedTLS,}) { this.androidOnReceivedLoginRequest,
this.onReceivedLoginRequest,
@Deprecated('Use onWebContentProcessDidTerminate instead')
this.iosOnWebContentProcessDidTerminate,
this.onWebContentProcessDidTerminate,
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
this.onDidReceiveServerRedirectForProvisionalNavigation,
@Deprecated('Use onNavigationResponse instead')
this.iosOnNavigationResponse,
this.onNavigationResponse,
@Deprecated('Use shouldAllowDeprecatedTLS instead')
this.iosShouldAllowDeprecatedTLS,
this.shouldAllowDeprecatedTLS,
}) {
id = IdGenerator.generate(); id = IdGenerator.generate();
webViewController = new InAppWebViewController(id, this); webViewController = new InAppWebViewController(id, this);
this._channel = this._channel =
@ -155,10 +169,16 @@ class HeadlessInAppWebView implements WebView {
} }
_started = true; _started = true;
Map<String, dynamic> initialSettings = (this.initialSettings != null ? Map<String, dynamic> initialSettings = this.initialSettings?.toMap() ??
this.initialSettings?.toMap() : // ignore: deprecated_member_use_from_same_package
// ignore: deprecated_member_use_from_same_package this.initialOptions?.toMap() ??
this.initialOptions?.toMap()) ?? {}; {};
Map<String, dynamic> pullToRefreshSettings =
this.pullToRefreshController?.settings.toMap() ??
// ignore: deprecated_member_use_from_same_package
this.pullToRefreshController?.options.toMap() ??
PullToRefreshSettings(enabled: false).toMap();
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent('id', () => id); args.putIfAbsent('id', () => id);
@ -174,9 +194,7 @@ class HeadlessInAppWebView implements WebView {
'implementation': this.implementation.toValue(), 'implementation': this.implementation.toValue(),
'initialUserScripts': 'initialUserScripts':
this.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], this.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
'pullToRefreshOptions': 'pullToRefreshSettings': pullToRefreshSettings,
this.pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap(),
'initialSize': this.initialSize.toMap() 'initialSize': this.initialSize.toMap()
}); });
await _sharedChannel.invokeMethod('run', args); await _sharedChannel.invokeMethod('run', args);
@ -425,8 +443,7 @@ class HeadlessInAppWebView implements WebView {
onScrollChanged; onScrollChanged;
@override @override
void Function( void Function(InAppWebViewController controller, Uri? url, bool? isReload)?
InAppWebViewController controller, Uri? url, bool? isReload)?
onUpdateVisitedHistory; onUpdateVisitedHistory;
@override @override
@ -528,53 +545,74 @@ class HeadlessInAppWebView implements WebView {
androidOnReceivedLoginRequest; androidOnReceivedLoginRequest;
@override @override
void Function(InAppWebViewController controller)? onDidReceiveServerRedirectForProvisionalNavigation; void Function(InAppWebViewController controller)?
onDidReceiveServerRedirectForProvisionalNavigation;
@override @override
Future<FormResubmissionAction?> Function(InAppWebViewController controller, Uri? url)? onFormResubmission; Future<FormResubmissionAction?> Function(
InAppWebViewController controller, Uri? url)? onFormResubmission;
@override @override
void Function(InAppWebViewController controller)? onGeolocationPermissionsHidePrompt; void Function(InAppWebViewController controller)?
onGeolocationPermissionsHidePrompt;
@override @override
Future<GeolocationPermissionShowPromptResponse?> Function(InAppWebViewController controller, String origin)? onGeolocationPermissionsShowPrompt; Future<GeolocationPermissionShowPromptResponse?> Function(
InAppWebViewController controller, String origin)?
onGeolocationPermissionsShowPrompt;
@override @override
Future<JsBeforeUnloadResponse?> Function(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload; Future<JsBeforeUnloadResponse?> Function(InAppWebViewController controller,
JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload;
@override @override
Future<NavigationResponseAction?> Function(InAppWebViewController controller, NavigationResponse navigationResponse)? onNavigationResponse; Future<NavigationResponseAction?> Function(InAppWebViewController controller,
NavigationResponse navigationResponse)? onNavigationResponse;
@override @override
Future<PermissionRequestResponse?> Function(InAppWebViewController controller, String origin, List<String> resources)? onPermissionRequest; Future<PermissionRequestResponse?> Function(InAppWebViewController controller,
String origin, List<String> resources)? onPermissionRequest;
@override @override
void Function(InAppWebViewController controller, Uint8List icon)? onReceivedIcon; void Function(InAppWebViewController controller, Uint8List icon)?
onReceivedIcon;
@override @override
void Function(InAppWebViewController controller, LoginRequest loginRequest)? onReceivedLoginRequest; void Function(InAppWebViewController controller, LoginRequest loginRequest)?
onReceivedLoginRequest;
@override @override
void Function(InAppWebViewController controller, Uri url, bool precomposed)? onReceivedTouchIconUrl; void Function(InAppWebViewController controller, Uri url, bool precomposed)?
onReceivedTouchIconUrl;
@override @override
void Function(InAppWebViewController controller, RenderProcessGoneDetail detail)? onRenderProcessGone; void Function(
InAppWebViewController controller, RenderProcessGoneDetail detail)?
onRenderProcessGone;
@override @override
Future<WebViewRenderProcessAction?> Function(InAppWebViewController controller, Uri? url)? onRenderProcessResponsive; Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessResponsive;
@override @override
Future<WebViewRenderProcessAction?> Function(InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive; Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive;
@override @override
Future<SafeBrowsingResponse?> Function(InAppWebViewController controller, Uri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit; Future<SafeBrowsingResponse?> Function(InAppWebViewController controller,
Uri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit;
@override @override
void Function(InAppWebViewController controller)? onWebContentProcessDidTerminate; void Function(InAppWebViewController controller)?
onWebContentProcessDidTerminate;
@override @override
Future<ShouldAllowDeprecatedTLSAction?> Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS; Future<ShouldAllowDeprecatedTLSAction?> Function(
InAppWebViewController controller,
URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS;
@override @override
Future<WebResourceResponse?> Function(InAppWebViewController controller, WebResourceRequest request)? shouldInterceptRequest; Future<WebResourceResponse?> Function(
InAppWebViewController controller, WebResourceRequest request)?
shouldInterceptRequest;
} }

View File

@ -82,38 +82,52 @@ class InAppWebView extends StatefulWidget implements WebView {
this.onZoomScaleChanged, this.onZoomScaleChanged,
@Deprecated('Use onSafeBrowsingHit instead') this.androidOnSafeBrowsingHit, @Deprecated('Use onSafeBrowsingHit instead') this.androidOnSafeBrowsingHit,
this.onSafeBrowsingHit, this.onSafeBrowsingHit,
@Deprecated('Use onPermissionRequest instead') this.androidOnPermissionRequest, @Deprecated('Use onPermissionRequest instead')
this.androidOnPermissionRequest,
this.onPermissionRequest, this.onPermissionRequest,
@Deprecated('Use onGeolocationPermissionsShowPrompt instead') this.androidOnGeolocationPermissionsShowPrompt, @Deprecated('Use onGeolocationPermissionsShowPrompt instead')
this.androidOnGeolocationPermissionsShowPrompt,
this.onGeolocationPermissionsShowPrompt, this.onGeolocationPermissionsShowPrompt,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead') this.androidOnGeolocationPermissionsHidePrompt, @Deprecated('Use onGeolocationPermissionsHidePrompt instead')
this.androidOnGeolocationPermissionsHidePrompt,
this.onGeolocationPermissionsHidePrompt, this.onGeolocationPermissionsHidePrompt,
@Deprecated('Use shouldInterceptRequest instead') this.androidShouldInterceptRequest, @Deprecated('Use shouldInterceptRequest instead')
this.androidShouldInterceptRequest,
this.shouldInterceptRequest, this.shouldInterceptRequest,
@Deprecated('Use onRenderProcessGone instead') this.androidOnRenderProcessGone, @Deprecated('Use onRenderProcessGone instead')
this.androidOnRenderProcessGone,
this.onRenderProcessGone, this.onRenderProcessGone,
@Deprecated('Use onRenderProcessResponsive instead') this.androidOnRenderProcessResponsive, @Deprecated('Use onRenderProcessResponsive instead')
this.androidOnRenderProcessResponsive,
this.onRenderProcessResponsive, this.onRenderProcessResponsive,
@Deprecated('Use onRenderProcessUnresponsive instead') this.androidOnRenderProcessUnresponsive, @Deprecated('Use onRenderProcessUnresponsive instead')
this.androidOnRenderProcessUnresponsive,
this.onRenderProcessUnresponsive, this.onRenderProcessUnresponsive,
@Deprecated('Use onFormResubmission instead') this.androidOnFormResubmission, @Deprecated('Use onFormResubmission instead')
this.androidOnFormResubmission,
this.onFormResubmission, this.onFormResubmission,
@Deprecated('Use onZoomScaleChanged instead') this.androidOnScaleChanged, @Deprecated('Use onZoomScaleChanged instead') this.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead') this.androidOnReceivedIcon, @Deprecated('Use onReceivedIcon instead') this.androidOnReceivedIcon,
this.onReceivedIcon, this.onReceivedIcon,
@Deprecated('Use onReceivedTouchIconUrl instead') this.androidOnReceivedTouchIconUrl, @Deprecated('Use onReceivedTouchIconUrl instead')
this.androidOnReceivedTouchIconUrl,
this.onReceivedTouchIconUrl, this.onReceivedTouchIconUrl,
@Deprecated('Use onJsBeforeUnload instead') this.androidOnJsBeforeUnload, @Deprecated('Use onJsBeforeUnload instead') this.androidOnJsBeforeUnload,
this.onJsBeforeUnload, this.onJsBeforeUnload,
@Deprecated('Use onReceivedLoginRequest instead') this.androidOnReceivedLoginRequest, @Deprecated('Use onReceivedLoginRequest instead')
this.androidOnReceivedLoginRequest,
this.onReceivedLoginRequest, this.onReceivedLoginRequest,
@Deprecated('Use onWebContentProcessDidTerminate instead') this.iosOnWebContentProcessDidTerminate, @Deprecated('Use onWebContentProcessDidTerminate instead')
this.iosOnWebContentProcessDidTerminate,
this.onWebContentProcessDidTerminate, this.onWebContentProcessDidTerminate,
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead') this.iosOnDidReceiveServerRedirectForProvisionalNavigation, @Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
this.onDidReceiveServerRedirectForProvisionalNavigation, this.onDidReceiveServerRedirectForProvisionalNavigation,
@Deprecated('Use onNavigationResponse instead') this.iosOnNavigationResponse, @Deprecated('Use onNavigationResponse instead')
this.iosOnNavigationResponse,
this.onNavigationResponse, this.onNavigationResponse,
@Deprecated('Use shouldAllowDeprecatedTLS instead') this.iosShouldAllowDeprecatedTLS, @Deprecated('Use shouldAllowDeprecatedTLS instead')
this.iosShouldAllowDeprecatedTLS,
this.shouldAllowDeprecatedTLS, this.shouldAllowDeprecatedTLS,
this.gestureRecognizers, this.gestureRecognizers,
}) : super(key: key); }) : super(key: key);
@ -428,55 +442,84 @@ class InAppWebView extends StatefulWidget implements WebView {
androidOnReceivedLoginRequest; androidOnReceivedLoginRequest;
@override @override
final void Function(InAppWebViewController controller)? onDidReceiveServerRedirectForProvisionalNavigation; final void Function(InAppWebViewController controller)?
onDidReceiveServerRedirectForProvisionalNavigation;
@override @override
final Future<FormResubmissionAction?> Function(InAppWebViewController controller, Uri? url)? onFormResubmission; final Future<FormResubmissionAction?> Function(
InAppWebViewController controller, Uri? url)? onFormResubmission;
@override @override
final void Function(InAppWebViewController controller)? onGeolocationPermissionsHidePrompt; final void Function(InAppWebViewController controller)?
onGeolocationPermissionsHidePrompt;
@override @override
final Future<GeolocationPermissionShowPromptResponse?> Function(InAppWebViewController controller, String origin)? onGeolocationPermissionsShowPrompt; final Future<GeolocationPermissionShowPromptResponse?> Function(
InAppWebViewController controller, String origin)?
onGeolocationPermissionsShowPrompt;
@override @override
final Future<JsBeforeUnloadResponse?> Function(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload; final Future<JsBeforeUnloadResponse?> Function(
InAppWebViewController controller,
JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload;
@override @override
final Future<NavigationResponseAction?> Function(InAppWebViewController controller, NavigationResponse navigationResponse)? onNavigationResponse; final Future<NavigationResponseAction?> Function(
InAppWebViewController controller,
NavigationResponse navigationResponse)? onNavigationResponse;
@override @override
final Future<PermissionRequestResponse?> Function(InAppWebViewController controller, String origin, List<String> resources)? onPermissionRequest; final Future<PermissionRequestResponse?> Function(
InAppWebViewController controller,
String origin,
List<String> resources)? onPermissionRequest;
@override @override
final void Function(InAppWebViewController controller, Uint8List icon)? onReceivedIcon; final void Function(InAppWebViewController controller, Uint8List icon)?
onReceivedIcon;
@override @override
final void Function(InAppWebViewController controller, LoginRequest loginRequest)? onReceivedLoginRequest; final void Function(
InAppWebViewController controller, LoginRequest loginRequest)?
onReceivedLoginRequest;
@override @override
final void Function(InAppWebViewController controller, Uri url, bool precomposed)? onReceivedTouchIconUrl; final void Function(
InAppWebViewController controller, Uri url, bool precomposed)?
onReceivedTouchIconUrl;
@override @override
final void Function(InAppWebViewController controller, RenderProcessGoneDetail detail)? onRenderProcessGone; final void Function(
InAppWebViewController controller, RenderProcessGoneDetail detail)?
onRenderProcessGone;
@override @override
final Future<WebViewRenderProcessAction?> Function(InAppWebViewController controller, Uri? url)? onRenderProcessResponsive; final Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessResponsive;
@override @override
final Future<WebViewRenderProcessAction?> Function(InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive; final Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive;
@override @override
final Future<SafeBrowsingResponse?> Function(InAppWebViewController controller, Uri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit; final Future<SafeBrowsingResponse?> Function(
InAppWebViewController controller,
Uri url,
SafeBrowsingThreat? threatType)? onSafeBrowsingHit;
@override @override
final void Function(InAppWebViewController controller)? onWebContentProcessDidTerminate; final void Function(InAppWebViewController controller)?
onWebContentProcessDidTerminate;
@override @override
final Future<ShouldAllowDeprecatedTLSAction?> Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS; final Future<ShouldAllowDeprecatedTLSAction?> Function(
InAppWebViewController controller,
URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS;
@override @override
final Future<WebResourceResponse?> Function(InAppWebViewController controller, WebResourceRequest request)? shouldInterceptRequest; final Future<WebResourceResponse?> Function(
InAppWebViewController controller, WebResourceRequest request)?
shouldInterceptRequest;
} }
class _InAppWebViewState extends State<InAppWebView> { class _InAppWebViewState extends State<InAppWebView> {
@ -484,16 +527,24 @@ class _InAppWebViewState extends State<InAppWebView> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
Map<String, dynamic> initialSettings = (widget.initialSettings != null ? Map<String, dynamic> initialSettings = widget.initialSettings?.toMap() ??
widget.initialSettings?.toMap() : // ignore: deprecated_member_use_from_same_package
// ignore: deprecated_member_use_from_same_package widget.initialOptions?.toMap() ??
widget.initialOptions?.toMap()) ?? {}; {};
Map<String, dynamic> pullToRefreshSettings =
widget.pullToRefreshController?.settings.toMap() ??
// ignore: deprecated_member_use_from_same_package
widget.pullToRefreshController?.options.toMap() ??
PullToRefreshSettings(enabled: false).toMap();
if (defaultTargetPlatform == TargetPlatform.android) { if (defaultTargetPlatform == TargetPlatform.android) {
var useHybridComposition = (widget.initialSettings != null ? var useHybridComposition = (widget.initialSettings != null
widget.initialSettings?.useHybridComposition : ? widget.initialSettings?.useHybridComposition
// ignore: deprecated_member_use_from_same_package :
widget.initialOptions?.android.useHybridComposition) ?? false; // ignore: deprecated_member_use_from_same_package
widget.initialOptions?.android.useHybridComposition) ??
false;
if (!useHybridComposition && widget.pullToRefreshController != null) { if (!useHybridComposition && widget.pullToRefreshController != null) {
throw new Exception( throw new Exception(
@ -530,9 +581,7 @@ class _InAppWebViewState extends State<InAppWebView> {
'initialUserScripts': 'initialUserScripts':
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? widget.initialUserScripts?.map((e) => e.toMap()).toList() ??
[], [],
'pullToRefreshOptions': 'pullToRefreshSettings': pullToRefreshSettings
widget.pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap()
}, },
creationParamsCodec: const StandardMessageCodec(), creationParamsCodec: const StandardMessageCodec(),
) )
@ -558,9 +607,7 @@ class _InAppWebViewState extends State<InAppWebView> {
'implementation': widget.implementation.toValue(), 'implementation': widget.implementation.toValue(),
'initialUserScripts': 'initialUserScripts':
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
'pullToRefreshOptions': 'pullToRefreshSettings': pullToRefreshSettings
widget.pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap()
}, },
creationParamsCodec: const StandardMessageCodec(), creationParamsCodec: const StandardMessageCodec(),
); );
@ -580,9 +627,7 @@ class _InAppWebViewState extends State<InAppWebView> {
'implementation': widget.implementation.toValue(), 'implementation': widget.implementation.toValue(),
'initialUserScripts': 'initialUserScripts':
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
'pullToRefreshOptions': 'pullToRefreshSettings': pullToRefreshSettings
widget.pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap()
}, },
creationParamsCodec: const StandardMessageCodec(), creationParamsCodec: const StandardMessageCodec(),
); );

View File

@ -46,7 +46,8 @@ final _JAVASCRIPT_HANDLER_FORBIDDEN_NAMES = UnmodifiableListView<String>([
/// ///
///If you are using the [InAppWebView] widget, an [InAppWebViewController] instance can be obtained by setting the [InAppWebView.onWebViewCreated] ///If you are using the [InAppWebView] widget, an [InAppWebViewController] instance can be obtained by setting the [InAppWebView.onWebViewCreated]
///callback. Instead, if you are using an [InAppBrowser] instance, you can get it through the [InAppBrowser.webViewController] attribute. ///callback. Instead, if you are using an [InAppBrowser] instance, you can get it through the [InAppBrowser.webViewController] attribute.
class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWebViewControllerMixin { class InAppWebViewController
with AndroidInAppWebViewControllerMixin, IOSInAppWebViewControllerMixin {
WebView? _webview; WebView? _webview;
late MethodChannel _channel; late MethodChannel _channel;
static MethodChannel _staticChannel = IN_APP_WEBVIEW_STATIC_CHANNEL; static MethodChannel _staticChannel = IN_APP_WEBVIEW_STATIC_CHANNEL;
@ -275,22 +276,30 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
case "onGeolocationPermissionsShowPrompt": case "onGeolocationPermissionsShowPrompt":
if ((_webview != null && if ((_webview != null &&
(_webview!.onGeolocationPermissionsShowPrompt != null || (_webview!.onGeolocationPermissionsShowPrompt != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnGeolocationPermissionsShowPrompt != null)) || _webview!.androidOnGeolocationPermissionsShowPrompt !=
null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String origin = call.arguments["origin"]; String origin = call.arguments["origin"];
if (_webview != null) { if (_webview != null) {
if (_webview!.onGeolocationPermissionsShowPrompt != null) if (_webview!.onGeolocationPermissionsShowPrompt != null)
return (await _webview!.onGeolocationPermissionsShowPrompt!(this, origin))?.toMap(); return (await _webview!.onGeolocationPermissionsShowPrompt!(
this, origin))
?.toMap();
else { else {
// ignore: deprecated_member_use_from_same_package return (await _webview!
return (await _webview!.androidOnGeolocationPermissionsShowPrompt!(this, origin))?.toMap(); // ignore: deprecated_member_use_from_same_package
.androidOnGeolocationPermissionsShowPrompt!(this, origin))
?.toMap();
} }
} else { } else {
return ((await _inAppBrowser!.onGeolocationPermissionsShowPrompt(origin)) ?? return ((await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package .onGeolocationPermissionsShowPrompt(origin)) ??
(await _inAppBrowser!.androidOnGeolocationPermissionsShowPrompt(origin)))?.toMap(); (await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidOnGeolocationPermissionsShowPrompt(origin)))
?.toMap();
} }
} }
break; break;
@ -305,8 +314,7 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnGeolocationPermissionsHidePrompt!(this); _webview!.androidOnGeolocationPermissionsHidePrompt!(this);
} }
} } else if (_inAppBrowser != null) {
else if (_inAppBrowser != null) {
_inAppBrowser!.onGeolocationPermissionsHidePrompt(); _inAppBrowser!.onGeolocationPermissionsHidePrompt();
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_inAppBrowser!.androidOnGeolocationPermissionsHidePrompt(); _inAppBrowser!.androidOnGeolocationPermissionsHidePrompt();
@ -315,8 +323,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
case "shouldInterceptRequest": case "shouldInterceptRequest":
if ((_webview != null && if ((_webview != null &&
(_webview!.shouldInterceptRequest != null || (_webview!.shouldInterceptRequest != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidShouldInterceptRequest != null)) || _webview!.androidShouldInterceptRequest != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
Map<String, dynamic> arguments = Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>(); call.arguments.cast<String, dynamic>();
@ -324,69 +332,84 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
if (_webview != null) { if (_webview != null) {
if (_webview!.shouldInterceptRequest != null) if (_webview!.shouldInterceptRequest != null)
return (await _webview!.shouldInterceptRequest!(this, request))?.toMap(); return (await _webview!.shouldInterceptRequest!(this, request))
?.toMap();
else { else {
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
return (await _webview!.androidShouldInterceptRequest!(this, request))?.toMap(); return (await _webview!.androidShouldInterceptRequest!(
this, request))
?.toMap();
} }
} else { } else {
return ((await _inAppBrowser!.shouldInterceptRequest(request)) ?? return ((await _inAppBrowser!.shouldInterceptRequest(request)) ??
// ignore: deprecated_member_use_from_same_package (await _inAppBrowser!
(await _inAppBrowser!.androidShouldInterceptRequest(request)))?.toMap(); // ignore: deprecated_member_use_from_same_package
.androidShouldInterceptRequest(request)))
?.toMap();
} }
} }
break; break;
case "onRenderProcessUnresponsive": case "onRenderProcessUnresponsive":
if ((_webview != null && if ((_webview != null &&
(_webview!.onRenderProcessUnresponsive != null || (_webview!.onRenderProcessUnresponsive != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessUnresponsive != null)) || _webview!.androidOnRenderProcessUnresponsive != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.parse(url) : null; Uri? uri = url != null ? Uri.parse(url) : null;
if (_webview != null) { if (_webview != null) {
if (_webview!.onRenderProcessUnresponsive != null) if (_webview!.onRenderProcessUnresponsive != null)
return (await _webview!.onRenderProcessUnresponsive!(this, uri))?.toMap(); return (await _webview!.onRenderProcessUnresponsive!(this, uri))
?.toMap();
else { else {
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnRenderProcessUnresponsive!(this, uri))?.toMap(); return (await _webview!.androidOnRenderProcessUnresponsive!(
this, uri))
?.toMap();
} }
} else { } else {
return ((await _inAppBrowser!.onRenderProcessUnresponsive(uri)) ?? return ((await _inAppBrowser!.onRenderProcessUnresponsive(uri)) ??
// ignore: deprecated_member_use_from_same_package (await _inAppBrowser!
(await _inAppBrowser!.androidOnRenderProcessUnresponsive(uri)))?.toMap(); // ignore: deprecated_member_use_from_same_package
.androidOnRenderProcessUnresponsive(uri)))
?.toMap();
} }
} }
break; break;
case "onRenderProcessResponsive": case "onRenderProcessResponsive":
if ((_webview != null && if ((_webview != null &&
(_webview!.onRenderProcessResponsive != null || (_webview!.onRenderProcessResponsive != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessResponsive != null)) || _webview!.androidOnRenderProcessResponsive != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.parse(url) : null; Uri? uri = url != null ? Uri.parse(url) : null;
if (_webview != null) { if (_webview != null) {
if (_webview!.onRenderProcessResponsive != null) if (_webview!.onRenderProcessResponsive != null)
return (await _webview!.onRenderProcessResponsive!(this, uri))?.toMap(); return (await _webview!.onRenderProcessResponsive!(this, uri))
?.toMap();
else { else {
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnRenderProcessResponsive!(this, uri))?.toMap(); return (await _webview!.androidOnRenderProcessResponsive!(
this, uri))
?.toMap();
} }
} else { } else {
return ((await _inAppBrowser!.onRenderProcessResponsive(uri)) ?? return ((await _inAppBrowser!.onRenderProcessResponsive(uri)) ??
// ignore: deprecated_member_use_from_same_package (await _inAppBrowser!
(await _inAppBrowser!.androidOnRenderProcessResponsive(uri)))?.toMap(); // ignore: deprecated_member_use_from_same_package
.androidOnRenderProcessResponsive(uri)))
?.toMap();
} }
} }
break; break;
case "onRenderProcessGone": case "onRenderProcessGone":
if ((_webview != null && if ((_webview != null &&
(_webview!.onRenderProcessGone != null || (_webview!.onRenderProcessGone != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessGone != null)) || _webview!.androidOnRenderProcessGone != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
Map<String, dynamic> arguments = Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>(); call.arguments.cast<String, dynamic>();
@ -400,8 +423,7 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessGone!(this, detail); _webview!.androidOnRenderProcessGone!(this, detail);
} }
} } else if (_inAppBrowser != null) {
else if (_inAppBrowser != null) {
_inAppBrowser!.onRenderProcessGone(detail); _inAppBrowser!.onRenderProcessGone(detail);
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_inAppBrowser!.androidOnRenderProcessGone(detail); _inAppBrowser!.androidOnRenderProcessGone(detail);
@ -410,9 +432,9 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
break; break;
case "onFormResubmission": case "onFormResubmission":
if ((_webview != null && if ((_webview != null &&
(_webview!.onFormResubmission != null || (_webview!.onFormResubmission != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnFormResubmission != null)) || _webview!.androidOnFormResubmission != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String? url = call.arguments["url"]; String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.parse(url) : null; Uri? uri = url != null ? Uri.parse(url) : null;
@ -422,12 +444,14 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
return (await _webview!.onFormResubmission!(this, uri))?.toMap(); return (await _webview!.onFormResubmission!(this, uri))?.toMap();
else { else {
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnFormResubmission!(this, uri))?.toMap(); return (await _webview!.androidOnFormResubmission!(this, uri))
?.toMap();
} }
} else { } else {
return ((await _inAppBrowser!.onFormResubmission(uri)) ?? return ((await _inAppBrowser!.onFormResubmission(uri)) ??
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.androidOnFormResubmission(uri)))?.toMap(); (await _inAppBrowser!.androidOnFormResubmission(uri)))
?.toMap();
} }
} }
break; break;
@ -455,10 +479,10 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
} }
break; break;
case "onReceivedIcon": case "onReceivedIcon":
if ((_webview != null && ( if ((_webview != null &&
_webview!.onReceivedIcon != null || (_webview!.onReceivedIcon != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnReceivedIcon != null)) || _webview!.androidOnReceivedIcon != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
Uint8List icon = Uint8List icon =
Uint8List.fromList(call.arguments["icon"].cast<int>()); Uint8List.fromList(call.arguments["icon"].cast<int>());
@ -480,8 +504,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
case "onReceivedTouchIconUrl": case "onReceivedTouchIconUrl":
if ((_webview != null && if ((_webview != null &&
(_webview!.onReceivedTouchIconUrl != null || (_webview!.onReceivedTouchIconUrl != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnReceivedTouchIconUrl != null)) || _webview!.androidOnReceivedTouchIconUrl != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String url = call.arguments["url"]; String url = call.arguments["url"];
bool precomposed = call.arguments["precomposed"]; bool precomposed = call.arguments["precomposed"];
@ -545,10 +569,10 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
} }
break; break;
case "onJsBeforeUnload": case "onJsBeforeUnload":
if ((_webview != null && ( if ((_webview != null &&
_webview!.onJsBeforeUnload != null || (_webview!.onJsBeforeUnload != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnJsBeforeUnload != null)) || _webview!.androidOnJsBeforeUnload != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
Map<String, dynamic> arguments = Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>(); call.arguments.cast<String, dynamic>();
@ -557,23 +581,30 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
if (_webview != null) { if (_webview != null) {
if (_webview!.onJsBeforeUnload != null) if (_webview!.onJsBeforeUnload != null)
return (await _webview!.onJsBeforeUnload!(this, jsBeforeUnloadRequest))?.toMap(); return (await _webview!.onJsBeforeUnload!(
this, jsBeforeUnloadRequest))
?.toMap();
else { else {
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnJsBeforeUnload!(this, jsBeforeUnloadRequest))?.toMap(); return (await _webview!.androidOnJsBeforeUnload!(
this, jsBeforeUnloadRequest))
?.toMap();
} }
} else { } else {
return ((await _inAppBrowser!.onJsBeforeUnload(jsBeforeUnloadRequest)) ?? return ((await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package .onJsBeforeUnload(jsBeforeUnloadRequest)) ??
(await _inAppBrowser!.androidOnJsBeforeUnload(jsBeforeUnloadRequest)))?.toMap(); (await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidOnJsBeforeUnload(jsBeforeUnloadRequest)))
?.toMap();
} }
} }
break; break;
case "onSafeBrowsingHit": case "onSafeBrowsingHit":
if ((_webview != null && ( if ((_webview != null &&
_webview!.onSafeBrowsingHit != null || (_webview!.onSafeBrowsingHit != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnSafeBrowsingHit != null)) || _webview!.androidOnSafeBrowsingHit != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String url = call.arguments["url"]; String url = call.arguments["url"];
SafeBrowsingThreat? threatType = SafeBrowsingThreat? threatType =
@ -582,23 +613,28 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
if (_webview != null) { if (_webview != null) {
if (_webview!.onSafeBrowsingHit != null) if (_webview!.onSafeBrowsingHit != null)
return (await _webview!.onSafeBrowsingHit!(this, uri, threatType))?.toMap(); return (await _webview!.onSafeBrowsingHit!(this, uri, threatType))
?.toMap();
else { else {
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnSafeBrowsingHit!(this, uri, threatType))?.toMap(); return (await _webview!.androidOnSafeBrowsingHit!(
this, uri, threatType))
?.toMap();
} }
} else { } else {
return ((await _inAppBrowser!.onSafeBrowsingHit(uri, threatType)) ?? return ((await _inAppBrowser!.onSafeBrowsingHit(uri, threatType)) ??
// ignore: deprecated_member_use_from_same_package (await _inAppBrowser!
(await _inAppBrowser!.androidOnSafeBrowsingHit(uri, threatType)))?.toMap(); // ignore: deprecated_member_use_from_same_package
.androidOnSafeBrowsingHit(uri, threatType)))
?.toMap();
} }
} }
break; break;
case "onReceivedLoginRequest": case "onReceivedLoginRequest":
if ((_webview != null && if ((_webview != null &&
(_webview!.onReceivedLoginRequest != null || (_webview!.onReceivedLoginRequest != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnReceivedLoginRequest != null)) || _webview!.androidOnReceivedLoginRequest != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
Map<String, dynamic> arguments = Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>(); call.arguments.cast<String, dynamic>();
@ -689,23 +725,30 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
case "onPermissionRequest": case "onPermissionRequest":
if ((_webview != null && if ((_webview != null &&
(_webview!.onPermissionRequest != null || (_webview!.onPermissionRequest != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.androidOnPermissionRequest != null)) || _webview!.androidOnPermissionRequest != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
String origin = call.arguments["origin"]; String origin = call.arguments["origin"];
List<String> resources = call.arguments["resources"].cast<String>(); List<String> resources = call.arguments["resources"].cast<String>();
if (_webview != null) { if (_webview != null) {
if (_webview!.onPermissionRequest != null) if (_webview!.onPermissionRequest != null)
return (await _webview!.onPermissionRequest!(this, origin, resources))?.toMap(); return (await _webview!.onPermissionRequest!(
this, origin, resources))
?.toMap();
else { else {
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnPermissionRequest!(this, origin, resources))?.toMap(); return (await _webview!.androidOnPermissionRequest!(
this, origin, resources))
?.toMap();
} }
} else { } else {
return ((await _inAppBrowser!.onPermissionRequest(origin, resources)) ?? return ((await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package .onPermissionRequest(origin, resources)) ??
(await _inAppBrowser!.androidOnPermissionRequest(origin, resources)))?.toMap(); (await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidOnPermissionRequest(origin, resources)))
?.toMap();
} }
} }
break; break;
@ -724,8 +767,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
case "onWebContentProcessDidTerminate": case "onWebContentProcessDidTerminate":
if (_webview != null && if (_webview != null &&
(_webview!.onWebContentProcessDidTerminate != null || (_webview!.onWebContentProcessDidTerminate != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.iosOnWebContentProcessDidTerminate != null)) { _webview!.iosOnWebContentProcessDidTerminate != null)) {
if (_webview!.onWebContentProcessDidTerminate != null) if (_webview!.onWebContentProcessDidTerminate != null)
_webview!.onWebContentProcessDidTerminate!(this); _webview!.onWebContentProcessDidTerminate!(this);
else { else {
@ -751,55 +794,70 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
break; break;
case "onDidReceiveServerRedirectForProvisionalNavigation": case "onDidReceiveServerRedirectForProvisionalNavigation":
if (_webview != null && if (_webview != null &&
(_webview!.onDidReceiveServerRedirectForProvisionalNavigation != null || (_webview!.onDidReceiveServerRedirectForProvisionalNavigation !=
// ignore: deprecated_member_use_from_same_package null ||
_webview!.iosOnDidReceiveServerRedirectForProvisionalNavigation != null)) { _webview!
if (_webview!.onDidReceiveServerRedirectForProvisionalNavigation != null) // ignore: deprecated_member_use_from_same_package
.iosOnDidReceiveServerRedirectForProvisionalNavigation !=
null)) {
if (_webview!.onDidReceiveServerRedirectForProvisionalNavigation !=
null)
_webview!.onDidReceiveServerRedirectForProvisionalNavigation!(this); _webview!.onDidReceiveServerRedirectForProvisionalNavigation!(this);
else { else {
// ignore: deprecated_member_use_from_same_package _webview!
_webview!.iosOnDidReceiveServerRedirectForProvisionalNavigation!(this); // ignore: deprecated_member_use_from_same_package
.iosOnDidReceiveServerRedirectForProvisionalNavigation!(this);
} }
} else if (_inAppBrowser != null) { } else if (_inAppBrowser != null) {
_inAppBrowser!.onDidReceiveServerRedirectForProvisionalNavigation(); _inAppBrowser!.onDidReceiveServerRedirectForProvisionalNavigation();
// ignore: deprecated_member_use_from_same_package _inAppBrowser!
_inAppBrowser!.iosOnDidReceiveServerRedirectForProvisionalNavigation(); // ignore: deprecated_member_use_from_same_package
.iosOnDidReceiveServerRedirectForProvisionalNavigation();
} }
break; break;
case "onNavigationResponse": case "onNavigationResponse":
if ((_webview != null && ( if ((_webview != null &&
_webview!.onNavigationResponse != null || (_webview!.onNavigationResponse != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.iosOnNavigationResponse != null)) || _webview!.iosOnNavigationResponse != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
Map<String, dynamic> arguments = Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>(); call.arguments.cast<String, dynamic>();
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
IOSWKNavigationResponse iosOnNavigationResponse = IOSWKNavigationResponse iosOnNavigationResponse =
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
IOSWKNavigationResponse.fromMap(arguments)!; IOSWKNavigationResponse.fromMap(arguments)!;
NavigationResponse navigationResponse = NavigationResponse.fromMap(arguments)!; NavigationResponse navigationResponse =
NavigationResponse.fromMap(arguments)!;
if (_webview != null) { if (_webview != null) {
if (_webview!.onNavigationResponse != null) if (_webview!.onNavigationResponse != null)
return (await _webview!.onNavigationResponse!(this, navigationResponse))?.toMap(); return (await _webview!.onNavigationResponse!(
this, navigationResponse))
?.toMap();
else { else {
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
return (await _webview!.iosOnNavigationResponse!(this, iosOnNavigationResponse))?.toMap(); return (await _webview!.iosOnNavigationResponse!(
this, iosOnNavigationResponse))
?.toMap();
} }
} else { } else {
return (await _inAppBrowser!.onNavigationResponse(navigationResponse))?.toMap() ?? return (await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package .onNavigationResponse(navigationResponse))
(await _inAppBrowser!.iosOnNavigationResponse(iosOnNavigationResponse))?.toMap(); ?.toMap() ??
(await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.iosOnNavigationResponse(iosOnNavigationResponse))
?.toMap();
} }
} }
break; break;
case "shouldAllowDeprecatedTLS": case "shouldAllowDeprecatedTLS":
if ((_webview != null && if ((_webview != null &&
(_webview!.shouldAllowDeprecatedTLS != null || (_webview!.shouldAllowDeprecatedTLS != null ||
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
_webview!.iosShouldAllowDeprecatedTLS != null)) || _webview!.iosShouldAllowDeprecatedTLS != null)) ||
_inAppBrowser != null) { _inAppBrowser != null) {
Map<String, dynamic> arguments = Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>(); call.arguments.cast<String, dynamic>();
@ -808,15 +866,21 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
if (_webview != null) { if (_webview != null) {
if (_webview!.shouldAllowDeprecatedTLS != null) if (_webview!.shouldAllowDeprecatedTLS != null)
return (await _webview!.shouldAllowDeprecatedTLS!(this, challenge))?.toMap(); return (await _webview!.shouldAllowDeprecatedTLS!(
this, challenge))
?.toMap();
else { else {
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
return (await _webview!.iosShouldAllowDeprecatedTLS!(this, challenge))?.toMap(); return (await _webview!.iosShouldAllowDeprecatedTLS!(
this, challenge))
?.toMap();
} }
} else { } else {
return (await _inAppBrowser!.shouldAllowDeprecatedTLS(challenge))?.toMap() ?? return (await _inAppBrowser!.shouldAllowDeprecatedTLS(challenge))
?.toMap() ??
// ignore: deprecated_member_use_from_same_package // ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.iosShouldAllowDeprecatedTLS(challenge))?.toMap(); (await _inAppBrowser!.iosShouldAllowDeprecatedTLS(challenge))
?.toMap();
} }
} }
break; break;
@ -1327,8 +1391,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
Uri? iosAllowingReadAccessTo, Uri? iosAllowingReadAccessTo,
Uri? allowingReadAccessTo}) async { Uri? allowingReadAccessTo}) async {
assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty); assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty);
assert(allowingReadAccessTo == null || assert(
allowingReadAccessTo.isScheme("file")); allowingReadAccessTo == null || allowingReadAccessTo.isScheme("file"));
assert(iosAllowingReadAccessTo == null || assert(iosAllowingReadAccessTo == null ||
iosAllowingReadAccessTo.isScheme("file")); iosAllowingReadAccessTo.isScheme("file"));
@ -1387,8 +1451,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
@Deprecated('Use allowingReadAccessTo instead') @Deprecated('Use allowingReadAccessTo instead')
Uri? iosAllowingReadAccessTo, Uri? iosAllowingReadAccessTo,
Uri? allowingReadAccessTo}) async { Uri? allowingReadAccessTo}) async {
assert(allowingReadAccessTo == null || assert(
allowingReadAccessTo.isScheme("file")); allowingReadAccessTo == null || allowingReadAccessTo.isScheme("file"));
assert(iosAllowingReadAccessTo == null || assert(iosAllowingReadAccessTo == null ||
iosAllowingReadAccessTo.isScheme("file")); iosAllowingReadAccessTo.isScheme("file"));
@ -1821,7 +1885,7 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
Map<dynamic, dynamic>? settings = Map<dynamic, dynamic>? settings =
await _channel.invokeMethod('getSettings', args); await _channel.invokeMethod('getSettings', args);
if (settings != null) { if (settings != null) {
settings = settings.cast<String, dynamic>(); settings = settings.cast<String, dynamic>();
return InAppWebViewSettings.fromMap(settings as Map<String, dynamic>); return InAppWebViewSettings.fromMap(settings as Map<String, dynamic>);
@ -2819,8 +2883,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
static Future<WebViewPackageInfo?> getCurrentWebViewPackage() async { static Future<WebViewPackageInfo?> getCurrentWebViewPackage() async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic>? packageInfo = Map<String, dynamic>? packageInfo =
(await _staticChannel.invokeMethod('getCurrentWebViewPackage', args)) (await _staticChannel.invokeMethod('getCurrentWebViewPackage', args))
?.cast<String, dynamic>(); ?.cast<String, dynamic>();
return WebViewPackageInfo.fromMap(packageInfo); return WebViewPackageInfo.fromMap(packageInfo);
} }

View File

@ -33,9 +33,9 @@ class WebViewOptions {
} }
} }
///This class represents all the WebView settings available. ///This class represents all the WebView settings available.
class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOptions, IosOptions { class InAppWebViewSettings
implements WebViewOptions, BrowserOptions, AndroidOptions, IosOptions {
///Set to `true` to be able to listen at the [WebView.shouldOverrideUrlLoading] event. The default value is `false`. ///Set to `true` to be able to listen at the [WebView.shouldOverrideUrlLoading] event. The default value is `false`.
/// ///
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
@ -957,126 +957,127 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
InAppWebViewSettings( InAppWebViewSettings(
{this.useShouldOverrideUrlLoading = false, {this.useShouldOverrideUrlLoading = false,
this.useOnLoadResource = false, this.useOnLoadResource = false,
this.useOnDownloadStart = false, this.useOnDownloadStart = false,
this.clearCache = false, this.clearCache = false,
this.userAgent = "", this.userAgent = "",
this.applicationNameForUserAgent = "", this.applicationNameForUserAgent = "",
this.javaScriptEnabled = true, this.javaScriptEnabled = true,
this.javaScriptCanOpenWindowsAutomatically = false, this.javaScriptCanOpenWindowsAutomatically = false,
this.mediaPlaybackRequiresUserGesture = true, this.mediaPlaybackRequiresUserGesture = true,
this.minimumFontSize, this.minimumFontSize,
this.verticalScrollBarEnabled = true, this.verticalScrollBarEnabled = true,
this.horizontalScrollBarEnabled = true, this.horizontalScrollBarEnabled = true,
this.resourceCustomSchemes = const [], this.resourceCustomSchemes = const [],
this.contentBlockers = const [], this.contentBlockers = const [],
this.preferredContentMode = UserPreferredContentMode.RECOMMENDED, this.preferredContentMode = UserPreferredContentMode.RECOMMENDED,
this.useShouldInterceptAjaxRequest = false, this.useShouldInterceptAjaxRequest = false,
this.useShouldInterceptFetchRequest = false, this.useShouldInterceptFetchRequest = false,
this.incognito = false, this.incognito = false,
this.cacheEnabled = true, this.cacheEnabled = true,
this.transparentBackground = false, this.transparentBackground = false,
this.disableVerticalScroll = false, this.disableVerticalScroll = false,
this.disableHorizontalScroll = false, this.disableHorizontalScroll = false,
this.disableContextMenu = false, this.disableContextMenu = false,
this.supportZoom = true, this.supportZoom = true,
this.allowFileAccessFromFileURLs = false, this.allowFileAccessFromFileURLs = false,
this.allowUniversalAccessFromFileURLs = false, this.allowUniversalAccessFromFileURLs = false,
this.textZoom = 100, this.textZoom = 100,
this.clearSessionCache = false, this.clearSessionCache = false,
this.builtInZoomControls = true, this.builtInZoomControls = true,
this.displayZoomControls = false, this.displayZoomControls = false,
this.databaseEnabled = true, this.databaseEnabled = true,
this.domStorageEnabled = true, this.domStorageEnabled = true,
this.useWideViewPort = true, this.useWideViewPort = true,
this.safeBrowsingEnabled = true, this.safeBrowsingEnabled = true,
this.mixedContentMode, this.mixedContentMode,
this.allowContentAccess = true, this.allowContentAccess = true,
this.allowFileAccess = true, this.allowFileAccess = true,
this.appCachePath, this.appCachePath,
this.blockNetworkImage = false, this.blockNetworkImage = false,
this.blockNetworkLoads = false, this.blockNetworkLoads = false,
this.cacheMode = CacheMode.LOAD_DEFAULT, this.cacheMode = CacheMode.LOAD_DEFAULT,
this.cursiveFontFamily = "cursive", this.cursiveFontFamily = "cursive",
this.defaultFixedFontSize = 16, this.defaultFixedFontSize = 16,
this.defaultFontSize = 16, this.defaultFontSize = 16,
this.defaultTextEncodingName = "UTF-8", this.defaultTextEncodingName = "UTF-8",
this.disabledActionModeMenuItems, this.disabledActionModeMenuItems,
this.fantasyFontFamily = "fantasy", this.fantasyFontFamily = "fantasy",
this.fixedFontFamily = "monospace", this.fixedFontFamily = "monospace",
this.forceDark = ForceDark.FORCE_DARK_OFF, this.forceDark = ForceDark.FORCE_DARK_OFF,
this.geolocationEnabled = true, this.geolocationEnabled = true,
this.layoutAlgorithm, this.layoutAlgorithm,
this.loadWithOverviewMode = true, this.loadWithOverviewMode = true,
this.loadsImagesAutomatically = true, this.loadsImagesAutomatically = true,
this.minimumLogicalFontSize = 8, this.minimumLogicalFontSize = 8,
this.needInitialFocus = true, this.needInitialFocus = true,
this.offscreenPreRaster = false, this.offscreenPreRaster = false,
this.sansSerifFontFamily = "sans-serif", this.sansSerifFontFamily = "sans-serif",
this.serifFontFamily = "sans-serif", this.serifFontFamily = "sans-serif",
this.standardFontFamily = "sans-serif", this.standardFontFamily = "sans-serif",
this.saveFormData = true, this.saveFormData = true,
this.thirdPartyCookiesEnabled = true, this.thirdPartyCookiesEnabled = true,
this.hardwareAcceleration = true, this.hardwareAcceleration = true,
this.initialScale = 0, this.initialScale = 0,
this.supportMultipleWindows = false, this.supportMultipleWindows = false,
this.regexToCancelSubFramesLoading, this.regexToCancelSubFramesLoading,
this.useHybridComposition = false, this.useHybridComposition = false,
this.useShouldInterceptRequest = false, this.useShouldInterceptRequest = false,
this.useOnRenderProcessGone = false, this.useOnRenderProcessGone = false,
this.overScrollMode = OverScrollMode.OVER_SCROLL_IF_CONTENT_SCROLLS, this.overScrollMode = OverScrollMode.OVER_SCROLL_IF_CONTENT_SCROLLS,
this.networkAvailable, this.networkAvailable,
this.scrollBarStyle = ScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY, this.scrollBarStyle = ScrollBarStyle.SCROLLBARS_INSIDE_OVERLAY,
this.verticalScrollbarPosition = this.verticalScrollbarPosition =
VerticalScrollbarPosition.SCROLLBAR_POSITION_DEFAULT, VerticalScrollbarPosition.SCROLLBAR_POSITION_DEFAULT,
this.scrollBarDefaultDelayBeforeFade, this.scrollBarDefaultDelayBeforeFade,
this.scrollbarFadingEnabled = true, this.scrollbarFadingEnabled = true,
this.scrollBarFadeDuration, this.scrollBarFadeDuration,
this.rendererPriorityPolicy, this.rendererPriorityPolicy,
this.disableDefaultErrorPage = false, this.disableDefaultErrorPage = false,
this.verticalScrollbarThumbColor, this.verticalScrollbarThumbColor,
this.verticalScrollbarTrackColor, this.verticalScrollbarTrackColor,
this.horizontalScrollbarThumbColor, this.horizontalScrollbarThumbColor,
this.horizontalScrollbarTrackColor, this.horizontalScrollbarTrackColor,
this.disallowOverScroll = false, this.disallowOverScroll = false,
this.enableViewportScale = false, this.enableViewportScale = false,
this.suppressesIncrementalRendering = false, this.suppressesIncrementalRendering = false,
this.allowsAirPlayForMediaPlayback = true, this.allowsAirPlayForMediaPlayback = true,
this.allowsBackForwardNavigationGestures = true, this.allowsBackForwardNavigationGestures = true,
this.allowsLinkPreview = true, this.allowsLinkPreview = true,
this.ignoresViewportScaleLimits = false, this.ignoresViewportScaleLimits = false,
this.allowsInlineMediaPlayback = false, this.allowsInlineMediaPlayback = false,
this.allowsPictureInPictureMediaPlayback = true, this.allowsPictureInPictureMediaPlayback = true,
this.isFraudulentWebsiteWarningEnabled = true, this.isFraudulentWebsiteWarningEnabled = true,
this.selectionGranularity = SelectionGranularity.DYNAMIC, this.selectionGranularity = SelectionGranularity.DYNAMIC,
this.dataDetectorTypes = const [DataDetectorTypes.NONE], this.dataDetectorTypes = const [DataDetectorTypes.NONE],
this.sharedCookiesEnabled = false, this.sharedCookiesEnabled = false,
this.automaticallyAdjustsScrollIndicatorInsets = false, this.automaticallyAdjustsScrollIndicatorInsets = false,
this.accessibilityIgnoresInvertColors = false, this.accessibilityIgnoresInvertColors = false,
this.decelerationRate = ScrollViewDecelerationRate.NORMAL, this.decelerationRate = ScrollViewDecelerationRate.NORMAL,
this.alwaysBounceVertical = false, this.alwaysBounceVertical = false,
this.alwaysBounceHorizontal = false, this.alwaysBounceHorizontal = false,
this.scrollsToTop = true, this.scrollsToTop = true,
this.isPagingEnabled = false, this.isPagingEnabled = false,
this.maximumZoomScale = 1.0, this.maximumZoomScale = 1.0,
this.minimumZoomScale = 1.0, this.minimumZoomScale = 1.0,
this.contentInsetAdjustmentBehavior = this.contentInsetAdjustmentBehavior =
ScrollViewContentInsetAdjustmentBehavior.NEVER, ScrollViewContentInsetAdjustmentBehavior.NEVER,
this.isDirectionalLockEnabled = false, this.isDirectionalLockEnabled = false,
this.mediaType, this.mediaType,
this.pageZoom = 1.0, this.pageZoom = 1.0,
this.limitsNavigationsToAppBoundDomains = false, this.limitsNavigationsToAppBoundDomains = false,
this.useOnNavigationResponse = false, this.useOnNavigationResponse = false,
this.applePayAPIEnabled = false, this.applePayAPIEnabled = false,
this.allowingReadAccessTo, this.allowingReadAccessTo,
this.disableLongPressContextMenuOnLinks = false, this.disableLongPressContextMenuOnLinks = false,
this.disableInputAccessoryView = false}) { this.disableInputAccessoryView = false}) {
if (this.minimumFontSize == null) if (this.minimumFontSize == null)
this.minimumFontSize = this.minimumFontSize =
defaultTargetPlatform == TargetPlatform.android ? 8 : 0; defaultTargetPlatform == TargetPlatform.android ? 8 : 0;
assert(!this.resourceCustomSchemes.contains("http") && assert(!this.resourceCustomSchemes.contains("http") &&
!this.resourceCustomSchemes.contains("https")); !this.resourceCustomSchemes.contains("https"));
assert(allowingReadAccessTo == null || allowingReadAccessTo!.isScheme("file")); assert(
allowingReadAccessTo == null || allowingReadAccessTo!.isScheme("file"));
} }
@override @override
@ -1099,7 +1100,7 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
"applicationNameForUserAgent": applicationNameForUserAgent, "applicationNameForUserAgent": applicationNameForUserAgent,
"javaScriptEnabled": javaScriptEnabled, "javaScriptEnabled": javaScriptEnabled,
"javaScriptCanOpenWindowsAutomatically": "javaScriptCanOpenWindowsAutomatically":
javaScriptCanOpenWindowsAutomatically, javaScriptCanOpenWindowsAutomatically,
"mediaPlaybackRequiresUserGesture": mediaPlaybackRequiresUserGesture, "mediaPlaybackRequiresUserGesture": mediaPlaybackRequiresUserGesture,
"verticalScrollBarEnabled": verticalScrollBarEnabled, "verticalScrollBarEnabled": verticalScrollBarEnabled,
"horizontalScrollBarEnabled": horizontalScrollBarEnabled, "horizontalScrollBarEnabled": horizontalScrollBarEnabled,
@ -1177,18 +1178,18 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
"suppressesIncrementalRendering": suppressesIncrementalRendering, "suppressesIncrementalRendering": suppressesIncrementalRendering,
"allowsAirPlayForMediaPlayback": allowsAirPlayForMediaPlayback, "allowsAirPlayForMediaPlayback": allowsAirPlayForMediaPlayback,
"allowsBackForwardNavigationGestures": "allowsBackForwardNavigationGestures":
allowsBackForwardNavigationGestures, allowsBackForwardNavigationGestures,
"allowsLinkPreview": allowsLinkPreview, "allowsLinkPreview": allowsLinkPreview,
"ignoresViewportScaleLimits": ignoresViewportScaleLimits, "ignoresViewportScaleLimits": ignoresViewportScaleLimits,
"allowsInlineMediaPlayback": allowsInlineMediaPlayback, "allowsInlineMediaPlayback": allowsInlineMediaPlayback,
"allowsPictureInPictureMediaPlayback": "allowsPictureInPictureMediaPlayback":
allowsPictureInPictureMediaPlayback, allowsPictureInPictureMediaPlayback,
"isFraudulentWebsiteWarningEnabled": isFraudulentWebsiteWarningEnabled, "isFraudulentWebsiteWarningEnabled": isFraudulentWebsiteWarningEnabled,
"selectionGranularity": selectionGranularity.toValue(), "selectionGranularity": selectionGranularity.toValue(),
"dataDetectorTypes": dataDetectorTypesList, "dataDetectorTypes": dataDetectorTypesList,
"sharedCookiesEnabled": sharedCookiesEnabled, "sharedCookiesEnabled": sharedCookiesEnabled,
"automaticallyAdjustsScrollIndicatorInsets": "automaticallyAdjustsScrollIndicatorInsets":
automaticallyAdjustsScrollIndicatorInsets, automaticallyAdjustsScrollIndicatorInsets,
"accessibilityIgnoresInvertColors": accessibilityIgnoresInvertColors, "accessibilityIgnoresInvertColors": accessibilityIgnoresInvertColors,
"decelerationRate": decelerationRate.toValue(), "decelerationRate": decelerationRate.toValue(),
"alwaysBounceVertical": alwaysBounceVertical, "alwaysBounceVertical": alwaysBounceVertical,
@ -1198,7 +1199,7 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
"maximumZoomScale": maximumZoomScale, "maximumZoomScale": maximumZoomScale,
"minimumZoomScale": minimumZoomScale, "minimumZoomScale": minimumZoomScale,
"contentInsetAdjustmentBehavior": "contentInsetAdjustmentBehavior":
contentInsetAdjustmentBehavior.toValue(), contentInsetAdjustmentBehavior.toValue(),
"isDirectionalLockEnabled": isDirectionalLockEnabled, "isDirectionalLockEnabled": isDirectionalLockEnabled,
"mediaType": mediaType, "mediaType": mediaType,
"pageZoom": pageZoom, "pageZoom": pageZoom,
@ -1223,10 +1224,9 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
} }
List<DataDetectorTypes> dataDetectorTypes = []; List<DataDetectorTypes> dataDetectorTypes = [];
List<String> dataDetectorTypesList = List<String> dataDetectorTypesList =
List<String>.from(map["dataDetectorTypes"] ?? []); List<String>.from(map["dataDetectorTypes"] ?? []);
dataDetectorTypesList.forEach((dataDetectorTypeValue) { dataDetectorTypesList.forEach((dataDetectorTypeValue) {
var dataDetectorType = var dataDetectorType = DataDetectorTypes.fromValue(dataDetectorTypeValue);
DataDetectorTypes.fromValue(dataDetectorTypeValue);
if (dataDetectorType != null) { if (dataDetectorType != null) {
dataDetectorTypes.add(dataDetectorType); dataDetectorTypes.add(dataDetectorType);
} }
@ -1241,20 +1241,20 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
instance.applicationNameForUserAgent = map["applicationNameForUserAgent"]; instance.applicationNameForUserAgent = map["applicationNameForUserAgent"];
instance.javaScriptEnabled = map["javaScriptEnabled"]; instance.javaScriptEnabled = map["javaScriptEnabled"];
instance.javaScriptCanOpenWindowsAutomatically = instance.javaScriptCanOpenWindowsAutomatically =
map["javaScriptCanOpenWindowsAutomatically"]; map["javaScriptCanOpenWindowsAutomatically"];
instance.mediaPlaybackRequiresUserGesture = instance.mediaPlaybackRequiresUserGesture =
map["mediaPlaybackRequiresUserGesture"]; map["mediaPlaybackRequiresUserGesture"];
instance.verticalScrollBarEnabled = map["verticalScrollBarEnabled"]; instance.verticalScrollBarEnabled = map["verticalScrollBarEnabled"];
instance.horizontalScrollBarEnabled = map["horizontalScrollBarEnabled"]; instance.horizontalScrollBarEnabled = map["horizontalScrollBarEnabled"];
instance.resourceCustomSchemes = instance.resourceCustomSchemes =
List<String>.from(map["resourceCustomSchemes"] ?? []); List<String>.from(map["resourceCustomSchemes"] ?? []);
instance.contentBlockers = contentBlockers; instance.contentBlockers = contentBlockers;
instance.preferredContentMode = instance.preferredContentMode =
UserPreferredContentMode.fromValue(map["preferredContentMode"]); UserPreferredContentMode.fromValue(map["preferredContentMode"]);
instance.useShouldInterceptAjaxRequest = instance.useShouldInterceptAjaxRequest =
map["useShouldInterceptAjaxRequest"]; map["useShouldInterceptAjaxRequest"];
instance.useShouldInterceptFetchRequest = instance.useShouldInterceptFetchRequest =
map["useShouldInterceptFetchRequest"]; map["useShouldInterceptFetchRequest"];
instance.incognito = map["incognito"]; instance.incognito = map["incognito"];
instance.cacheEnabled = map["cacheEnabled"]; instance.cacheEnabled = map["cacheEnabled"];
instance.transparentBackground = map["transparentBackground"]; instance.transparentBackground = map["transparentBackground"];
@ -1264,7 +1264,7 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
instance.supportZoom = map["supportZoom"]; instance.supportZoom = map["supportZoom"];
instance.allowFileAccessFromFileURLs = map["allowFileAccessFromFileURLs"]; instance.allowFileAccessFromFileURLs = map["allowFileAccessFromFileURLs"];
instance.allowUniversalAccessFromFileURLs = instance.allowUniversalAccessFromFileURLs =
map["allowUniversalAccessFromFileURLs"]; map["allowUniversalAccessFromFileURLs"];
instance.textZoom = map["textZoom"]; instance.textZoom = map["textZoom"];
instance.clearSessionCache = map["clearSessionCache"]; instance.clearSessionCache = map["clearSessionCache"];
instance.builtInZoomControls = map["builtInZoomControls"]; instance.builtInZoomControls = map["builtInZoomControls"];
@ -1307,20 +1307,17 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
instance.hardwareAcceleration = map["hardwareAcceleration"]; instance.hardwareAcceleration = map["hardwareAcceleration"];
instance.supportMultipleWindows = map["supportMultipleWindows"]; instance.supportMultipleWindows = map["supportMultipleWindows"];
instance.regexToCancelSubFramesLoading = instance.regexToCancelSubFramesLoading =
map["regexToCancelSubFramesLoading"]; map["regexToCancelSubFramesLoading"];
instance.useHybridComposition = map["useHybridComposition"]; instance.useHybridComposition = map["useHybridComposition"];
instance.useShouldInterceptRequest = map["useShouldInterceptRequest"]; instance.useShouldInterceptRequest = map["useShouldInterceptRequest"];
instance.useOnRenderProcessGone = map["useOnRenderProcessGone"]; instance.useOnRenderProcessGone = map["useOnRenderProcessGone"];
instance.overScrollMode = instance.overScrollMode = OverScrollMode.fromValue(map["overScrollMode"]);
OverScrollMode.fromValue(map["overScrollMode"]);
instance.networkAvailable = map["networkAvailable"]; instance.networkAvailable = map["networkAvailable"];
instance.scrollBarStyle = instance.scrollBarStyle = ScrollBarStyle.fromValue(map["scrollBarStyle"]);
ScrollBarStyle.fromValue(map["scrollBarStyle"]);
instance.verticalScrollbarPosition = instance.verticalScrollbarPosition =
VerticalScrollbarPosition.fromValue( VerticalScrollbarPosition.fromValue(map["verticalScrollbarPosition"]);
map["verticalScrollbarPosition"]);
instance.scrollBarDefaultDelayBeforeFade = instance.scrollBarDefaultDelayBeforeFade =
map["scrollBarDefaultDelayBeforeFade"]; map["scrollBarDefaultDelayBeforeFade"];
instance.scrollbarFadingEnabled = map["scrollbarFadingEnabled"]; instance.scrollbarFadingEnabled = map["scrollbarFadingEnabled"];
instance.scrollBarFadeDuration = map["scrollBarFadeDuration"]; instance.scrollBarFadeDuration = map["scrollBarFadeDuration"];
instance.rendererPriorityPolicy = RendererPriorityPolicy.fromMap( instance.rendererPriorityPolicy = RendererPriorityPolicy.fromMap(
@ -1337,28 +1334,28 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
instance.disallowOverScroll = map["disallowOverScroll"]; instance.disallowOverScroll = map["disallowOverScroll"];
instance.enableViewportScale = map["enableViewportScale"]; instance.enableViewportScale = map["enableViewportScale"];
instance.suppressesIncrementalRendering = instance.suppressesIncrementalRendering =
map["suppressesIncrementalRendering"]; map["suppressesIncrementalRendering"];
instance.allowsAirPlayForMediaPlayback = instance.allowsAirPlayForMediaPlayback =
map["allowsAirPlayForMediaPlayback"]; map["allowsAirPlayForMediaPlayback"];
instance.allowsBackForwardNavigationGestures = instance.allowsBackForwardNavigationGestures =
map["allowsBackForwardNavigationGestures"]; map["allowsBackForwardNavigationGestures"];
instance.allowsLinkPreview = map["allowsLinkPreview"]; instance.allowsLinkPreview = map["allowsLinkPreview"];
instance.ignoresViewportScaleLimits = map["ignoresViewportScaleLimits"]; instance.ignoresViewportScaleLimits = map["ignoresViewportScaleLimits"];
instance.allowsInlineMediaPlayback = map["allowsInlineMediaPlayback"]; instance.allowsInlineMediaPlayback = map["allowsInlineMediaPlayback"];
instance.allowsPictureInPictureMediaPlayback = instance.allowsPictureInPictureMediaPlayback =
map["allowsPictureInPictureMediaPlayback"]; map["allowsPictureInPictureMediaPlayback"];
instance.isFraudulentWebsiteWarningEnabled = instance.isFraudulentWebsiteWarningEnabled =
map["isFraudulentWebsiteWarningEnabled"]; map["isFraudulentWebsiteWarningEnabled"];
instance.selectionGranularity = instance.selectionGranularity =
SelectionGranularity.fromValue(map["selectionGranularity"])!; SelectionGranularity.fromValue(map["selectionGranularity"])!;
instance.dataDetectorTypes = dataDetectorTypes; instance.dataDetectorTypes = dataDetectorTypes;
instance.sharedCookiesEnabled = map["sharedCookiesEnabled"]; instance.sharedCookiesEnabled = map["sharedCookiesEnabled"];
instance.automaticallyAdjustsScrollIndicatorInsets = instance.automaticallyAdjustsScrollIndicatorInsets =
map["automaticallyAdjustsScrollIndicatorInsets"]; map["automaticallyAdjustsScrollIndicatorInsets"];
instance.accessibilityIgnoresInvertColors = instance.accessibilityIgnoresInvertColors =
map["accessibilityIgnoresInvertColors"]; map["accessibilityIgnoresInvertColors"];
instance.decelerationRate = instance.decelerationRate =
ScrollViewDecelerationRate.fromValue(map["decelerationRate"])!; ScrollViewDecelerationRate.fromValue(map["decelerationRate"])!;
instance.alwaysBounceVertical = map["alwaysBounceVertical"]; instance.alwaysBounceVertical = map["alwaysBounceVertical"];
instance.alwaysBounceHorizontal = map["alwaysBounceHorizontal"]; instance.alwaysBounceHorizontal = map["alwaysBounceHorizontal"];
instance.scrollsToTop = map["scrollsToTop"]; instance.scrollsToTop = map["scrollsToTop"];
@ -1366,20 +1363,20 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
instance.maximumZoomScale = map["maximumZoomScale"]; instance.maximumZoomScale = map["maximumZoomScale"];
instance.minimumZoomScale = map["minimumZoomScale"]; instance.minimumZoomScale = map["minimumZoomScale"];
instance.contentInsetAdjustmentBehavior = instance.contentInsetAdjustmentBehavior =
ScrollViewContentInsetAdjustmentBehavior.fromValue( ScrollViewContentInsetAdjustmentBehavior.fromValue(
map["contentInsetAdjustmentBehavior"])!; map["contentInsetAdjustmentBehavior"])!;
instance.isDirectionalLockEnabled = map["isDirectionalLockEnabled"]; instance.isDirectionalLockEnabled = map["isDirectionalLockEnabled"];
instance.mediaType = map["mediaType"]; instance.mediaType = map["mediaType"];
instance.pageZoom = map["pageZoom"]; instance.pageZoom = map["pageZoom"];
instance.limitsNavigationsToAppBoundDomains = instance.limitsNavigationsToAppBoundDomains =
map["limitsNavigationsToAppBoundDomains"]; map["limitsNavigationsToAppBoundDomains"];
instance.useOnNavigationResponse = map["useOnNavigationResponse"]; instance.useOnNavigationResponse = map["useOnNavigationResponse"];
instance.applePayAPIEnabled = map["applePayAPIEnabled"]; instance.applePayAPIEnabled = map["applePayAPIEnabled"];
instance.allowingReadAccessTo = map["allowingReadAccessTo"] != null instance.allowingReadAccessTo = map["allowingReadAccessTo"] != null
? Uri.parse(map["allowingReadAccessTo"]) ? Uri.parse(map["allowingReadAccessTo"])
: null; : null;
instance.disableLongPressContextMenuOnLinks = instance.disableLongPressContextMenuOnLinks =
map["disableLongPressContextMenuOnLinks"]; map["disableLongPressContextMenuOnLinks"];
instance.disableInputAccessoryView = map["disableInputAccessoryView"]; instance.disableInputAccessoryView = map["disableInputAccessoryView"];
return instance; return instance;
} }
@ -1393,7 +1390,7 @@ class InAppWebViewSettings implements WebViewOptions, BrowserOptions, AndroidOpt
String toString() { String toString() {
return toMap().toString(); return toMap().toString();
} }
@override @override
InAppWebViewSettings copy() { InAppWebViewSettings copy() {
return InAppWebViewSettings.fromMap(this.toMap()); return InAppWebViewSettings.fromMap(this.toMap());
@ -1660,7 +1657,6 @@ class InAppWebViewOptions
}); });
} }
var instance = InAppWebViewOptions(); var instance = InAppWebViewOptions();
instance.useShouldOverrideUrlLoading = map["useShouldOverrideUrlLoading"]; instance.useShouldOverrideUrlLoading = map["useShouldOverrideUrlLoading"];
instance.useOnLoadResource = map["useOnLoadResource"]; instance.useOnLoadResource = map["useOnLoadResource"];

View File

@ -29,12 +29,13 @@ abstract class IOSInAppWebViewControllerMixin {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebView.createPdf](https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf)) ///- iOS ([Official API - WKWebView.createPdf](https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf))
Future<Uint8List?> createPdf( Future<Uint8List?> createPdf(
// ignore: deprecated_member_use_from_same_package {@Deprecated("Use pdfConfiguration instead")
{@Deprecated("Use pdfConfiguration instead") IOSWKPDFConfiguration? iosWKPdfConfiguration, // ignore: deprecated_member_use_from_same_package
PDFConfiguration? pdfConfiguration}) async { IOSWKPDFConfiguration? iosWKPdfConfiguration,
PDFConfiguration? pdfConfiguration}) async {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent( args.putIfAbsent('pdfConfiguration',
'pdfConfiguration', () => pdfConfiguration?.toMap() ?? iosWKPdfConfiguration?.toMap()); () => pdfConfiguration?.toMap() ?? iosWKPdfConfiguration?.toMap());
return await _channel.invokeMethod('createPdf', args); return await _channel.invokeMethod('createPdf', args);
} }

View File

@ -530,8 +530,8 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsShowPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback))) ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsShowPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)))
final Future<GeolocationPermissionShowPromptResponse?> Function( final Future<GeolocationPermissionShowPromptResponse?> Function(
InAppWebViewController controller, String origin)? InAppWebViewController controller, String origin)?
onGeolocationPermissionsShowPrompt; onGeolocationPermissionsShowPrompt;
///Use [onGeolocationPermissionsHidePrompt] instead. ///Use [onGeolocationPermissionsHidePrompt] instead.
@Deprecated("Use onGeolocationPermissionsHidePrompt instead") @Deprecated("Use onGeolocationPermissionsHidePrompt instead")
@ -544,7 +544,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsHidePrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt())) ///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsHidePrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt()))
final void Function(InAppWebViewController controller)? final void Function(InAppWebViewController controller)?
onGeolocationPermissionsHidePrompt; onGeolocationPermissionsHidePrompt;
///Use [shouldInterceptRequest] instead. ///Use [shouldInterceptRequest] instead.
@Deprecated("Use shouldInterceptRequest instead") @Deprecated("Use shouldInterceptRequest instead")
@ -569,8 +569,8 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.shouldInterceptRequest](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest))) ///- Android native WebView ([Official API - WebViewClient.shouldInterceptRequest](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest)))
final Future<WebResourceResponse?> Function( final Future<WebResourceResponse?> Function(
InAppWebViewController controller, WebResourceRequest request)? InAppWebViewController controller, WebResourceRequest request)?
shouldInterceptRequest; shouldInterceptRequest;
///Use [onRenderProcessUnresponsive] instead. ///Use [onRenderProcessUnresponsive] instead.
@Deprecated("Use onRenderProcessUnresponsive instead") @Deprecated("Use onRenderProcessUnresponsive instead")
@ -598,8 +598,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)))
final Future<WebViewRenderProcessAction?> Function( final Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive;
onRenderProcessUnresponsive;
///Use [onRenderProcessResponsive] instead. ///Use [onRenderProcessResponsive] instead.
@Deprecated("Use onRenderProcessResponsive instead") @Deprecated("Use onRenderProcessResponsive instead")
@ -620,8 +619,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess))) ///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)))
final Future<WebViewRenderProcessAction?> Function( final Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? InAppWebViewController controller, Uri? url)? onRenderProcessResponsive;
onRenderProcessResponsive;
///Use [onRenderProcessGone] instead. ///Use [onRenderProcessGone] instead.
@Deprecated("Use onRenderProcessGone instead") @Deprecated("Use onRenderProcessGone instead")
@ -640,8 +638,8 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onRenderProcessGone](https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail))) ///- Android native WebView ([Official API - WebViewClient.onRenderProcessGone](https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail)))
final void Function( final void Function(
InAppWebViewController controller, RenderProcessGoneDetail detail)? InAppWebViewController controller, RenderProcessGoneDetail detail)?
onRenderProcessGone; onRenderProcessGone;
///Use [onFormResubmission] instead. ///Use [onFormResubmission] instead.
@Deprecated('Use onFormResubmission instead') @Deprecated('Use onFormResubmission instead')
@ -673,7 +671,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onReceivedIcon](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap))) ///- Android native WebView ([Official API - WebChromeClient.onReceivedIcon](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap)))
final void Function(InAppWebViewController controller, Uint8List icon)? final void Function(InAppWebViewController controller, Uint8List icon)?
onReceivedIcon; onReceivedIcon;
///Use [onReceivedTouchIconUrl] instead. ///Use [onReceivedTouchIconUrl] instead.
@Deprecated('Use onReceivedTouchIconUrl instead') @Deprecated('Use onReceivedTouchIconUrl instead')
@ -690,8 +688,8 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean))) ///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)))
final void Function( final void Function(
InAppWebViewController controller, Uri url, bool precomposed)? InAppWebViewController controller, Uri url, bool precomposed)?
onReceivedTouchIconUrl; onReceivedTouchIconUrl;
///Use [onJsBeforeUnload] instead. ///Use [onJsBeforeUnload] instead.
@Deprecated('Use onJsBeforeUnload instead') @Deprecated('Use onJsBeforeUnload instead')
@ -728,8 +726,8 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- Android native WebView ([Official API - WebViewClient.onReceivedLoginRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String))) ///- Android native WebView ([Official API - WebViewClient.onReceivedLoginRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String)))
final void Function( final void Function(
InAppWebViewController controller, LoginRequest loginRequest)? InAppWebViewController controller, LoginRequest loginRequest)?
onReceivedLoginRequest; onReceivedLoginRequest;
///Use [onWebContentProcessDidTerminate] instead. ///Use [onWebContentProcessDidTerminate] instead.
@Deprecated('Use onWebContentProcessDidTerminate instead') @Deprecated('Use onWebContentProcessDidTerminate instead')
@ -741,7 +739,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi)) ///- iOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi))
final void Function(InAppWebViewController controller)? final void Function(InAppWebViewController controller)?
onWebContentProcessDidTerminate; onWebContentProcessDidTerminate;
///Use [onDidReceiveServerRedirectForProvisionalNavigation] instead. ///Use [onDidReceiveServerRedirectForProvisionalNavigation] instead.
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead') @Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
@ -753,7 +751,7 @@ abstract class WebView {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview)) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview))
final void Function(InAppWebViewController controller)? final void Function(InAppWebViewController controller)?
onDidReceiveServerRedirectForProvisionalNavigation; onDidReceiveServerRedirectForProvisionalNavigation;
///Use [onNavigationResponse] instead. ///Use [onNavigationResponse] instead.
@Deprecated('Use onNavigationResponse instead') @Deprecated('Use onNavigationResponse instead')
@ -870,45 +868,64 @@ abstract class WebView {
this.onWindowBlur, this.onWindowBlur,
this.onOverScrolled, this.onOverScrolled,
this.onZoomScaleChanged, this.onZoomScaleChanged,
@Deprecated('Use onSafeBrowsingHit instead') this.androidOnSafeBrowsingHit, @Deprecated('Use onSafeBrowsingHit instead')
this.androidOnSafeBrowsingHit,
this.onSafeBrowsingHit, this.onSafeBrowsingHit,
@Deprecated('Use onPermissionRequest instead') this.androidOnPermissionRequest, @Deprecated('Use onPermissionRequest instead')
this.androidOnPermissionRequest,
this.onPermissionRequest, this.onPermissionRequest,
@Deprecated('Use onGeolocationPermissionsShowPrompt instead') this.androidOnGeolocationPermissionsShowPrompt, @Deprecated('Use onGeolocationPermissionsShowPrompt instead')
this.androidOnGeolocationPermissionsShowPrompt,
this.onGeolocationPermissionsShowPrompt, this.onGeolocationPermissionsShowPrompt,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead') this.androidOnGeolocationPermissionsHidePrompt, @Deprecated('Use onGeolocationPermissionsHidePrompt instead')
this.androidOnGeolocationPermissionsHidePrompt,
this.onGeolocationPermissionsHidePrompt, this.onGeolocationPermissionsHidePrompt,
@Deprecated('Use shouldInterceptRequest instead') this.androidShouldInterceptRequest, @Deprecated('Use shouldInterceptRequest instead')
this.androidShouldInterceptRequest,
this.shouldInterceptRequest, this.shouldInterceptRequest,
@Deprecated('Use onRenderProcessGone instead') this.androidOnRenderProcessGone, @Deprecated('Use onRenderProcessGone instead')
this.androidOnRenderProcessGone,
this.onRenderProcessGone, this.onRenderProcessGone,
@Deprecated('Use onRenderProcessResponsive instead') this.androidOnRenderProcessResponsive, @Deprecated('Use onRenderProcessResponsive instead')
this.androidOnRenderProcessResponsive,
this.onRenderProcessResponsive, this.onRenderProcessResponsive,
@Deprecated('Use onRenderProcessUnresponsive instead') this.androidOnRenderProcessUnresponsive, @Deprecated('Use onRenderProcessUnresponsive instead')
this.androidOnRenderProcessUnresponsive,
this.onRenderProcessUnresponsive, this.onRenderProcessUnresponsive,
@Deprecated('Use onFormResubmission instead') this.androidOnFormResubmission, @Deprecated('Use onFormResubmission instead')
this.androidOnFormResubmission,
this.onFormResubmission, this.onFormResubmission,
@Deprecated('Use onZoomScaleChanged instead') this.androidOnScaleChanged, @Deprecated('Use onZoomScaleChanged instead')
@Deprecated('Use onReceivedIcon instead') this.androidOnReceivedIcon, this.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead')
this.androidOnReceivedIcon,
this.onReceivedIcon, this.onReceivedIcon,
@Deprecated('Use onReceivedTouchIconUrl instead') this.androidOnReceivedTouchIconUrl, @Deprecated('Use onReceivedTouchIconUrl instead')
this.androidOnReceivedTouchIconUrl,
this.onReceivedTouchIconUrl, this.onReceivedTouchIconUrl,
@Deprecated('Use onJsBeforeUnload instead') this.androidOnJsBeforeUnload, @Deprecated('Use onJsBeforeUnload instead')
this.androidOnJsBeforeUnload,
this.onJsBeforeUnload, this.onJsBeforeUnload,
@Deprecated('Use onReceivedLoginRequest instead') this.androidOnReceivedLoginRequest, @Deprecated('Use onReceivedLoginRequest instead')
this.androidOnReceivedLoginRequest,
this.onReceivedLoginRequest, this.onReceivedLoginRequest,
@Deprecated('Use onWebContentProcessDidTerminate instead') this.iosOnWebContentProcessDidTerminate, @Deprecated('Use onWebContentProcessDidTerminate instead')
this.iosOnWebContentProcessDidTerminate,
this.onWebContentProcessDidTerminate, this.onWebContentProcessDidTerminate,
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead') this.iosOnDidReceiveServerRedirectForProvisionalNavigation, @Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
this.onDidReceiveServerRedirectForProvisionalNavigation, this.onDidReceiveServerRedirectForProvisionalNavigation,
@Deprecated('Use onNavigationResponse instead') this.iosOnNavigationResponse, @Deprecated('Use onNavigationResponse instead')
this.iosOnNavigationResponse,
this.onNavigationResponse, this.onNavigationResponse,
@Deprecated('Use shouldAllowDeprecatedTLS instead') this.iosShouldAllowDeprecatedTLS, @Deprecated('Use shouldAllowDeprecatedTLS instead')
this.iosShouldAllowDeprecatedTLS,
this.shouldAllowDeprecatedTLS, this.shouldAllowDeprecatedTLS,
this.initialUrlRequest, this.initialUrlRequest,
this.initialFile, this.initialFile,
this.initialData, this.initialData,
@Deprecated('Use initialSettings instead') this.initialOptions, @Deprecated('Use initialSettings instead')
this.initialOptions,
this.initialSettings, this.initialSettings,
this.contextMenu, this.contextMenu,
this.initialUserScripts, this.initialUserScripts,

View File

@ -1,2 +1,2 @@
export 'pull_to_refresh_controller.dart'; export 'pull_to_refresh_controller.dart';
export 'pull_to_refresh_options.dart'; export 'pull_to_refresh_settings.dart';

View File

@ -6,7 +6,7 @@ import '../in_app_browser/in_app_browser.dart';
import '../util.dart'; import '../util.dart';
import '../types.dart'; import '../types.dart';
import '../in_app_webview/in_app_webview_settings.dart'; import '../in_app_webview/in_app_webview_settings.dart';
import 'pull_to_refresh_options.dart'; import 'pull_to_refresh_settings.dart';
///A standard controller that can initiate the refreshing of a scroll views contents. ///A standard controller that can initiate the refreshing of a scroll views contents.
///This should be used whenever the user can refresh the contents of a WebView via a vertical swipe gesture. ///This should be used whenever the user can refresh the contents of a WebView via a vertical swipe gesture.
@ -16,14 +16,24 @@ import 'pull_to_refresh_options.dart';
/// ///
///**NOTE for Android**: to be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`. ///**NOTE for Android**: to be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`.
class PullToRefreshController { class PullToRefreshController {
@Deprecated("Use settings instead")
// ignore: deprecated_member_use_from_same_package
late PullToRefreshOptions options; late PullToRefreshOptions options;
late PullToRefreshSettings settings;
MethodChannel? _channel; MethodChannel? _channel;
///Event called when a swipe gesture triggers a refresh. ///Event called when a swipe gesture triggers a refresh.
final void Function()? onRefresh; final void Function()? onRefresh;
PullToRefreshController({PullToRefreshOptions? options, this.onRefresh}) { PullToRefreshController(
{
// ignore: deprecated_member_use_from_same_package
@Deprecated("Use settings instead") PullToRefreshOptions? options,
PullToRefreshSettings? settings,
this.onRefresh}) {
// ignore: deprecated_member_use_from_same_package
this.options = options ?? PullToRefreshOptions(); this.options = options ?? PullToRefreshOptions();
this.settings = settings ?? PullToRefreshSettings();
} }
Future<dynamic> handleMethod(MethodCall call) async { Future<dynamic> handleMethod(MethodCall call) async {

View File

@ -1,64 +0,0 @@
import 'dart:ui';
import '../util.dart';
import '../types.dart';
class PullToRefreshOptions {
///Sets whether the pull-to-refresh feature is enabled or not.
bool enabled;
///The color of the refresh control.
Color? color;
///The background color of the refresh control.
Color? backgroundColor;
///The distance to trigger a sync in dips.
///
///**NOTE**: Available only on Android.
int? distanceToTriggerSync;
///The distance in pixels that the refresh indicator can be pulled beyond its resting position.
///
///**NOTE**: Available only on Android.
int? slingshotDistance;
///The size of the refresh indicator.
///
///**NOTE**: Available only on Android.
AndroidPullToRefreshSize? size;
///The title text to display in the refresh control.
///
///**NOTE**: Available only on iOS.
IOSNSAttributedString? attributedTitle;
PullToRefreshOptions(
{this.enabled = true,
this.color,
this.backgroundColor,
this.distanceToTriggerSync,
this.slingshotDistance,
this.size,
this.attributedTitle});
Map<String, dynamic> toMap() {
return {
"enabled": enabled,
"color": color?.toHex(),
"backgroundColor": backgroundColor?.toHex(),
"distanceToTriggerSync": distanceToTriggerSync,
"slingshotDistance": slingshotDistance,
"size": size?.toValue(),
"attributedTitle": attributedTitle?.toMap() ?? {}
};
}
Map<String, dynamic> toJson() {
return this.toMap();
}
@override
String toString() {
return toMap().toString();
}
}

View File

@ -0,0 +1,128 @@
import 'dart:ui';
import '../util.dart';
import '../types.dart';
///Pull-To-Refresh Settings
class PullToRefreshSettings {
///Sets whether the pull-to-refresh feature is enabled or not.
bool enabled;
///The color of the refresh control.
Color? color;
///The background color of the refresh control.
Color? backgroundColor;
///The distance to trigger a sync in dips.
///
///**NOTE**: Available only on Android.
int? distanceToTriggerSync;
///The distance in pixels that the refresh indicator can be pulled beyond its resting position.
///
///**NOTE**: Available only on Android.
int? slingshotDistance;
///The size of the refresh indicator.
///
///**NOTE**: Available only on Android.
PullToRefreshSize? size;
///The title text to display in the refresh control.
///
///**NOTE**: Available only on iOS.
AttributedString? attributedTitle;
PullToRefreshSettings(
{this.enabled = true,
this.color,
this.backgroundColor,
this.distanceToTriggerSync,
this.slingshotDistance,
this.size,
this.attributedTitle});
Map<String, dynamic> toMap() {
return {
"enabled": enabled,
"color": color?.toHex(),
"backgroundColor": backgroundColor?.toHex(),
"distanceToTriggerSync": distanceToTriggerSync,
"slingshotDistance": slingshotDistance,
"size": size?.toValue(),
"attributedTitle": attributedTitle?.toMap() ?? {}
};
}
Map<String, dynamic> toJson() {
return this.toMap();
}
@override
String toString() {
return toMap().toString();
}
}
///Use [PullToRefreshSettings] instead.
@Deprecated("Use PullToRefreshSettings instead")
class PullToRefreshOptions {
///Sets whether the pull-to-refresh feature is enabled or not.
bool enabled;
///The color of the refresh control.
Color? color;
///The background color of the refresh control.
Color? backgroundColor;
///The distance to trigger a sync in dips.
///
///**NOTE**: Available only on Android.
int? distanceToTriggerSync;
///The distance in pixels that the refresh indicator can be pulled beyond its resting position.
///
///**NOTE**: Available only on Android.
int? slingshotDistance;
///The size of the refresh indicator.
///
///**NOTE**: Available only on Android.
AndroidPullToRefreshSize? size;
///The title text to display in the refresh control.
///
///**NOTE**: Available only on iOS.
IOSNSAttributedString? attributedTitle;
PullToRefreshOptions(
{this.enabled = true,
this.color,
this.backgroundColor,
this.distanceToTriggerSync,
this.slingshotDistance,
this.size,
this.attributedTitle});
Map<String, dynamic> toMap() {
return {
"enabled": enabled,
"color": color?.toHex(),
"backgroundColor": backgroundColor?.toHex(),
"distanceToTriggerSync": distanceToTriggerSync,
"slingshotDistance": slingshotDistance,
"size": size?.toValue(),
"attributedTitle": attributedTitle?.toMap() ?? {}
};
}
Map<String, dynamic> toJson() {
return this.toMap();
}
@override
String toString() {
return toMap().toString();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -6,7 +6,6 @@ import '_static_channel.dart';
import 'android/web_storage_manager.dart'; import 'android/web_storage_manager.dart';
import 'ios/web_storage_manager.dart'; import 'ios/web_storage_manager.dart';
import '../types.dart'; import '../types.dart';
///Class that implements a singleton object (shared instance) which manages the web storage used by WebView instances. ///Class that implements a singleton object (shared instance) which manages the web storage used by WebView instances.
@ -48,8 +47,8 @@ class WebStorageManager {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
List<Map<dynamic, dynamic>> origins = List<Map<dynamic, dynamic>> origins =
(await _staticChannel.invokeMethod('getOrigins', args)) (await _staticChannel.invokeMethod('getOrigins', args))
.cast<Map<dynamic, dynamic>>(); .cast<Map<dynamic, dynamic>>();
for (var origin in origins) { for (var origin in origins) {
originsList.add(WebStorageOrigin( originsList.add(WebStorageOrigin(
@ -121,8 +120,8 @@ class WebStorageManager {
Map<String, dynamic> args = <String, dynamic>{}; Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("dataTypes", () => dataTypesList); args.putIfAbsent("dataTypes", () => dataTypesList);
List<Map<dynamic, dynamic>> records = List<Map<dynamic, dynamic>> records =
(await _staticChannel.invokeMethod('fetchDataRecords', args)) (await _staticChannel.invokeMethod('fetchDataRecords', args))
.cast<Map<dynamic, dynamic>>(); .cast<Map<dynamic, dynamic>>();
for (var record in records) { for (var record in records) {
List<String> dataTypesString = record["dataTypes"].cast<String>(); List<String> dataTypesString = record["dataTypes"].cast<String>();
Set<WebsiteDataType> dataTypes = Set(); Set<WebsiteDataType> dataTypes = Set();
@ -148,7 +147,7 @@ class WebStorageManager {
///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata)) ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata))
Future<void> removeDataFor( Future<void> removeDataFor(
{required Set<WebsiteDataType> dataTypes, {required Set<WebsiteDataType> dataTypes,
required List<WebsiteDataRecord> dataRecords}) async { required List<WebsiteDataRecord> dataRecords}) async {
List<String> dataTypesList = []; List<String> dataTypesList = [];
for (var dataType in dataTypes) { for (var dataType in dataTypes) {
dataTypesList.add(dataType.toValue()); dataTypesList.add(dataType.toValue());
@ -174,8 +173,7 @@ class WebStorageManager {
///**Supported Platforms/Implementations**: ///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
Future<void> removeDataModifiedSince( Future<void> removeDataModifiedSince(
{required Set<WebsiteDataType> dataTypes, {required Set<WebsiteDataType> dataTypes, required DateTime date}) async {
required DateTime date}) async {
List<String> dataTypesList = []; List<String> dataTypesList = [];
for (var dataType in dataTypes) { for (var dataType in dataTypes) {
dataTypesList.add(dataType.toValue()); dataTypesList.add(dataType.toValue());