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.InAppWebViewSettings;
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.UserScript;
@ -81,13 +81,13 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow
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);
PullToRefreshOptions pullToRefreshOptions = new PullToRefreshOptions();
pullToRefreshOptions.parse(pullToRefreshInitialOptions);
PullToRefreshSettings pullToRefreshSettings = new PullToRefreshSettings();
pullToRefreshSettings.parse(pullToRefreshInitialSettings);
pullToRefreshLayout = findViewById(R.id.pullToRefresh);
pullToRefreshLayout.channel = pullToRefreshLayoutChannel;
pullToRefreshLayout.options = pullToRefreshOptions;
pullToRefreshLayout.options = pullToRefreshSettings;
pullToRefreshLayout.prepare();
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");
Integer windowId = (Integer) arguments.get("windowId");
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();
extras.putString("fromActivity", activity.getClass().getName());
@ -191,7 +191,7 @@ public class InAppBrowserManager implements MethodChannel.MethodCallHandler {
extras.putSerializable("contextMenu", (Serializable) contextMenu);
extras.putInt("windowId", windowId != null ? windowId : -1);
extras.putSerializable("initialUserScripts", (Serializable) initialUserScripts);
extras.putSerializable("pullToRefreshInitialOptions", (Serializable) pullToRefreshInitialOptions);
extras.putSerializable("pullToRefreshInitialSettings", (Serializable) pullToRefreshInitialSettings);
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.plugin_scripts_js.JavaScriptBridgeJS;
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.URLRequest;
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");
Integer windowId = (Integer) params.get("windowId");
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();
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!
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);
PullToRefreshOptions pullToRefreshOptions = new PullToRefreshOptions();
pullToRefreshOptions.parse(pullToRefreshInitialOptions);
pullToRefreshLayout = new PullToRefreshLayout(context, pullToRefreshLayoutChannel, pullToRefreshOptions);
PullToRefreshSettings pullToRefreshSettings = new PullToRefreshSettings();
pullToRefreshSettings.parse(pullToRefreshInitialSettings);
pullToRefreshLayout = new PullToRefreshLayout(context, pullToRefreshLayoutChannel, pullToRefreshSettings);
pullToRefreshLayout.addView(webView);
pullToRefreshLayout.prepare();
}

View File

@ -21,9 +21,9 @@ public class PullToRefreshLayout extends SwipeRefreshLayout implements MethodCha
static final String LOG_TAG = "PullToRefreshLayout";
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);
this.channel = channel;
this.options = options;

View File

