diff --git a/.idea/libraries/Dart_Packages.xml b/.idea/libraries/Dart_Packages.xml deleted file mode 100644 index 3d5970d9..00000000 --- a/.idea/libraries/Dart_Packages.xml +++ /dev/null @@ -1,772 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Flutter_Plugins.xml b/.idea/libraries/Flutter_Plugins.xml index 31799730..c241dc8c 100755 --- a/.idea/libraries/Flutter_Plugins.xml +++ b/.idea/libraries/Flutter_Plugins.xml @@ -1,6 +1,9 @@ - + + + + diff --git a/example/.flutter-plugins-dependencies b/example/.flutter-plugins-dependencies index c7ba9039..e6799223 100644 --- a/example/.flutter-plugins-dependencies +++ b/example/.flutter-plugins-dependencies @@ -1 +1 @@ -{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"device_info","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/device_info-2.0.0-nullsafety.2/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":["device_info"]},{"name":"integration_test","path":"/Users/lorenzopichilli/flutter/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"android":[{"name":"device_info","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/device_info-2.0.0-nullsafety.2/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":["device_info"]},{"name":"integration_test","path":"/Users/lorenzopichilli/flutter/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.5-nullsafety/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.1.0-nullsafety.2/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.2.0-nullsafety/","dependencies":[]},{"name":"url_launcher_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.1.0-nullsafety.3/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-0.1.0-nullsafety.3/","dependencies":[]},{"name":"url_launcher_windows","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-0.1.0-nullsafety.2/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"device_info","dependencies":[]},{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":["device_info"]},{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-02-22 23:35:30.325662","version":"1.27.0-5.0.pre.90"} \ No newline at end of file +{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"device_info","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/device_info-2.0.0-nullsafety.2/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":["device_info"]},{"name":"integration_test","path":"/Users/lorenzopichilli/flutter/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"android":[{"name":"device_info","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/device_info-2.0.0-nullsafety.2/","dependencies":[]},{"name":"flutter_downloader","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_downloader-1.5.2/","dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/lorenzopichilli/Desktop/flutter_inappwebview/","dependencies":["device_info"]},{"name":"integration_test","path":"/Users/lorenzopichilli/flutter/packages/integration_test/","dependencies":[]},{"name":"path_provider","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider-2.0.0-nullsafety/","dependencies":[]},{"name":"permission_handler","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/permission_handler-5.1.0+2/","dependencies":[]},{"name":"url_launcher","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher-6.0.0-nullsafety.6/","dependencies":[]}],"macos":[{"name":"path_provider_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_macos-0.0.5-nullsafety/","dependencies":[]},{"name":"url_launcher_macos","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_macos-0.1.0-nullsafety.2/","dependencies":[]}],"linux":[{"name":"path_provider_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_linux-0.2.0-nullsafety/","dependencies":[]},{"name":"url_launcher_linux","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_linux-0.1.0-nullsafety.3/","dependencies":[]}],"windows":[{"name":"path_provider_windows","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/path_provider_windows-0.1.0-nullsafety.3/","dependencies":[]},{"name":"url_launcher_windows","path":"/Users/lorenzopichilli/flutter/.pub-cache/hosted/pub.dartlang.org/url_launcher_windows-0.1.0-nullsafety.2/","dependencies":[]}],"web":[]},"dependencyGraph":[{"name":"device_info","dependencies":[]},{"name":"flutter_downloader","dependencies":[]},{"name":"flutter_inappwebview","dependencies":["device_info"]},{"name":"integration_test","dependencies":[]},{"name":"path_provider","dependencies":["path_provider_macos","path_provider_linux","path_provider_windows"]},{"name":"path_provider_linux","dependencies":[]},{"name":"path_provider_macos","dependencies":[]},{"name":"path_provider_windows","dependencies":[]},{"name":"permission_handler","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_linux","url_launcher_macos","url_launcher_windows"]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2021-02-22 23:52:14.900647","version":"1.27.0-5.0.pre.90"} \ No newline at end of file diff --git a/example/ios/Flutter/flutter_export_environment.sh b/example/ios/Flutter/flutter_export_environment.sh index b59a9d8e..ff2151af 100755 --- a/example/ios/Flutter/flutter_export_environment.sh +++ b/example/ios/Flutter/flutter_export_environment.sh @@ -2,12 +2,12 @@ # This is a generated file; do not edit or check into version control. export "FLUTTER_ROOT=/Users/lorenzopichilli/flutter" export "FLUTTER_APPLICATION_PATH=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example" -export "FLUTTER_TARGET=integration_test/webview_flutter_test.dart" +export "FLUTTER_TARGET=/Users/lorenzopichilli/Desktop/flutter_inappwebview/example/lib/main.dart" export "FLUTTER_BUILD_DIR=build" export "SYMROOT=${SOURCE_ROOT}/../build/ios" export "FLUTTER_BUILD_NAME=1.0.0" export "FLUTTER_BUILD_NUMBER=1" -export "DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" +export "DART_DEFINES=Zmx1dHRlci5pbnNwZWN0b3Iuc3RydWN0dXJlZEVycm9ycz10cnVl,RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ==" export "DART_OBFUSCATION=false" export "TRACK_WIDGET_CREATION=true" export "TREE_SHAKE_ICONS=false" diff --git a/flutter_inappwebview.iml b/flutter_inappwebview.iml index 4cb39159..0adae5aa 100755 --- a/flutter_inappwebview.iml +++ b/flutter_inappwebview.iml @@ -80,6 +80,5 @@ - \ No newline at end of file diff --git a/lib/flutter_inappwebview.dart b/lib/flutter_inappwebview.dart index aeef7034..5d49df01 100755 --- a/lib/flutter_inappwebview.dart +++ b/lib/flutter_inappwebview.dart @@ -21,4 +21,4 @@ library flutter_inappwebview; -export 'src/main.dart'; \ No newline at end of file +export 'src/main.dart'; diff --git a/lib/src/_uuid_generator.dart b/lib/src/_uuid_generator.dart index 9d603455..883d290c 100644 --- a/lib/src/_uuid_generator.dart +++ b/lib/src/_uuid_generator.dart @@ -1,3 +1,3 @@ import 'package:uuid/uuid.dart'; -final UUID_GENERATOR = Uuid(); \ No newline at end of file +final UUID_GENERATOR = Uuid(); diff --git a/lib/src/android/service_worker_controller.dart b/lib/src/android/service_worker_controller.dart index d4bfb7c0..2d364e45 100644 --- a/lib/src/android/service_worker_controller.dart +++ b/lib/src/android/service_worker_controller.dart @@ -27,17 +27,21 @@ class AndroidServiceWorkerController { } static Future _handleMethod(MethodCall call) async { - AndroidServiceWorkerController controller = AndroidServiceWorkerController.instance(); - AndroidServiceWorkerClient? serviceWorkerClient = controller.serviceWorkerClient; + AndroidServiceWorkerController controller = + AndroidServiceWorkerController.instance(); + AndroidServiceWorkerClient? serviceWorkerClient = + controller.serviceWorkerClient; switch (call.method) { case "shouldInterceptRequest": - if (serviceWorkerClient != null && serviceWorkerClient.shouldInterceptRequest != null) { - Map arguments = call.arguments.cast(); + if (serviceWorkerClient != null && + serviceWorkerClient.shouldInterceptRequest != null) { + Map arguments = + call.arguments.cast(); WebResourceRequest request = WebResourceRequest.fromMap(arguments)!; return (await serviceWorkerClient.shouldInterceptRequest!(request)) - ?.toMap(); + ?.toMap(); } break; default: @@ -88,7 +92,8 @@ class AndroidServiceWorkerController { ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getCacheMode() static Future getCacheMode() async { Map args = {}; - return AndroidCacheMode.fromValue(await _channel.invokeMethod('getCacheMode', args)); + return AndroidCacheMode.fromValue( + await _channel.invokeMethod('getCacheMode', args)); } ///Enables or disables content URL access from Service Workers. @@ -146,7 +151,6 @@ class AndroidServiceWorkerController { /// ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat class AndroidServiceWorkerClient { - ///Notify the host application of a resource request and allow the application to return the data. ///If the return value is `null`, the Service Worker will continue to load the resource as usual. ///Otherwise, the return response and data will be used. @@ -158,9 +162,7 @@ class AndroidServiceWorkerClient { /// ///**NOTE**: available on Android 24+. final Future Function(WebResourceRequest request)? - shouldInterceptRequest; + shouldInterceptRequest; - AndroidServiceWorkerClient({ - this.shouldInterceptRequest - }); -} \ No newline at end of file + AndroidServiceWorkerClient({this.shouldInterceptRequest}); +} diff --git a/lib/src/android/webview_feature.dart b/lib/src/android/webview_feature.dart index d30e7bf0..839547c2 100644 --- a/lib/src/android/webview_feature.dart +++ b/lib/src/android/webview_feature.dart @@ -59,8 +59,8 @@ class AndroidWebViewFeature { static AndroidWebViewFeature? fromValue(String? value) { if (value != null) { try { - return AndroidWebViewFeature.values.firstWhere( - (element) => element.toValue() == value); + return AndroidWebViewFeature.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -74,127 +74,174 @@ class AndroidWebViewFeature { String toString() => _value; /// - static const CREATE_WEB_MESSAGE_CHANNEL = const AndroidWebViewFeature._internal("CREATE_WEB_MESSAGE_CHANNEL"); + static const CREATE_WEB_MESSAGE_CHANNEL = + const AndroidWebViewFeature._internal("CREATE_WEB_MESSAGE_CHANNEL"); /// - static const DISABLED_ACTION_MODE_MENU_ITEMS = const AndroidWebViewFeature._internal("DISABLED_ACTION_MODE_MENU_ITEMS"); + static const DISABLED_ACTION_MODE_MENU_ITEMS = + const AndroidWebViewFeature._internal("DISABLED_ACTION_MODE_MENU_ITEMS"); /// static const FORCE_DARK = const AndroidWebViewFeature._internal("FORCE_DARK"); /// - static const FORCE_DARK_STRATEGY = const AndroidWebViewFeature._internal("FORCE_DARK_STRATEGY"); + static const FORCE_DARK_STRATEGY = + const AndroidWebViewFeature._internal("FORCE_DARK_STRATEGY"); /// - static const GET_WEB_CHROME_CLIENT = const AndroidWebViewFeature._internal("GET_WEB_CHROME_CLIENT"); + static const GET_WEB_CHROME_CLIENT = + const AndroidWebViewFeature._internal("GET_WEB_CHROME_CLIENT"); /// - static const GET_WEB_VIEW_CLIENT = const AndroidWebViewFeature._internal("GET_WEB_VIEW_CLIENT"); + static const GET_WEB_VIEW_CLIENT = + const AndroidWebViewFeature._internal("GET_WEB_VIEW_CLIENT"); /// - static const GET_WEB_VIEW_RENDERER = const AndroidWebViewFeature._internal("GET_WEB_VIEW_RENDERER"); + static const GET_WEB_VIEW_RENDERER = + const AndroidWebViewFeature._internal("GET_WEB_VIEW_RENDERER"); /// - static const MULTI_PROCESS = const AndroidWebViewFeature._internal("MULTI_PROCESS"); + static const MULTI_PROCESS = + const AndroidWebViewFeature._internal("MULTI_PROCESS"); /// - static const OFF_SCREEN_PRERASTER = const AndroidWebViewFeature._internal("OFF_SCREEN_PRERASTER"); + static const OFF_SCREEN_PRERASTER = + const AndroidWebViewFeature._internal("OFF_SCREEN_PRERASTER"); /// - static const POST_WEB_MESSAGE = const AndroidWebViewFeature._internal("POST_WEB_MESSAGE"); + static const POST_WEB_MESSAGE = + const AndroidWebViewFeature._internal("POST_WEB_MESSAGE"); /// - static const PROXY_OVERRIDE = const AndroidWebViewFeature._internal("PROXY_OVERRIDE"); + static const PROXY_OVERRIDE = + const AndroidWebViewFeature._internal("PROXY_OVERRIDE"); /// - static const RECEIVE_HTTP_ERROR = const AndroidWebViewFeature._internal("RECEIVE_HTTP_ERROR"); + static const RECEIVE_HTTP_ERROR = + const AndroidWebViewFeature._internal("RECEIVE_HTTP_ERROR"); /// - static const RECEIVE_WEB_RESOURCE_ERROR = const AndroidWebViewFeature._internal("RECEIVE_WEB_RESOURCE_ERROR"); + static const RECEIVE_WEB_RESOURCE_ERROR = + const AndroidWebViewFeature._internal("RECEIVE_WEB_RESOURCE_ERROR"); /// - static const SAFE_BROWSING_ALLOWLIST = const AndroidWebViewFeature._internal("SAFE_BROWSING_ALLOWLIST"); + static const SAFE_BROWSING_ALLOWLIST = + const AndroidWebViewFeature._internal("SAFE_BROWSING_ALLOWLIST"); /// - static const SAFE_BROWSING_ENABLE = const AndroidWebViewFeature._internal("SAFE_BROWSING_ENABLE"); + static const SAFE_BROWSING_ENABLE = + const AndroidWebViewFeature._internal("SAFE_BROWSING_ENABLE"); /// - static const SAFE_BROWSING_HIT = const AndroidWebViewFeature._internal("SAFE_BROWSING_HIT"); + static const SAFE_BROWSING_HIT = + const AndroidWebViewFeature._internal("SAFE_BROWSING_HIT"); /// - static const SAFE_BROWSING_PRIVACY_POLICY_URL = const AndroidWebViewFeature._internal("SAFE_BROWSING_PRIVACY_POLICY_URL"); + static const SAFE_BROWSING_PRIVACY_POLICY_URL = + const AndroidWebViewFeature._internal("SAFE_BROWSING_PRIVACY_POLICY_URL"); /// - static const SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY = const AndroidWebViewFeature._internal("SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY"); + static const SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY = + const AndroidWebViewFeature._internal( + "SAFE_BROWSING_RESPONSE_BACK_TO_SAFETY"); /// - static const SAFE_BROWSING_RESPONSE_PROCEED = const AndroidWebViewFeature._internal("SAFE_BROWSING_RESPONSE_PROCEED"); + static const SAFE_BROWSING_RESPONSE_PROCEED = + const AndroidWebViewFeature._internal("SAFE_BROWSING_RESPONSE_PROCEED"); /// - static const SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL = const AndroidWebViewFeature._internal("SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL"); + static const SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL = + const AndroidWebViewFeature._internal( + "SAFE_BROWSING_RESPONSE_SHOW_INTERSTITIAL"); /// - static const SAFE_BROWSING_WHITELIST = const AndroidWebViewFeature._internal("SAFE_BROWSING_WHITELIST"); + static const SAFE_BROWSING_WHITELIST = + const AndroidWebViewFeature._internal("SAFE_BROWSING_WHITELIST"); /// - static const SERVICE_WORKER_BASIC_USAGE = const AndroidWebViewFeature._internal("SERVICE_WORKER_BASIC_USAGE"); + static const SERVICE_WORKER_BASIC_USAGE = + const AndroidWebViewFeature._internal("SERVICE_WORKER_BASIC_USAGE"); /// - static const SERVICE_WORKER_BLOCK_NETWORK_LOADS = const AndroidWebViewFeature._internal("SERVICE_WORKER_BLOCK_NETWORK_LOADS"); + static const SERVICE_WORKER_BLOCK_NETWORK_LOADS = + const AndroidWebViewFeature._internal( + "SERVICE_WORKER_BLOCK_NETWORK_LOADS"); /// - static const SERVICE_WORKER_CACHE_MODE = const AndroidWebViewFeature._internal("SERVICE_WORKER_CACHE_MODE"); + static const SERVICE_WORKER_CACHE_MODE = + const AndroidWebViewFeature._internal("SERVICE_WORKER_CACHE_MODE"); /// - static const SERVICE_WORKER_CONTENT_ACCESS = const AndroidWebViewFeature._internal("SERVICE_WORKER_CONTENT_ACCESS"); + static const SERVICE_WORKER_CONTENT_ACCESS = + const AndroidWebViewFeature._internal("SERVICE_WORKER_CONTENT_ACCESS"); /// - static const SERVICE_WORKER_FILE_ACCESS = const AndroidWebViewFeature._internal("SERVICE_WORKER_FILE_ACCESS"); + static const SERVICE_WORKER_FILE_ACCESS = + const AndroidWebViewFeature._internal("SERVICE_WORKER_FILE_ACCESS"); /// - static const SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST = const AndroidWebViewFeature._internal("SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST"); + static const SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST = + const AndroidWebViewFeature._internal( + "SERVICE_WORKER_SHOULD_INTERCEPT_REQUEST"); /// - static const SHOULD_OVERRIDE_WITH_REDIRECTS = const AndroidWebViewFeature._internal("SHOULD_OVERRIDE_WITH_REDIRECTS"); + static const SHOULD_OVERRIDE_WITH_REDIRECTS = + const AndroidWebViewFeature._internal("SHOULD_OVERRIDE_WITH_REDIRECTS"); /// - static const START_SAFE_BROWSING = const AndroidWebViewFeature._internal("START_SAFE_BROWSING"); + static const START_SAFE_BROWSING = + const AndroidWebViewFeature._internal("START_SAFE_BROWSING"); /// - static const TRACING_CONTROLLER_BASIC_USAGE = const AndroidWebViewFeature._internal("TRACING_CONTROLLER_BASIC_USAGE"); + static const TRACING_CONTROLLER_BASIC_USAGE = + const AndroidWebViewFeature._internal("TRACING_CONTROLLER_BASIC_USAGE"); /// - static const VISUAL_STATE_CALLBACK = const AndroidWebViewFeature._internal("VISUAL_STATE_CALLBACK"); + static const VISUAL_STATE_CALLBACK = + const AndroidWebViewFeature._internal("VISUAL_STATE_CALLBACK"); /// - static const WEB_MESSAGE_CALLBACK_ON_MESSAGE = const AndroidWebViewFeature._internal("WEB_MESSAGE_CALLBACK_ON_MESSAGE"); + static const WEB_MESSAGE_CALLBACK_ON_MESSAGE = + const AndroidWebViewFeature._internal("WEB_MESSAGE_CALLBACK_ON_MESSAGE"); /// - static const WEB_MESSAGE_LISTENER = const AndroidWebViewFeature._internal("WEB_MESSAGE_LISTENER"); + static const WEB_MESSAGE_LISTENER = + const AndroidWebViewFeature._internal("WEB_MESSAGE_LISTENER"); /// - static const WEB_MESSAGE_PORT_CLOSE = const AndroidWebViewFeature._internal("WEB_MESSAGE_PORT_CLOSE"); + static const WEB_MESSAGE_PORT_CLOSE = + const AndroidWebViewFeature._internal("WEB_MESSAGE_PORT_CLOSE"); /// - static const WEB_MESSAGE_PORT_POST_MESSAGE = const AndroidWebViewFeature._internal("WEB_MESSAGE_PORT_POST_MESSAGE"); + static const WEB_MESSAGE_PORT_POST_MESSAGE = + const AndroidWebViewFeature._internal("WEB_MESSAGE_PORT_POST_MESSAGE"); /// - static const WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK = const AndroidWebViewFeature._internal("WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK"); + static const WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK = + const AndroidWebViewFeature._internal( + "WEB_MESSAGE_PORT_SET_MESSAGE_CALLBACK"); /// - static const WEB_RESOURCE_ERROR_GET_CODE = const AndroidWebViewFeature._internal("WEB_RESOURCE_ERROR_GET_CODE"); + static const WEB_RESOURCE_ERROR_GET_CODE = + const AndroidWebViewFeature._internal("WEB_RESOURCE_ERROR_GET_CODE"); /// - static const WEB_RESOURCE_ERROR_GET_DESCRIPTION = const AndroidWebViewFeature._internal("WEB_RESOURCE_ERROR_GET_DESCRIPTION"); + static const WEB_RESOURCE_ERROR_GET_DESCRIPTION = + const AndroidWebViewFeature._internal( + "WEB_RESOURCE_ERROR_GET_DESCRIPTION"); /// - static const WEB_RESOURCE_REQUEST_IS_REDIRECT = const AndroidWebViewFeature._internal("WEB_RESOURCE_REQUEST_IS_REDIRECT"); + static const WEB_RESOURCE_REQUEST_IS_REDIRECT = + const AndroidWebViewFeature._internal("WEB_RESOURCE_REQUEST_IS_REDIRECT"); /// - static const WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE = const AndroidWebViewFeature._internal("WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE"); + static const WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE = + const AndroidWebViewFeature._internal( + "WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE"); /// - static const WEB_VIEW_RENDERER_TERMINATE = const AndroidWebViewFeature._internal("WEB_VIEW_RENDERER_TERMINATE"); + static const WEB_VIEW_RENDERER_TERMINATE = + const AndroidWebViewFeature._internal("WEB_VIEW_RENDERER_TERMINATE"); bool operator ==(value) => value == _value; @@ -211,4 +258,4 @@ class AndroidWebViewFeature { args.putIfAbsent("feature", () => feature.toValue()); return await _channel.invokeMethod('isFeatureSupported', args); } -} \ No newline at end of file +} diff --git a/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart b/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart index 3350acf2..d6901bb8 100755 --- a/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart +++ b/lib/src/chrome_safari_browser/android/chrome_custom_tabs_options.dart @@ -62,7 +62,8 @@ class AndroidChromeCustomTabsOptions new AndroidChromeCustomTabsOptions(); options.addDefaultShareMenuItem = map["addDefaultShareMenuItem"]; options.showTitle = map["showTitle"]; - options.toolbarBackgroundColor = UtilColor.fromHex(map["toolbarBackgroundColor"]); + options.toolbarBackgroundColor = + UtilColor.fromHex(map["toolbarBackgroundColor"]); options.enableUrlBarHiding = map["enableUrlBarHiding"]; options.instantAppsEnabled = map["instantAppsEnabled"]; options.packageName = map["packageName"]; @@ -84,4 +85,4 @@ class AndroidChromeCustomTabsOptions AndroidChromeCustomTabsOptions copy() { return AndroidChromeCustomTabsOptions.fromMap(this.toMap()); } -} \ No newline at end of file +} diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser.dart b/lib/src/chrome_safari_browser/chrome_safari_browser.dart index 601b0550..b6fc4780 100755 --- a/lib/src/chrome_safari_browser/chrome_safari_browser.dart +++ b/lib/src/chrome_safari_browser/chrome_safari_browser.dart @@ -83,8 +83,7 @@ class ChromeSafariBrowser { /// ///[options]: Options for the [ChromeSafariBrowser]. Future open( - {required Uri url, - ChromeSafariBrowserClassOptions? options}) async { + {required Uri url, ChromeSafariBrowserClassOptions? options}) async { assert(url.toString().isNotEmpty); this.throwIsAlreadyOpened(message: 'Cannot open $url!'); diff --git a/lib/src/chrome_safari_browser/chrome_safari_browser_options.dart b/lib/src/chrome_safari_browser/chrome_safari_browser_options.dart index 8b8b91ca..ca432ec5 100755 --- a/lib/src/chrome_safari_browser/chrome_safari_browser_options.dart +++ b/lib/src/chrome_safari_browser/chrome_safari_browser_options.dart @@ -43,7 +43,8 @@ class ChromeSafariBrowserClassOptions { Map options = {}; if (defaultTargetPlatform == TargetPlatform.android) options.addAll(this.android?.toMap() ?? {}); - else if (defaultTargetPlatform == TargetPlatform.iOS) options.addAll(this.ios?.toMap() ?? {}); + else if (defaultTargetPlatform == TargetPlatform.iOS) + options.addAll(this.ios?.toMap() ?? {}); return options; } @@ -56,4 +57,4 @@ class ChromeSafariBrowserClassOptions { String toString() { return toMap().toString(); } -} \ No newline at end of file +} diff --git a/lib/src/chrome_safari_browser/ios/main.dart b/lib/src/chrome_safari_browser/ios/main.dart index 35573726..88c59931 100644 --- a/lib/src/chrome_safari_browser/ios/main.dart +++ b/lib/src/chrome_safari_browser/ios/main.dart @@ -1 +1 @@ -export 'safari_options.dart'; \ No newline at end of file +export 'safari_options.dart'; diff --git a/lib/src/chrome_safari_browser/ios/safari_options.dart b/lib/src/chrome_safari_browser/ios/safari_options.dart index 1eee87a9..b7a2c4a7 100755 --- a/lib/src/chrome_safari_browser/ios/safari_options.dart +++ b/lib/src/chrome_safari_browser/ios/safari_options.dart @@ -65,8 +65,10 @@ class IOSSafariOptions implements ChromeSafariBrowserOptions, IosOptions { options.barCollapsingEnabled = map["barCollapsingEnabled"]; options.dismissButtonStyle = IOSSafariDismissButtonStyle.fromValue(map["dismissButtonStyle"])!; - options.preferredBarTintColor = UtilColor.fromHex(map["preferredBarTintColor"]); - options.preferredControlTintColor = UtilColor.fromHex(map["preferredControlTintColor"]); + options.preferredBarTintColor = + UtilColor.fromHex(map["preferredBarTintColor"]); + options.preferredControlTintColor = + UtilColor.fromHex(map["preferredControlTintColor"]); options.presentationStyle = IOSUIModalPresentationStyle.fromValue(map["presentationStyle"])!; options.transitionStyle = diff --git a/lib/src/chrome_safari_browser/main.dart b/lib/src/chrome_safari_browser/main.dart index dfe4093e..1565ca1e 100644 --- a/lib/src/chrome_safari_browser/main.dart +++ b/lib/src/chrome_safari_browser/main.dart @@ -1,4 +1,4 @@ export 'chrome_safari_browser.dart'; export 'chrome_safari_browser_options.dart'; export 'android/main.dart'; -export 'ios/main.dart'; \ No newline at end of file +export 'ios/main.dart'; diff --git a/lib/src/context_menu.dart b/lib/src/context_menu.dart index aaadbfab..1ff12542 100644 --- a/lib/src/context_menu.dart +++ b/lib/src/context_menu.dart @@ -65,10 +65,7 @@ class ContextMenuItem { Function()? action; ContextMenuItem( - {this.androidId, - this.iosId, - required this.title, - this.action}); + {this.androidId, this.iosId, required this.title, this.action}); Map toMap() { return {"androidId": androidId, "iosId": iosId, "title": title}; diff --git a/lib/src/cookie_manager.dart b/lib/src/cookie_manager.dart index 98191480..9b8c0b40 100755 --- a/lib/src/cookie_manager.dart +++ b/lib/src/cookie_manager.dart @@ -76,9 +76,17 @@ class CookieManager { IosDeviceInfo iosInfo = await deviceInfo.iosInfo; var version = double.tryParse(iosInfo.systemVersion); if (version != null && version < 11.0) { - await _setCookieWithJavaScript(url: url, name: name, value: value, domain: domain, - path: path, expiresDate: expiresDate, maxAge: maxAge, isSecure: isSecure, - sameSite: sameSite, webViewController: iosBelow11WebViewController); + await _setCookieWithJavaScript( + url: url, + name: name, + value: value, + domain: domain, + path: path, + expiresDate: expiresDate, + maxAge: maxAge, + isSecure: isSecure, + sameSite: sameSite, + webViewController: iosBelow11WebViewController); return; } } @@ -100,35 +108,32 @@ class CookieManager { Future _setCookieWithJavaScript( {required Uri url, - required String name, - required String value, - required String domain, - String path = "/", - int? expiresDate, - int? maxAge, - bool? isSecure, - HTTPCookieSameSitePolicy? sameSite, - InAppWebViewController? webViewController}) async { - var cookieValue = name + "=" + value + "; Domain=" + domain + "; Path=" + path; + required String name, + required String value, + required String domain, + String path = "/", + int? expiresDate, + int? maxAge, + bool? isSecure, + HTTPCookieSameSitePolicy? sameSite, + InAppWebViewController? webViewController}) async { + var cookieValue = + name + "=" + value + "; Domain=" + domain + "; Path=" + path; if (expiresDate != null) cookieValue += "; Expires=" + _getCookieExpirationDate(expiresDate); - if (maxAge != null) - cookieValue += "; Max-Age=" + maxAge.toString(); + if (maxAge != null) cookieValue += "; Max-Age=" + maxAge.toString(); - if (isSecure != null && isSecure) - cookieValue += "; Secure"; + if (isSecure != null && isSecure) cookieValue += "; Secure"; - if (sameSite != null) - cookieValue += "; SameSite=" + sameSite.toValue(); + if (sameSite != null) cookieValue += "; SameSite=" + sameSite.toValue(); cookieValue += ";"; if (webViewController != null) { InAppWebViewGroupOptions? options = await webViewController.getOptions(); - if (options != null && - options.crossPlatform.javaScriptEnabled) { + if (options != null && options.crossPlatform.javaScriptEnabled) { await webViewController.evaluateJavascript( source: 'document.cookie="$cookieValue"'); return; @@ -158,7 +163,9 @@ class CookieManager { ///**NOTE for iOS below 11.0**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. ///If [iosBelow11WebViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] ///to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!). - Future> getCookies({required Uri url, InAppWebViewController? iosBelow11WebViewController}) async { + Future> getCookies( + {required Uri url, + InAppWebViewController? iosBelow11WebViewController}) async { assert(url.toString().isNotEmpty); if (Platform.isIOS) { @@ -166,7 +173,8 @@ class CookieManager { IosDeviceInfo iosInfo = await deviceInfo.iosInfo; var version = double.tryParse(iosInfo.systemVersion); if (version != null && version < 11.0) { - return await _getCookiesWithJavaScript(url: url, webViewController: iosBelow11WebViewController); + return await _getCookiesWithJavaScript( + url: url, webViewController: iosBelow11WebViewController); } } @@ -185,8 +193,7 @@ class CookieManager { expiresDate: cookieMap["expiresDate"], isSessionOnly: cookieMap["isSessionOnly"], domain: cookieMap["domain"], - sameSite: - HTTPCookieSameSitePolicy.fromValue(cookieMap["sameSite"]), + sameSite: HTTPCookieSameSitePolicy.fromValue(cookieMap["sameSite"]), isSecure: cookieMap["isSecure"], isHttpOnly: cookieMap["isHttpOnly"], path: cookieMap["path"])); @@ -194,24 +201,26 @@ class CookieManager { return cookies; } - Future> _getCookiesWithJavaScript({required Uri url, InAppWebViewController? webViewController}) async { + Future> _getCookiesWithJavaScript( + {required Uri url, InAppWebViewController? webViewController}) async { assert(url.toString().isNotEmpty); List cookies = []; if (webViewController != null) { InAppWebViewGroupOptions? options = await webViewController.getOptions(); - if (options != null && - options.crossPlatform.javaScriptEnabled) { - List documentCookies = (await webViewController.evaluateJavascript(source: 'document.cookie') as String) - .split(';').map((documentCookie) => documentCookie.trim()).toList(); + if (options != null && options.crossPlatform.javaScriptEnabled) { + List documentCookies = (await webViewController + .evaluateJavascript(source: 'document.cookie') as String) + .split(';') + .map((documentCookie) => documentCookie.trim()) + .toList(); documentCookies.forEach((documentCookie) { List cookie = documentCookie.split('='); cookies.add(Cookie( name: cookie[0], value: cookie[1], - ) - ); + )); }); return cookies; } @@ -227,15 +236,17 @@ class CookieManager { await headlessWebView.run(); await pageLoaded.future; - List documentCookies = (await headlessWebView.webViewController.evaluateJavascript(source: 'document.cookie') as String) - .split(';').map((documentCookie) => documentCookie.trim()).toList(); + List documentCookies = (await headlessWebView.webViewController + .evaluateJavascript(source: 'document.cookie') as String) + .split(';') + .map((documentCookie) => documentCookie.trim()) + .toList(); documentCookies.forEach((documentCookie) { List cookie = documentCookie.split('='); cookies.add(Cookie( name: cookie[0], value: cookie[1], - ) - ); + )); }); await headlessWebView.dispose(); return cookies; @@ -251,8 +262,9 @@ class CookieManager { ///If [iosBelow11WebViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] ///to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!). Future getCookie( - {required Uri url, required String name, InAppWebViewController? iosBelow11WebViewController}) async { - + {required Uri url, + required String name, + InAppWebViewController? iosBelow11WebViewController}) async { assert(url.toString().isNotEmpty); assert(name.isNotEmpty); @@ -261,8 +273,11 @@ class CookieManager { IosDeviceInfo iosInfo = await deviceInfo.iosInfo; var version = double.tryParse(iosInfo.systemVersion); if (version != null && version < 11.0) { - List cookies = await _getCookiesWithJavaScript(url: url, webViewController: iosBelow11WebViewController); - return cookies.cast().firstWhere((cookie) => cookie!.name == name, orElse: () => null); + List cookies = await _getCookiesWithJavaScript( + url: url, webViewController: iosBelow11WebViewController); + return cookies + .cast() + .firstWhere((cookie) => cookie!.name == name, orElse: () => null); } } @@ -315,7 +330,14 @@ class CookieManager { IosDeviceInfo iosInfo = await deviceInfo.iosInfo; var version = double.tryParse(iosInfo.systemVersion); if (version != null && version < 11.0) { - await _setCookieWithJavaScript(url: url, name: name, value: "", path: path, domain: domain, maxAge: -1, webViewController: iosBelow11WebViewController); + await _setCookieWithJavaScript( + url: url, + name: name, + value: "", + path: path, + domain: domain, + maxAge: -1, + webViewController: iosBelow11WebViewController); return; } } @@ -340,8 +362,10 @@ class CookieManager { ///**NOTE for iOS below 11.0**: If [iosBelow11WebViewController] is `null` or JavaScript is disabled for it, it will try to use a [HeadlessInAppWebView] ///to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). Future deleteCookies( - {required Uri url, String domain = "", String path = "/", - InAppWebViewController? iosBelow11WebViewController}) async { + {required Uri url, + String domain = "", + String path = "/", + InAppWebViewController? iosBelow11WebViewController}) async { if (domain.isEmpty) domain = _getDomainName(url); assert(url.toString().isNotEmpty); @@ -351,9 +375,17 @@ class CookieManager { IosDeviceInfo iosInfo = await deviceInfo.iosInfo; var version = double.tryParse(iosInfo.systemVersion); if (version != null && version < 11.0) { - List cookies = await _getCookiesWithJavaScript(url: url, webViewController: iosBelow11WebViewController); + List cookies = await _getCookiesWithJavaScript( + url: url, webViewController: iosBelow11WebViewController); for (var i = 0; i < cookies.length; i++) { - await _setCookieWithJavaScript(url: url, name: cookies[i].name, value: "", path: path, domain: domain, maxAge: -1, webViewController: iosBelow11WebViewController); + await _setCookieWithJavaScript( + url: url, + name: cookies[i].name, + value: "", + path: path, + domain: domain, + maxAge: -1, + webViewController: iosBelow11WebViewController); } return; } @@ -383,7 +415,8 @@ class CookieManager { String _getCookieExpirationDate(int expiresDate) { var dateTime = DateTime.fromMillisecondsSinceEpoch(expiresDate).toUtc(); - return DateFormat('EEE, d MMM yyyy hh:mm:ss', "en_US").format(dateTime) + ' GMT'; + return DateFormat('EEE, d MMM yyyy hh:mm:ss', "en_US").format(dateTime) + + ' GMT'; } } @@ -411,7 +444,7 @@ class IOSCookieManager { Map args = {}; List cookieListMap = - await CookieManager._channel.invokeMethod('getAllCookies', args); + await CookieManager._channel.invokeMethod('getAllCookies', args); cookieListMap = cookieListMap.cast>(); cookieListMap.forEach((cookieMap) { @@ -421,12 +454,11 @@ class IOSCookieManager { expiresDate: cookieMap["expiresDate"], isSessionOnly: cookieMap["isSessionOnly"], domain: cookieMap["domain"], - sameSite: - HTTPCookieSameSitePolicy.fromValue(cookieMap["sameSite"]), + sameSite: HTTPCookieSameSitePolicy.fromValue(cookieMap["sameSite"]), isSecure: cookieMap["isSecure"], isHttpOnly: cookieMap["isHttpOnly"], path: cookieMap["path"])); }); return cookies; } -} \ No newline at end of file +} diff --git a/lib/src/http_auth_credentials_database.dart b/lib/src/http_auth_credentials_database.dart index 7ae70e9b..24b34ce0 100755 --- a/lib/src/http_auth_credentials_database.dart +++ b/lib/src/http_auth_credentials_database.dart @@ -38,7 +38,8 @@ class HttpAuthCredentialDatabase { List result = []; for (Map map in allCredentials) { - var element = URLProtectionSpaceHttpAuthCredentials.fromMap(map.cast()); + var element = URLProtectionSpaceHttpAuthCredentials.fromMap( + map.cast()); if (element != null) { result.add(element); } diff --git a/lib/src/in_app_browser/android/in_app_browser_options.dart b/lib/src/in_app_browser/android/in_app_browser_options.dart index 9b2d090a..96cce075 100755 --- a/lib/src/in_app_browser/android/in_app_browser_options.dart +++ b/lib/src/in_app_browser/android/in_app_browser_options.dart @@ -50,4 +50,4 @@ class AndroidInAppBrowserOptions implements BrowserOptions, AndroidOptions { AndroidInAppBrowserOptions copy() { return AndroidInAppBrowserOptions.fromMap(this.toMap()); } -} \ No newline at end of file +} diff --git a/lib/src/in_app_browser/android/main.dart b/lib/src/in_app_browser/android/main.dart index de948df1..3e701957 100644 --- a/lib/src/in_app_browser/android/main.dart +++ b/lib/src/in_app_browser/android/main.dart @@ -1 +1 @@ -export 'in_app_browser_options.dart'; \ No newline at end of file +export 'in_app_browser_options.dart'; diff --git a/lib/src/in_app_browser/in_app_browser.dart b/lib/src/in_app_browser/in_app_browser.dart index da80519a..0c11961d 100755 --- a/lib/src/in_app_browser/in_app_browser.dart +++ b/lib/src/in_app_browser/in_app_browser.dart @@ -67,8 +67,8 @@ class InAppBrowser { MethodChannel('com.pichillilorenzo/flutter_inappbrowser_$uuid'); this._channel.setMethodCallHandler(handleMethod); _isOpened = false; - webViewController = - new InAppWebViewController.fromInAppBrowser(uuid, this._channel, this, this.initialUserScripts); + webViewController = new InAppWebViewController.fromInAppBrowser( + uuid, this._channel, this, this.initialUserScripts); } Future handleMethod(MethodCall call) async { @@ -100,10 +100,12 @@ class InAppBrowser { Map args = {}; args.putIfAbsent('uuid', () => uuid); args.putIfAbsent('urlRequest', () => urlRequest.toMap()); - args.putIfAbsent('options', () => options?.toMap() ?? InAppBrowserClassOptions().toMap()); + args.putIfAbsent('options', + () => options?.toMap() ?? InAppBrowserClassOptions().toMap()); args.putIfAbsent('contextMenu', () => contextMenu?.toMap() ?? {}); args.putIfAbsent('windowId', () => windowId); - args.putIfAbsent('initialUserScripts', () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); + args.putIfAbsent('initialUserScripts', + () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); await _sharedChannel.invokeMethod('openUrlRequest', args); } @@ -151,10 +153,12 @@ class InAppBrowser { Map args = {}; args.putIfAbsent('uuid', () => uuid); args.putIfAbsent('assetFilePath', () => assetFilePath); - args.putIfAbsent('options', () => options?.toMap() ?? InAppBrowserClassOptions().toMap()); + args.putIfAbsent('options', + () => options?.toMap() ?? InAppBrowserClassOptions().toMap()); args.putIfAbsent('contextMenu', () => contextMenu?.toMap() ?? {}); args.putIfAbsent('windowId', () => windowId); - args.putIfAbsent('initialUserScripts', () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); + args.putIfAbsent('initialUserScripts', + () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); await _sharedChannel.invokeMethod('openFile', args); } @@ -175,18 +179,21 @@ class InAppBrowser { Uri? androidHistoryUrl, InAppBrowserClassOptions? options}) async { this.throwIfAlreadyOpened(message: 'Cannot open data!'); - + Map args = {}; args.putIfAbsent('uuid', () => uuid); - args.putIfAbsent('options', () => options?.toMap() ?? InAppBrowserClassOptions().toMap()); + args.putIfAbsent('options', + () => options?.toMap() ?? InAppBrowserClassOptions().toMap()); args.putIfAbsent('data', () => data); args.putIfAbsent('mimeType', () => mimeType); args.putIfAbsent('encoding', () => encoding); args.putIfAbsent('baseUrl', () => baseUrl?.toString() ?? "about:blank"); - args.putIfAbsent('historyUrl', () => androidHistoryUrl?.toString() ?? "about:blank"); + args.putIfAbsent( + 'historyUrl', () => androidHistoryUrl?.toString() ?? "about:blank"); args.putIfAbsent('contextMenu', () => contextMenu?.toMap() ?? {}); args.putIfAbsent('windowId', () => windowId); - args.putIfAbsent('initialUserScripts', () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); + args.putIfAbsent('initialUserScripts', + () => initialUserScripts?.map((e) => e.toMap()).toList() ?? []); await _sharedChannel.invokeMethod('openData', args); } @@ -360,8 +367,7 @@ class InAppBrowser { ///[url] represents the url of the request. /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkurlschemehandler - Future? onLoadResourceCustomScheme( - Uri url) {} + Future? onLoadResourceCustomScheme(Uri url) {} ///Event fired when the [InAppBrowser] webview requests the host application to create a new window, ///for example when trying to open a link with `target="_blank"` or when `window.open()` is called by JavaScript side. @@ -518,7 +524,8 @@ class InAppBrowser { ///[fetchRequest] represents a resource request. /// ///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewOptions.useShouldInterceptFetchRequest] option to `true`. - Future? shouldInterceptFetchRequest(FetchRequest fetchRequest) {} + Future? shouldInterceptFetchRequest( + FetchRequest fetchRequest) {} ///Event fired when the host application updates its visited links database. ///This event is also fired when the navigation state of the [InAppWebView] changes through the usage of @@ -643,8 +650,8 @@ class InAppBrowser { ///**Official Android API**: ///- https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest) ///- https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20java.lang.String) - Future? - androidShouldInterceptRequest(WebResourceRequest request) {} + Future? androidShouldInterceptRequest( + WebResourceRequest request) {} ///Event called when the renderer currently associated with the WebView becomes unresponsive as a result of a long running blocking task such as the execution of JavaScript. /// @@ -664,8 +671,8 @@ class InAppBrowser { ///**NOTE**: available only on Android 29+. /// ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess) - Future? - androidOnRenderProcessUnresponsive(Uri? url) {} + Future? androidOnRenderProcessUnresponsive( + Uri? url) {} ///Event called once when an unresponsive renderer currently associated with the WebView becomes responsive. /// @@ -678,8 +685,8 @@ class InAppBrowser { ///**NOTE**: available only on Android 29+. /// ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess) - Future? - androidOnRenderProcessResponsive(Uri? url) {} + Future? androidOnRenderProcessResponsive( + Uri? url) {} ///Event fired when the given WebView's render process has exited. ///The application's implementation of this callback should only attempt to clean up the WebView. @@ -697,8 +704,7 @@ class InAppBrowser { ///**NOTE**: available only on Android. /// ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message) - Future? - androidOnFormResubmission(Uri? url) {} + Future? androidOnFormResubmission(Uri? url) {} ///Event fired when the scale applied to the WebView has changed. /// @@ -777,8 +783,8 @@ class InAppBrowser { ///**NOTE**: available only on iOS. /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview - Future? - iosOnNavigationResponse(IOSWKNavigationResponse navigationResponse) {} + Future? iosOnNavigationResponse( + IOSWKNavigationResponse navigationResponse) {} ///Called when a web view asks whether to continue with a connection that uses a deprecated version of TLS (v1.0 and v1.1). /// @@ -787,8 +793,8 @@ class InAppBrowser { ///**NOTE**: available only on iOS 14.0+. /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview - Future? - iosShouldAllowDeprecatedTLS(URLAuthenticationChallenge challenge) {} + Future? iosShouldAllowDeprecatedTLS( + URLAuthenticationChallenge challenge) {} void throwIfAlreadyOpened({String message = ''}) { if (this.isOpened()) { diff --git a/lib/src/in_app_browser/in_app_browser_options.dart b/lib/src/in_app_browser/in_app_browser_options.dart index 2d4d71c4..5a9f8790 100755 --- a/lib/src/in_app_browser/in_app_browser_options.dart +++ b/lib/src/in_app_browser/in_app_browser_options.dart @@ -35,7 +35,6 @@ class BrowserOptions { } } - ///Class that represents the options that can be used for an [InAppBrowser] WebView. class InAppBrowserClassOptions { ///Cross-platform options. @@ -52,9 +51,9 @@ class InAppBrowserClassOptions { InAppBrowserClassOptions( {InAppBrowserOptions? crossPlatform, - AndroidInAppBrowserOptions? android, - IOSInAppBrowserOptions? ios, - InAppWebViewGroupOptions? inAppWebViewGroupOptions}) { + AndroidInAppBrowserOptions? android, + IOSInAppBrowserOptions? ios, + InAppWebViewGroupOptions? inAppWebViewGroupOptions}) { this.crossPlatform = crossPlatform ?? InAppBrowserOptions(); this.android = android ?? AndroidInAppBrowserOptions(); this.ios = ios ?? IOSInAppBrowserOptions(); @@ -89,7 +88,7 @@ class InAppBrowserClassOptions { static InAppBrowserClassOptions fromMap(Map options) { InAppBrowserClassOptions inAppBrowserClassOptions = - InAppBrowserClassOptions(); + InAppBrowserClassOptions(); inAppBrowserClassOptions.crossPlatform = InAppBrowserOptions.fromMap(options); @@ -157,7 +156,8 @@ class InAppBrowserOptions InAppBrowserOptions options = InAppBrowserOptions(); options.hidden = map["hidden"]; options.hideToolbarTop = map["hideToolbarTop"]; - options.toolbarTopBackgroundColor = UtilColor.fromHex(map["toolbarTopBackgroundColor"]); + options.toolbarTopBackgroundColor = + UtilColor.fromHex(map["toolbarTopBackgroundColor"]); options.hideUrlBar = map["hideUrlBar"]; options.hideProgressBar = map["hideProgressBar"]; return options; diff --git a/lib/src/in_app_browser/ios/in_app_browser_options.dart b/lib/src/in_app_browser/ios/in_app_browser_options.dart index 08648bf9..e3b377a8 100755 --- a/lib/src/in_app_browser/ios/in_app_browser_options.dart +++ b/lib/src/in_app_browser/ios/in_app_browser_options.dart @@ -76,8 +76,10 @@ class IOSInAppBrowserOptions implements BrowserOptions, IosOptions { options.toolbarTopTranslucent = map["toolbarTopTranslucent"]; options.toolbarTopTintColor = UtilColor.fromHex(map["toolbarTopTintColor"]); options.hideToolbarBottom = map["hideToolbarBottom"]; - options.toolbarBottomBackgroundColor = UtilColor.fromHex(map["toolbarBottomBackgroundColor"]); - options.toolbarBottomTintColor = UtilColor.fromHex(map["toolbarBottomTintColor"]); + options.toolbarBottomBackgroundColor = + UtilColor.fromHex(map["toolbarBottomBackgroundColor"]); + options.toolbarBottomTintColor = + UtilColor.fromHex(map["toolbarBottomTintColor"]); options.toolbarBottomTranslucent = map["toolbarBottomTranslucent"]; options.closeButtonCaption = map["closeButtonCaption"]; options.closeButtonColor = UtilColor.fromHex(map["closeButtonColor"]); diff --git a/lib/src/in_app_browser/ios/main.dart b/lib/src/in_app_browser/ios/main.dart index de948df1..3e701957 100644 --- a/lib/src/in_app_browser/ios/main.dart +++ b/lib/src/in_app_browser/ios/main.dart @@ -1 +1 @@ -export 'in_app_browser_options.dart'; \ No newline at end of file +export 'in_app_browser_options.dart'; diff --git a/lib/src/in_app_browser/main.dart b/lib/src/in_app_browser/main.dart index 96ec1eee..8d2c6b77 100644 --- a/lib/src/in_app_browser/main.dart +++ b/lib/src/in_app_browser/main.dart @@ -1,4 +1,4 @@ export 'in_app_browser.dart'; export 'in_app_browser_options.dart'; export 'android/main.dart'; -export 'ios/main.dart'; \ No newline at end of file +export 'ios/main.dart'; diff --git a/lib/src/in_app_webview/_static_channel.dart b/lib/src/in_app_webview/_static_channel.dart index eab9a19e..07f94bf3 100644 --- a/lib/src/in_app_webview/_static_channel.dart +++ b/lib/src/in_app_webview/_static_channel.dart @@ -1,3 +1,4 @@ import 'package:flutter/services.dart'; -const IN_APP_WEBVIEW_STATIC_CHANNEL = const MethodChannel('com.pichillilorenzo/flutter_inappwebview_static'); \ No newline at end of file +const IN_APP_WEBVIEW_STATIC_CHANNEL = + const MethodChannel('com.pichillilorenzo/flutter_inappwebview_static'); diff --git a/lib/src/in_app_webview/android/in_app_webview_controller.dart b/lib/src/in_app_webview/android/in_app_webview_controller.dart index 063974b7..b2411d98 100644 --- a/lib/src/in_app_webview/android/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/android/in_app_webview_controller.dart @@ -9,7 +9,6 @@ import '../../types.dart'; ///Class represents the Android controller that contains only android-specific methods for the WebView. class AndroidInAppWebViewController { - late MethodChannel _channel; static MethodChannel _staticChannel = IN_APP_WEBVIEW_STATIC_CHANNEL; @@ -130,8 +129,7 @@ class AndroidInAppWebViewController { ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#clearClientCertPreferences(java.lang.Runnable) static Future clearClientCertPreferences() async { Map args = {}; - await _staticChannel - .invokeMethod('clearClientCertPreferences', args); + await _staticChannel.invokeMethod('clearClientCertPreferences', args); } ///Returns a URL pointing to the privacy policy for Safe Browsing reporting. @@ -141,8 +139,8 @@ class AndroidInAppWebViewController { ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewCompat#getSafeBrowsingPrivacyPolicyUrl() static Future getSafeBrowsingPrivacyPolicyUrl() async { Map args = {}; - String? url = await _staticChannel - .invokeMethod('getSafeBrowsingPrivacyPolicyUrl', args); + String? url = await _staticChannel.invokeMethod( + 'getSafeBrowsingPrivacyPolicyUrl', args); return url != null ? Uri.parse(url) : null; } @@ -167,8 +165,7 @@ class AndroidInAppWebViewController { {required List hosts}) async { Map args = {}; args.putIfAbsent('hosts', () => hosts); - return await _staticChannel - .invokeMethod('setSafeBrowsingWhitelist', args); + return await _staticChannel.invokeMethod('setSafeBrowsingWhitelist', args); } ///If WebView has already been loaded into the current process this method will return the package that was used to load it. @@ -184,9 +181,9 @@ class AndroidInAppWebViewController { ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewCompat#getCurrentWebViewPackage(android.content.Context) static Future getCurrentWebViewPackage() async { Map args = {}; - Map? packageInfo = (await _staticChannel - .invokeMethod('getCurrentWebViewPackage', args)) - ?.cast(); + Map? packageInfo = + (await _staticChannel.invokeMethod('getCurrentWebViewPackage', args)) + ?.cast(); return AndroidWebViewPackageInfo.fromMap(packageInfo); } @@ -199,11 +196,11 @@ class AndroidInAppWebViewController { ///**NOTE**: available only on Android 19+. /// ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#setWebContentsDebuggingEnabled(boolean) - static Future setWebContentsDebuggingEnabled(bool debuggingEnabled) async { + static Future setWebContentsDebuggingEnabled( + bool debuggingEnabled) async { Map args = {}; args.putIfAbsent('debuggingEnabled', () => debuggingEnabled); - return await _staticChannel - .invokeMethod('setWebContentsDebuggingEnabled', args); + return await _staticChannel.invokeMethod( + 'setWebContentsDebuggingEnabled', args); } } - diff --git a/lib/src/in_app_webview/android/main.dart b/lib/src/in_app_webview/android/main.dart index 7725f881..1b928b50 100644 --- a/lib/src/in_app_webview/android/main.dart +++ b/lib/src/in_app_webview/android/main.dart @@ -1,2 +1,2 @@ export 'in_app_webview_options.dart'; -export 'in_app_webview_controller.dart'; \ No newline at end of file +export 'in_app_webview_controller.dart'; diff --git a/lib/src/in_app_webview/headless_in_app_webview.dart b/lib/src/in_app_webview/headless_in_app_webview.dart index 9b46ac26..3df7c02d 100644 --- a/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/lib/src/in_app_webview/headless_in_app_webview.dart @@ -113,13 +113,16 @@ class HeadlessInAppWebView implements WebView { args.putIfAbsent( 'params', () => { - 'initialUrlRequest': (this.initialUrlRequest ?? URLRequest(url: Uri.parse("about:blank"))).toMap(), + 'initialUrlRequest': (this.initialUrlRequest ?? + URLRequest(url: Uri.parse("about:blank"))) + .toMap(), 'initialFile': this.initialFile, 'initialData': this.initialData?.toMap(), 'initialOptions': this.initialOptions?.toMap() ?? {}, 'contextMenu': this.contextMenu?.toMap() ?? {}, 'windowId': this.windowId, - 'initialUserScripts': this.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], + 'initialUserScripts': + this.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], }); await _sharedChannel.invokeMethod('createHeadlessWebView', args); } @@ -151,8 +154,10 @@ class HeadlessInAppWebView implements WebView { List resources)? androidOnPermissionRequest; @override - final Future Function(InAppWebViewController controller, - Uri url, SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit; + final Future Function( + InAppWebViewController controller, + Uri url, + SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit; @override final InAppWebViewInitialData? initialData; @@ -189,14 +194,14 @@ class HeadlessInAppWebView implements WebView { iosOnWebContentProcessDidTerminate; @override - final Future Function(InAppWebViewController controller, - IOSWKNavigationResponse navigationResponse)? - iosOnNavigationResponse; + final Future Function( + InAppWebViewController controller, + IOSWKNavigationResponse navigationResponse)? iosOnNavigationResponse; @override - final Future Function(InAppWebViewController controller, - URLAuthenticationChallenge challenge)? - iosShouldAllowDeprecatedTLS; + final Future Function( + InAppWebViewController controller, + URLAuthenticationChallenge challenge)? iosShouldAllowDeprecatedTLS; @override final Future Function( @@ -264,12 +269,10 @@ class HeadlessInAppWebView implements WebView { @override final Future Function( - InAppWebViewController controller, Uri url)? - onLoadResourceCustomScheme; + InAppWebViewController controller, Uri url)? onLoadResourceCustomScheme; @override - final void Function(InAppWebViewController controller, Uri? url)? - onLoadStart; + final void Function(InAppWebViewController controller, Uri? url)? onLoadStart; @override final void Function(InAppWebViewController controller, Uri? url)? onLoadStop; @@ -286,19 +289,17 @@ class HeadlessInAppWebView implements WebView { onProgressChanged; @override - final Future Function( - InAppWebViewController controller, URLAuthenticationChallenge challenge)? - onReceivedClientCertRequest; + final Future Function(InAppWebViewController controller, + URLAuthenticationChallenge challenge)? onReceivedClientCertRequest; @override - final Future Function( - InAppWebViewController controller, URLAuthenticationChallenge challenge)? - onReceivedHttpAuthRequest; + final Future Function(InAppWebViewController controller, + URLAuthenticationChallenge challenge)? onReceivedHttpAuthRequest; @override final Future Function( - InAppWebViewController controller, URLAuthenticationChallenge challenge)? - onReceivedServerTrustAuthRequest; + InAppWebViewController controller, + URLAuthenticationChallenge challenge)? onReceivedServerTrustAuthRequest; @override final void Function(InAppWebViewController controller, int x, int y)? diff --git a/lib/src/in_app_webview/in_app_webview.dart b/lib/src/in_app_webview/in_app_webview.dart index ad475e08..c6b0019e 100755 --- a/lib/src/in_app_webview/in_app_webview.dart +++ b/lib/src/in_app_webview/in_app_webview.dart @@ -113,8 +113,10 @@ class InAppWebView extends StatefulWidget implements WebView { List resources)? androidOnPermissionRequest; @override - final Future Function(InAppWebViewController controller, - Uri url, SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit; + final Future Function( + InAppWebViewController controller, + Uri url, + SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit; @override final InAppWebViewInitialData? initialData; @@ -151,14 +153,14 @@ class InAppWebView extends StatefulWidget implements WebView { iosOnWebContentProcessDidTerminate; @override - final Future Function(InAppWebViewController controller, - IOSWKNavigationResponse navigationResponse)? - iosOnNavigationResponse; + final Future Function( + InAppWebViewController controller, + IOSWKNavigationResponse navigationResponse)? iosOnNavigationResponse; @override - final Future Function(InAppWebViewController controller, - URLAuthenticationChallenge challenge)? - iosShouldAllowDeprecatedTLS; + final Future Function( + InAppWebViewController controller, + URLAuthenticationChallenge challenge)? iosShouldAllowDeprecatedTLS; @override final Future Function( @@ -235,12 +237,10 @@ class InAppWebView extends StatefulWidget implements WebView { @override final Future Function( - InAppWebViewController controller, Uri url)? - onLoadResourceCustomScheme; + InAppWebViewController controller, Uri url)? onLoadResourceCustomScheme; @override - final void Function(InAppWebViewController controller, Uri? url)? - onLoadStart; + final void Function(InAppWebViewController controller, Uri? url)? onLoadStart; @override final void Function(InAppWebViewController controller, Uri? url)? onLoadStop; @@ -257,19 +257,17 @@ class InAppWebView extends StatefulWidget implements WebView { onProgressChanged; @override - final Future Function( - InAppWebViewController controller, URLAuthenticationChallenge challenge)? - onReceivedClientCertRequest; + final Future Function(InAppWebViewController controller, + URLAuthenticationChallenge challenge)? onReceivedClientCertRequest; @override - final Future Function( - InAppWebViewController controller, URLAuthenticationChallenge challenge)? - onReceivedHttpAuthRequest; + final Future Function(InAppWebViewController controller, + URLAuthenticationChallenge challenge)? onReceivedHttpAuthRequest; @override final Future Function( - InAppWebViewController controller, URLAuthenticationChallenge challenge)? - onReceivedServerTrustAuthRequest; + InAppWebViewController controller, + URLAuthenticationChallenge challenge)? onReceivedServerTrustAuthRequest; @override final void Function(InAppWebViewController controller, int x, int y)? @@ -354,12 +352,13 @@ class _InAppWebViewState extends State { return PlatformViewLink( viewType: 'com.pichillilorenzo/flutter_inappwebview', surfaceFactory: ( - BuildContext context, - PlatformViewController controller, - ) { + BuildContext context, + PlatformViewController controller, + ) { return AndroidViewSurface( controller: controller as AndroidViewController, - gestureRecognizers: widget.gestureRecognizers ?? const >{}, + gestureRecognizers: widget.gestureRecognizers ?? + const >{}, hitTestBehavior: PlatformViewHitTestBehavior.opaque, ); }, @@ -369,18 +368,23 @@ class _InAppWebViewState extends State { viewType: 'com.pichillilorenzo/flutter_inappwebview', layoutDirection: TextDirection.rtl, creationParams: { - 'initialUrlRequest': (widget.initialUrlRequest ?? URLRequest(url: Uri.parse("about:blank"))).toMap(), + 'initialUrlRequest': (widget.initialUrlRequest ?? + URLRequest(url: Uri.parse("about:blank"))) + .toMap(), 'initialFile': widget.initialFile, 'initialData': widget.initialData?.toMap(), 'initialOptions': widget.initialOptions?.toMap() ?? {}, 'contextMenu': widget.contextMenu?.toMap() ?? {}, 'windowId': widget.windowId, - 'initialUserScripts': widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], + 'initialUserScripts': + widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? + [], }, creationParamsCodec: const StandardMessageCodec(), ) ..addOnPlatformViewCreatedListener(params.onPlatformViewCreated) - ..addOnPlatformViewCreatedListener((id) => _onPlatformViewCreated(id)) + ..addOnPlatformViewCreatedListener( + (id) => _onPlatformViewCreated(id)) ..create(); }, ); @@ -391,13 +395,16 @@ class _InAppWebViewState extends State { gestureRecognizers: widget.gestureRecognizers, layoutDirection: TextDirection.rtl, creationParams: { - 'initialUrlRequest': (widget.initialUrlRequest ?? URLRequest(url: Uri.parse("about:blank"))).toMap(), + 'initialUrlRequest': (widget.initialUrlRequest ?? + URLRequest(url: Uri.parse("about:blank"))) + .toMap(), 'initialFile': widget.initialFile, 'initialData': widget.initialData?.toMap(), 'initialOptions': widget.initialOptions?.toMap() ?? {}, 'contextMenu': widget.contextMenu?.toMap() ?? {}, 'windowId': widget.windowId, - 'initialUserScripts': widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], + 'initialUserScripts': + widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], }, creationParamsCodec: const StandardMessageCodec(), ); @@ -408,13 +415,16 @@ class _InAppWebViewState extends State { onPlatformViewCreated: _onPlatformViewCreated, gestureRecognizers: widget.gestureRecognizers, creationParams: { - 'initialUrlRequest': (widget.initialUrlRequest ?? URLRequest(url: Uri.parse("about:blank"))).toMap(), + 'initialUrlRequest': (widget.initialUrlRequest ?? + URLRequest(url: Uri.parse("about:blank"))) + .toMap(), 'initialFile': widget.initialFile, 'initialData': widget.initialData?.toMap(), 'initialOptions': widget.initialOptions?.toMap() ?? {}, 'contextMenu': widget.contextMenu?.toMap() ?? {}, 'windowId': widget.windowId, - 'initialUserScripts': widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], + 'initialUserScripts': + widget.initialUserScripts?.map((e) => e.toMap()).toList() ?? [], }, creationParamsCodec: const StandardMessageCodec(), ); diff --git a/lib/src/in_app_webview/in_app_webview_controller.dart b/lib/src/in_app_webview/in_app_webview_controller.dart index 15c470ab..d3431261 100644 --- a/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/in_app_webview_controller.dart @@ -77,16 +77,21 @@ class InAppWebViewController { MethodChannel('com.pichillilorenzo/flutter_inappwebview_$id'); this._channel.setMethodCallHandler(handleMethod); this._webview = webview; - this._userScripts = List.from(webview.initialUserScripts ?? []); + this._userScripts = + List.from(webview.initialUserScripts ?? []); this._init(); } InAppWebViewController.fromInAppBrowser( - String uuid, MethodChannel channel, InAppBrowser inAppBrowser, UnmodifiableListView? initialUserScripts) { + String uuid, + MethodChannel channel, + InAppBrowser inAppBrowser, + UnmodifiableListView? initialUserScripts) { this._inAppBrowserUuid = uuid; this._channel = channel; this._inAppBrowser = inAppBrowser; - this._userScripts = List.from(initialUserScripts ?? []); + this._userScripts = + List.from(initialUserScripts ?? []); this._init(); } @@ -100,11 +105,14 @@ class InAppWebViewController { Future handleMethod(MethodCall call) async { switch (call.method) { case "onHeadlessWebViewCreated": - if (_webview != null && _webview is HeadlessInAppWebView && _webview!.onWebViewCreated != null) + if (_webview != null && + _webview is HeadlessInAppWebView && + _webview!.onWebViewCreated != null) _webview!.onWebViewCreated!(this); break; case "onLoadStart": - if ((_webview != null && _webview!.onLoadStart != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onLoadStart != null) || + _inAppBrowser != null) { String? url = call.arguments["url"]; Uri? uri = url != null ? Uri.parse(url) : null; if (_webview != null && _webview!.onLoadStart != null) @@ -114,7 +122,8 @@ class InAppWebViewController { } break; case "onLoadStop": - if ((_webview != null && _webview!.onLoadStop != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onLoadStop != null) || + _inAppBrowser != null) { String? url = call.arguments["url"]; Uri? uri = url != null ? Uri.parse(url) : null; if (_webview != null && _webview!.onLoadStop != null) @@ -124,7 +133,8 @@ class InAppWebViewController { } break; case "onLoadError": - if ((_webview != null && _webview!.onLoadError != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onLoadError != null) || + _inAppBrowser != null) { String? url = call.arguments["url"]; int code = call.arguments["code"]; String message = call.arguments["message"]; @@ -136,7 +146,8 @@ class InAppWebViewController { } break; case "onLoadHttpError": - if ((_webview != null && _webview!.onLoadHttpError != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onLoadHttpError != null) || + _inAppBrowser != null) { String? url = call.arguments["url"]; int statusCode = call.arguments["statusCode"]; String description = call.arguments["description"]; @@ -148,7 +159,8 @@ class InAppWebViewController { } break; case "onProgressChanged": - if ((_webview != null && _webview!.onProgressChanged != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onProgressChanged != null) || + _inAppBrowser != null) { int progress = call.arguments["progress"]; if (_webview != null && _webview!.onProgressChanged != null) _webview!.onProgressChanged!(this, progress); @@ -157,22 +169,27 @@ class InAppWebViewController { } break; case "shouldOverrideUrlLoading": - if ((_webview != null && _webview!.shouldOverrideUrlLoading != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - NavigationAction navigationAction = NavigationAction.fromMap(arguments)!; + if ((_webview != null && _webview!.shouldOverrideUrlLoading != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + NavigationAction navigationAction = + NavigationAction.fromMap(arguments)!; if (_webview != null && _webview!.shouldOverrideUrlLoading != null) return (await _webview!.shouldOverrideUrlLoading!( - this, navigationAction)) + this, navigationAction)) ?.toMap(); return (await _inAppBrowser! - .shouldOverrideUrlLoading(navigationAction)) + .shouldOverrideUrlLoading(navigationAction)) ?.toMap(); } break; case "onConsoleMessage": - if ((_webview != null && _webview!.onConsoleMessage != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); + if ((_webview != null && _webview!.onConsoleMessage != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); ConsoleMessage consoleMessage = ConsoleMessage.fromMap(arguments)!; if (_webview != null && _webview!.onConsoleMessage != null) _webview!.onConsoleMessage!(this, consoleMessage); @@ -181,7 +198,8 @@ class InAppWebViewController { } break; case "onScrollChanged": - if ((_webview != null && _webview!.onScrollChanged != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onScrollChanged != null) || + _inAppBrowser != null) { int x = call.arguments["x"]; int y = call.arguments["y"]; if (_webview != null && _webview!.onScrollChanged != null) @@ -191,7 +209,8 @@ class InAppWebViewController { } break; case "onDownloadStart": - if ((_webview != null && _webview!.onDownloadStart != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onDownloadStart != null) || + _inAppBrowser != null) { String url = call.arguments["url"]; Uri uri = Uri.parse(url); if (_webview != null && _webview!.onDownloadStart != null) @@ -201,19 +220,26 @@ class InAppWebViewController { } break; case "onLoadResourceCustomScheme": - if ((_webview != null && _webview!.onLoadResourceCustomScheme != null) || _inAppBrowser != null) { + if ((_webview != null && + _webview!.onLoadResourceCustomScheme != null) || + _inAppBrowser != null) { String url = call.arguments["url"]; Uri uri = Uri.parse(url); if (_webview != null && _webview!.onLoadResourceCustomScheme != null) - return (await _webview!.onLoadResourceCustomScheme!(this, uri))?.toMap(); + return (await _webview!.onLoadResourceCustomScheme!(this, uri)) + ?.toMap(); else - return (await _inAppBrowser!.onLoadResourceCustomScheme(uri))?.toMap(); + return (await _inAppBrowser!.onLoadResourceCustomScheme(uri)) + ?.toMap(); } break; case "onCreateWindow": - if ((_webview != null && _webview!.onCreateWindow != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - CreateWindowAction createWindowAction = CreateWindowAction.fromMap(arguments)!; + if ((_webview != null && _webview!.onCreateWindow != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + CreateWindowAction createWindowAction = + CreateWindowAction.fromMap(arguments)!; if (_webview != null && _webview!.onCreateWindow != null) return await _webview!.onCreateWindow!(this, createWindowAction); @@ -227,7 +253,8 @@ class InAppWebViewController { else if (_inAppBrowser != null) _inAppBrowser!.onCloseWindow(); break; case "onTitleChanged": - if ((_webview != null && _webview!.onTitleChanged != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onTitleChanged != null) || + _inAppBrowser != null) { String? title = call.arguments["title"]; if (_webview != null && _webview!.onTitleChanged != null) _webview!.onTitleChanged!(this, title); @@ -236,31 +263,40 @@ class InAppWebViewController { } break; case "onGeolocationPermissionsShowPrompt": - if ((_webview != null && _webview!.androidOnGeolocationPermissionsShowPrompt != null) || _inAppBrowser != null) { + if ((_webview != null && + _webview!.androidOnGeolocationPermissionsShowPrompt != null) || + _inAppBrowser != null) { String origin = call.arguments["origin"]; - if (_webview != null && _webview!.androidOnGeolocationPermissionsShowPrompt != null) + if (_webview != null && + _webview!.androidOnGeolocationPermissionsShowPrompt != null) return (await _webview!.androidOnGeolocationPermissionsShowPrompt!( - this, origin)) + this, origin)) ?.toMap(); else return (await _inAppBrowser! - .androidOnGeolocationPermissionsShowPrompt(origin)) + .androidOnGeolocationPermissionsShowPrompt(origin)) ?.toMap(); } break; case "onGeolocationPermissionsHidePrompt": - if (_webview != null && _webview!.androidOnGeolocationPermissionsHidePrompt != null) + if (_webview != null && + _webview!.androidOnGeolocationPermissionsHidePrompt != null) _webview!.androidOnGeolocationPermissionsHidePrompt!(this); else if (_inAppBrowser != null) _inAppBrowser!.androidOnGeolocationPermissionsHidePrompt(); break; case "shouldInterceptRequest": - if ((_webview != null && _webview!.androidShouldInterceptRequest != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); + if ((_webview != null && + _webview!.androidShouldInterceptRequest != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); WebResourceRequest request = WebResourceRequest.fromMap(arguments)!; - if (_webview != null && _webview!.androidShouldInterceptRequest != null) - return (await _webview!.androidShouldInterceptRequest!(this, request)) + if (_webview != null && + _webview!.androidShouldInterceptRequest != null) + return (await _webview!.androidShouldInterceptRequest!( + this, request)) ?.toMap(); else return (await _inAppBrowser!.androidShouldInterceptRequest(request)) @@ -268,23 +304,32 @@ class InAppWebViewController { } break; case "onRenderProcessUnresponsive": - if ((_webview != null && _webview!.androidOnRenderProcessUnresponsive != null) || _inAppBrowser != null) { + if ((_webview != null && + _webview!.androidOnRenderProcessUnresponsive != null) || + _inAppBrowser != null) { String? url = call.arguments["url"]; Uri? uri = url != null ? Uri.parse(url) : null; - if (_webview != null && _webview!.androidOnRenderProcessUnresponsive != null) - return (await _webview!.androidOnRenderProcessUnresponsive!(this, uri)) + if (_webview != null && + _webview!.androidOnRenderProcessUnresponsive != null) + return (await _webview!.androidOnRenderProcessUnresponsive!( + this, uri)) ?.toMap(); else - return (await _inAppBrowser!.androidOnRenderProcessUnresponsive(uri)) + return (await _inAppBrowser! + .androidOnRenderProcessUnresponsive(uri)) ?.toMap(); } - break; + break; case "onRenderProcessResponsive": - if ((_webview != null && _webview!.androidOnRenderProcessResponsive != null) || _inAppBrowser != null) { + if ((_webview != null && + _webview!.androidOnRenderProcessResponsive != null) || + _inAppBrowser != null) { String? url = call.arguments["url"]; Uri? uri = url != null ? Uri.parse(url) : null; - if (_webview != null && _webview!.androidOnRenderProcessResponsive != null) - return (await _webview!.androidOnRenderProcessResponsive!(this, uri)) + if (_webview != null && + _webview!.androidOnRenderProcessResponsive != null) + return (await _webview!.androidOnRenderProcessResponsive!( + this, uri)) ?.toMap(); else return (await _inAppBrowser!.androidOnRenderProcessResponsive(uri)) @@ -292,9 +337,13 @@ class InAppWebViewController { } break; case "onRenderProcessGone": - if ((_webview != null && _webview!.androidOnRenderProcessGone != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - RenderProcessGoneDetail detail = RenderProcessGoneDetail.fromMap(arguments)!; + if ((_webview != null && + _webview!.androidOnRenderProcessGone != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + RenderProcessGoneDetail detail = + RenderProcessGoneDetail.fromMap(arguments)!; if (_webview != null && _webview!.androidOnRenderProcessGone != null) _webview!.androidOnRenderProcessGone!(this, detail); @@ -303,17 +352,21 @@ class InAppWebViewController { } break; case "onFormResubmission": - if ((_webview != null && _webview!.androidOnFormResubmission != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.androidOnFormResubmission != null) || + _inAppBrowser != null) { String? url = call.arguments["url"]; Uri? uri = url != null ? Uri.parse(url) : null; if (_webview != null && _webview!.androidOnFormResubmission != null) - return (await _webview!.androidOnFormResubmission!(this, uri))?.toMap(); + return (await _webview!.androidOnFormResubmission!(this, uri)) + ?.toMap(); else - return (await _inAppBrowser!.androidOnFormResubmission(uri))?.toMap(); + return (await _inAppBrowser!.androidOnFormResubmission(uri)) + ?.toMap(); } break; case "onScaleChanged": - if ((_webview != null && _webview!.androidOnScaleChanged != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.androidOnScaleChanged != null) || + _inAppBrowser != null) { double oldScale = call.arguments["oldScale"]; double newScale = call.arguments["newScale"]; if (_webview != null && _webview!.androidOnScaleChanged != null) @@ -323,8 +376,10 @@ class InAppWebViewController { } break; case "onReceivedIcon": - if ((_webview != null && _webview!.androidOnReceivedIcon != null) || _inAppBrowser != null) { - Uint8List icon = Uint8List.fromList(call.arguments["icon"].cast()); + if ((_webview != null && _webview!.androidOnReceivedIcon != null) || + _inAppBrowser != null) { + Uint8List icon = + Uint8List.fromList(call.arguments["icon"].cast()); if (_webview != null && _webview!.androidOnReceivedIcon != null) _webview!.androidOnReceivedIcon!(this, icon); @@ -333,19 +388,24 @@ class InAppWebViewController { } break; case "onReceivedTouchIconUrl": - if ((_webview != null && _webview!.androidOnReceivedTouchIconUrl != null) || _inAppBrowser != null) { + if ((_webview != null && + _webview!.androidOnReceivedTouchIconUrl != null) || + _inAppBrowser != null) { String url = call.arguments["url"]; bool precomposed = call.arguments["precomposed"]; Uri uri = Uri.parse(url); - if (_webview != null && _webview!.androidOnReceivedTouchIconUrl != null) + if (_webview != null && + _webview!.androidOnReceivedTouchIconUrl != null) _webview!.androidOnReceivedTouchIconUrl!(this, uri, precomposed); else _inAppBrowser!.androidOnReceivedTouchIconUrl(uri, precomposed); } break; case "onJsAlert": - if ((_webview != null && _webview!.onJsAlert != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); + if ((_webview != null && _webview!.onJsAlert != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); JsAlertRequest jsAlertRequest = JsAlertRequest.fromMap(arguments)!; if (_webview != null && _webview!.onJsAlert != null) @@ -355,72 +415,92 @@ class InAppWebViewController { } break; case "onJsConfirm": - if ((_webview != null && _webview!.onJsConfirm != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - JsConfirmRequest jsConfirmRequest = JsConfirmRequest.fromMap(arguments)!; + if ((_webview != null && _webview!.onJsConfirm != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + JsConfirmRequest jsConfirmRequest = + JsConfirmRequest.fromMap(arguments)!; if (_webview != null && _webview!.onJsConfirm != null) - return (await _webview!.onJsConfirm!(this, jsConfirmRequest))?.toMap(); + return (await _webview!.onJsConfirm!(this, jsConfirmRequest)) + ?.toMap(); else - return (await _inAppBrowser!.onJsConfirm(jsConfirmRequest))?.toMap(); + return (await _inAppBrowser!.onJsConfirm(jsConfirmRequest)) + ?.toMap(); } break; case "onJsPrompt": - if ((_webview != null && _webview!.onJsPrompt != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); + if ((_webview != null && _webview!.onJsPrompt != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); JsPromptRequest jsPromptRequest = JsPromptRequest.fromMap(arguments)!; if (_webview != null && _webview!.onJsPrompt != null) - return (await _webview!.onJsPrompt!(this, jsPromptRequest))?.toMap(); + return (await _webview!.onJsPrompt!(this, jsPromptRequest)) + ?.toMap(); else return (await _inAppBrowser!.onJsPrompt(jsPromptRequest))?.toMap(); } break; case "onJsBeforeUnload": - if ((_webview != null && _webview!.androidOnJsBeforeUnload != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - JsBeforeUnloadRequest jsBeforeUnloadRequest = JsBeforeUnloadRequest.fromMap(arguments)!; + if ((_webview != null && _webview!.androidOnJsBeforeUnload != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + JsBeforeUnloadRequest jsBeforeUnloadRequest = + JsBeforeUnloadRequest.fromMap(arguments)!; if (_webview != null && _webview!.androidOnJsBeforeUnload != null) return (await _webview!.androidOnJsBeforeUnload!( - this, jsBeforeUnloadRequest)) + this, jsBeforeUnloadRequest)) ?.toMap(); else return (await _inAppBrowser! - .androidOnJsBeforeUnload(jsBeforeUnloadRequest)) + .androidOnJsBeforeUnload(jsBeforeUnloadRequest)) ?.toMap(); } break; case "onSafeBrowsingHit": - if ((_webview != null && _webview!.androidOnSafeBrowsingHit != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.androidOnSafeBrowsingHit != null) || + _inAppBrowser != null) { String url = call.arguments["url"]; SafeBrowsingThreat? threatType = - SafeBrowsingThreat.fromValue(call.arguments["threatType"]); + SafeBrowsingThreat.fromValue(call.arguments["threatType"]); Uri uri = Uri.parse(url); if (_webview != null && _webview!.androidOnSafeBrowsingHit != null) return (await _webview!.androidOnSafeBrowsingHit!( - this, uri, threatType)) + this, uri, threatType)) ?.toMap(); else - return (await _inAppBrowser!.androidOnSafeBrowsingHit(uri, threatType)) + return (await _inAppBrowser! + .androidOnSafeBrowsingHit(uri, threatType)) ?.toMap(); } break; case "onReceivedLoginRequest": - if ((_webview != null && _webview!.androidOnReceivedLoginRequest != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); + if ((_webview != null && + _webview!.androidOnReceivedLoginRequest != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); LoginRequest loginRequest = LoginRequest.fromMap(arguments)!; - if (_webview != null && _webview!.androidOnReceivedLoginRequest != null) + if (_webview != null && + _webview!.androidOnReceivedLoginRequest != null) _webview!.androidOnReceivedLoginRequest!(this, loginRequest); else _inAppBrowser!.androidOnReceivedLoginRequest(loginRequest); } break; case "onReceivedHttpAuthRequest": - if ((_webview != null && _webview!.onReceivedHttpAuthRequest != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - HttpAuthenticationChallenge challenge = HttpAuthenticationChallenge.fromMap(arguments)!; + if ((_webview != null && _webview!.onReceivedHttpAuthRequest != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + HttpAuthenticationChallenge challenge = + HttpAuthenticationChallenge.fromMap(arguments)!; if (_webview != null && _webview!.onReceivedHttpAuthRequest != null) return (await _webview!.onReceivedHttpAuthRequest!(this, challenge)) @@ -431,27 +511,37 @@ class InAppWebViewController { } break; case "onReceivedServerTrustAuthRequest": - if ((_webview != null && _webview!.onReceivedServerTrustAuthRequest != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - ServerTrustChallenge challenge = ServerTrustChallenge.fromMap(arguments)!; + if ((_webview != null && + _webview!.onReceivedServerTrustAuthRequest != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + ServerTrustChallenge challenge = + ServerTrustChallenge.fromMap(arguments)!; - if (_webview != null && _webview!.onReceivedServerTrustAuthRequest != null) + if (_webview != null && + _webview!.onReceivedServerTrustAuthRequest != null) return (await _webview!.onReceivedServerTrustAuthRequest!( - this, challenge)) + this, challenge)) ?.toMap(); else return (await _inAppBrowser! - .onReceivedServerTrustAuthRequest(challenge)) + .onReceivedServerTrustAuthRequest(challenge)) ?.toMap(); } break; case "onReceivedClientCertRequest": - if ((_webview != null && _webview!.onReceivedClientCertRequest != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - ClientCertChallenge challenge = ClientCertChallenge.fromMap(arguments)!; + if ((_webview != null && + _webview!.onReceivedClientCertRequest != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + ClientCertChallenge challenge = + ClientCertChallenge.fromMap(arguments)!; if (_webview != null && _webview!.onReceivedClientCertRequest != null) - return (await _webview!.onReceivedClientCertRequest!(this, challenge)) + return (await _webview!.onReceivedClientCertRequest!( + this, challenge)) ?.toMap(); else return (await _inAppBrowser!.onReceivedClientCertRequest(challenge)) @@ -459,7 +549,8 @@ class InAppWebViewController { } break; case "onFindResultReceived": - if ((_webview != null && _webview!.onFindResultReceived != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onFindResultReceived != null) || + _inAppBrowser != null) { int activeMatchOrdinal = call.arguments["activeMatchOrdinal"]; int numberOfMatches = call.arguments["numberOfMatches"]; bool isDoneCounting = call.arguments["isDoneCounting"]; @@ -472,21 +563,24 @@ class InAppWebViewController { } break; case "onPermissionRequest": - if ((_webview != null && _webview!.androidOnPermissionRequest != null) || _inAppBrowser != null) { + if ((_webview != null && + _webview!.androidOnPermissionRequest != null) || + _inAppBrowser != null) { String origin = call.arguments["origin"]; List resources = call.arguments["resources"].cast(); if (_webview != null && _webview!.androidOnPermissionRequest != null) return (await _webview!.androidOnPermissionRequest!( - this, origin, resources)) + this, origin, resources)) ?.toMap(); else - return (await _inAppBrowser!.androidOnPermissionRequest( - origin, resources)) + return (await _inAppBrowser! + .androidOnPermissionRequest(origin, resources)) ?.toMap(); } break; case "onUpdateVisitedHistory": - if ((_webview != null && _webview!.onUpdateVisitedHistory != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onUpdateVisitedHistory != null) || + _inAppBrowser != null) { String? url = call.arguments["url"]; bool? androidIsReload = call.arguments["androidIsReload"]; Uri? uri = url != null ? Uri.parse(url) : null; @@ -504,7 +598,8 @@ class InAppWebViewController { _inAppBrowser!.iosOnWebContentProcessDidTerminate(); break; case "onPageCommitVisible": - if ((_webview != null && _webview!.onPageCommitVisible != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onPageCommitVisible != null) || + _inAppBrowser != null) { String? url = call.arguments["url"]; Uri? uri = url != null ? Uri.parse(url) : null; if (_webview != null && _webview!.onPageCommitVisible != null) @@ -517,44 +612,55 @@ class InAppWebViewController { if (_webview != null && _webview!.iosOnDidReceiveServerRedirectForProvisionalNavigation != null) - _webview!.iosOnDidReceiveServerRedirectForProvisionalNavigation!(this); + _webview! + .iosOnDidReceiveServerRedirectForProvisionalNavigation!(this); else if (_inAppBrowser != null) - _inAppBrowser!.iosOnDidReceiveServerRedirectForProvisionalNavigation(); + _inAppBrowser! + .iosOnDidReceiveServerRedirectForProvisionalNavigation(); break; case "onNavigationResponse": - if ((_webview != null && _webview!.iosOnNavigationResponse != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - IOSWKNavigationResponse iosOnNavigationResponse = IOSWKNavigationResponse.fromMap(arguments)!; + if ((_webview != null && _webview!.iosOnNavigationResponse != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + IOSWKNavigationResponse iosOnNavigationResponse = + IOSWKNavigationResponse.fromMap(arguments)!; if (_webview != null && _webview!.iosOnNavigationResponse != null) return (await _webview!.iosOnNavigationResponse!( - this, iosOnNavigationResponse)) + this, iosOnNavigationResponse)) ?.toMap(); else return (await _inAppBrowser! - .iosOnNavigationResponse(iosOnNavigationResponse)) + .iosOnNavigationResponse(iosOnNavigationResponse)) ?.toMap(); } break; case "shouldAllowDeprecatedTLS": - if ((_webview != null && _webview!.iosShouldAllowDeprecatedTLS != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - URLAuthenticationChallenge challenge = URLAuthenticationChallenge.fromMap(arguments)!; + if ((_webview != null && + _webview!.iosShouldAllowDeprecatedTLS != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + URLAuthenticationChallenge challenge = + URLAuthenticationChallenge.fromMap(arguments)!; if (_webview != null && _webview!.iosShouldAllowDeprecatedTLS != null) return (await _webview!.iosShouldAllowDeprecatedTLS!( - this, challenge)) + this, challenge)) ?.toMap(); else - return (await _inAppBrowser! - .iosShouldAllowDeprecatedTLS(challenge)) + return (await _inAppBrowser!.iosShouldAllowDeprecatedTLS(challenge)) ?.toMap(); } break; case "onLongPressHitTestResult": - if ((_webview != null && _webview!.onLongPressHitTestResult != null) || _inAppBrowser != null) { - Map arguments = call.arguments.cast(); - InAppWebViewHitTestResult hitTestResult = InAppWebViewHitTestResult.fromMap(arguments)!; + if ((_webview != null && _webview!.onLongPressHitTestResult != null) || + _inAppBrowser != null) { + Map arguments = + call.arguments.cast(); + InAppWebViewHitTestResult hitTestResult = + InAppWebViewHitTestResult.fromMap(arguments)!; if (_webview != null && _webview!.onLongPressHitTestResult != null) _webview!.onLongPressHitTestResult!(this, hitTestResult); @@ -566,13 +672,16 @@ class InAppWebViewController { ContextMenu? contextMenu; if (_webview != null && _webview!.contextMenu != null) { contextMenu = _webview!.contextMenu; - } else if (_inAppBrowser != null && _inAppBrowser!.contextMenu != null) { + } else if (_inAppBrowser != null && + _inAppBrowser!.contextMenu != null) { contextMenu = _inAppBrowser!.contextMenu; } if (contextMenu != null && contextMenu.onCreateContextMenu != null) { - Map arguments = call.arguments.cast(); - InAppWebViewHitTestResult hitTestResult = InAppWebViewHitTestResult.fromMap(arguments)!; + Map arguments = + call.arguments.cast(); + InAppWebViewHitTestResult hitTestResult = + InAppWebViewHitTestResult.fromMap(arguments)!; contextMenu.onCreateContextMenu!(hitTestResult); } @@ -581,7 +690,8 @@ class InAppWebViewController { ContextMenu? contextMenu; if (_webview != null && _webview!.contextMenu != null) { contextMenu = _webview!.contextMenu; - } else if (_inAppBrowser != null && _inAppBrowser!.contextMenu != null) { + } else if (_inAppBrowser != null && + _inAppBrowser!.contextMenu != null) { contextMenu = _inAppBrowser!.contextMenu; } @@ -593,7 +703,8 @@ class InAppWebViewController { ContextMenu? contextMenu; if (_webview != null && _webview!.contextMenu != null) { contextMenu = _webview!.contextMenu; - } else if (_inAppBrowser != null && _inAppBrowser!.contextMenu != null) { + } else if (_inAppBrowser != null && + _inAppBrowser!.contextMenu != null) { contextMenu = _inAppBrowser!.contextMenu; } @@ -606,8 +717,10 @@ class InAppWebViewController { androidId: androidId, iosId: iosId, title: title, action: null); for (var menuItem in contextMenu.menuItems) { - if ((defaultTargetPlatform == TargetPlatform.android && menuItem.androidId == androidId) || - (defaultTargetPlatform == TargetPlatform.iOS && menuItem.iosId == iosId)) { + if ((defaultTargetPlatform == TargetPlatform.android && + menuItem.androidId == androidId) || + (defaultTargetPlatform == TargetPlatform.iOS && + menuItem.iosId == iosId)) { menuItemClicked = menuItem; if (menuItem.action != null) { menuItem.action!(); @@ -638,7 +751,8 @@ class InAppWebViewController { switch (handlerName) { case "onLoadResource": - if ((_webview != null && _webview!.onLoadResource != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onLoadResource != null) || + _inAppBrowser != null) { Map arguments = args[0].cast(); arguments["startTime"] = arguments["startTime"] is int ? arguments["startTime"].toDouble() @@ -656,11 +770,14 @@ class InAppWebViewController { } return null; case "shouldInterceptAjaxRequest": - if ((_webview != null && _webview!.shouldInterceptAjaxRequest != null) || _inAppBrowser != null) { + if ((_webview != null && + _webview!.shouldInterceptAjaxRequest != null) || + _inAppBrowser != null) { Map arguments = args[0].cast(); AjaxRequest request = AjaxRequest.fromMap(arguments)!; - if (_webview != null && _webview!.shouldInterceptAjaxRequest != null) + if (_webview != null && + _webview!.shouldInterceptAjaxRequest != null) return jsonEncode( await _webview!.shouldInterceptAjaxRequest!(this, request)); else @@ -669,7 +786,9 @@ class InAppWebViewController { } return null; case "onAjaxReadyStateChange": - if ((_webview != null && _webview!.onAjaxReadyStateChange != null) || _inAppBrowser != null) { + if ((_webview != null && + _webview!.onAjaxReadyStateChange != null) || + _inAppBrowser != null) { Map arguments = args[0].cast(); AjaxRequest request = AjaxRequest.fromMap(arguments)!; @@ -682,31 +801,37 @@ class InAppWebViewController { } return null; case "onAjaxProgress": - if ((_webview != null && _webview!.onAjaxProgress != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onAjaxProgress != null) || + _inAppBrowser != null) { Map arguments = args[0].cast(); AjaxRequest request = AjaxRequest.fromMap(arguments)!; if (_webview != null && _webview!.onAjaxProgress != null) - return jsonEncode(await _webview!.onAjaxProgress!(this, request)); + return jsonEncode( + await _webview!.onAjaxProgress!(this, request)); else return jsonEncode(await _inAppBrowser!.onAjaxProgress(request)); } return null; case "shouldInterceptFetchRequest": - if ((_webview != null && _webview!.shouldInterceptFetchRequest != null) || _inAppBrowser != null) { + if ((_webview != null && + _webview!.shouldInterceptFetchRequest != null) || + _inAppBrowser != null) { Map arguments = args[0].cast(); FetchRequest request = FetchRequest.fromMap(arguments)!; - if (_webview != null && _webview!.shouldInterceptFetchRequest != null) - return jsonEncode( - await _webview!.shouldInterceptFetchRequest!(this, request)); + if (_webview != null && + _webview!.shouldInterceptFetchRequest != null) + return jsonEncode(await _webview!.shouldInterceptFetchRequest!( + this, request)); else return jsonEncode( await _inAppBrowser!.shouldInterceptFetchRequest(request)); } return null; case "onPrint": - if ((_webview != null && _webview!.onPrint != null) || _inAppBrowser != null) { + if ((_webview != null && _webview!.onPrint != null) || + _inAppBrowser != null) { String? url = args[0]; Uri? uri = url != null ? Uri.parse(url) : null; if (_webview != null && _webview!.onPrint != null) @@ -785,8 +910,7 @@ class InAppWebViewController { String? html; InAppWebViewGroupOptions? options = await getOptions(); - if (options != null && - options.crossPlatform.javaScriptEnabled == true) { + if (options != null && options.crossPlatform.javaScriptEnabled == true) { html = await evaluateJavascript( source: "window.document.getElementsByTagName('html')[0].outerHTML;"); if (html != null && html.isNotEmpty) return html; @@ -809,7 +933,7 @@ class InAppWebViewController { try { var htmlRequest = await client.getUrl(webviewUrl); html = - await (await htmlRequest.close()).transform(Utf8Decoder()).join(); + await (await htmlRequest.close()).transform(Utf8Decoder()).join(); } catch (e) { print(e); } @@ -843,8 +967,7 @@ class InAppWebViewController { } InAppWebViewGroupOptions? options = await getOptions(); - if (options != null && - options.crossPlatform.javaScriptEnabled == true) { + if (options != null && options.crossPlatform.javaScriptEnabled == true) { List> links = (await evaluateJavascript(source: """ (function() { var linkNodes = document.head.getElementsByTagName("link"); @@ -893,7 +1016,8 @@ class InAppWebViewController { // try to get /favicon.ico try { - var faviconUrl = webviewUrl.scheme + "://" + webviewUrl.host + "/favicon.ico"; + var faviconUrl = + webviewUrl.scheme + "://" + webviewUrl.host + "/favicon.ico"; var faviconUri = Uri.parse(faviconUrl); await client.headUrl(faviconUri); favicons.add(Favicon(url: faviconUri, rel: "shortcut icon")); @@ -907,7 +1031,8 @@ class InAppWebViewController { HttpClientResponse? manifestResponse; bool manifestFound = false; if (manifestUrl == null) { - manifestUrl = webviewUrl.scheme + "://" + webviewUrl.host + "/manifest.json"; + manifestUrl = + webviewUrl.scheme + "://" + webviewUrl.host + "/manifest.json"; } try { manifestRequest = await client.getUrl(Uri.parse(manifestUrl)); @@ -924,8 +1049,8 @@ class InAppWebViewController { json.decode(await manifestResponse!.transform(Utf8Decoder()).join()); if (manifest.containsKey("icons")) { for (Map icon in manifest["icons"]) { - favicons.addAll(_createFavicons(webviewUrl, assetPathBase, icon["src"], - icon["rel"], icon["sizes"], true)); + favicons.addAll(_createFavicons(webviewUrl, assetPathBase, + icon["src"], icon["rel"], icon["sizes"], true)); } } } @@ -964,11 +1089,12 @@ class InAppWebViewController { for (String size in sizesSplitted) { int width = int.parse(size.split("x")[0]); int height = int.parse(size.split("x")[1]); - favicons - .add(Favicon(url: Uri.parse(urlIcon), rel: rel, width: width, height: height)); + favicons.add(Favicon( + url: Uri.parse(urlIcon), rel: rel, width: width, height: height)); } } else { - favicons.add(Favicon(url: Uri.parse(urlIcon), rel: rel, width: null, height: null)); + favicons.add(Favicon( + url: Uri.parse(urlIcon), rel: rel, width: null, height: null)); } return favicons; @@ -989,13 +1115,16 @@ class InAppWebViewController { ///**Official iOS API**: ///- https://developer.apple.com/documentation/webkit/wkwebview/1414954-load ///- if [iosAllowingReadAccessTo] is used, https://developer.apple.com/documentation/webkit/wkwebview/1414973-loadfileurl - Future loadUrl({required URLRequest urlRequest, Uri? iosAllowingReadAccessTo}) async { + Future loadUrl( + {required URLRequest urlRequest, Uri? iosAllowingReadAccessTo}) async { assert(urlRequest.url != null && urlRequest.url.toString().isNotEmpty); - assert(iosAllowingReadAccessTo == null || iosAllowingReadAccessTo.isScheme("file")); + assert(iosAllowingReadAccessTo == null || + iosAllowingReadAccessTo.isScheme("file")); Map args = {}; args.putIfAbsent('urlRequest', () => urlRequest.toMap()); - args.putIfAbsent('allowingReadAccessTo', () => iosAllowingReadAccessTo.toString()); + args.putIfAbsent( + 'allowingReadAccessTo', () => iosAllowingReadAccessTo.toString()); await _channel.invokeMethod('loadUrl', args); } @@ -1040,7 +1169,8 @@ class InAppWebViewController { args.putIfAbsent('mimeType', () => mimeType); args.putIfAbsent('encoding', () => encoding); args.putIfAbsent('baseUrl', () => baseUrl?.toString() ?? "about:blank"); - args.putIfAbsent('historyUrl', () => androidHistoryUrl?.toString() ?? "about:blank"); + args.putIfAbsent( + 'historyUrl', () => androidHistoryUrl?.toString() ?? "about:blank"); await _channel.invokeMethod('loadData', args); } @@ -1192,12 +1322,14 @@ class InAppWebViewController { ///**Official iOS API**: ///- https://developer.apple.com/documentation/webkit/wkwebview/1415017-evaluatejavascript ///- https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript - Future evaluateJavascript({required String source, ContentWorld? contentWorld}) async { + Future evaluateJavascript( + {required String source, ContentWorld? contentWorld}) async { Map args = {}; args.putIfAbsent('source', () => source); args.putIfAbsent('contentWorld', () => contentWorld?.toMap()); var data = await _channel.invokeMethod('evaluateJavascript', args); - if (data != null && defaultTargetPlatform == TargetPlatform.android) data = json.decode(data); + if (data != null && defaultTargetPlatform == TargetPlatform.android) + data = json.decode(data); return data; } @@ -1209,11 +1341,14 @@ class InAppWebViewController { ///because, in these events, the [WebView] is not ready to handle it yet. ///Instead, you should call this method, for example, inside the [WebView.onLoadStop] event or in any other events ///where you know the page is ready "enough". - Future injectJavascriptFileFromUrl({required Uri urlFile, ScriptHtmlTagAttributes? scriptHtmlTagAttributes}) async { + Future injectJavascriptFileFromUrl( + {required Uri urlFile, + ScriptHtmlTagAttributes? scriptHtmlTagAttributes}) async { assert(urlFile.toString().isNotEmpty); Map args = {}; args.putIfAbsent('urlFile', () => urlFile.toString()); - args.putIfAbsent('scriptHtmlTagAttributes', () => scriptHtmlTagAttributes?.toMap()); + args.putIfAbsent( + 'scriptHtmlTagAttributes', () => scriptHtmlTagAttributes?.toMap()); await _channel.invokeMethod('injectJavascriptFileFromUrl', args); } @@ -1249,11 +1384,14 @@ class InAppWebViewController { ///because, in these events, the [WebView] is not ready to handle it yet. ///Instead, you should call this method, for example, inside the [WebView.onLoadStop] event or in any other events ///where you know the page is ready "enough". - Future injectCSSFileFromUrl({required Uri urlFile, CSSLinkHtmlTagAttributes? cssLinkHtmlTagAttributes}) async { + Future injectCSSFileFromUrl( + {required Uri urlFile, + CSSLinkHtmlTagAttributes? cssLinkHtmlTagAttributes}) async { assert(urlFile.toString().isNotEmpty); Map args = {}; args.putIfAbsent('urlFile', () => urlFile.toString()); - args.putIfAbsent('cssLinkHtmlTagAttributes', () => cssLinkHtmlTagAttributes?.toMap()); + args.putIfAbsent( + 'cssLinkHtmlTagAttributes', () => cssLinkHtmlTagAttributes?.toMap()); await _channel.invokeMethod('injectCSSFileFromUrl', args); } @@ -1340,9 +1478,11 @@ class InAppWebViewController { ///**NOTE for iOS**: available on iOS 11.0+. /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot - Future takeScreenshot({ScreenshotConfiguration? screenshotConfiguration}) async { + Future takeScreenshot( + {ScreenshotConfiguration? screenshotConfiguration}) async { Map args = {}; - args.putIfAbsent('screenshotConfiguration', () => screenshotConfiguration?.toMap()); + args.putIfAbsent( + 'screenshotConfiguration', () => screenshotConfiguration?.toMap()); return await _channel.invokeMethod('takeScreenshot', args); } @@ -1378,7 +1518,9 @@ class InAppWebViewController { ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist Future getCopyBackForwardList() async { Map args = {}; - Map? result = (await _channel.invokeMethod('getCopyBackForwardList', args))?.cast(); + Map? result = + (await _channel.invokeMethod('getCopyBackForwardList', args)) + ?.cast(); return WebHistory.fromMap(result); } @@ -1533,9 +1675,12 @@ class InAppWebViewController { ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebView#zoomBy(float) /// ///**Official iOS API**: https://developer.apple.com/documentation/uikit/uiscrollview/1619412-setzoomscale - Future zoomBy({required double zoomFactor, bool iosAnimated = false}) async { + Future zoomBy( + {required double zoomFactor, bool iosAnimated = false}) async { assert(defaultTargetPlatform != TargetPlatform.android || - (defaultTargetPlatform == TargetPlatform.android && zoomFactor > 0.01 && zoomFactor <= 100.0)); + (defaultTargetPlatform == TargetPlatform.android && + zoomFactor > 0.01 && + zoomFactor <= 100.0)); Map args = {}; args.putIfAbsent('zoomFactor', () => zoomFactor); @@ -1723,7 +1868,9 @@ class InAppWebViewController { var colorValue = metaTagThemeColor.content; - return colorValue != null ? UtilColor.fromStringRepresentation(colorValue) : null; + return colorValue != null + ? UtilColor.fromStringRepresentation(colorValue) + : null; } ///Returns the scrolled left position of the current WebView. @@ -1832,7 +1979,8 @@ class InAppWebViewController { ///**NOTE for iOS**: this method will throw an error if the [WebView.windowId] has been set. ///There isn't any way to add/remove user scripts specific to iOS window WebViews. ///This is a limitation of the native iOS WebKit APIs. - Future removeUserScripts({required List userScripts}) async { + Future removeUserScripts( + {required List userScripts}) async { assert(_webview?.windowId == null || !Platform.isIOS); for (var i = 0; i < userScripts.length; i++) { @@ -1880,7 +2028,8 @@ class InAppWebViewController { ///**NOTE for Android**: available only on Android 21+. /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript - Future callAsyncJavaScript({required String functionBody, + Future callAsyncJavaScript( + {required String functionBody, Map arguments = const {}, ContentWorld? contentWorld}) async { Map args = {}; @@ -1894,7 +2043,8 @@ class InAppWebViewController { if (defaultTargetPlatform == TargetPlatform.android) { data = json.decode(data); } - return CallAsyncJavaScriptResult(value: data["value"], error: data["error"]); + return CallAsyncJavaScriptResult( + value: data["value"], error: data["error"]); } ///Saves the current WebView as a web archive. @@ -1919,7 +2069,7 @@ class InAppWebViewController { assert(filePath.endsWith("." + WebArchiveFormat.WEBARCHIVE.toValue())); } } - + Map args = {}; args.putIfAbsent("filePath", () => filePath); args.putIfAbsent("autoname", () => autoname); @@ -1932,8 +2082,7 @@ class InAppWebViewController { ///**NOTE for Android**: available Android 21.0+. Future isSecureContext() async { Map args = {}; - return await _channel - .invokeMethod('isSecureContext', args); + return await _channel.invokeMethod('isSecureContext', args); } ///Gets the default user agent. @@ -1943,4 +2092,4 @@ class InAppWebViewController { Map args = {}; return await _staticChannel.invokeMethod('getDefaultUserAgent', args); } -} \ No newline at end of file +} diff --git a/lib/src/in_app_webview/in_app_webview_options.dart b/lib/src/in_app_webview/in_app_webview_options.dart index 5f040484..cad4d874 100755 --- a/lib/src/in_app_webview/in_app_webview_options.dart +++ b/lib/src/in_app_webview/in_app_webview_options.dart @@ -41,7 +41,10 @@ class InAppWebViewGroupOptions { ///iOS-specific options. late IOSInAppWebViewOptions ios; - InAppWebViewGroupOptions({InAppWebViewOptions? crossPlatform, AndroidInAppWebViewOptions? android, IOSInAppWebViewOptions? ios}) { + InAppWebViewGroupOptions( + {InAppWebViewOptions? crossPlatform, + AndroidInAppWebViewOptions? android, + IOSInAppWebViewOptions? ios}) { this.crossPlatform = crossPlatform ?? InAppWebViewOptions(); this.android = android ?? AndroidInAppWebViewOptions(); this.ios = ios ?? IOSInAppWebViewOptions(); @@ -52,14 +55,15 @@ class InAppWebViewGroupOptions { options.addAll(this.crossPlatform.toMap()); if (defaultTargetPlatform == TargetPlatform.android) options.addAll(this.android.toMap()); - else if (defaultTargetPlatform == TargetPlatform.iOS) options.addAll(this.ios.toMap()); + else if (defaultTargetPlatform == TargetPlatform.iOS) + options.addAll(this.ios.toMap()); return options; } static InAppWebViewGroupOptions fromMap(Map options) { InAppWebViewGroupOptions inAppWebViewGroupOptions = - InAppWebViewGroupOptions(); + InAppWebViewGroupOptions(); inAppWebViewGroupOptions.crossPlatform = InAppWebViewOptions.fromMap(options); @@ -229,7 +233,8 @@ class InAppWebViewOptions this.allowFileAccessFromFileURLs = false, this.allowUniversalAccessFromFileURLs = false}) { if (this.minimumFontSize == null) - this.minimumFontSize = defaultTargetPlatform == TargetPlatform.android ? 8 : 0; + this.minimumFontSize = + defaultTargetPlatform == TargetPlatform.android ? 8 : 0; assert(!this.resourceCustomSchemes.contains("http") && !this.resourceCustomSchemes.contains("https")); } @@ -313,7 +318,8 @@ class InAppWebViewOptions options.disableContextMenu = map["disableContextMenu"]; options.supportZoom = map["supportZoom"]; options.allowFileAccessFromFileURLs = map["allowFileAccessFromFileURLs"]; - options.allowUniversalAccessFromFileURLs = map["allowUniversalAccessFromFileURLs"]; + options.allowUniversalAccessFromFileURLs = + map["allowUniversalAccessFromFileURLs"]; return options; } diff --git a/lib/src/in_app_webview/ios/in_app_webview_controller.dart b/lib/src/in_app_webview/ios/in_app_webview_controller.dart index 3b0a2074..296656a9 100644 --- a/lib/src/in_app_webview/ios/in_app_webview_controller.dart +++ b/lib/src/in_app_webview/ios/in_app_webview_controller.dart @@ -33,9 +33,11 @@ class IOSInAppWebViewController { ///**NOTE**: available only on iOS 14.0+. /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf - Future createPdf({IOSWKPDFConfiguration? iosWKPdfConfiguration}) async { + Future createPdf( + {IOSWKPDFConfiguration? iosWKPdfConfiguration}) async { Map args = {}; - args.putIfAbsent('iosWKPdfConfiguration', () => iosWKPdfConfiguration?.toMap()); + args.putIfAbsent( + 'iosWKPdfConfiguration', () => iosWKPdfConfiguration?.toMap()); return await _channel.invokeMethod('createPdf', args); } @@ -55,8 +57,7 @@ class IOSInAppWebViewController { ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent Future hasOnlySecureContent() async { Map args = {}; - return await _channel - .invokeMethod('hasOnlySecureContent', args); + return await _channel.invokeMethod('hasOnlySecureContent', args); } ///Returns a Boolean value that indicates whether WebKit natively supports resources with the specified URL scheme. @@ -69,7 +70,6 @@ class IOSInAppWebViewController { static Future handlesURLScheme(String urlScheme) async { Map args = {}; args.putIfAbsent('urlScheme', () => urlScheme); - return await _staticChannel - .invokeMethod('handlesURLScheme', args); + return await _staticChannel.invokeMethod('handlesURLScheme', args); } } diff --git a/lib/src/in_app_webview/ios/in_app_webview_options.dart b/lib/src/in_app_webview/ios/in_app_webview_options.dart index 76592813..fc42d2da 100755 --- a/lib/src/in_app_webview/ios/in_app_webview_options.dart +++ b/lib/src/in_app_webview/ios/in_app_webview_options.dart @@ -247,7 +247,8 @@ class IOSInAppWebViewOptions this.applePayAPIEnabled = false, this.allowingReadAccessTo, this.disableLongPressContextMenuOnLinks = false}) { - assert(allowingReadAccessTo == null || allowingReadAccessTo!.isScheme("file")); + assert( + allowingReadAccessTo == null || allowingReadAccessTo!.isScheme("file")); } @override @@ -283,7 +284,8 @@ class IOSInAppWebViewOptions "isPagingEnabled": isPagingEnabled, "maximumZoomScale": maximumZoomScale, "minimumZoomScale": minimumZoomScale, - "contentInsetAdjustmentBehavior": contentInsetAdjustmentBehavior.toValue(), + "contentInsetAdjustmentBehavior": + contentInsetAdjustmentBehavior.toValue(), "isDirectionalLockEnabled": isDirectionalLockEnabled, "mediaType": mediaType, "pageZoom": pageZoom, @@ -300,7 +302,8 @@ class IOSInAppWebViewOptions List dataDetectorTypesList = List.from(map["dataDetectorTypes"] ?? []); dataDetectorTypesList.forEach((dataDetectorTypeValue) { - var dataDetectorType = IOSWKDataDetectorTypes.fromValue(dataDetectorTypeValue); + var dataDetectorType = + IOSWKDataDetectorTypes.fromValue(dataDetectorTypeValue); if (dataDetectorType != null) { dataDetectorTypes.add(dataDetectorType); } @@ -344,11 +347,15 @@ class IOSInAppWebViewOptions options.isDirectionalLockEnabled = map["isDirectionalLockEnabled"]; options.mediaType = map["mediaType"]; options.pageZoom = map["pageZoom"]; - options.limitsNavigationsToAppBoundDomains = map["limitsNavigationsToAppBoundDomains"]; + options.limitsNavigationsToAppBoundDomains = + map["limitsNavigationsToAppBoundDomains"]; options.useOnNavigationResponse = map["useOnNavigationResponse"]; options.applePayAPIEnabled = map["applePayAPIEnabled"]; - options.allowingReadAccessTo = map["allowingReadAccessTo"] != null ? Uri.parse(map["allowingReadAccessTo"]) : null; - options.disableLongPressContextMenuOnLinks = map["disableLongPressContextMenuOnLinks"]; + options.allowingReadAccessTo = map["allowingReadAccessTo"] != null + ? Uri.parse(map["allowingReadAccessTo"]) + : null; + options.disableLongPressContextMenuOnLinks = + map["disableLongPressContextMenuOnLinks"]; return options; } diff --git a/lib/src/in_app_webview/ios/main.dart b/lib/src/in_app_webview/ios/main.dart index 7725f881..1b928b50 100644 --- a/lib/src/in_app_webview/ios/main.dart +++ b/lib/src/in_app_webview/ios/main.dart @@ -1,2 +1,2 @@ export 'in_app_webview_options.dart'; -export 'in_app_webview_controller.dart'; \ No newline at end of file +export 'in_app_webview_controller.dart'; diff --git a/lib/src/in_app_webview/main.dart b/lib/src/in_app_webview/main.dart index c64e9a93..5d7fe28a 100644 --- a/lib/src/in_app_webview/main.dart +++ b/lib/src/in_app_webview/main.dart @@ -4,4 +4,4 @@ export 'in_app_webview_controller.dart'; export 'in_app_webview_options.dart'; export 'headless_in_app_webview.dart'; export 'android/main.dart'; -export 'ios/main.dart'; \ No newline at end of file +export 'ios/main.dart'; diff --git a/lib/src/in_app_webview/webview.dart b/lib/src/in_app_webview/webview.dart index 0d26f7bf..6db7237a 100644 --- a/lib/src/in_app_webview/webview.dart +++ b/lib/src/in_app_webview/webview.dart @@ -21,8 +21,7 @@ abstract class WebView { ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap) /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview - final void Function(InAppWebViewController controller, Uri? url)? - onLoadStart; + final void Function(InAppWebViewController controller, Uri? url)? onLoadStart; ///Event fired when the [WebView] finishes loading an [url]. /// @@ -126,8 +125,7 @@ abstract class WebView { /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wkurlschemehandler final Future Function( - InAppWebViewController controller, Uri url)? - onLoadResourceCustomScheme; + InAppWebViewController controller, Uri url)? onLoadResourceCustomScheme; ///Event fired when the [WebView] requests the host application to create a new window, ///for example when trying to open a link with `target="_blank"` or when `window.open()` is called by JavaScript side. @@ -221,9 +219,8 @@ abstract class WebView { ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String) /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview - final Future Function( - InAppWebViewController controller, HttpAuthenticationChallenge challenge)? - onReceivedHttpAuthRequest; + final Future Function(InAppWebViewController controller, + HttpAuthenticationChallenge challenge)? onReceivedHttpAuthRequest; ///Event fired when the WebView need to perform server trust authentication (certificate validation). ///The host application must return either [ServerTrustAuthResponse] instance with [ServerTrustAuthResponseAction.CANCEL] or [ServerTrustAuthResponseAction.PROCEED]. @@ -396,8 +393,10 @@ abstract class WebView { ///**NOTE**: available only on Android 27+. /// ///**Official Android API**: https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse) - final Future Function(InAppWebViewController controller, - Uri url, SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit; + final Future Function( + InAppWebViewController controller, + Uri url, + SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit; ///Event fired when the WebView is requesting permission to access the specified resources and the permission currently isn't granted or denied. /// @@ -602,9 +601,9 @@ abstract class WebView { /// /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview - final Future Function(InAppWebViewController controller, - IOSWKNavigationResponse navigationResponse)? - iosOnNavigationResponse; + final Future Function( + InAppWebViewController controller, + IOSWKNavigationResponse navigationResponse)? iosOnNavigationResponse; ///Called when a web view asks whether to continue with a connection that uses a deprecated version of TLS (v1.0 and v1.1). /// @@ -613,9 +612,9 @@ abstract class WebView { ///**NOTE**: available only on iOS 14.0+. /// ///**Official iOS API**: https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview - final Future Function(InAppWebViewController controller, - URLAuthenticationChallenge challenge)? - iosShouldAllowDeprecatedTLS; + final Future Function( + InAppWebViewController controller, + URLAuthenticationChallenge challenge)? iosShouldAllowDeprecatedTLS; ///Initial url request that will be loaded. /// diff --git a/lib/src/ios/main.dart b/lib/src/ios/main.dart index e69de29b..8b137891 100644 --- a/lib/src/ios/main.dart +++ b/lib/src/ios/main.dart @@ -0,0 +1 @@ + diff --git a/lib/src/main.dart b/lib/src/main.dart index 96825670..fe56afce 100644 --- a/lib/src/main.dart +++ b/lib/src/main.dart @@ -13,4 +13,4 @@ export 'cookie_manager.dart'; export 'in_app_localhost_server.dart'; export 'content_blocker.dart'; export 'http_auth_credentials_database.dart'; -export 'context_menu.dart'; \ No newline at end of file +export 'context_menu.dart'; diff --git a/lib/src/types.dart b/lib/src/types.dart index bab23c0f..d042939b 100755 --- a/lib/src/types.dart +++ b/lib/src/types.dart @@ -43,8 +43,8 @@ class ConsoleMessageLevel { static ConsoleMessageLevel? fromValue(int? value) { if (value != null) { try { - return ConsoleMessageLevel.values.firstWhere( - (element) => element.toValue() == value); + return ConsoleMessageLevel.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -105,11 +105,10 @@ class LoadedResource { return null; } return LoadedResource( - initiatorType: map["initiatorType"], - url: map["url"] != null ? Uri.parse(map["url"]) : null, - startTime: map["startTime"], - duration: map["duration"] - ); + initiatorType: map["initiatorType"], + url: map["url"] != null ? Uri.parse(map["url"]) : null, + startTime: map["startTime"], + duration: map["duration"]); } Map toMap() { @@ -156,8 +155,10 @@ class InAppWebViewInitialData { this.encoding = "utf8", Uri? baseUrl, Uri? androidHistoryUrl}) { - this.baseUrl = baseUrl == null ? Uri.parse("about:blank") : baseUrl; - this.androidHistoryUrl = androidHistoryUrl == null ? Uri.parse("about:blank") : androidHistoryUrl; + this.baseUrl = baseUrl == null ? Uri.parse("about:blank") : baseUrl; + this.androidHistoryUrl = androidHistoryUrl == null + ? Uri.parse("about:blank") + : androidHistoryUrl; } Map toMap() { @@ -219,10 +220,10 @@ class WebResourceRequest { WebResourceRequest( {required this.url, this.headers, - required this.method, - required this.hasGesture, - required this.isForMainFrame, - required this.isRedirect}); + required this.method, + required this.hasGesture, + required this.isForMainFrame, + required this.isRedirect}); static WebResourceRequest? fromMap(Map? map) { if (map == null) { @@ -230,13 +231,12 @@ class WebResourceRequest { } return WebResourceRequest( - url: Uri.parse(map["url"]), - headers: map["headers"]?.cast(), - method: map["method"], - hasGesture: map["hasGesture"], - isForMainFrame: map["isForMainFrame"], - isRedirect: map["isRedirect"] - ); + url: Uri.parse(map["url"]), + headers: map["headers"]?.cast(), + method: map["method"], + hasGesture: map["hasGesture"], + isForMainFrame: map["isForMainFrame"], + isRedirect: map["isRedirect"]); } Map toMap() { @@ -372,7 +372,8 @@ class ConsoleMessage { } return ConsoleMessage( message: map["message"], - messageLevel: ConsoleMessageLevel.fromValue(map["messageLevel"]) ?? ConsoleMessageLevel.LOG, + messageLevel: ConsoleMessageLevel.fromValue(map["messageLevel"]) ?? + ConsoleMessageLevel.LOG, ); } @@ -405,7 +406,8 @@ class WebHistory { return null; } - List>? historyListMap = map["history"]?.cast>(); + List>? historyListMap = + map["history"]?.cast>(); int currentIndex = map["currentIndex"]; List historyList = []; @@ -413,9 +415,13 @@ class WebHistory { for (var i = 0; i < historyListMap.length; i++) { var historyItem = historyListMap[i]; historyList.add(WebHistoryItem( - originalUrl: historyItem["originalUrl"] != null ? Uri.parse(historyItem["originalUrl"]) : null, + originalUrl: historyItem["originalUrl"] != null + ? Uri.parse(historyItem["originalUrl"]) + : null, title: historyItem["title"], - url: historyItem["url"] != null ? Uri.parse(historyItem["url"]) : null, + url: historyItem["url"] != null + ? Uri.parse(historyItem["url"]) + : null, index: i, offset: i - currentIndex)); } @@ -522,7 +528,11 @@ class JsAlertRequest { JsAlertRequest({this.url, this.message, this.iosIsMainFrame}); Map toMap() { - return {"url": url?.toString(), "message": message, "iosIsMainFrame": iosIsMainFrame}; + return { + "url": url?.toString(), + "message": message, + "iosIsMainFrame": iosIsMainFrame + }; } static JsAlertRequest? fromMap(Map? map) { @@ -616,7 +626,11 @@ class JsConfirmRequest { JsConfirmRequest({this.url, this.message, this.iosIsMainFrame}); Map toMap() { - return {"url": url?.toString(), "message": message, "iosIsMainFrame": iosIsMainFrame}; + return { + "url": url?.toString(), + "message": message, + "iosIsMainFrame": iosIsMainFrame + }; } static JsConfirmRequest? fromMap(Map? map) { @@ -932,8 +946,8 @@ class SafeBrowsingThreat { static SafeBrowsingThreat? fromValue(int? value) { if (value != null) { try { - return SafeBrowsingThreat.values.firstWhere( - (element) => element.toValue() == value); + return SafeBrowsingThreat.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -1107,8 +1121,8 @@ class IOSURLCredentialPersistence { static IOSURLCredentialPersistence? fromValue(int? value) { if (value != null) { try { - return IOSURLCredentialPersistence.values.firstWhere( - (element) => element.toValue() == value); + return IOSURLCredentialPersistence.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -1134,21 +1148,17 @@ class IOSURLCredentialPersistence { } ///The credential should not be stored. - static const NONE = - const IOSURLCredentialPersistence._internal(0); + static const NONE = const IOSURLCredentialPersistence._internal(0); ///The credential should be stored only for this session - static const FOR_SESSION = - const IOSURLCredentialPersistence._internal(1); + static const FOR_SESSION = const IOSURLCredentialPersistence._internal(1); ///The credential should be stored in the keychain. - static const PERMANENT = - const IOSURLCredentialPersistence._internal(2); + static const PERMANENT = const IOSURLCredentialPersistence._internal(2); ///The credential should be stored permanently in the keychain, ///and in addition should be distributed to other devices based on the owning Apple ID. - static const SYNCHRONIZABLE = - const IOSURLCredentialPersistence._internal(3); + static const SYNCHRONIZABLE = const IOSURLCredentialPersistence._internal(3); bool operator ==(value) => value == _value; @@ -1175,12 +1185,11 @@ class URLCredential { ///**NOTE**: available only on iOS. IOSURLCredentialPersistence? iosPersistence; - URLCredential({ - this.username, - this.password, - this.iosPersistence, - this.iosCertificates - }); + URLCredential( + {this.username, + this.password, + this.iosPersistence, + this.iosCertificates}); Map toMap() { return { @@ -1199,7 +1208,8 @@ class URLCredential { List? iosCertificates; if (map["iosCertificates"] != null) { iosCertificates = []; - (map["iosCertificates"].cast() as List).forEach((data) { + (map["iosCertificates"].cast() as List) + .forEach((data) { try { iosCertificates!.add(X509Certificate.fromData(data: data)); } catch (e, stacktrace) { @@ -1213,7 +1223,8 @@ class URLCredential { username: map["user"], password: map["password"], iosCertificates: iosCertificates, - iosPersistence: IOSURLCredentialPersistence.fromValue(map["iosPersistence"]), + iosPersistence: + IOSURLCredentialPersistence.fromValue(map["iosPersistence"]), ); } @@ -1230,7 +1241,6 @@ class URLCredential { ///Class that represents a challenge from a server requiring authentication from the client. ///It provides all the information about the challenge. class URLAuthenticationChallenge { - ///The protection space requiring authentication. URLProtectionSpace protectionSpace; @@ -1249,7 +1259,8 @@ class URLAuthenticationChallenge { return null; } return URLAuthenticationChallenge( - protectionSpace: URLProtectionSpace.fromMap(map["protectionSpace"].cast())!, + protectionSpace: URLProtectionSpace.fromMap( + map["protectionSpace"].cast())!, ); } @@ -1315,9 +1326,12 @@ class HttpAuthenticationChallenge extends URLAuthenticationChallenge { } return HttpAuthenticationChallenge( previousFailureCount: map["previousFailureCount"], - protectionSpace: URLProtectionSpace.fromMap(map["protectionSpace"].cast())!, - proposedCredential: URLCredential.fromMap(map["proposedCredential"]?.cast()), - iosFailureResponse: IOSURLResponse.fromMap(map["iosFailureResponse"]?.cast()), + protectionSpace: URLProtectionSpace.fromMap( + map["protectionSpace"].cast())!, + proposedCredential: URLCredential.fromMap( + map["proposedCredential"]?.cast()), + iosFailureResponse: IOSURLResponse.fromMap( + map["iosFailureResponse"]?.cast()), iosError: map["iosError"], ); } @@ -1326,16 +1340,16 @@ class HttpAuthenticationChallenge extends URLAuthenticationChallenge { ///Class that represents the challenge of the [WebView.onReceivedServerTrustAuthRequest] event. ///It provides all the information about the challenge. class ServerTrustChallenge extends URLAuthenticationChallenge { - ServerTrustChallenge({ - required URLProtectionSpace protectionSpace - }) : super(protectionSpace: protectionSpace); + ServerTrustChallenge({required URLProtectionSpace protectionSpace}) + : super(protectionSpace: protectionSpace); static ServerTrustChallenge? fromMap(Map? map) { if (map == null) { return null; } return ServerTrustChallenge( - protectionSpace: URLProtectionSpace.fromMap(map["protectionSpace"].cast())!, + protectionSpace: URLProtectionSpace.fromMap( + map["protectionSpace"].cast())!, ); } } @@ -1353,21 +1367,21 @@ class ClientCertChallenge extends URLAuthenticationChallenge { ///**NOTE**: available only on Android. List? androidKeyTypes; - ClientCertChallenge({ - required URLProtectionSpace protectionSpace, - this.androidPrincipals, - this.androidKeyTypes - }) : super(protectionSpace: protectionSpace); + ClientCertChallenge( + {required URLProtectionSpace protectionSpace, + this.androidPrincipals, + this.androidKeyTypes}) + : super(protectionSpace: protectionSpace); static ClientCertChallenge? fromMap(Map? map) { if (map == null) { return null; } return ClientCertChallenge( - protectionSpace: URLProtectionSpace.fromMap(map["protectionSpace"].cast())!, - androidPrincipals: map["androidPrincipals"]?.cast(), - androidKeyTypes: map["androidKeyTypes"]?.cast() - ); + protectionSpace: URLProtectionSpace.fromMap( + map["protectionSpace"].cast())!, + androidPrincipals: map["androidPrincipals"]?.cast(), + androidKeyTypes: map["androidKeyTypes"]?.cast()); } } @@ -1387,8 +1401,8 @@ class IOSNSURLProtectionSpaceProxyType { static IOSNSURLProtectionSpaceProxyType? fromValue(String? value) { if (value != null) { try { - return IOSNSURLProtectionSpaceProxyType.values.firstWhere( - (element) => element.toValue() == value); + return IOSNSURLProtectionSpaceProxyType.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -1402,19 +1416,24 @@ class IOSNSURLProtectionSpaceProxyType { String toString() => _value; ///The proxy type for HTTP proxies. - static const NSUR_PROTECTION_SPACE_HTTP_PROXY = const IOSNSURLProtectionSpaceProxyType._internal("NSURLProtectionSpaceHTTPProxy"); + static const NSUR_PROTECTION_SPACE_HTTP_PROXY = + const IOSNSURLProtectionSpaceProxyType._internal( + "NSURLProtectionSpaceHTTPProxy"); ///The proxy type for HTTPS proxies. static const NSURL_PROTECTION_SPACE_HTTPS_PROXY = - const IOSNSURLProtectionSpaceProxyType._internal("NSURLProtectionSpaceHTTPSProxy"); + const IOSNSURLProtectionSpaceProxyType._internal( + "NSURLProtectionSpaceHTTPSProxy"); ///The proxy type for FTP proxies. static const NSURL_PROTECTION_SPACE_FTP_PROXY = - const IOSNSURLProtectionSpaceProxyType._internal("NSURLProtectionSpaceFTPProxy"); + const IOSNSURLProtectionSpaceProxyType._internal( + "NSURLProtectionSpaceFTPProxy"); ///The proxy type for SOCKS proxies. static const NSURL_PROTECTION_SPACE_SOCKS_PROXY = - const IOSNSURLProtectionSpaceProxyType._internal("NSURLProtectionSpaceSOCKSProxy"); + const IOSNSURLProtectionSpaceProxyType._internal( + "NSURLProtectionSpaceSOCKSProxy"); bool operator ==(value) => value == _value; @@ -1429,17 +1448,21 @@ class IOSNSURLProtectionSpaceAuthenticationMethod { const IOSNSURLProtectionSpaceAuthenticationMethod._internal(this._value); static final Set values = [ - IOSNSURLProtectionSpaceAuthenticationMethod.NSURL_AUTHENTICATION_METHOD_CLIENT_CERTIFICATE, - IOSNSURLProtectionSpaceAuthenticationMethod.NSURL_AUTHENTICATION_METHOD_NEGOTIATE, - IOSNSURLProtectionSpaceAuthenticationMethod.NSURL_AUTHENTICATION_METHOD_NTLM, - IOSNSURLProtectionSpaceAuthenticationMethod.NSURL_AUTHENTICATION_METHOD_SERVER_TRUST, + IOSNSURLProtectionSpaceAuthenticationMethod + .NSURL_AUTHENTICATION_METHOD_CLIENT_CERTIFICATE, + IOSNSURLProtectionSpaceAuthenticationMethod + .NSURL_AUTHENTICATION_METHOD_NEGOTIATE, + IOSNSURLProtectionSpaceAuthenticationMethod + .NSURL_AUTHENTICATION_METHOD_NTLM, + IOSNSURLProtectionSpaceAuthenticationMethod + .NSURL_AUTHENTICATION_METHOD_SERVER_TRUST, ].toSet(); static IOSNSURLProtectionSpaceAuthenticationMethod? fromValue(String? value) { if (value != null) { try { - return IOSNSURLProtectionSpaceAuthenticationMethod.values.firstWhere( - (element) => element.toValue() == value); + return IOSNSURLProtectionSpaceAuthenticationMethod.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -1454,19 +1477,23 @@ class IOSNSURLProtectionSpaceAuthenticationMethod { ///Use client certificate authentication for this protection space. static const NSURL_AUTHENTICATION_METHOD_CLIENT_CERTIFICATE = - const IOSNSURLProtectionSpaceAuthenticationMethod._internal("NSURLAuthenticationMethodClientCertificate"); + const IOSNSURLProtectionSpaceAuthenticationMethod._internal( + "NSURLAuthenticationMethodClientCertificate"); ///Negotiate whether to use Kerberos or NTLM authentication for this protection space. static const NSURL_AUTHENTICATION_METHOD_NEGOTIATE = - const IOSNSURLProtectionSpaceAuthenticationMethod._internal("NSURLAuthenticationMethodNegotiate"); + const IOSNSURLProtectionSpaceAuthenticationMethod._internal( + "NSURLAuthenticationMethodNegotiate"); ///Use NTLM authentication for this protection space. static const NSURL_AUTHENTICATION_METHOD_NTLM = - const IOSNSURLProtectionSpaceAuthenticationMethod._internal("NSURLAuthenticationMethodNTLM"); + const IOSNSURLProtectionSpaceAuthenticationMethod._internal( + "NSURLAuthenticationMethodNTLM"); ///Perform server trust authentication (certificate validation) for this protection space. static const NSURL_AUTHENTICATION_METHOD_SERVER_TRUST = - const IOSNSURLProtectionSpaceAuthenticationMethod._internal("NSURLAuthenticationMethodServerTrust"); + const IOSNSURLProtectionSpaceAuthenticationMethod._internal( + "NSURLAuthenticationMethodServerTrust"); bool operator ==(value) => value == _value; @@ -1485,11 +1512,7 @@ class SslError { ///The message associated to the [androidError]/[iosError]. String? message; - SslError({ - this.androidError, - this.iosError, - this.message - }); + SslError({this.androidError, this.iosError, this.message}); static SslError? fromMap(Map? map) { if (map == null) { @@ -1498,8 +1521,7 @@ class SslError { return SslError( androidError: AndroidSslError.fromValue(map["androidError"]), iosError: IOSSslError.fromValue(map["iosError"]), - message: map["message"] - ); + message: map["message"]); } Map toMap() { @@ -1572,19 +1594,18 @@ class URLProtectionSpace { ///**NOTE**: available only on iOS. IOSNSURLProtectionSpaceProxyType? iosProxyType; - URLProtectionSpace({ - required this.host, - this.protocol, - this.realm, - this.port, - this.sslCertificate, - this.sslError, - this.iosAuthenticationMethod, - this.iosDistinguishedNames, - this.iosReceivesCredentialSecurely, - this.iosIsProxy, - this.iosProxyType - }); + URLProtectionSpace( + {required this.host, + this.protocol, + this.realm, + this.port, + this.sslCertificate, + this.sslError, + this.iosAuthenticationMethod, + this.iosDistinguishedNames, + this.iosReceivesCredentialSecurely, + this.iosIsProxy, + this.iosProxyType}); static URLProtectionSpace? fromMap(Map? map) { if (map == null) { @@ -1593,7 +1614,8 @@ class URLProtectionSpace { List? iosDistinguishedNames; if (map["iosDistinguishedNames"] != null) { iosDistinguishedNames = []; - (map["iosDistinguishedNames"].cast() as List).forEach((data) { + (map["iosDistinguishedNames"].cast() as List) + .forEach((data) { try { iosDistinguishedNames!.add(X509Certificate.fromData(data: data)); } catch (e, stacktrace) { @@ -1608,13 +1630,17 @@ class URLProtectionSpace { protocol: map["protocol"], realm: map["realm"], port: map["port"], - sslCertificate: SslCertificate.fromMap(map["sslCertificate"]?.cast()), + sslCertificate: SslCertificate.fromMap( + map["sslCertificate"]?.cast()), sslError: SslError.fromMap(map["sslError"]?.cast()), - iosAuthenticationMethod: IOSNSURLProtectionSpaceAuthenticationMethod.fromValue(map["iosAuthenticationMethod"]), + iosAuthenticationMethod: + IOSNSURLProtectionSpaceAuthenticationMethod.fromValue( + map["iosAuthenticationMethod"]), iosDistinguishedNames: iosDistinguishedNames, iosReceivesCredentialSecurely: map["iosReceivesCredentialSecurely"], iosIsProxy: map["iosIsProxy"], - iosProxyType: IOSNSURLProtectionSpaceProxyType.fromValue(map["iosProxyType"]), + iosProxyType: + IOSNSURLProtectionSpaceProxyType.fromValue(map["iosProxyType"]), ); } @@ -1627,7 +1653,8 @@ class URLProtectionSpace { "sslCertificate": sslCertificate?.toMap(), "sslError": sslError?.toMap(), "iosAuthenticationMethod": iosAuthenticationMethod, - "iosDistinguishedNames": iosDistinguishedNames?.map((e) => e.toMap()).toList(), + "iosDistinguishedNames": + iosDistinguishedNames?.map((e) => e.toMap()).toList(), "iosReceivesCredentialSecurely": iosReceivesCredentialSecurely, "iosIsProxy": iosIsProxy, "iosProxyType": iosProxyType?.toValue() @@ -1653,9 +1680,11 @@ class URLProtectionSpaceHttpAuthCredentials { ///The list of all its http authentication credentials. List? credentials; - URLProtectionSpaceHttpAuthCredentials({this.protectionSpace, this.credentials}); + URLProtectionSpaceHttpAuthCredentials( + {this.protectionSpace, this.credentials}); - static URLProtectionSpaceHttpAuthCredentials? fromMap(Map? map) { + static URLProtectionSpaceHttpAuthCredentials? fromMap( + Map? map) { if (map == null) { return null; } @@ -1663,7 +1692,9 @@ class URLProtectionSpaceHttpAuthCredentials { List? credentials; if (map["credentials"] != null) { credentials = []; - (map["credentials"].cast>() as List>).forEach((element) { + (map["credentials"].cast>() + as List>) + .forEach((element) { var credential = URLCredential.fromMap(element); if (credential != null) { credentials!.add(credential); @@ -1672,7 +1703,10 @@ class URLProtectionSpaceHttpAuthCredentials { } return URLProtectionSpaceHttpAuthCredentials( - protectionSpace: map["protectionSpace"] != null ? URLProtectionSpace.fromMap(map["protectionSpace"]?.cast()) : null, + protectionSpace: map["protectionSpace"] != null + ? URLProtectionSpace.fromMap( + map["protectionSpace"]?.cast()) + : null, credentials: credentials, ); } @@ -1680,8 +1714,9 @@ class URLProtectionSpaceHttpAuthCredentials { Map toMap() { return { "protectionSpace": protectionSpace?.toMap(), - "credentials": credentials != null ? - credentials!.map((credential) => credential.toMap()).toList() : null + "credentials": credentials != null + ? credentials!.map((credential) => credential.toMap()).toList() + : null }; } @@ -1818,7 +1853,12 @@ class Favicon { Favicon({required this.url, this.rel, this.width, this.height}); Map toMap() { - return {"url": url.toString(), "rel": rel, "width": width, "height": height}; + return { + "url": url.toString(), + "rel": rel, + "width": width, + "height": height + }; } Map toJson() { @@ -1847,8 +1887,8 @@ class AndroidCacheMode { static AndroidCacheMode? fromValue(int? value) { if (value != null) { try { - return AndroidCacheMode.values.firstWhere( - (element) => element.toValue() == value); + return AndroidCacheMode.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -1910,8 +1950,8 @@ class AndroidActionModeMenuItem { static AndroidActionModeMenuItem? fromValue(int? value) { if (value != null) { try { - return AndroidActionModeMenuItem.values.firstWhere( - (element) => element.toValue() == value); + return AndroidActionModeMenuItem.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -1973,8 +2013,8 @@ class AndroidForceDark { static AndroidForceDark? fromValue(int? value) { if (value != null) { try { - return AndroidForceDark.values.firstWhere( - (element) => element.toValue() == value); + return AndroidForceDark.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2028,8 +2068,8 @@ class AndroidLayoutAlgorithm { static AndroidLayoutAlgorithm? fromValue(String? value) { if (value != null) { try { - return AndroidLayoutAlgorithm.values.firstWhere( - (element) => element.toValue() == value); + return AndroidLayoutAlgorithm.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2079,8 +2119,8 @@ class AndroidMixedContentMode { static AndroidMixedContentMode? fromValue(int? value) { if (value != null) { try { - return AndroidMixedContentMode.values.firstWhere( - (element) => element.toValue() == value); + return AndroidMixedContentMode.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2141,8 +2181,8 @@ class IOSWKSelectionGranularity { static IOSWKSelectionGranularity? fromValue(int? value) { if (value != null) { try { - return IOSWKSelectionGranularity.values.firstWhere( - (element) => element.toValue() == value); + return IOSWKSelectionGranularity.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2199,8 +2239,8 @@ class IOSWKDataDetectorTypes { static IOSWKDataDetectorTypes? fromValue(String? value) { if (value != null) { try { - return IOSWKDataDetectorTypes.values.firstWhere( - (element) => element.toValue() == value); + return IOSWKDataDetectorTypes.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2269,8 +2309,8 @@ class IOSUIScrollViewDecelerationRate { static IOSUIScrollViewDecelerationRate? fromValue(String? value) { if (value != null) { try { - return IOSUIScrollViewDecelerationRate.values.firstWhere( - (element) => element.toValue() == value); + return IOSUIScrollViewDecelerationRate.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2311,8 +2351,8 @@ class UserPreferredContentMode { static UserPreferredContentMode? fromValue(int? value) { if (value != null) { try { - return UserPreferredContentMode.values.firstWhere( - (element) => element.toValue() == value); + return UserPreferredContentMode.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2372,8 +2412,8 @@ class IOSUIModalPresentationStyle { static IOSUIModalPresentationStyle? fromValue(int? value) { if (value != null) { try { - return IOSUIModalPresentationStyle.values.firstWhere( - (element) => element.toValue() == value); + return IOSUIModalPresentationStyle.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2466,8 +2506,8 @@ class IOSUIModalTransitionStyle { static IOSUIModalTransitionStyle? fromValue(int? value) { if (value != null) { try { - return IOSUIModalTransitionStyle.values.firstWhere( - (element) => element.toValue() == value); + return IOSUIModalTransitionStyle.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2533,8 +2573,8 @@ class IOSSafariDismissButtonStyle { static IOSSafariDismissButtonStyle? fromValue(int? value) { if (value != null) { try { - return IOSSafariDismissButtonStyle.values.firstWhere( - (element) => element.toValue() == value); + return IOSSafariDismissButtonStyle.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2626,8 +2666,8 @@ class AjaxRequestEventType { static AjaxRequestEventType? fromValue(String? value) { if (value != null) { try { - return AjaxRequestEventType.values.firstWhere( - (element) => element.toValue() == value); + return AjaxRequestEventType.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2693,11 +2733,10 @@ class AjaxRequestEvent { } return AjaxRequestEvent( - type: AjaxRequestEventType.fromValue(map["type"]), - lengthComputable: map["lengthComputable"], - loaded: map["loaded"], - total: map["total"] - ); + type: AjaxRequestEventType.fromValue(map["type"]), + lengthComputable: map["lengthComputable"], + loaded: map["loaded"], + total: map["total"]); } Map toMap() { @@ -2736,8 +2775,8 @@ class AjaxRequestReadyState { static AjaxRequestReadyState? fromValue(int? value) { if (value != null) { try { - return AjaxRequestReadyState.values.firstWhere( - (element) => element.toValue() == value); + return AjaxRequestReadyState.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -2923,25 +2962,26 @@ class AjaxRequest { } return AjaxRequest( - data: map["data"], - method: map["method"], - url: map["url"] != null ? Uri.parse(map["url"]) : null, - isAsync: map["isAsync"], - user: map["user"], - password: map["password"], - withCredentials: map["withCredentials"], - headers: AjaxRequestHeaders.fromMap(map["headers"]?.cast()), - readyState: AjaxRequestReadyState.fromValue(map["readyState"]), - status: map["status"], - responseURL: map["responseURL"] != null ? Uri.parse(map["responseURL"]) : null, - responseType: map["responseType"], - response: map["response"], - responseText: map["responseText"], - responseXML: map["responseXML"], - statusText: map["statusText"], - responseHeaders: map["responseHeaders"]?.cast(), - event: AjaxRequestEvent.fromMap(map["event"]?.cast()) - ); + data: map["data"], + method: map["method"], + url: map["url"] != null ? Uri.parse(map["url"]) : null, + isAsync: map["isAsync"], + user: map["user"], + password: map["password"], + withCredentials: map["withCredentials"], + headers: + AjaxRequestHeaders.fromMap(map["headers"]?.cast()), + readyState: AjaxRequestReadyState.fromValue(map["readyState"]), + status: map["status"], + responseURL: + map["responseURL"] != null ? Uri.parse(map["responseURL"]) : null, + responseType: map["responseType"], + response: map["response"], + responseText: map["responseText"], + responseXML: map["responseXML"], + statusText: map["statusText"], + responseHeaders: map["responseHeaders"]?.cast(), + event: AjaxRequestEvent.fromMap(map["event"]?.cast())); } Map toMap() { @@ -3012,9 +3052,7 @@ class FetchRequestCredential { if (map == null) { return null; } - return FetchRequestCredential( - type: map["type"] - ); + return FetchRequestCredential(type: map["type"]); } Map toJson() { @@ -3041,13 +3079,13 @@ class FetchRequestCredentialDefault extends FetchRequestCredential { }; } - static FetchRequestCredentialDefault? fromMap(Map? credentialsMap) { + static FetchRequestCredentialDefault? fromMap( + Map? credentialsMap) { if (credentialsMap == null) { return null; } return FetchRequestCredentialDefault( - type: credentialsMap["type"], - value: credentialsMap["value"]); + type: credentialsMap["type"], value: credentialsMap["value"]); } Map toJson() { @@ -3081,7 +3119,8 @@ class FetchRequestFederatedCredential extends FetchRequestCredential { {type, this.id, this.name, this.protocol, this.provider, this.iconURL}) : super(type: type); - static FetchRequestFederatedCredential? fromMap(Map? credentialsMap) { + static FetchRequestFederatedCredential? fromMap( + Map? credentialsMap) { if (credentialsMap == null) { return null; } @@ -3091,7 +3130,9 @@ class FetchRequestFederatedCredential extends FetchRequestCredential { name: credentialsMap["name"], protocol: credentialsMap["protocol"], provider: credentialsMap["provider"], - iconURL: credentialsMap["iconURL"] != null ? Uri.parse(credentialsMap["iconURL"]) : null); + iconURL: credentialsMap["iconURL"] != null + ? Uri.parse(credentialsMap["iconURL"]) + : null); } Map toMap() { @@ -3133,7 +3174,8 @@ class FetchRequestPasswordCredential extends FetchRequestCredential { {type, this.id, this.name, this.password, this.iconURL}) : super(type: type); - static FetchRequestPasswordCredential? fromMap(Map? credentialsMap) { + static FetchRequestPasswordCredential? fromMap( + Map? credentialsMap) { if (credentialsMap == null) { return null; } @@ -3142,7 +3184,9 @@ class FetchRequestPasswordCredential extends FetchRequestCredential { id: credentialsMap["id"], name: credentialsMap["name"], password: credentialsMap["password"], - iconURL: credentialsMap["iconURL"] != null ? Uri.parse(credentialsMap["iconURL"]) : null); + iconURL: credentialsMap["iconURL"] != null + ? Uri.parse(credentialsMap["iconURL"]) + : null); } Map toMap() { @@ -3226,7 +3270,8 @@ class FetchRequest { return null; } - Map? credentialMap = map["credentials"]?.cast(); + Map? credentialMap = + map["credentials"]?.cast(); FetchRequestCredential? credentials; if (credentialMap != null) { if (credentialMap["type"] == "default") { @@ -3239,19 +3284,20 @@ class FetchRequest { } return FetchRequest( - url: map["url"] != null ? Uri.parse(map["url"]) : null, - method: map["method"], - headers: map["headers"]?.cast(), - body: map["body"] != null ? Uint8List.fromList(map["body"].cast()) : null, - mode: map["mode"], - credentials: credentials, - cache: map["cache"], - redirect: map["redirect"], - referrer: map["referrer"], - referrerPolicy: ReferrerPolicy.fromValue(map["referrerPolicy"]), - integrity: map["integrity"], - keepalive: map["keepalive"] - ); + url: map["url"] != null ? Uri.parse(map["url"]) : null, + method: map["method"], + headers: map["headers"]?.cast(), + body: map["body"] != null + ? Uint8List.fromList(map["body"].cast()) + : null, + mode: map["mode"], + credentials: credentials, + cache: map["cache"], + redirect: map["redirect"], + referrer: map["referrer"], + referrerPolicy: ReferrerPolicy.fromValue(map["referrerPolicy"]), + integrity: map["integrity"], + keepalive: map["keepalive"]); } Map toMap() { @@ -3302,8 +3348,8 @@ class ContentBlockerTriggerResourceType { static ContentBlockerTriggerResourceType? fromValue(String? value) { if (value != null) { try { - return ContentBlockerTriggerResourceType.values.firstWhere( - (element) => element.toValue() == value); + return ContentBlockerTriggerResourceType.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -3353,8 +3399,8 @@ class ContentBlockerTriggerLoadType { static ContentBlockerTriggerLoadType? fromValue(String? value) { if (value != null) { try { - return ContentBlockerTriggerLoadType.values.firstWhere( - (element) => element.toValue() == value); + return ContentBlockerTriggerLoadType.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -3396,8 +3442,8 @@ class ContentBlockerActionType { static ContentBlockerActionType? fromValue(String? value) { if (value != null) { try { - return ContentBlockerActionType.values.firstWhere( - (element) => element.toValue() == value); + return ContentBlockerActionType.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -3598,8 +3644,8 @@ class IOSWKNavigationType { static IOSWKNavigationType? fromValue(int? value) { if (value != null) { try { - return IOSWKNavigationType.values.firstWhere( - (element) => element.toValue() == value); + return IOSWKNavigationType.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -3670,8 +3716,8 @@ class IOSURLRequestCachePolicy { static IOSURLRequestCachePolicy? fromValue(int? value) { if (value != null) { try { - return IOSURLRequestCachePolicy.values.firstWhere( - (element) => element.toValue() == value); + return IOSURLRequestCachePolicy.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -3702,33 +3748,39 @@ class IOSURLRequestCachePolicy { ///Use the caching logic defined in the protocol implementation, if any, for a particular URL load request. ///This is the default policy for URL load requests. - static const USE_PROTOCOL_CACHE_POLICY = const IOSURLRequestCachePolicy._internal(0); + static const USE_PROTOCOL_CACHE_POLICY = + const IOSURLRequestCachePolicy._internal(0); ///The URL load should be loaded only from the originating source. ///This policy specifies that no existing cache data should be used to satisfy a URL load request. /// ///**NOTE**: Always use this policy if you are making HTTP or HTTPS byte-range requests. - static const RELOAD_IGNORING_LOCAL_CACHE_DATA = const IOSURLRequestCachePolicy._internal(1); + static const RELOAD_IGNORING_LOCAL_CACHE_DATA = + const IOSURLRequestCachePolicy._internal(1); ///Use existing cache data, regardless or age or expiration date, loading from originating source only if there is no cached data. - static const RETURN_CACHE_DATA_ELSE_LOAD = const IOSURLRequestCachePolicy._internal(2); + static const RETURN_CACHE_DATA_ELSE_LOAD = + const IOSURLRequestCachePolicy._internal(2); ///Use existing cache data, regardless or age or expiration date, and fail if no cached data is available. /// ///If there is no existing data in the cache corresponding to a URL load request, ///no attempt is made to load the data from the originating source, and the load is considered to have failed. ///This constant specifies a behavior that is similar to an “offline” mode. - static const RETURN_CACHE_DATA_DONT_LOAD = const IOSURLRequestCachePolicy._internal(3); + static const RETURN_CACHE_DATA_DONT_LOAD = + const IOSURLRequestCachePolicy._internal(3); ///Ignore local cache data, and instruct proxies and other intermediates to disregard their caches so far as the protocol allows. /// ///**NOTE**: Versions earlier than macOS 15, iOS 13, watchOS 6, and tvOS 13 don’t implement this constant. - static const RELOAD_IGNORING_LOCAL_AND_REMOTE_CACHE_DATA = const IOSURLRequestCachePolicy._internal(4); + static const RELOAD_IGNORING_LOCAL_AND_REMOTE_CACHE_DATA = + const IOSURLRequestCachePolicy._internal(4); ///Use cache data if the origin source can validate it; otherwise, load from the origin. /// ///**NOTE**: Versions earlier than macOS 15, iOS 13, watchOS 6, and tvOS 13 don’t implement this constant. - static const RELOAD_REVALIDATING_CACHE_DATA = const IOSURLRequestCachePolicy._internal(5); + static const RELOAD_REVALIDATING_CACHE_DATA = + const IOSURLRequestCachePolicy._internal(5); bool operator ==(value) => value == _value; @@ -3756,8 +3808,8 @@ class IOSURLRequestNetworkServiceType { static IOSURLRequestNetworkServiceType? fromValue(int? value) { if (value != null) { try { - return IOSURLRequestNetworkServiceType.values.firstWhere( - (element) => element.toValue() == value); + return IOSURLRequestNetworkServiceType.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -3808,18 +3860,22 @@ class IOSURLRequestNetworkServiceType { ///A service type for data that the user is actively waiting for. /// ///Use this service type for interactive situations where the user is anticipating a quick response, like instant messaging or completing a purchase. - static const RESPONSIVE_DATA = const IOSURLRequestNetworkServiceType._internal(6); + static const RESPONSIVE_DATA = + const IOSURLRequestNetworkServiceType._internal(6); ///A service type for streaming audio/video data. - static const AV_STREAMING = const IOSURLRequestNetworkServiceType._internal(8); + static const AV_STREAMING = + const IOSURLRequestNetworkServiceType._internal(8); ///A service type for responsive (time-sensitive) audio/video data. - static const RESPONSIVE_AV = const IOSURLRequestNetworkServiceType._internal(9); + static const RESPONSIVE_AV = + const IOSURLRequestNetworkServiceType._internal(9); ///A service type for call signaling. /// ///Use this service type with network traffic that establishes, maintains, or tears down a VoIP call. - static const CALL_SIGNALING = const IOSURLRequestNetworkServiceType._internal(11); + static const CALL_SIGNALING = + const IOSURLRequestNetworkServiceType._internal(11); bool operator ==(value) => value == _value; @@ -3840,21 +3896,19 @@ class IOSWKSecurityOrigin { ///The security origin's protocol. String protocol; - IOSWKSecurityOrigin({required this.host, required this.port, required this.protocol}); + IOSWKSecurityOrigin( + {required this.host, required this.port, required this.protocol}); static IOSWKSecurityOrigin? fromMap(Map? map) { if (map == null) { return null; } - return IOSWKSecurityOrigin(host: map["host"], port: map["port"], protocol: map["protocol"]); + return IOSWKSecurityOrigin( + host: map["host"], port: map["port"], protocol: map["protocol"]); } Map toMap() { - return { - "host": host, - "port": port, - "protocol": protocol - }; + return {"host": host, "port": port, "protocol": protocol}; } Map toJson() { @@ -3880,7 +3934,8 @@ class IOSWKFrameInfo { ///The frame’s security origin. IOSWKSecurityOrigin? securityOrigin; - IOSWKFrameInfo({required this.isMainFrame, required this.request, this.securityOrigin}); + IOSWKFrameInfo( + {required this.isMainFrame, required this.request, this.securityOrigin}); static IOSWKFrameInfo? fromMap(Map? map) { if (map == null) { @@ -3889,8 +3944,8 @@ class IOSWKFrameInfo { return IOSWKFrameInfo( isMainFrame: map["isMainFrame"], request: URLRequest.fromMap(map["request"]?.cast()), - securityOrigin: IOSWKSecurityOrigin.fromMap(map["securityOrigin"]?.cast()) - ); + securityOrigin: IOSWKSecurityOrigin.fromMap( + map["securityOrigin"]?.cast())); } Map toMap() { @@ -3957,15 +4012,14 @@ class NavigationAction { ///**NOTE**: available only on iOS. IOSWKFrameInfo? iosTargetFrame; - NavigationAction({ - required this.request, - required this.isForMainFrame, - this.androidHasGesture, - this.androidIsRedirect, - this.iosWKNavigationType, - this.iosSourceFrame, - this.iosTargetFrame - }); + NavigationAction( + {required this.request, + required this.isForMainFrame, + this.androidHasGesture, + this.androidIsRedirect, + this.iosWKNavigationType, + this.iosSourceFrame, + this.iosTargetFrame}); static NavigationAction? fromMap(Map? map) { if (map == null) { @@ -3976,13 +4030,14 @@ class NavigationAction { isForMainFrame: map["isForMainFrame"], androidHasGesture: map["androidHasGesture"], androidIsRedirect: map["androidIsRedirect"], - iosWKNavigationType: IOSWKNavigationType.fromValue(map["iosWKNavigationType"]), - iosSourceFrame: IOSWKFrameInfo.fromMap(map["iosSourceFrame"]?.cast()), - iosTargetFrame: IOSWKFrameInfo.fromMap(map["iosTargetFrame"]?.cast()) - ); + iosWKNavigationType: + IOSWKNavigationType.fromValue(map["iosWKNavigationType"]), + iosSourceFrame: IOSWKFrameInfo.fromMap( + map["iosSourceFrame"]?.cast()), + iosTargetFrame: IOSWKFrameInfo.fromMap( + map["iosTargetFrame"]?.cast())); } - Map toMap() { return { "request": request.toString(), @@ -4007,7 +4062,6 @@ class NavigationAction { ///Class that represents the navigation request used by the [WebView.onCreateWindow] event. class CreateWindowAction extends NavigationAction { - ///The window id. Used by [WebView] to create a new WebView. int windowId; @@ -4021,24 +4075,25 @@ class CreateWindowAction extends NavigationAction { ///**NOTE**: available only on iOS. IOSWKWindowFeatures? iosWindowFeatures; - CreateWindowAction({ - required this.windowId, - this.androidIsDialog, - this.iosWindowFeatures, - required URLRequest request, - required bool isForMainFrame, - bool? androidHasGesture, - bool? androidIsRedirect, - IOSWKNavigationType? iosWKNavigationType, - IOSWKFrameInfo? iosSourceFrame, - IOSWKFrameInfo? iosTargetFrame - }) : super(request: request, - isForMainFrame: isForMainFrame, - androidHasGesture: androidHasGesture, - androidIsRedirect: androidIsRedirect, - iosWKNavigationType: iosWKNavigationType, - iosSourceFrame: iosSourceFrame, - iosTargetFrame: iosTargetFrame); + CreateWindowAction( + {required this.windowId, + this.androidIsDialog, + this.iosWindowFeatures, + required URLRequest request, + required bool isForMainFrame, + bool? androidHasGesture, + bool? androidIsRedirect, + IOSWKNavigationType? iosWKNavigationType, + IOSWKFrameInfo? iosSourceFrame, + IOSWKFrameInfo? iosTargetFrame}) + : super( + request: request, + isForMainFrame: isForMainFrame, + androidHasGesture: androidHasGesture, + androidIsRedirect: androidIsRedirect, + iosWKNavigationType: iosWKNavigationType, + iosSourceFrame: iosSourceFrame, + iosTargetFrame: iosTargetFrame); static CreateWindowAction? fromMap(Map? map) { if (map == null) { @@ -4047,15 +4102,18 @@ class CreateWindowAction extends NavigationAction { return CreateWindowAction( windowId: map["windowId"], androidIsDialog: map["androidIsDialog"], - iosWindowFeatures: IOSWKWindowFeatures.fromMap(map["iosWindowFeatures"]?.cast()), + iosWindowFeatures: IOSWKWindowFeatures.fromMap( + map["iosWindowFeatures"]?.cast()), request: URLRequest.fromMap(map["request"].cast())!, isForMainFrame: map["isForMainFrame"], androidHasGesture: map["androidHasGesture"], androidIsRedirect: map["androidIsRedirect"], - iosWKNavigationType: IOSWKNavigationType.fromValue(map["iosWKNavigationType"]), - iosSourceFrame: IOSWKFrameInfo.fromMap(map["iosSourceFrame"]?.cast()), - iosTargetFrame: IOSWKFrameInfo.fromMap(map["iosTargetFrame"]?.cast()) - ); + iosWKNavigationType: + IOSWKNavigationType.fromValue(map["iosWKNavigationType"]), + iosSourceFrame: IOSWKFrameInfo.fromMap( + map["iosSourceFrame"]?.cast()), + iosTargetFrame: IOSWKFrameInfo.fromMap( + map["iosTargetFrame"]?.cast())); } @override @@ -4127,8 +4185,8 @@ class IOSWKWebsiteDataType { static IOSWKWebsiteDataType? fromValue(String? value) { if (value != null) { try { - return IOSWKWebsiteDataType.values.firstWhere( - (element) => element.toValue() == value); + return IOSWKWebsiteDataType.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -4262,8 +4320,8 @@ class InAppWebViewHitTestResultType { static InAppWebViewHitTestResultType? fromValue(int? value) { if (value != null) { try { - return InAppWebViewHitTestResultType.values.firstWhere( - (element) => element.toValue() == value); + return InAppWebViewHitTestResultType.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -4349,9 +4407,8 @@ class InAppWebViewHitTestResult { } return InAppWebViewHitTestResult( - type: InAppWebViewHitTestResultType.fromValue(map["type"]), - extra: map["extra"] - ); + type: InAppWebViewHitTestResultType.fromValue(map["type"]), + extra: map["extra"]); } Map toJson() { @@ -4398,16 +4455,17 @@ class RenderProcessGoneDetail { /// any individual [WebView] requested using []. RendererPriority? rendererPriorityAtExit; - RenderProcessGoneDetail({required this.didCrash, this.rendererPriorityAtExit}); + RenderProcessGoneDetail( + {required this.didCrash, this.rendererPriorityAtExit}); static RenderProcessGoneDetail? fromMap(Map? map) { if (map == null) { return null; } return RenderProcessGoneDetail( - didCrash: map["didCrash"], - rendererPriorityAtExit: RendererPriority.fromValue( - map["rendererPriorityAtExit"]), + didCrash: map["didCrash"], + rendererPriorityAtExit: + RendererPriority.fromValue(map["rendererPriorityAtExit"]), ); } @@ -4443,8 +4501,8 @@ class RendererPriority { static RendererPriority? fromValue(int? value) { if (value != null) { try { - return RendererPriority.values.firstWhere( - (element) => element.toValue() == value); + return RendererPriority.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -4576,8 +4634,8 @@ class AndroidOverScrollMode { static AndroidOverScrollMode? fromValue(int? value) { if (value != null) { try { - return AndroidOverScrollMode.values.firstWhere( - (element) => element.toValue() == value); + return AndroidOverScrollMode.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -4638,8 +4696,8 @@ class AndroidScrollBarStyle { static AndroidScrollBarStyle? fromValue(int? value) { if (value != null) { try { - return AndroidScrollBarStyle.values.firstWhere( - (element) => element.toValue() == value); + return AndroidScrollBarStyle.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -4705,8 +4763,8 @@ class AndroidVerticalScrollbarPosition { static AndroidVerticalScrollbarPosition? fromValue(int? value) { if (value != null) { try { - return AndroidVerticalScrollbarPosition.values.firstWhere( - (element) => element.toValue() == value); + return AndroidVerticalScrollbarPosition.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -4897,8 +4955,8 @@ class WebStorageType { static WebStorageType? fromValue(String? value) { if (value != null) { try { - return WebStorageType.values.firstWhere( - (element) => element.toValue() == value); + return WebStorageType.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -4940,8 +4998,8 @@ class HTTPCookieSameSitePolicy { static HTTPCookieSameSitePolicy? fromValue(String? value) { if (value != null) { try { - return HTTPCookieSameSitePolicy.values.firstWhere( - (element) => element.toValue() == value); + return HTTPCookieSameSitePolicy.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -4996,8 +5054,8 @@ class AndroidSslError { static AndroidSslError? fromValue(int? value) { if (value != null) { try { - return AndroidSslError.values.firstWhere( - (element) => element.toValue() == value); + return AndroidSslError.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -5069,8 +5127,8 @@ class IOSSslError { static IOSSslError? fromValue(int? value) { if (value != null) { try { - return IOSSslError.values.firstWhere( - (element) => element.toValue() == value); + return IOSSslError.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -5141,8 +5199,8 @@ class IOSUIScrollViewContentInsetAdjustmentBehavior { static IOSUIScrollViewContentInsetAdjustmentBehavior? fromValue(int? value) { if (value != null) { try { - return IOSUIScrollViewContentInsetAdjustmentBehavior.values.firstWhere( - (element) => element.toValue() == value); + return IOSUIScrollViewContentInsetAdjustmentBehavior.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -5231,27 +5289,25 @@ class SslCertificate { return SslCertificate( issuedBy: SslCertificateDName( CName: x509Certificate.issuer( - dn: ASN1DistinguishedNames.COMMON_NAME) ?? + dn: ASN1DistinguishedNames.COMMON_NAME) ?? "", DName: x509Certificate.issuerDistinguishedName ?? "", OName: x509Certificate.issuer( - dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ?? + dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ?? "", UName: x509Certificate.issuer( - dn: ASN1DistinguishedNames - .ORGANIZATIONAL_UNIT_NAME) ?? + dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME) ?? ""), issuedTo: SslCertificateDName( CName: x509Certificate.subject( - dn: ASN1DistinguishedNames.COMMON_NAME) ?? + dn: ASN1DistinguishedNames.COMMON_NAME) ?? "", DName: x509Certificate.subjectDistinguishedName ?? "", OName: x509Certificate.subject( - dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ?? + dn: ASN1DistinguishedNames.ORGANIZATION_NAME) ?? "", UName: x509Certificate.subject( - dn: ASN1DistinguishedNames - .ORGANIZATIONAL_UNIT_NAME) ?? + dn: ASN1DistinguishedNames.ORGANIZATIONAL_UNIT_NAME) ?? ""), validNotAfterDate: x509Certificate.notAfter, validNotBeforeDate: x509Certificate.notBefore, @@ -5262,10 +5318,10 @@ class SslCertificate { } return SslCertificate( - issuedBy: SslCertificateDName.fromMap( - map["issuedBy"]?.cast()), - issuedTo: SslCertificateDName.fromMap( - map["issuedTo"]?.cast()), + issuedBy: + SslCertificateDName.fromMap(map["issuedBy"]?.cast()), + issuedTo: + SslCertificateDName.fromMap(map["issuedTo"]?.cast()), validNotAfterDate: DateTime.fromMillisecondsSinceEpoch(map["validNotAfterDate"]), validNotBeforeDate: @@ -5405,8 +5461,8 @@ class UserScriptInjectionTime { static UserScriptInjectionTime? fromValue(int? value) { if (value != null) { try { - return UserScriptInjectionTime.values.firstWhere( - (element) => element.toValue() == value); + return UserScriptInjectionTime.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -5430,14 +5486,12 @@ class UserScriptInjectionTime { ///**NOTE for iOS**: A constant to inject the script after the creation of the webpage’s document element, but before loading any other content. /// ///**NOTE for Android**: A constant to try to inject the script as soon as the page starts loading. - static const AT_DOCUMENT_START = - const UserScriptInjectionTime._internal(0); + static const AT_DOCUMENT_START = const UserScriptInjectionTime._internal(0); ///**NOTE for iOS**: A constant to inject the script after the document finishes loading, but before loading any other subresources. /// ///**NOTE for Android**: A constant to inject the script as soon as the page finishes loading. - static const AT_DOCUMENT_END = - const UserScriptInjectionTime._internal(1); + static const AT_DOCUMENT_END = const UserScriptInjectionTime._internal(1); bool operator ==(value) => value == _value; @@ -5467,7 +5521,12 @@ class UserScript { ///For more information about content worlds, see [ContentWorld]. late ContentWorld contentWorld; - UserScript({this.groupName, required this.source, required this.injectionTime, this.iosForMainFrameOnly = true, ContentWorld? contentWorld}) { + UserScript( + {this.groupName, + required this.source, + required this.injectionTime, + this.iosForMainFrameOnly = true, + ContentWorld? contentWorld}) { this.contentWorld = contentWorld ?? ContentWorld.PAGE; } @@ -5492,6 +5551,7 @@ class UserScript { } final _contentWorldNameRegExp = RegExp(r'[\s]'); + ///Class that represents an object that defines a scope of execution for JavaScript code and which you use to prevent conflicts between different scripts. /// ///**NOTE for iOS**: available on iOS 14.0+. This class represents the native [WKContentWorld](https://developer.apple.com/documentation/webkit/wkcontentworld) class. @@ -5511,11 +5571,13 @@ class ContentWorld { ///Returns the custom content world with the specified name. ContentWorld.world({required this.name}) { // WINDOW-ID- is used internally by the plugin! - assert(!this.name.startsWith("WINDOW-ID-") && !this.name.contains(_contentWorldNameRegExp)); + assert(!this.name.startsWith("WINDOW-ID-") && + !this.name.contains(_contentWorldNameRegExp)); } ///The default world for clients. - static final ContentWorld DEFAULT_CLIENT = ContentWorld.world(name: "defaultClient"); + static final ContentWorld DEFAULT_CLIENT = + ContentWorld.world(name: "defaultClient"); ///The content world for the current webpage’s content. ///This property contains the content world for scripts that the current webpage executes. @@ -5565,14 +5627,21 @@ class CallAsyncJavaScriptResult { class InAppWebViewRect { /// double x; + /// double y; + /// double width; + /// double height; - InAppWebViewRect({required this.x, required this.y, required this.width, required this.height}) { + InAppWebViewRect( + {required this.x, + required this.y, + required this.width, + required this.height}) { assert(this.x >= 0 && this.y >= 0 && this.width >= 0 && this.height >= 0); } @@ -5607,8 +5676,8 @@ class CompressFormat { static CompressFormat? fromValue(String? value) { if (value != null) { try { - return CompressFormat.values.firstWhere( - (element) => element.toValue() == value); + return CompressFormat.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -5662,7 +5731,6 @@ class CompressFormat { int get hashCode => _value.hashCode; } - ///Class that represents the configuration data to use when generating an image from a web view’s contents using [InAppWebViewController.takeScreenshot]. /// ///**NOTE for iOS**: available from iOS 11.0+. @@ -5696,12 +5764,12 @@ class ScreenshotConfiguration { ///**NOTE for iOS**: available only on iOS. Available from iOS 13.0+. bool iosAfterScreenUpdates; - ScreenshotConfiguration({ - this.rect, - this.snapshotWidth, - this.compressFormat = CompressFormat.PNG, - this.quality = 100, - this.iosAfterScreenUpdates = true}) { + ScreenshotConfiguration( + {this.rect, + this.snapshotWidth, + this.compressFormat = CompressFormat.PNG, + this.quality = 100, + this.iosAfterScreenUpdates = true}) { assert(this.quality >= 0); } @@ -5711,7 +5779,8 @@ class ScreenshotConfiguration { "snapshotWidth": snapshotWidth, "compressFormat": compressFormat.toValue(), "quality": quality, - "iosAfterScreenUpdates": iosAfterScreenUpdates}; + "iosAfterScreenUpdates": iosAfterScreenUpdates + }; } Map toJson() { @@ -5733,13 +5802,10 @@ class IOSWKPDFConfiguration { ///If you specify a custom rectangle, it must lie within the bounds rectangle of the [WebView] object. InAppWebViewRect? rect; - IOSWKPDFConfiguration({ - this.rect}); + IOSWKPDFConfiguration({this.rect}); Map toMap() { - return { - "rect": rect?.toMap() - }; + return {"rect": rect?.toMap()}; } Map toJson() { @@ -5758,16 +5824,14 @@ class WebArchiveFormat { const WebArchiveFormat._internal(this._value); - static final Set values = [ - WebArchiveFormat.MHT, - WebArchiveFormat.WEBARCHIVE - ].toSet(); + static final Set values = + [WebArchiveFormat.MHT, WebArchiveFormat.WEBARCHIVE].toSet(); static WebArchiveFormat? fromValue(String? value) { if (value != null) { try { - return WebArchiveFormat.values.firstWhere( - (element) => element.toValue() == value); + return WebArchiveFormat.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -5808,8 +5872,8 @@ class CrossOrigin { static CrossOrigin? fromValue(String? value) { if (value != null) { try { - return CrossOrigin.values.firstWhere( - (element) => element.toValue() == value); + return CrossOrigin.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -5856,8 +5920,8 @@ class ReferrerPolicy { static ReferrerPolicy? fromValue(String? value) { if (value != null) { try { - return ReferrerPolicy.values.firstWhere( - (element) => element.toValue() == value); + return ReferrerPolicy.values + .firstWhere((element) => element.toValue() == value); } catch (e) { return null; } @@ -5874,14 +5938,16 @@ class ReferrerPolicy { static const NO_REFERRER = const ReferrerPolicy._internal("no-referrer"); ///The Referer header will not be sent to origins without TLS (HTTPS). - static const NO_REFERRER_WHEN_DOWNGRADE = const ReferrerPolicy._internal("no-referrer-when-downgrade"); + static const NO_REFERRER_WHEN_DOWNGRADE = + const ReferrerPolicy._internal("no-referrer-when-downgrade"); ///The sent referrer will be limited to the origin of the referring page: its scheme, host, and port. static const ORIGIN = const ReferrerPolicy._internal("origin"); ///The referrer sent to other origins will be limited to the scheme, the host, and the port. ///Navigations on the same origin will still include the path. - static const ORIGIN_WHEN_CROSS_ORIGIN = const ReferrerPolicy._internal("origin-when-cross-origin"); + static const ORIGIN_WHEN_CROSS_ORIGIN = + const ReferrerPolicy._internal("origin-when-cross-origin"); ///A referrer will be sent for same origin, but cross-origin requests will contain no referrer information. static const SAME_ORIGIN = const ReferrerPolicy._internal("same-origin"); @@ -5892,7 +5958,8 @@ class ReferrerPolicy { ///Send a full URL when performing a same-origin request, but only send the origin when the protocol security level stays the same (e.g.HTTPS -> HTTPS), ///and send no header to a less secure destination (e.g. HTTPS -> HTTP). - static const STRICT_ORIGIN_WHEN_CROSS_ORIGIN = const ReferrerPolicy._internal("strict-origin-when-cross-origin"); + static const STRICT_ORIGIN_WHEN_CROSS_ORIGIN = + const ReferrerPolicy._internal("strict-origin-when-cross-origin"); ///The referrer will include the origin and the path (but not the fragment, password, or username). ///This value is unsafe, because it leaks origins and paths from TLS-protected resources to insecure origins. @@ -5906,7 +5973,6 @@ class ReferrerPolicy { ///Class that represents the possible the `