@ -7,8 +7,8 @@ import com.pichillilorenzo.flutter_inappwebview.IWebViewSettings;
import java.util.HashMap;
import java.util.Map;
public class PullToRefreshOptions implements IWebViewSettings<PullToRefreshLayout> {
public static final String LOG_TAG = "PullToRefreshOptions";
public class PullToRefreshSettings implements IWebViewSettings<PullToRefreshLayout> {
public static final String LOG_TAG = "PullToRefreshSettings";
public Boolean enabled = true;
@Nullable
@ -22,7 +22,7 @@ public class PullToRefreshOptions implements IWebViewSettings<PullToRefreshLayou
@Nullable
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()) {
String key = pair.getKey();
Object value = pair.getValue();
@ -56,20 +56,20 @@ public class PullToRefreshOptions implements IWebViewSettings<PullToRefreshLayou
}
public Map<String, Object> toMap() {
Map<String, Object> options = new HashMap<>();
options.put("enabled", enabled);
options.put("color", color);
options.put("backgroundColor", backgroundColor);
options.put("distanceToTriggerSync", distanceToTriggerSync);
options.put("slingshotDistance", slingshotDistance);
options.put("size", size);
return options;
Map<String, Object> settings = new HashMap<>();
settings.put("enabled", enabled);
settings.put("color", color);
settings.put("backgroundColor", backgroundColor);
settings.put("distanceToTriggerSync", distanceToTriggerSync);
settings.put("slingshotDistance", slingshotDistance);
settings.put("size", size);
return settings;
}
@Override
public Map<String, Object> getRealSettings(PullToRefreshLayout pullToRefreshLayout) {
Map<String, Object> realOptions = toMap();
return realOptions;
Map<String, Object> realSettings = toMap();
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_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example"
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
export "FLUTTER_TARGET=lib/main.dart"
export "FLUTTER_TARGET=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/lib/main.dart"
export "FLUTTER_BUILD_DIR=build"
export "FLUTTER_BUILD_NAME=1.0.0"
export "FLUTTER_BUILD_NUMBER=1"
export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
export "DART_OBFUSCATION=false"
export "TRACK_WIDGET_CREATION=false"
export "TRACK_WIDGET_CREATION=true"
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 windowId = arguments["windowId"] as? Int64
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)
@ -94,7 +94,7 @@ public class InAppBrowserManager: NSObject, FlutterPlugin {
webViewController.contextMenu = contextMenu
webViewController.windowId = windowId
webViewController.initialUserScripts = initialUserScripts ?? []
webViewController.pullToRefreshInitialOptions = pullToRefreshInitialOptions
webViewController.pullToRefreshInitialSettings = pullToRefreshInitialSettings
presentViewController(webViewController: webViewController)
}

View File

@ -36,7 +36,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
var initialBaseUrl: String?
var previousStatusBarStyle = -1
var initialUserScripts: [[String: Any]] = []
var pullToRefreshInitialOptions: [String: Any?] = [:]
var pullToRefreshInitialSettings: [String: Any?] = [:]
var methodCallDelegate: InAppWebViewMethodHandler?
public override func loadView() {
@ -47,7 +47,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
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] {
webView = webViewTransport.webView
webView.contextMenu = contextMenu
@ -67,9 +67,9 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
let pullToRefreshLayoutChannel = FlutterMethodChannel(name: "com.pichillilorenzo/flutter_inappwebview_pull_to_refresh_" + id,
binaryMessenger: SwiftFlutterPlugin.instance!.registrar!.messenger())
let pullToRefreshOptions = PullToRefreshSettings()
let _ = pullToRefreshOptions.parse(options: pullToRefreshInitialOptions)
let pullToRefreshControl = PullToRefreshControl(channel: pullToRefreshLayoutChannel, options: pullToRefreshOptions)
let pullToRefreshSettings = PullToRefreshSettings()
let _ = pullToRefreshSettings.parse(settings: pullToRefreshInitialSettings)
let pullToRefreshControl = PullToRefreshControl(channel: pullToRefreshLayoutChannel, settings: pullToRefreshSettings)
webView.pullToRefreshControl = pullToRefreshControl
pullToRefreshControl.delegate = webView
pullToRefreshControl.prepare()
@ -429,8 +429,8 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
public func setSettings(newSettings: InAppBrowserSettings, newSettingsMap: [String: Any]) {
let newInAppWebViewOptions = InAppWebViewSettings()
let _ = newInAppWebViewOptions.parse(options: newSettingsMap)
self.webView.setOptions(newSettings: newInAppWebViewOptions, newOptionsMap: newSettingsMap)
let _ = newInAppWebViewOptions.parse(settings: newSettingsMap)
self.webView.setSettings(newSettings: newInAppWebViewOptions, newSettingsMap: newSettingsMap)
if newSettingsMap["hidden"] != nil, browserSettings?.hidden != newSettings.hidden {
if newSettings.hidden {
@ -474,7 +474,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega
}
if newSettingsMap["hideToolbarBottom"] != nil, browserSettings?.hideToolbarBottom != newSettings.hideToolbarBottom {
navigationController?.isToolbarHidden = !newOptions.hideToolbarBottom
navigationController?.isToolbarHidden = !newSettings.hideToolbarBottom
}
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 windowId = params["windowId"] as? Int64
let initialUserScripts = params["initialUserScripts"] as? [[String: Any]]
let pullToRefreshInitialOptions = params["pullToRefreshOptions"] as! [String: Any?]
let pullToRefreshInitialSettings = params["pullToRefreshSettings"] as! [String: Any?]
var userScripts: [UserScript] = []
if let initialUserScripts = initialUserScripts {
@ -44,7 +44,7 @@ public class FlutterWebViewController: NSObject, FlutterPlatformView {
let settings = InAppWebViewSettings()
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] {
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),
binaryMessenger: registrar.messenger())
let pullToRefreshOptions = PullToRefreshSettings()
let _ = pullToRefreshOptions.parse(settings: pullToRefreshInitialOptions)
let pullToRefreshControl = PullToRefreshControl(channel: pullToRefreshLayoutChannel, options: pullToRefreshOptions)
let pullToRefreshSettings = PullToRefreshSettings()
let _ = pullToRefreshSettings.parse(settings: pullToRefreshInitialSettings)
let pullToRefreshControl = PullToRefreshControl(channel: pullToRefreshLayoutChannel, settings: pullToRefreshSettings)
webView!.pullToRefreshControl = pullToRefreshControl
pullToRefreshControl.delegate = webView!
pullToRefreshControl.prepare()

View File

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

View File

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

View File

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

View File

@ -72,174 +72,167 @@ class WebViewFeature {
///
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 =
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_STRATEGY =
const WebViewFeature._internal("FORCE_DARK_STRATEGY");
const WebViewFeature._internal("FORCE_DARK_STRATEGY");
///
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 =
const WebViewFeature._internal("GET_WEB_VIEW_CLIENT");
const WebViewFeature._internal("GET_WEB_VIEW_CLIENT");
///
static const GET_WEB_VIEW_RENDERER =
const WebViewFeature._internal("GET_WEB_VIEW_RENDERER");
const WebViewFeature._internal("GET_WEB_VIEW_RENDERER");
///
static const MULTI_PROCESS =
const WebViewFeature._internal("MULTI_PROCESS");
static const MULTI_PROCESS = const WebViewFeature._internal("MULTI_PROCESS");
///
static const OFF_SCREEN_PRERASTER =
const WebViewFeature._internal("OFF_SCREEN_PRERASTER");
const WebViewFeature._internal("OFF_SCREEN_PRERASTER");
///
static const POST_WEB_MESSAGE =
const WebViewFeature._internal("POST_WEB_MESSAGE");
const WebViewFeature._internal("POST_WEB_MESSAGE");
///
static const PROXY_OVERRIDE =
const WebViewFeature._internal("PROXY_OVERRIDE");
const WebViewFeature._internal("PROXY_OVERRIDE");
///
static const RECEIVE_HTTP_ERROR =
const WebViewFeature._internal("RECEIVE_HTTP_ERROR");
const WebViewFeature._internal("RECEIVE_HTTP_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 =
const WebViewFeature._internal("SAFE_BROWSING_ALLOWLIST");
const WebViewFeature._internal("SAFE_BROWSING_ALLOWLIST");
///
static const SAFE_BROWSING_ENABLE =
const WebViewFeature._internal("SAFE_BROWSING_ENABLE");
const WebViewFeature._internal("SAFE_BROWSING_ENABLE");
///
static const SAFE_BROWSING_HIT =
const WebViewFeature._internal("SAFE_BROWSING_HIT");
const WebViewFeature._internal("SAFE_BROWSING_HIT");
///
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 =
const WebViewFeature._internal(
"SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY");
const WebViewFeature._internal("SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY");
///
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 =
const WebViewFeature._internal(
"SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL");
const WebViewFeature._internal(
"SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL");
///Use [SAFE_BROWSING_ALLOWLIST] instead.
@Deprecated('Use SAFE_BROWSING_ALLOWLIST instead')
static const SAFE_BROWSING_WHITELIST =
const WebViewFeature._internal("SAFE_BROWSING_WHITELIST");
const WebViewFeature._internal("SAFE_BROWSING_WHITELIST");
///
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 =
const WebViewFeature._internal(
"SERVICE_WORKER_BLOCK_NETWORK_LOADS");
const WebViewFeature._internal("SERVICE_WORKER_BLOCK_NETWORK_LOADS");
///
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 =
const WebViewFeature._internal("SERVICE_WORKER_CONTENT_ACCESS");
const WebViewFeature._internal("SERVICE_WORKER_CONTENT_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 =
const WebViewFeature._internal(
"SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST");
const WebViewFeature._internal("SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST");
///
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 =
const WebViewFeature._internal("START_SAFE_BROWSING");
const WebViewFeature._internal("START_SAFE_BROWSING");
///
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 =
const WebViewFeature._internal("VISUAL_STATE_CALLBACK");
const WebViewFeature._internal("VISUAL_STATE_CALLBACK");
///
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 =
const WebViewFeature._internal("WEB_MESSAGE_LISTENER");
const WebViewFeature._internal("WEB_MESSAGE_LISTENER");
///
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 =
const WebViewFeature._internal("WEB_MESSAGE_PORT_POST_MESSAGE");
const WebViewFeature._internal("WEB_MESSAGE_PORT_POST_MESSAGE");
///
static const WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK =
const WebViewFeature._internal(
"WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK");
const WebViewFeature._internal("WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK");
///
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 =
const WebViewFeature._internal(
"WEB_RESOURCE_ERROR_GET_DESCRIPTION");
const WebViewFeature._internal("WEB_RESOURCE_ERROR_GET_DESCRIPTION");
///
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 =
const WebViewFeature._internal(
"WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE");
const WebViewFeature._internal("WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE");
///
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;
@ -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.
///Use [WebViewFeature] instead.
@Deprecated("Use WebViewFeature instead")

View File

@ -88,8 +88,9 @@ class ChromeSafariBrowser {
///[settings]: Settings for the [ChromeSafariBrowser].
Future<void> open(
{required Uri url,
// ignore: deprecated_member_use_from_same_package
@Deprecated('Use settings instead') ChromeSafariBrowserClassOptions? options,
@Deprecated('Use settings instead')
// ignore: deprecated_member_use_from_same_package
ChromeSafariBrowserClassOptions? options,
ChromeSafariBrowserSettings? settings}) async {
assert(url.toString().isNotEmpty);
this.throwIsAlreadyOpened(message: 'Cannot open $url!');
@ -99,7 +100,8 @@ class ChromeSafariBrowser {
menuItemList.add({"id": value.id, "label": value.label});
});
var initialSettings = settings?.toMap() ?? options?.toMap() ??
var initialSettings = settings?.toMap() ??
options?.toMap() ??
ChromeSafariBrowserSettings().toMap();
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 ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions {
///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.
@ -179,25 +178,25 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions {
ChromeSafariBrowserSettings(
{this.shareState = CustomTabsShareState.SHARE_STATE_DEFAULT,
this.showTitle = true,
this.toolbarBackgroundColor,
this.enableUrlBarHiding = false,
this.instantAppsEnabled = false,
this.packageName,
this.keepAliveEnabled = false,
this.isSingleInstance = false,
this.noHistory = false,
this.isTrustedWebActivity = false,
this.additionalTrustedOrigins = const [],
this.displayMode,
this.screenOrientation = TrustedWebActivityScreenOrientation.DEFAULT,
this.entersReaderIfAvailable = false,
this.barCollapsingEnabled = false,
this.dismissButtonStyle = DismissButtonStyle.DONE,
this.preferredBarTintColor,
this.preferredControlTintColor,
this.presentationStyle = ModalPresentationStyle.FULL_SCREEN,
this.transitionStyle = ModalTransitionStyle.COVER_VERTICAL});
this.showTitle = true,
this.toolbarBackgroundColor,
this.enableUrlBarHiding = false,
this.instantAppsEnabled = false,
this.packageName,
this.keepAliveEnabled = false,
this.isSingleInstance = false,
this.noHistory = false,
this.isTrustedWebActivity = false,
this.additionalTrustedOrigins = const [],
this.displayMode,
this.screenOrientation = TrustedWebActivityScreenOrientation.DEFAULT,
this.entersReaderIfAvailable = false,
this.barCollapsingEnabled = false,
this.dismissButtonStyle = DismissButtonStyle.DONE,
this.preferredBarTintColor,
this.preferredControlTintColor,
this.presentationStyle = ModalPresentationStyle.FULL_SCREEN,
this.transitionStyle = ModalTransitionStyle.COVER_VERTICAL});
@override
Map<String, dynamic> toMap() {
@ -226,8 +225,7 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions {
}
static ChromeSafariBrowserSettings fromMap(Map<String, dynamic> map) {
ChromeSafariBrowserSettings options =
new ChromeSafariBrowserSettings();
ChromeSafariBrowserSettings options = new ChromeSafariBrowserSettings();
options.shareState = map["shareState"];
options.showTitle = map["showTitle"];
options.toolbarBackgroundColor =

View File

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

View File

@ -107,15 +107,22 @@ class InAppBrowser {
///[settings]: Settings for the [InAppBrowser].
Future<void> openUrlRequest(
{required URLRequest urlRequest,
// ignore: deprecated_member_use_from_same_package
@Deprecated('Use settings instead') InAppBrowserClassOptions? options,
InAppBrowserClassSettings? settings}) async {
// ignore: deprecated_member_use_from_same_package
@Deprecated('Use settings instead') InAppBrowserClassOptions? options,
InAppBrowserClassSettings? settings}) async {
this.throwIfAlreadyOpened(message: 'Cannot open $urlRequest!');
assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty);
var initialSettings = settings?.toMap() ?? options?.toMap() ??
var initialSettings = settings?.toMap() ??
options?.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>{};
args.putIfAbsent('id', () => id);
args.putIfAbsent('urlRequest', () => urlRequest.toMap());
@ -125,11 +132,7 @@ class InAppBrowser {
args.putIfAbsent('implementation', () => implementation.toValue());
args.putIfAbsent('initialUserScripts',
() => initialUserScripts?.map((e) => e.toMap()).toList() ?? []);
args.putIfAbsent(
'pullToRefreshOptions',
() =>
pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap());
args.putIfAbsent('pullToRefreshSettings', () => pullToRefreshSettings);
await _sharedChannel.invokeMethod('open', args);
}
@ -178,9 +181,16 @@ class InAppBrowser {
this.throwIfAlreadyOpened(message: 'Cannot open $assetFilePath!');
assert(assetFilePath.isNotEmpty);
var initialSettings = settings?.toMap() ?? options?.toMap() ??
var initialSettings = settings?.toMap() ??
options?.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>{};
args.putIfAbsent('id', () => id);
args.putIfAbsent('assetFilePath', () => assetFilePath);
@ -190,11 +200,7 @@ class InAppBrowser {
args.putIfAbsent('implementation', () => implementation.toValue());
args.putIfAbsent('initialUserScripts',
() => initialUserScripts?.map((e) => e.toMap()).toList() ?? []);
args.putIfAbsent(
'pullToRefreshOptions',
() =>
pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap());
args.putIfAbsent('pullToRefreshSettings', () => pullToRefreshSettings);
await _sharedChannel.invokeMethod('open', args);
}
@ -221,9 +227,16 @@ class InAppBrowser {
InAppBrowserClassSettings? settings}) async {
this.throwIfAlreadyOpened(message: 'Cannot open data!');
var initialSettings = settings?.toMap() ?? options?.toMap() ??
var initialSettings = settings?.toMap() ??
options?.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>{};
args.putIfAbsent('id', () => id);
args.putIfAbsent('settings', () => initialSettings);
@ -231,18 +244,14 @@ class InAppBrowser {
args.putIfAbsent('mimeType', () => mimeType);
args.putIfAbsent('encoding', () => encoding);
args.putIfAbsent('baseUrl', () => baseUrl?.toString() ?? "about:blank");
args.putIfAbsent(
'historyUrl', () => (historyUrl ?? androidHistoryUrl)?.toString() ?? "about:blank");
args.putIfAbsent('historyUrl',
() => (historyUrl ?? androidHistoryUrl)?.toString() ?? "about:blank");
args.putIfAbsent('contextMenu', () => contextMenu?.toMap() ?? {});
args.putIfAbsent('windowId', () => windowId);
args.putIfAbsent('implementation', () => implementation.toValue());
args.putIfAbsent('initialUserScripts',
() => initialUserScripts?.map((e) => e.toMap()).toList() ?? []);
args.putIfAbsent(
'pullToRefreshOptions',
() =>
pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap());
args.putIfAbsent('pullToRefreshSettings', () => pullToRefreshSettings);
await _sharedChannel.invokeMethod('open', args);
}
@ -309,7 +318,8 @@ class InAppBrowser {
}
///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();
Map<String, dynamic> args = <String, dynamic>{};
@ -323,10 +333,11 @@ class InAppBrowser {
Map<String, dynamic> args = <String, dynamic>{};
Map<dynamic, dynamic>? settings =
await _channel.invokeMethod('getSettings', args);
await _channel.invokeMethod('getSettings', args);
if (settings != null) {
settings = settings.cast<String, dynamic>();
return InAppBrowserClassSettings.fromMap(settings as Map<String, dynamic>);
return InAppBrowserClassSettings.fromMap(
settings as Map<String, dynamic>);
}
return null;
@ -802,7 +813,7 @@ class InAppBrowser {
///**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)))
Future<GeolocationPermissionShowPromptResponse?>?
onGeolocationPermissionsShowPrompt(String origin) {}
onGeolocationPermissionsShowPrompt(String origin) {}
///Use [onGeolocationPermissionsHidePrompt] instead.
@Deprecated("Use onGeolocationPermissionsHidePrompt instead")
@ -863,8 +874,7 @@ class InAppBrowser {
///
///**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)))
Future<WebViewRenderProcessAction?>? onRenderProcessUnresponsive(
Uri? url) {}
Future<WebViewRenderProcessAction?>? onRenderProcessUnresponsive(Uri? url) {}
///Use [onRenderProcessResponsive] instead.
@Deprecated("Use onRenderProcessResponsive instead")
@ -883,8 +893,7 @@ class InAppBrowser {
///
///**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)))
Future<WebViewRenderProcessAction?>? onRenderProcessResponsive(
Uri? url) {}
Future<WebViewRenderProcessAction?>? onRenderProcessResponsive(Uri? url) {}
///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)))
void onReceivedIcon(Uint8List icon) {}
///Use [onReceivedTouchIconUrl] instead.
@Deprecated('Use onReceivedTouchIconUrl instead')
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)))
void onReceivedTouchIconUrl(Uri url, bool precomposed) {}
///Use [onJsBeforeUnload] instead.
@Deprecated('Use onJsBeforeUnload instead')
Future<JsBeforeUnloadResponse?>? androidOnJsBeforeUnload(

View File

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

View File

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

View File

@ -127,7 +127,8 @@ class AndroidInAppWebViewController with AndroidInAppWebViewControllerMixin {
}
///Use [InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl] instead.
@Deprecated("Use InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl instead")
@Deprecated(
"Use InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl instead")
static Future<Uri?> getSafeBrowsingPrivacyPolicyUrl() async {
return await InAppWebViewController.getSafeBrowsingPrivacyPolicyUrl();
}
@ -142,15 +143,18 @@ class AndroidInAppWebViewController with AndroidInAppWebViewControllerMixin {
///Use [InAppWebViewController.getCurrentWebViewPackage] instead.
@Deprecated("Use InAppWebViewController.getCurrentWebViewPackage instead")
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);
}
///Use [InAppWebViewController.setWebContentsDebuggingEnabled] instead.
@Deprecated("Use InAppWebViewController.setWebContentsDebuggingEnabled instead")
@Deprecated(
"Use InAppWebViewController.setWebContentsDebuggingEnabled instead")
static Future<void> setWebContentsDebuggingEnabled(
bool debuggingEnabled) async {
return await InAppWebViewController.setWebContentsDebuggingEnabled(debuggingEnabled);
return await InAppWebViewController.setWebContentsDebuggingEnabled(
debuggingEnabled);
}
///Use [InAppWebViewController.getOriginalUrl] instead.
@ -160,4 +164,4 @@ class AndroidInAppWebViewController with AndroidInAppWebViewControllerMixin {
String? url = await _channel.invokeMethod('getOriginalUrl', args);
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_settings.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';
///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.
final Size initialSize;
HeadlessInAppWebView(
{this.initialSize = const Size(-1, -1),
this.windowId,
this.initialUrlRequest,
this.initialFile,
this.initialData,
@Deprecated('Use initialSettings instead') this.initialOptions,
this.initialSettings,
this.contextMenu,
this.initialUserScripts,
this.pullToRefreshController,
this.implementation = WebViewImplementation.NATIVE,
this.onWebViewCreated,
this.onLoadStart,
this.onLoadStop,
this.onLoadError,
this.onLoadHttpError,
this.onProgressChanged,
this.onConsoleMessage,
this.shouldOverrideUrlLoading,
this.onLoadResource,
this.onScrollChanged,
@Deprecated('Use onDownloadStartRequest instead')
this.onDownloadStart,
this.onDownloadStartRequest,
this.onLoadResourceCustomScheme,
this.onCreateWindow,
this.onCloseWindow,
this.onJsAlert,
this.onJsConfirm,
this.onJsPrompt,
this.onReceivedHttpAuthRequest,
this.onReceivedServerTrustAuthRequest,
this.onReceivedClientCertRequest,
this.onFindResultReceived,
this.shouldInterceptAjaxRequest,
this.onAjaxReadyStateChange,
this.onAjaxProgress,
this.shouldInterceptFetchRequest,
this.onUpdateVisitedHistory,
this.onPrint,
this.onLongPressHitTestResult,
this.onEnterFullscreen,
this.onExitFullscreen,
this.onPageCommitVisible,
this.onTitleChanged,
this.onWindowFocus,
this.onWindowBlur,
this.onOverScrolled,
@Deprecated('Use onSafeBrowsingHit instead') this.androidOnSafeBrowsingHit,
this.onSafeBrowsingHit,
@Deprecated('Use onPermissionRequest instead') this.androidOnPermissionRequest,
this.onPermissionRequest,
@Deprecated('Use onGeolocationPermissionsShowPrompt instead') this.androidOnGeolocationPermissionsShowPrompt,
this.onGeolocationPermissionsShowPrompt,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead') this.androidOnGeolocationPermissionsHidePrompt,
this.onGeolocationPermissionsHidePrompt,
@Deprecated('Use shouldInterceptRequest instead') this.androidShouldInterceptRequest,
this.shouldInterceptRequest,
@Deprecated('Use onRenderProcessGone instead') this.androidOnRenderProcessGone,
this.onRenderProcessGone,
@Deprecated('Use onRenderProcessResponsive instead') this.androidOnRenderProcessResponsive,
this.onRenderProcessResponsive,
@Deprecated('Use onRenderProcessUnresponsive instead') this.androidOnRenderProcessUnresponsive,
this.onRenderProcessUnresponsive,
@Deprecated('Use onFormResubmission instead') this.androidOnFormResubmission,
this.onFormResubmission,
@Deprecated('Use onZoomScaleChanged instead') this.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead') this.androidOnReceivedIcon,
this.onReceivedIcon,
@Deprecated('Use onReceivedTouchIconUrl instead') this.androidOnReceivedTouchIconUrl,
this.onReceivedTouchIconUrl,
@Deprecated('Use onJsBeforeUnload instead') this.androidOnJsBeforeUnload,
this.onJsBeforeUnload,
@Deprecated('Use onReceivedLoginRequest instead') 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,}) {
HeadlessInAppWebView({
this.initialSize = const Size(-1, -1),
this.windowId,
this.initialUrlRequest,
this.initialFile,
this.initialData,
@Deprecated('Use initialSettings instead') this.initialOptions,
this.initialSettings,
this.contextMenu,
this.initialUserScripts,
this.pullToRefreshController,
this.implementation = WebViewImplementation.NATIVE,
this.onWebViewCreated,
this.onLoadStart,
this.onLoadStop,
this.onLoadError,
this.onLoadHttpError,
this.onProgressChanged,
this.onConsoleMessage,
this.shouldOverrideUrlLoading,
this.onLoadResource,
this.onScrollChanged,
@Deprecated('Use onDownloadStartRequest instead') this.onDownloadStart,
this.onDownloadStartRequest,
this.onLoadResourceCustomScheme,
this.onCreateWindow,
this.onCloseWindow,
this.onJsAlert,
this.onJsConfirm,
this.onJsPrompt,
this.onReceivedHttpAuthRequest,
this.onReceivedServerTrustAuthRequest,
this.onReceivedClientCertRequest,
this.onFindResultReceived,
this.shouldInterceptAjaxRequest,
this.onAjaxReadyStateChange,
this.onAjaxProgress,
this.shouldInterceptFetchRequest,
this.onUpdateVisitedHistory,
this.onPrint,
this.onLongPressHitTestResult,
this.onEnterFullscreen,
this.onExitFullscreen,
this.onPageCommitVisible,
this.onTitleChanged,
this.onWindowFocus,
this.onWindowBlur,
this.onOverScrolled,
@Deprecated('Use onSafeBrowsingHit instead') this.androidOnSafeBrowsingHit,
this.onSafeBrowsingHit,
@Deprecated('Use onPermissionRequest instead')
this.androidOnPermissionRequest,
this.onPermissionRequest,
@Deprecated('Use onGeolocationPermissionsShowPrompt instead')
this.androidOnGeolocationPermissionsShowPrompt,
this.onGeolocationPermissionsShowPrompt,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead')
this.androidOnGeolocationPermissionsHidePrompt,
this.onGeolocationPermissionsHidePrompt,
@Deprecated('Use shouldInterceptRequest instead')
this.androidShouldInterceptRequest,
this.shouldInterceptRequest,
@Deprecated('Use onRenderProcessGone instead')
this.androidOnRenderProcessGone,
this.onRenderProcessGone,
@Deprecated('Use onRenderProcessResponsive instead')
this.androidOnRenderProcessResponsive,
this.onRenderProcessResponsive,
@Deprecated('Use onRenderProcessUnresponsive instead')
this.androidOnRenderProcessUnresponsive,
this.onRenderProcessUnresponsive,
@Deprecated('Use onFormResubmission instead')
this.androidOnFormResubmission,
this.onFormResubmission,
@Deprecated('Use onZoomScaleChanged instead') this.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead') this.androidOnReceivedIcon,
this.onReceivedIcon,
@Deprecated('Use onReceivedTouchIconUrl instead')
this.androidOnReceivedTouchIconUrl,
this.onReceivedTouchIconUrl,
@Deprecated('Use onJsBeforeUnload instead') this.androidOnJsBeforeUnload,
this.onJsBeforeUnload,
@Deprecated('Use onReceivedLoginRequest instead')
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();
webViewController = new InAppWebViewController(id, this);
this._channel =
@ -155,10 +169,16 @@ class HeadlessInAppWebView implements WebView {
}
_started = true;
Map<String, dynamic> initialSettings = (this.initialSettings != null ?
this.initialSettings?.toMap() :
// ignore: deprecated_member_use_from_same_package
this.initialOptions?.toMap()) ?? {};
Map<String, dynamic> initialSettings = this.initialSettings?.toMap() ??
// ignore: deprecated_member_use_from_same_package
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>{};
args.putIfAbsent('id', () => id);
@ -174,9 +194,7 @@ class HeadlessInAppWebView implements WebView {
'implementation': this.implementation.toValue(),
'initialUserScripts':
this.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
'pullToRefreshOptions':
this.pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap(),
'pullToRefreshSettings': pullToRefreshSettings,
'initialSize': this.initialSize.toMap()
});
await _sharedChannel.invokeMethod('run', args);
@ -425,8 +443,7 @@ class HeadlessInAppWebView implements WebView {
onScrollChanged;
@override
void Function(
InAppWebViewController controller, Uri? url, bool? isReload)?
void Function(InAppWebViewController controller, Uri? url, bool? isReload)?
onUpdateVisitedHistory;
@override
@ -528,53 +545,74 @@ class HeadlessInAppWebView implements WebView {
androidOnReceivedLoginRequest;
@override
void Function(InAppWebViewController controller)? onDidReceiveServerRedirectForProvisionalNavigation;
void Function(InAppWebViewController controller)?
onDidReceiveServerRedirectForProvisionalNavigation;
@override
Future<FormResubmissionAction?> Function(InAppWebViewController controller, Uri? url)? onFormResubmission;
Future<FormResubmissionAction?> Function(
InAppWebViewController controller, Uri? url)? onFormResubmission;
@override
void Function(InAppWebViewController controller)? onGeolocationPermissionsHidePrompt;
void Function(InAppWebViewController controller)?
onGeolocationPermissionsHidePrompt;
@override
Future<GeolocationPermissionShowPromptResponse?> Function(InAppWebViewController controller, String origin)? onGeolocationPermissionsShowPrompt;
Future<GeolocationPermissionShowPromptResponse?> Function(
InAppWebViewController controller, String origin)?
onGeolocationPermissionsShowPrompt;
@override
Future<JsBeforeUnloadResponse?> Function(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload;
Future<JsBeforeUnloadResponse?> Function(InAppWebViewController controller,
JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload;
@override
Future<NavigationResponseAction?> Function(InAppWebViewController controller, NavigationResponse navigationResponse)? onNavigationResponse;
Future<NavigationResponseAction?> Function(InAppWebViewController controller,
NavigationResponse navigationResponse)? onNavigationResponse;
@override
Future<PermissionRequestResponse?> Function(InAppWebViewController controller, String origin, List<String> resources)? onPermissionRequest;
Future<PermissionRequestResponse?> Function(InAppWebViewController controller,
String origin, List<String> resources)? onPermissionRequest;
@override
void Function(InAppWebViewController controller, Uint8List icon)? onReceivedIcon;
void Function(InAppWebViewController controller, Uint8List icon)?
onReceivedIcon;
@override
void Function(InAppWebViewController controller, LoginRequest loginRequest)? onReceivedLoginRequest;
void Function(InAppWebViewController controller, LoginRequest loginRequest)?
onReceivedLoginRequest;
@override
void Function(InAppWebViewController controller, Uri url, bool precomposed)? onReceivedTouchIconUrl;
void Function(InAppWebViewController controller, Uri url, bool precomposed)?
onReceivedTouchIconUrl;
@override
void Function(InAppWebViewController controller, RenderProcessGoneDetail detail)? onRenderProcessGone;
void Function(
InAppWebViewController controller, RenderProcessGoneDetail detail)?
onRenderProcessGone;
@override
Future<WebViewRenderProcessAction?> Function(InAppWebViewController controller, Uri? url)? onRenderProcessResponsive;
Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessResponsive;
@override
Future<WebViewRenderProcessAction?> Function(InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive;
Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive;
@override
Future<SafeBrowsingResponse?> Function(InAppWebViewController controller, Uri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit;
Future<SafeBrowsingResponse?> Function(InAppWebViewController controller,
Uri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit;
@override
void Function(InAppWebViewController controller)? onWebContentProcessDidTerminate;
void Function(InAppWebViewController controller)?
onWebContentProcessDidTerminate;
@override
Future<ShouldAllowDeprecatedTLSAction?> Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS;
Future<ShouldAllowDeprecatedTLSAction?> Function(
InAppWebViewController controller,
URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS;
@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,
@Deprecated('Use onSafeBrowsingHit instead') this.androidOnSafeBrowsingHit,
this.onSafeBrowsingHit,
@Deprecated('Use onPermissionRequest instead') this.androidOnPermissionRequest,
@Deprecated('Use onPermissionRequest instead')
this.androidOnPermissionRequest,
this.onPermissionRequest,
@Deprecated('Use onGeolocationPermissionsShowPrompt instead') this.androidOnGeolocationPermissionsShowPrompt,
@Deprecated('Use onGeolocationPermissionsShowPrompt instead')
this.androidOnGeolocationPermissionsShowPrompt,
this.onGeolocationPermissionsShowPrompt,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead') this.androidOnGeolocationPermissionsHidePrompt,
@Deprecated('Use onGeolocationPermissionsHidePrompt instead')
this.androidOnGeolocationPermissionsHidePrompt,
this.onGeolocationPermissionsHidePrompt,
@Deprecated('Use shouldInterceptRequest instead') this.androidShouldInterceptRequest,
@Deprecated('Use shouldInterceptRequest instead')
this.androidShouldInterceptRequest,
this.shouldInterceptRequest,
@Deprecated('Use onRenderProcessGone instead') this.androidOnRenderProcessGone,
@Deprecated('Use onRenderProcessGone instead')
this.androidOnRenderProcessGone,
this.onRenderProcessGone,
@Deprecated('Use onRenderProcessResponsive instead') this.androidOnRenderProcessResponsive,
@Deprecated('Use onRenderProcessResponsive instead')
this.androidOnRenderProcessResponsive,
this.onRenderProcessResponsive,
@Deprecated('Use onRenderProcessUnresponsive instead') this.androidOnRenderProcessUnresponsive,
@Deprecated('Use onRenderProcessUnresponsive instead')
this.androidOnRenderProcessUnresponsive,
this.onRenderProcessUnresponsive,
@Deprecated('Use onFormResubmission instead') this.androidOnFormResubmission,
@Deprecated('Use onFormResubmission instead')
this.androidOnFormResubmission,
this.onFormResubmission,
@Deprecated('Use onZoomScaleChanged instead') this.androidOnScaleChanged,
@Deprecated('Use onReceivedIcon instead') this.androidOnReceivedIcon,
this.onReceivedIcon,
@Deprecated('Use onReceivedTouchIconUrl instead') this.androidOnReceivedTouchIconUrl,
@Deprecated('Use onReceivedTouchIconUrl instead')
this.androidOnReceivedTouchIconUrl,
this.onReceivedTouchIconUrl,
@Deprecated('Use onJsBeforeUnload instead') this.androidOnJsBeforeUnload,
this.onJsBeforeUnload,
@Deprecated('Use onReceivedLoginRequest instead') this.androidOnReceivedLoginRequest,
@Deprecated('Use onReceivedLoginRequest instead')
this.androidOnReceivedLoginRequest,
this.onReceivedLoginRequest,
@Deprecated('Use onWebContentProcessDidTerminate instead') this.iosOnWebContentProcessDidTerminate,
@Deprecated('Use onWebContentProcessDidTerminate instead')
this.iosOnWebContentProcessDidTerminate,
this.onWebContentProcessDidTerminate,
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead') this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
this.onDidReceiveServerRedirectForProvisionalNavigation,
@Deprecated('Use onNavigationResponse instead') this.iosOnNavigationResponse,
@Deprecated('Use onNavigationResponse instead')
this.iosOnNavigationResponse,
this.onNavigationResponse,
@Deprecated('Use shouldAllowDeprecatedTLS instead') this.iosShouldAllowDeprecatedTLS,
@Deprecated('Use shouldAllowDeprecatedTLS instead')
this.iosShouldAllowDeprecatedTLS,
this.shouldAllowDeprecatedTLS,
this.gestureRecognizers,
}) : super(key: key);
@ -428,55 +442,84 @@ class InAppWebView extends StatefulWidget implements WebView {
androidOnReceivedLoginRequest;
@override
final void Function(InAppWebViewController controller)? onDidReceiveServerRedirectForProvisionalNavigation;
final void Function(InAppWebViewController controller)?
onDidReceiveServerRedirectForProvisionalNavigation;
@override
final Future<FormResubmissionAction?> Function(InAppWebViewController controller, Uri? url)? onFormResubmission;
final Future<FormResubmissionAction?> Function(
InAppWebViewController controller, Uri? url)? onFormResubmission;
@override
final void Function(InAppWebViewController controller)? onGeolocationPermissionsHidePrompt;
final void Function(InAppWebViewController controller)?
onGeolocationPermissionsHidePrompt;
@override
final Future<GeolocationPermissionShowPromptResponse?> Function(InAppWebViewController controller, String origin)? onGeolocationPermissionsShowPrompt;
final Future<GeolocationPermissionShowPromptResponse?> Function(
InAppWebViewController controller, String origin)?
onGeolocationPermissionsShowPrompt;
@override
final Future<JsBeforeUnloadResponse?> Function(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload;
final Future<JsBeforeUnloadResponse?> Function(
InAppWebViewController controller,
JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload;
@override
final Future<NavigationResponseAction?> Function(InAppWebViewController controller, NavigationResponse navigationResponse)? onNavigationResponse;
final Future<NavigationResponseAction?> Function(
InAppWebViewController controller,
NavigationResponse navigationResponse)? onNavigationResponse;
@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
final void Function(InAppWebViewController controller, Uint8List icon)? onReceivedIcon;
final void Function(InAppWebViewController controller, Uint8List icon)?
onReceivedIcon;
@override
final void Function(InAppWebViewController controller, LoginRequest loginRequest)? onReceivedLoginRequest;
final void Function(
InAppWebViewController controller, LoginRequest loginRequest)?
onReceivedLoginRequest;
@override
final void Function(InAppWebViewController controller, Uri url, bool precomposed)? onReceivedTouchIconUrl;
final void Function(
InAppWebViewController controller, Uri url, bool precomposed)?
onReceivedTouchIconUrl;
@override
final void Function(InAppWebViewController controller, RenderProcessGoneDetail detail)? onRenderProcessGone;
final void Function(
InAppWebViewController controller, RenderProcessGoneDetail detail)?
onRenderProcessGone;
@override
final Future<WebViewRenderProcessAction?> Function(InAppWebViewController controller, Uri? url)? onRenderProcessResponsive;
final Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessResponsive;
@override
final Future<WebViewRenderProcessAction?> Function(InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive;
final Future<WebViewRenderProcessAction?> Function(
InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive;
@override
final Future<SafeBrowsingResponse?> Function(InAppWebViewController controller, Uri url, SafeBrowsingThreat? threatType)? onSafeBrowsingHit;
final Future<SafeBrowsingResponse?> Function(
InAppWebViewController controller,
Uri url,
SafeBrowsingThreat? threatType)? onSafeBrowsingHit;
@override
final void Function(InAppWebViewController controller)? onWebContentProcessDidTerminate;
final void Function(InAppWebViewController controller)?
onWebContentProcessDidTerminate;
@override
final Future<ShouldAllowDeprecatedTLSAction?> Function(InAppWebViewController controller, URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS;
final Future<ShouldAllowDeprecatedTLSAction?> Function(
InAppWebViewController controller,
URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS;
@override
final Future<WebResourceResponse?> Function(InAppWebViewController controller, WebResourceRequest request)? shouldInterceptRequest;
final Future<WebResourceResponse?> Function(
InAppWebViewController controller, WebResourceRequest request)?
shouldInterceptRequest;
}
class _InAppWebViewState extends State<InAppWebView> {
@ -484,16 +527,24 @@ class _InAppWebViewState extends State<InAppWebView> {
@override
Widget build(BuildContext context) {
Map<String, dynamic> initialSettings = (widget.initialSettings != null ?
widget.initialSettings?.toMap() :
// ignore: deprecated_member_use_from_same_package
widget.initialOptions?.toMap()) ?? {};
Map<String, dynamic> initialSettings = widget.initialSettings?.toMap() ??
// ignore: deprecated_member_use_from_same_package
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) {
var useHybridComposition = (widget.initialSettings != null ?
widget.initialSettings?.useHybridComposition :
// ignore: deprecated_member_use_from_same_package
widget.initialOptions?.android.useHybridComposition) ?? false;
var useHybridComposition = (widget.initialSettings != null
? widget.initialSettings?.useHybridComposition
:
// ignore: deprecated_member_use_from_same_package
widget.initialOptions?.android.useHybridComposition) ??
false;
if (!useHybridComposition && widget.pullToRefreshController != null) {
throw new Exception(
@ -530,9 +581,7 @@ class _InAppWebViewState extends State<InAppWebView> {
'initialUserScripts':
widget.initialUserScripts?.map((e) => e.toMap()).toList() ??
[],
'pullToRefreshOptions':
widget.pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap()
'pullToRefreshSettings': pullToRefreshSettings
},
creationParamsCodec: const StandardMessageCodec(),
)
@ -558,9 +607,7 @@ class _InAppWebViewState extends State<InAppWebView> {
'implementation': widget.implementation.toValue(),
'initialUserScripts':
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
'pullToRefreshOptions':
widget.pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap()
'pullToRefreshSettings': pullToRefreshSettings
},
creationParamsCodec: const StandardMessageCodec(),
);
@ -580,9 +627,7 @@ class _InAppWebViewState extends State<InAppWebView> {
'implementation': widget.implementation.toValue(),
'initialUserScripts':
widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [],
'pullToRefreshOptions':
widget.pullToRefreshController?.options.toMap() ??
PullToRefreshOptions(enabled: false).toMap()
'pullToRefreshSettings': pullToRefreshSettings
},
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]
///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;
late MethodChannel _channel;
static MethodChannel _staticChannel = IN_APP_WEBVIEW_STATIC_CHANNEL;
@ -275,22 +276,30 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
case "onGeolocationPermissionsShowPrompt":
if ((_webview != null &&
(_webview!.onGeolocationPermissionsShowPrompt != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnGeolocationPermissionsShowPrompt != null)) ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnGeolocationPermissionsShowPrompt !=
null)) ||
_inAppBrowser != null) {
String origin = call.arguments["origin"];
if (_webview != null) {
if (_webview!.onGeolocationPermissionsShowPrompt != null)
return (await _webview!.onGeolocationPermissionsShowPrompt!(this, origin))?.toMap();
return (await _webview!.onGeolocationPermissionsShowPrompt!(
this, origin))
?.toMap();
else {
// ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnGeolocationPermissionsShowPrompt!(this, origin))?.toMap();
return (await _webview!
// ignore: deprecated_member_use_from_same_package
.androidOnGeolocationPermissionsShowPrompt!(this, origin))
?.toMap();
}
} else {
return ((await _inAppBrowser!.onGeolocationPermissionsShowPrompt(origin)) ??
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.androidOnGeolocationPermissionsShowPrompt(origin)))?.toMap();
return ((await _inAppBrowser!
.onGeolocationPermissionsShowPrompt(origin)) ??
(await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidOnGeolocationPermissionsShowPrompt(origin)))
?.toMap();
}
}
break;
@ -305,8 +314,7 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnGeolocationPermissionsHidePrompt!(this);
}
}
else if (_inAppBrowser != null) {
} else if (_inAppBrowser != null) {
_inAppBrowser!.onGeolocationPermissionsHidePrompt();
// ignore: deprecated_member_use_from_same_package
_inAppBrowser!.androidOnGeolocationPermissionsHidePrompt();
@ -315,8 +323,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
case "shouldInterceptRequest":
if ((_webview != null &&
(_webview!.shouldInterceptRequest != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidShouldInterceptRequest != null)) ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidShouldInterceptRequest != null)) ||
_inAppBrowser != null) {
Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>();
@ -324,69 +332,84 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
if (_webview != null) {
if (_webview!.shouldInterceptRequest != null)
return (await _webview!.shouldInterceptRequest!(this, request))?.toMap();
return (await _webview!.shouldInterceptRequest!(this, request))
?.toMap();
else {
// ignore: deprecated_member_use_from_same_package
return (await _webview!.androidShouldInterceptRequest!(this, request))?.toMap();
return (await _webview!.androidShouldInterceptRequest!(
this, request))
?.toMap();
}
} else {
return ((await _inAppBrowser!.shouldInterceptRequest(request)) ??
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.androidShouldInterceptRequest(request)))?.toMap();
(await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidShouldInterceptRequest(request)))
?.toMap();
}
}
break;
case "onRenderProcessUnresponsive":
if ((_webview != null &&
(_webview!.onRenderProcessUnresponsive != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessUnresponsive != null)) ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessUnresponsive != null)) ||
_inAppBrowser != null) {
String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.parse(url) : null;
if (_webview != null) {
if (_webview!.onRenderProcessUnresponsive != null)
return (await _webview!.onRenderProcessUnresponsive!(this, uri))?.toMap();
return (await _webview!.onRenderProcessUnresponsive!(this, uri))
?.toMap();
else {
// ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnRenderProcessUnresponsive!(this, uri))?.toMap();
return (await _webview!.androidOnRenderProcessUnresponsive!(
this, uri))
?.toMap();
}
} else {
return ((await _inAppBrowser!.onRenderProcessUnresponsive(uri)) ??
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.androidOnRenderProcessUnresponsive(uri)))?.toMap();
(await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidOnRenderProcessUnresponsive(uri)))
?.toMap();
}
}
break;
case "onRenderProcessResponsive":
if ((_webview != null &&
(_webview!.onRenderProcessResponsive != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessResponsive != null)) ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessResponsive != null)) ||
_inAppBrowser != null) {
String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.parse(url) : null;
if (_webview != null) {
if (_webview!.onRenderProcessResponsive != null)
return (await _webview!.onRenderProcessResponsive!(this, uri))?.toMap();
return (await _webview!.onRenderProcessResponsive!(this, uri))
?.toMap();
else {
// ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnRenderProcessResponsive!(this, uri))?.toMap();
return (await _webview!.androidOnRenderProcessResponsive!(
this, uri))
?.toMap();
}
} else {
return ((await _inAppBrowser!.onRenderProcessResponsive(uri)) ??
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.androidOnRenderProcessResponsive(uri)))?.toMap();
(await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidOnRenderProcessResponsive(uri)))
?.toMap();
}
}
break;
case "onRenderProcessGone":
if ((_webview != null &&
(_webview!.onRenderProcessGone != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessGone != null)) ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessGone != null)) ||
_inAppBrowser != null) {
Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>();
@ -400,8 +423,7 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnRenderProcessGone!(this, detail);
}
}
else if (_inAppBrowser != null) {
} else if (_inAppBrowser != null) {
_inAppBrowser!.onRenderProcessGone(detail);
// ignore: deprecated_member_use_from_same_package
_inAppBrowser!.androidOnRenderProcessGone(detail);
@ -410,9 +432,9 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
break;
case "onFormResubmission":
if ((_webview != null &&
(_webview!.onFormResubmission != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnFormResubmission != null)) ||
(_webview!.onFormResubmission != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnFormResubmission != null)) ||
_inAppBrowser != null) {
String? url = call.arguments["url"];
Uri? uri = url != null ? Uri.parse(url) : null;
@ -422,12 +444,14 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
return (await _webview!.onFormResubmission!(this, uri))?.toMap();
else {
// ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnFormResubmission!(this, uri))?.toMap();
return (await _webview!.androidOnFormResubmission!(this, uri))
?.toMap();
}
} else {
return ((await _inAppBrowser!.onFormResubmission(uri)) ??
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.androidOnFormResubmission(uri)))?.toMap();
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.androidOnFormResubmission(uri)))
?.toMap();
}
}
break;
@ -455,10 +479,10 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
}
break;
case "onReceivedIcon":
if ((_webview != null && (
_webview!.onReceivedIcon != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnReceivedIcon != null)) ||
if ((_webview != null &&
(_webview!.onReceivedIcon != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnReceivedIcon != null)) ||
_inAppBrowser != null) {
Uint8List icon =
Uint8List.fromList(call.arguments["icon"].cast<int>());
@ -480,8 +504,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
case "onReceivedTouchIconUrl":
if ((_webview != null &&
(_webview!.onReceivedTouchIconUrl != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnReceivedTouchIconUrl != null)) ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnReceivedTouchIconUrl != null)) ||
_inAppBrowser != null) {
String url = call.arguments["url"];
bool precomposed = call.arguments["precomposed"];
@ -545,10 +569,10 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
}
break;
case "onJsBeforeUnload":
if ((_webview != null && (
_webview!.onJsBeforeUnload != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnJsBeforeUnload != null)) ||
if ((_webview != null &&
(_webview!.onJsBeforeUnload != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnJsBeforeUnload != null)) ||
_inAppBrowser != null) {
Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>();
@ -557,23 +581,30 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
if (_webview != null) {
if (_webview!.onJsBeforeUnload != null)
return (await _webview!.onJsBeforeUnload!(this, jsBeforeUnloadRequest))?.toMap();
return (await _webview!.onJsBeforeUnload!(
this, jsBeforeUnloadRequest))
?.toMap();
else {
// ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnJsBeforeUnload!(this, jsBeforeUnloadRequest))?.toMap();
return (await _webview!.androidOnJsBeforeUnload!(
this, jsBeforeUnloadRequest))
?.toMap();
}
} else {
return ((await _inAppBrowser!.onJsBeforeUnload(jsBeforeUnloadRequest)) ??
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.androidOnJsBeforeUnload(jsBeforeUnloadRequest)))?.toMap();
return ((await _inAppBrowser!
.onJsBeforeUnload(jsBeforeUnloadRequest)) ??
(await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidOnJsBeforeUnload(jsBeforeUnloadRequest)))
?.toMap();
}
}
break;
case "onSafeBrowsingHit":
if ((_webview != null && (
_webview!.onSafeBrowsingHit != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnSafeBrowsingHit != null)) ||
if ((_webview != null &&
(_webview!.onSafeBrowsingHit != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnSafeBrowsingHit != null)) ||
_inAppBrowser != null) {
String url = call.arguments["url"];
SafeBrowsingThreat? threatType =
@ -582,23 +613,28 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
if (_webview != null) {
if (_webview!.onSafeBrowsingHit != null)
return (await _webview!.onSafeBrowsingHit!(this, uri, threatType))?.toMap();
return (await _webview!.onSafeBrowsingHit!(this, uri, threatType))
?.toMap();
else {
// ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnSafeBrowsingHit!(this, uri, threatType))?.toMap();
return (await _webview!.androidOnSafeBrowsingHit!(
this, uri, threatType))
?.toMap();
}
} else {
return ((await _inAppBrowser!.onSafeBrowsingHit(uri, threatType)) ??
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.androidOnSafeBrowsingHit(uri, threatType)))?.toMap();
(await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidOnSafeBrowsingHit(uri, threatType)))
?.toMap();
}
}
break;
case "onReceivedLoginRequest":
if ((_webview != null &&
(_webview!.onReceivedLoginRequest != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnReceivedLoginRequest != null)) ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnReceivedLoginRequest != null)) ||
_inAppBrowser != null) {
Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>();
@ -689,23 +725,30 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
case "onPermissionRequest":
if ((_webview != null &&
(_webview!.onPermissionRequest != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnPermissionRequest != null)) ||
// ignore: deprecated_member_use_from_same_package
_webview!.androidOnPermissionRequest != null)) ||
_inAppBrowser != null) {
String origin = call.arguments["origin"];
List<String> resources = call.arguments["resources"].cast<String>();
if (_webview != null) {
if (_webview!.onPermissionRequest != null)
return (await _webview!.onPermissionRequest!(this, origin, resources))?.toMap();
return (await _webview!.onPermissionRequest!(
this, origin, resources))
?.toMap();
else {
// ignore: deprecated_member_use_from_same_package
return (await _webview!.androidOnPermissionRequest!(this, origin, resources))?.toMap();
return (await _webview!.androidOnPermissionRequest!(
this, origin, resources))
?.toMap();
}
} else {
return ((await _inAppBrowser!.onPermissionRequest(origin, resources)) ??
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.androidOnPermissionRequest(origin, resources)))?.toMap();
return ((await _inAppBrowser!
.onPermissionRequest(origin, resources)) ??
(await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.androidOnPermissionRequest(origin, resources)))
?.toMap();
}
}
break;
@ -724,8 +767,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
case "onWebContentProcessDidTerminate":
if (_webview != null &&
(_webview!.onWebContentProcessDidTerminate != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.iosOnWebContentProcessDidTerminate != null)) {
// ignore: deprecated_member_use_from_same_package
_webview!.iosOnWebContentProcessDidTerminate != null)) {
if (_webview!.onWebContentProcessDidTerminate != null)
_webview!.onWebContentProcessDidTerminate!(this);
else {
@ -751,55 +794,70 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
break;
case "onDidReceiveServerRedirectForProvisionalNavigation":
if (_webview != null &&
(_webview!.onDidReceiveServerRedirectForProvisionalNavigation != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.iosOnDidReceiveServerRedirectForProvisionalNavigation != null)) {
if (_webview!.onDidReceiveServerRedirectForProvisionalNavigation != null)
(_webview!.onDidReceiveServerRedirectForProvisionalNavigation !=
null ||
_webview!
// ignore: deprecated_member_use_from_same_package
.iosOnDidReceiveServerRedirectForProvisionalNavigation !=
null)) {
if (_webview!.onDidReceiveServerRedirectForProvisionalNavigation !=
null)
_webview!.onDidReceiveServerRedirectForProvisionalNavigation!(this);
else {
// ignore: deprecated_member_use_from_same_package
_webview!.iosOnDidReceiveServerRedirectForProvisionalNavigation!(this);
_webview!
// ignore: deprecated_member_use_from_same_package
.iosOnDidReceiveServerRedirectForProvisionalNavigation!(this);
}
} else if (_inAppBrowser != null) {
_inAppBrowser!.onDidReceiveServerRedirectForProvisionalNavigation();
// ignore: deprecated_member_use_from_same_package
_inAppBrowser!.iosOnDidReceiveServerRedirectForProvisionalNavigation();
_inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.iosOnDidReceiveServerRedirectForProvisionalNavigation();
}
break;
case "onNavigationResponse":
if ((_webview != null && (
_webview!.onNavigationResponse != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.iosOnNavigationResponse != null)) ||
if ((_webview != null &&
(_webview!.onNavigationResponse != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.iosOnNavigationResponse != null)) ||
_inAppBrowser != null) {
Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>();
// ignore: deprecated_member_use_from_same_package
IOSWKNavigationResponse iosOnNavigationResponse =
// ignore: deprecated_member_use_from_same_package
// ignore: deprecated_member_use_from_same_package
IOSWKNavigationResponse.fromMap(arguments)!;
NavigationResponse navigationResponse = NavigationResponse.fromMap(arguments)!;
NavigationResponse navigationResponse =
NavigationResponse.fromMap(arguments)!;
if (_webview != null) {
if (_webview!.onNavigationResponse != null)
return (await _webview!.onNavigationResponse!(this, navigationResponse))?.toMap();
return (await _webview!.onNavigationResponse!(
this, navigationResponse))
?.toMap();
else {
// ignore: deprecated_member_use_from_same_package
return (await _webview!.iosOnNavigationResponse!(this, iosOnNavigationResponse))?.toMap();
return (await _webview!.iosOnNavigationResponse!(
this, iosOnNavigationResponse))
?.toMap();
}
} else {
return (await _inAppBrowser!.onNavigationResponse(navigationResponse))?.toMap() ??
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.iosOnNavigationResponse(iosOnNavigationResponse))?.toMap();
return (await _inAppBrowser!
.onNavigationResponse(navigationResponse))
?.toMap() ??
(await _inAppBrowser!
// ignore: deprecated_member_use_from_same_package
.iosOnNavigationResponse(iosOnNavigationResponse))
?.toMap();
}
}
break;
case "shouldAllowDeprecatedTLS":
if ((_webview != null &&
(_webview!.shouldAllowDeprecatedTLS != null ||
// ignore: deprecated_member_use_from_same_package
_webview!.iosShouldAllowDeprecatedTLS != null)) ||
// ignore: deprecated_member_use_from_same_package
_webview!.iosShouldAllowDeprecatedTLS != null)) ||
_inAppBrowser != null) {
Map<String, dynamic> arguments =
call.arguments.cast<String, dynamic>();
@ -808,15 +866,21 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
if (_webview != null) {
if (_webview!.shouldAllowDeprecatedTLS != null)
return (await _webview!.shouldAllowDeprecatedTLS!(this, challenge))?.toMap();
return (await _webview!.shouldAllowDeprecatedTLS!(
this, challenge))
?.toMap();
else {
// ignore: deprecated_member_use_from_same_package
return (await _webview!.iosShouldAllowDeprecatedTLS!(this, challenge))?.toMap();
return (await _webview!.iosShouldAllowDeprecatedTLS!(
this, challenge))
?.toMap();
}
} else {
return (await _inAppBrowser!.shouldAllowDeprecatedTLS(challenge))?.toMap() ??
return (await _inAppBrowser!.shouldAllowDeprecatedTLS(challenge))
?.toMap() ??
// ignore: deprecated_member_use_from_same_package
(await _inAppBrowser!.iosShouldAllowDeprecatedTLS(challenge))?.toMap();
(await _inAppBrowser!.iosShouldAllowDeprecatedTLS(challenge))
?.toMap();
}
}
break;
@ -1327,8 +1391,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
Uri? iosAllowingReadAccessTo,
Uri? allowingReadAccessTo}) async {
assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty);
assert(allowingReadAccessTo == null ||
allowingReadAccessTo.isScheme("file"));
assert(
allowingReadAccessTo == null || allowingReadAccessTo.isScheme("file"));
assert(iosAllowingReadAccessTo == null ||
iosAllowingReadAccessTo.isScheme("file"));
@ -1387,8 +1451,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
@Deprecated('Use allowingReadAccessTo instead')
Uri? iosAllowingReadAccessTo,
Uri? allowingReadAccessTo}) async {
assert(allowingReadAccessTo == null ||
allowingReadAccessTo.isScheme("file"));
assert(
allowingReadAccessTo == null || allowingReadAccessTo.isScheme("file"));
assert(iosAllowingReadAccessTo == null ||
iosAllowingReadAccessTo.isScheme("file"));
@ -1821,7 +1885,7 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
Map<String, dynamic> args = <String, dynamic>{};
Map<dynamic, dynamic>? settings =
await _channel.invokeMethod('getSettings', args);
await _channel.invokeMethod('getSettings', args);
if (settings != null) {
settings = settings.cast<String, dynamic>();
return InAppWebViewSettings.fromMap(settings as Map<String, dynamic>);
@ -2819,8 +2883,8 @@ class InAppWebViewController with AndroidInAppWebViewControllerMixin, IOSInAppWe
static Future<WebViewPackageInfo?> getCurrentWebViewPackage() async {
Map<String, dynamic> args = <String, dynamic>{};
Map<String, dynamic>? packageInfo =
(await _staticChannel.invokeMethod('getCurrentWebViewPackage', args))
?.cast<String, dynamic>();
(await _staticChannel.invokeMethod('getCurrentWebViewPackage', args))
?.cast<String, dynamic>();
return WebViewPackageInfo.fromMap(packageInfo);
}

View File

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

View File

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

View File

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

View File

@ -1,2 +1,2 @@
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 '../types.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.
///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`.
class PullToRefreshController {
@Deprecated("Use settings instead")
// ignore: deprecated_member_use_from_same_package
late PullToRefreshOptions options;
late PullToRefreshSettings settings;
MethodChannel? _channel;
///Event called when a swipe gesture triggers a refresh.
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.settings = settings ?? PullToRefreshSettings();
}
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 'ios/web_storage_manager.dart';
import '../types.dart';
///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>{};
List<Map<dynamic, dynamic>> origins =
(await _staticChannel.invokeMethod('getOrigins', args))
.cast<Map<dynamic, dynamic>>();
(await _staticChannel.invokeMethod('getOrigins', args))
.cast<Map<dynamic, dynamic>>();
for (var origin in origins) {
originsList.add(WebStorageOrigin(
@ -121,8 +120,8 @@ class WebStorageManager {
Map<String, dynamic> args = <String, dynamic>{};
args.putIfAbsent("dataTypes", () => dataTypesList);
List<Map<dynamic, dynamic>> records =
(await _staticChannel.invokeMethod('fetchDataRecords', args))
.cast<Map<dynamic, dynamic>>();
(await _staticChannel.invokeMethod('fetchDataRecords', args))
.cast<Map<dynamic, dynamic>>();
for (var record in records) {
List<String> dataTypesString = record["dataTypes"].cast<String>();
Set<WebsiteDataType> dataTypes = Set();
@ -148,7 +147,7 @@ class WebStorageManager {
///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata))
Future<void> removeDataFor(
{required Set<WebsiteDataType> dataTypes,
required List<WebsiteDataRecord> dataRecords}) async {
required List<WebsiteDataRecord> dataRecords}) async {
List<String> dataTypesList = [];
for (var dataType in dataTypes) {
dataTypesList.add(dataType.toValue());
@ -174,8 +173,7 @@ class WebStorageManager {
///**Supported Platforms/Implementations**:
///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata))
Future<void> removeDataModifiedSince(
{required Set<WebsiteDataType> dataTypes,
required DateTime date}) async {
{required Set<WebsiteDataType> dataTypes, required DateTime date}) async {
List<String> dataTypesList = [];
for (var dataType in dataTypes) {
dataTypesList.add(dataType.toValue());