From 7e1ba2c2c8772f2d8ee89e40a1b40caa91b2aa27 Mon Sep 17 00:00:00 2001 From: "Suzuki, Shuhei" Date: Thu, 18 Jan 2024 13:40:16 +0900 Subject: [PATCH 001/181] issue #1983: Fixed to prevent Activity from being restored --- .../in_app_browser/InAppBrowserActivity.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java index 6cb763c49..d2c193b4b 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java @@ -82,6 +82,11 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); + if (savedInstanceState != null) { + finish(); + return; + } + Bundle b = getIntent().getExtras(); if (b == null) return; From 69c629e020a4eb527c85bf119e4e0f1fdd970f92 Mon Sep 17 00:00:00 2001 From: liyuanbo Date: Thu, 1 Feb 2024 17:43:28 +0800 Subject: [PATCH 002/181] redirect bug fix solution [issue 1884](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1884) --- .../in_app_webview/InAppWebViewClient.java | 49 +++++++----- .../in_app_webview/InAppWebViewSettings.java | 5 ++ .../in_app_webview_settings.dart | 75 +++++++------------ .../in_app_webview_settings.g.dart | 19 +++-- 4 files changed, 72 insertions(+), 76 deletions(-) diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java index c409efe54..b06276b79 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java @@ -56,6 +56,7 @@ import java.util.List; import java.util.Map; import java.util.regex.Matcher; +import java.util.regex.Pattern; public class InAppWebViewClient extends WebViewClient { @@ -74,6 +75,12 @@ public InAppWebViewClient(InAppBrowserDelegate inAppBrowserDelegate) { public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) { InAppWebView webView = (InAppWebView) view; if (webView.customSettings.useShouldOverrideUrlLoading) { + if (webView.customSettings.regexToCancelOverrideUrlLoading != null) { + Pattern pattern = Pattern.compile(webView.customSettings.regexToCancelOverrideUrlLoading); + Matcher m = pattern.matcher(request.getUrl().toString()); + Log.i(LOG_TAG, request.getUrl().toString() + " isMatch " + m.matches()); + if (m.matches() == false) return false; + } boolean isRedirect = false; if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_RESOURCE_REQUEST_IS_REDIRECT)) { isRedirect = WebResourceRequestCompat.isRedirect(request); @@ -108,6 +115,12 @@ public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request public boolean shouldOverrideUrlLoading(WebView webView, String url) { InAppWebView inAppWebView = (InAppWebView) webView; if (inAppWebView.customSettings.useShouldOverrideUrlLoading) { + if (inAppWebView.customSettings.regexToCancelOverrideUrlLoading != null) { + Pattern pattern = Pattern.compile(inAppWebView.customSettings.regexToCancelOverrideUrlLoading); + Matcher m = pattern.matcher(url); + Log.i(LOG_TAG, url + " isMatch " + m.matches()); + if (m.matches() == false) return false; + } onShouldOverrideUrlLoading(inAppWebView, url, "GET", null,true, false, false); return true; } @@ -164,7 +177,7 @@ public void error(String errorCode, @Nullable String errorMessage, @Nullable Obj defaultBehaviour(null); } }; - + if (webView.channelDelegate != null) { webView.channelDelegate.shouldOverrideUrlLoading(navigationAction, callback); } else { @@ -216,7 +229,7 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) { webView.channelDelegate.onLoadStart(url); } } - + public void onPageFinished(WebView view, String url) { final InAppWebView webView = (InAppWebView) view; webView.isLoading = false; @@ -260,13 +273,13 @@ public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) { if (inAppBrowserDelegate != null) { inAppBrowserDelegate.didUpdateVisitedHistory(url); } - + final InAppWebView webView = (InAppWebView) view; if (webView.channelDelegate != null) { webView.channelDelegate.onUpdateVisitedHistory(url, isReload); } } - + @RequiresApi(api = Build.VERSION_CODES.M) @Override public void onReceivedError(WebView view, @NonNull WebResourceRequest request, @NonNull WebResourceError error) { @@ -430,7 +443,7 @@ public void error(String errorCode, @Nullable String errorMessage, @Nullable Obj defaultBehaviour(null); } }; - + if (webView.channelDelegate != null) { webView.channelDelegate.onReceivedHttpAuthRequest(challenge, callback); } else { @@ -489,7 +502,7 @@ public void error(String errorCode, @Nullable String errorMessage, @Nullable Obj defaultBehaviour(null); } }; - + if (webView.channelDelegate != null) { webView.channelDelegate.onReceivedServerTrustAuthRequest(challenge, callback); } else { @@ -525,19 +538,19 @@ public boolean nonNullSuccess(@NonNull ClientCertResponse response) { if (action != null && webView.plugin != null) { switch (action) { case 1: - { - String certificatePath = (String) response.getCertificatePath(); - String certificatePassword = (String) response.getCertificatePassword(); - String keyStoreType = (String) response.getKeyStoreType(); - Util.PrivateKeyAndCertificates privateKeyAndCertificates = - Util.loadPrivateKeyAndCertificate(webView.plugin, certificatePath, certificatePassword, keyStoreType); - if (privateKeyAndCertificates != null) { - request.proceed(privateKeyAndCertificates.privateKey, privateKeyAndCertificates.certificates); - } else { - request.cancel(); - } + { + String certificatePath = (String) response.getCertificatePath(); + String certificatePassword = (String) response.getCertificatePassword(); + String keyStoreType = (String) response.getKeyStoreType(); + Util.PrivateKeyAndCertificates privateKeyAndCertificates = + Util.loadPrivateKeyAndCertificate(webView.plugin, certificatePath, certificatePassword, keyStoreType); + if (privateKeyAndCertificates != null) { + request.proceed(privateKeyAndCertificates.privateKey, privateKeyAndCertificates.certificates); + } else { + request.cancel(); } - break; + } + break; case 2: request.ignore(); break; diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java index 6bf17f607..6bdeb9ec8 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java @@ -104,6 +104,7 @@ public class InAppWebViewSettings implements ISettings { public Boolean hardwareAcceleration = true; public Boolean supportMultipleWindows = false; public String regexToCancelSubFramesLoading; + public String regexToCancelOverrideUrlLoading; public Integer overScrollMode = View.OVER_SCROLL_IF_CONTENT_SCROLLS; public Boolean networkAvailable = null; public Integer scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY; @@ -346,6 +347,9 @@ public InAppWebViewSettings parse(@NonNull Map settings) { case "regexToCancelSubFramesLoading": regexToCancelSubFramesLoading = (String) value; break; + case "regexToCancelOverrideUrlLoading": + regexToCancelOverrideUrlLoading = (String) value; + break; case "overScrollMode": overScrollMode = (Integer) value; break; @@ -489,6 +493,7 @@ public Map toMap() { settings.put("hardwareAcceleration", hardwareAcceleration); settings.put("supportMultipleWindows", supportMultipleWindows); settings.put("regexToCancelSubFramesLoading", regexToCancelSubFramesLoading); + settings.put("regexToCancelOverrideUrlLoading", regexToCancelOverrideUrlLoading); settings.put("overScrollMode", overScrollMode); settings.put("networkAvailable", networkAvailable); settings.put("scrollBarStyle", scrollBarStyle); diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart index f12b274ce..2b0f896f0 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart @@ -1,15 +1,23 @@ +import 'dart:typed_data'; + import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; -import 'dart:typed_data'; +import '../content_blocker.dart'; +import '../context_menu/context_menu.dart'; +import '../in_app_browser/in_app_browser_settings.dart'; +import '../in_app_browser/platform_in_app_browser.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; import '../platform_webview_asset_loader.dart'; +import '../platform_webview_feature.dart'; import '../types/action_mode_menu_item.dart'; import '../types/cache_mode.dart'; import '../types/data_detector_types.dart'; import '../types/force_dark.dart'; import '../types/force_dark_strategy.dart'; import '../types/layout_algorithm.dart'; +import '../types/main.dart'; import '../types/mixed_content_mode.dart'; import '../types/over_scroll_mode.dart'; import '../types/referrer_policy.dart'; @@ -21,17 +29,10 @@ import '../types/scrollview_deceleration_rate.dart'; import '../types/selection_granularity.dart'; import '../types/user_preferred_content_mode.dart'; import '../types/vertical_scrollbar_position.dart'; +import '../util.dart'; import '../web_uri.dart'; import 'android/in_app_webview_options.dart'; import 'apple/in_app_webview_options.dart'; -import '../content_blocker.dart'; -import '../types/main.dart'; -import '../util.dart'; -import '../in_app_browser/in_app_browser_settings.dart'; -import '../platform_webview_feature.dart'; -import '../in_app_webview/platform_inappwebview_controller.dart'; -import '../context_menu/context_menu.dart'; -import '../in_app_browser/platform_in_app_browser.dart'; import 'platform_webview.dart'; part 'in_app_webview_settings.g.dart'; @@ -57,12 +58,8 @@ class InAppWebViewSettings_ { ///If the [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. - @SupportedPlatforms(platforms: [ - AndroidPlatform(), - IOSPlatform(), - MacOSPlatform(), - WindowsPlatform() - ]) + @SupportedPlatforms( + platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) bool? useShouldOverrideUrlLoading; ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.onLoadResource] event. @@ -102,11 +99,7 @@ class InAppWebViewSettings_ { MacOSPlatform( apiName: "WKWebView.customUserAgent", apiUrl: - "https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent"), - WindowsPlatform( - apiName: 'ICoreWebView2Settings2.put_UserAgent', - apiUrl: - 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings2?view=webview2-1.0.2210.55#put_useragent') + "https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent") ]) String? userAgent; @@ -138,11 +131,7 @@ class InAppWebViewSettings_ { apiName: "WKWebpagePreferences.allowsContentJavaScript", apiUrl: "https://developer.apple.com/documentation/webkit/wkwebpagepreferences/3552422-allowscontentjavascript/"), - WebPlatform(requiresSameOrigin: false), - WindowsPlatform( - apiName: "ICoreWebView2Settings.put_IsScriptEnabled", - apiUrl: - "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_isscriptenabled") + WebPlatform(requiresSameOrigin: false) ]) bool? javaScriptEnabled; @@ -319,12 +308,7 @@ because there isn't any way to make the website data store non-persistent for th @SupportedPlatforms(platforms: [ AndroidPlatform(), IOSPlatform(), - MacOSPlatform(available: "12.0"), - WindowsPlatform( - available: '1.0.774.44', - apiName: 'ICoreWebView2Controller2.put_DefaultBackgroundColor', - apiUrl: - 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller2?view=webview2-1.0.2210.55#put_defaultbackgroundcolor') + MacOSPlatform(available: "12.0") ]) bool? transparentBackground; @@ -339,15 +323,8 @@ because there isn't any way to make the website data store non-persistent for th bool? disableHorizontalScroll; ///Set to `true` to disable context menu. The default value is `false`. - @SupportedPlatforms(platforms: [ - AndroidPlatform(), - IOSPlatform(), - WebPlatform(), - WindowsPlatform( - apiName: "ICoreWebView2Settings.put_AreDefaultContextMenusEnabled", - apiUrl: - "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredefaultcontextmenusenabled") - ]) + @SupportedPlatforms( + platforms: [AndroidPlatform(), IOSPlatform(), WebPlatform()]) bool? disableContextMenu; ///Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`. @@ -357,11 +334,7 @@ because there isn't any way to make the website data store non-persistent for th apiUrl: "https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setSupportZoom(boolean)"), IOSPlatform(), - MacOSPlatform(), - WindowsPlatform( - apiName: "ICoreWebView2Settings.put_IsZoomControlEnabled", - apiUrl: - "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_iszoomcontrolenabled") + MacOSPlatform() ]) bool? supportZoom; @@ -805,6 +778,11 @@ because there isn't any way to make the website data store non-persistent for th @SupportedPlatforms(platforms: [AndroidPlatform()]) String? regexToCancelSubFramesLoading; + ///Regular expression used by [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event to cancel navigation requests + ///If the url request not matches the regular expression, then the shouldOverrideUrlLoading is return false. + @SupportedPlatforms(platforms: [AndroidPlatform()]) + String? regexToCancelOverrideUrlLoading; + ///Set to `false` to disable Flutter Hybrid Composition. The default value is `true`. ///Hybrid Composition is supported starting with Flutter v1.20+. @SupportedPlatforms(platforms: [ @@ -1565,11 +1543,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri available: "13.3", apiName: "WKWebView.isInspectable", apiUrl: - "https://developer.apple.com/documentation/webkit/wkwebview/4111163-isinspectable"), - WindowsPlatform( - apiName: "ICoreWebView2Settings.put_AreDevToolsEnabled", - apiUrl: - "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredevtoolsenabled") + "https://developer.apple.com/documentation/webkit/wkwebview/4111163-isinspectable") ]) bool? isInspectable; @@ -1722,6 +1696,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri this.initialScale = 0, this.supportMultipleWindows = false, this.regexToCancelSubFramesLoading, + this.regexToCancelOverrideUrlLoading, this.useHybridComposition = true, this.useShouldInterceptRequest, this.useOnRenderProcessGone, diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart index 7c30031d1..0eed562b2 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart @@ -371,7 +371,6 @@ class InAppWebViewSettings { ///- Android native WebView ///- iOS ///- Web but iframe requires same origin - ///- Windows ([Official API - ICoreWebView2Settings.put_AreDefaultContextMenusEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredefaultcontextmenusenabled)) bool? disableContextMenu; ///Sets whether the default Android WebView’s internal error page should be suppressed or displayed for bad navigations. @@ -649,7 +648,6 @@ class InAppWebViewSettings { ///**Officially Supported Platforms/Implementations**: ///- iOS 16.4+ ([Official API - WKWebView.isInspectable](https://developer.apple.com/documentation/webkit/wkwebview/4111163-isinspectable)) ///- MacOS 13.3+ ([Official API - WKWebView.isInspectable](https://developer.apple.com/documentation/webkit/wkwebview/4111163-isinspectable)) - ///- Windows ([Official API - ICoreWebView2Settings.put_AreDevToolsEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredevtoolsenabled)) bool? isInspectable; ///A Boolean value that determines whether paging is enabled for the scroll view. @@ -693,7 +691,6 @@ class InAppWebViewSettings { ///- iOS ([Official API - WKWebpagePreferences.allowsContentJavaScript](https://developer.apple.com/documentation/webkit/wkwebpagepreferences/3552422-allowscontentjavascript/)) ///- MacOS ([Official API - WKWebpagePreferences.allowsContentJavaScript](https://developer.apple.com/documentation/webkit/wkwebpagepreferences/3552422-allowscontentjavascript/)) ///- Web - ///- Windows ([Official API - ICoreWebView2Settings.put_IsScriptEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_isscriptenabled)) bool? javaScriptEnabled; ///Sets the underlying layout algorithm. This will cause a re-layout of the WebView. @@ -849,6 +846,13 @@ class InAppWebViewSettings { ///- Android native WebView String? regexToCancelSubFramesLoading; + ///Regular expression used by [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event to cancel navigation requests + ///If the url request not matches the regular expression, then the shouldOverrideUrlLoading is return false. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android native WebView + String? regexToCancelOverrideUrlLoading; + ///Sets the renderer priority policy for this WebView. /// ///**Officially Supported Platforms/Implementations**: @@ -986,7 +990,6 @@ class InAppWebViewSettings { ///- Android native WebView ([Official API - WebSettings.setSupportZoom](https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setSupportZoom(boolean))) ///- iOS ///- MacOS - ///- Windows ([Official API - ICoreWebView2Settings.put_IsZoomControlEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_iszoomcontrolenabled)) bool? supportZoom; ///Set to `true` if you want the WebView suppresses content rendering until it is fully loaded into memory. The default value is `false`. @@ -1016,7 +1019,6 @@ class InAppWebViewSettings { ///- Android native WebView ///- iOS ///- MacOS 12.0+ - ///- Windows 1.0.774.44+ ([Official API - ICoreWebView2Controller2.put_DefaultBackgroundColor](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller2?view=webview2-1.0.2210.55#put_defaultbackgroundcolor)) bool? transparentBackground; ///The color the web view displays behind the active page, visible when the user scrolls beyond the bounds of the page. @@ -1142,7 +1144,6 @@ class InAppWebViewSettings { ///- Android native WebView ///- iOS ///- MacOS - ///- Windows bool? useShouldOverrideUrlLoading; ///Set to `true` if the WebView should enable support for the "viewport" HTML meta tag or should use a wide viewport. @@ -1160,7 +1161,6 @@ class InAppWebViewSettings { ///- Android native WebView ([Official API - WebSettings.setUserAgentString](https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setUserAgentString(java.lang.String))) ///- iOS ([Official API - WKWebView.customUserAgent](https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent)) ///- MacOS ([Official API - WKWebView.customUserAgent](https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent)) - ///- Windows ([Official API - ICoreWebView2Settings2.put_UserAgent](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings2?view=webview2-1.0.2210.55#put_useragent)) String? userAgent; ///Define whether the vertical scrollbar should be drawn or not. The default value is `true`. @@ -1267,6 +1267,7 @@ class InAppWebViewSettings { this.initialScale = 0, this.supportMultipleWindows = false, this.regexToCancelSubFramesLoading, + this.regexToCancelOverrideUrlLoading, this.useHybridComposition = true, this.useShouldInterceptRequest, this.useOnRenderProcessGone, @@ -1404,6 +1405,7 @@ class InAppWebViewSettings { MixedContentMode.fromNativeValue(map['mixedContentMode']), networkAvailable: map['networkAvailable'], regexToCancelSubFramesLoading: map['regexToCancelSubFramesLoading'], + regexToCancelOverrideUrlLoading: map['regexToCancelOverrideUrlLoading'], rendererPriorityPolicy: RendererPriorityPolicy.fromMap( map['rendererPriorityPolicy']?.cast()), requestedWithHeaderOriginAllowList: @@ -1676,6 +1678,7 @@ class InAppWebViewSettings { "pageZoom": pageZoom, "preferredContentMode": preferredContentMode?.toNativeValue(), "regexToCancelSubFramesLoading": regexToCancelSubFramesLoading, + "regexToCancelOverrideUrlLoading": regexToCancelOverrideUrlLoading, "rendererPriorityPolicy": rendererPriorityPolicy?.toMap(), "requestedWithHeaderOriginAllowList": requestedWithHeaderOriginAllowList?.toList(), @@ -1732,6 +1735,6 @@ class InAppWebViewSettings { @override String toString() { - return 'InAppWebViewSettings{accessibilityIgnoresInvertColors: $accessibilityIgnoresInvertColors, algorithmicDarkeningAllowed: $algorithmicDarkeningAllowed, allowBackgroundAudioPlaying: $allowBackgroundAudioPlaying, allowContentAccess: $allowContentAccess, allowFileAccess: $allowFileAccess, allowFileAccessFromFileURLs: $allowFileAccessFromFileURLs, allowUniversalAccessFromFileURLs: $allowUniversalAccessFromFileURLs, allowingReadAccessTo: $allowingReadAccessTo, allowsAirPlayForMediaPlayback: $allowsAirPlayForMediaPlayback, allowsBackForwardNavigationGestures: $allowsBackForwardNavigationGestures, allowsInlineMediaPlayback: $allowsInlineMediaPlayback, allowsLinkPreview: $allowsLinkPreview, allowsPictureInPictureMediaPlayback: $allowsPictureInPictureMediaPlayback, alwaysBounceHorizontal: $alwaysBounceHorizontal, alwaysBounceVertical: $alwaysBounceVertical, appCachePath: $appCachePath, applePayAPIEnabled: $applePayAPIEnabled, applicationNameForUserAgent: $applicationNameForUserAgent, automaticallyAdjustsScrollIndicatorInsets: $automaticallyAdjustsScrollIndicatorInsets, blockNetworkImage: $blockNetworkImage, blockNetworkLoads: $blockNetworkLoads, builtInZoomControls: $builtInZoomControls, cacheEnabled: $cacheEnabled, cacheMode: $cacheMode, contentBlockers: $contentBlockers, contentInsetAdjustmentBehavior: $contentInsetAdjustmentBehavior, cursiveFontFamily: $cursiveFontFamily, dataDetectorTypes: $dataDetectorTypes, databaseEnabled: $databaseEnabled, decelerationRate: $decelerationRate, defaultFixedFontSize: $defaultFixedFontSize, defaultFontSize: $defaultFontSize, defaultTextEncodingName: $defaultTextEncodingName, defaultVideoPoster: $defaultVideoPoster, disableContextMenu: $disableContextMenu, disableDefaultErrorPage: $disableDefaultErrorPage, disableHorizontalScroll: $disableHorizontalScroll, disableInputAccessoryView: $disableInputAccessoryView, disableLongPressContextMenuOnLinks: $disableLongPressContextMenuOnLinks, disableVerticalScroll: $disableVerticalScroll, disabledActionModeMenuItems: $disabledActionModeMenuItems, disallowOverScroll: $disallowOverScroll, displayZoomControls: $displayZoomControls, domStorageEnabled: $domStorageEnabled, enableViewportScale: $enableViewportScale, enterpriseAuthenticationAppLinkPolicyEnabled: $enterpriseAuthenticationAppLinkPolicyEnabled, fantasyFontFamily: $fantasyFontFamily, fixedFontFamily: $fixedFontFamily, forceDark: $forceDark, forceDarkStrategy: $forceDarkStrategy, geolocationEnabled: $geolocationEnabled, hardwareAcceleration: $hardwareAcceleration, horizontalScrollBarEnabled: $horizontalScrollBarEnabled, horizontalScrollbarThumbColor: $horizontalScrollbarThumbColor, horizontalScrollbarTrackColor: $horizontalScrollbarTrackColor, iframeAllow: $iframeAllow, iframeAllowFullscreen: $iframeAllowFullscreen, iframeCsp: $iframeCsp, iframeName: $iframeName, iframeReferrerPolicy: $iframeReferrerPolicy, iframeSandbox: $iframeSandbox, ignoresViewportScaleLimits: $ignoresViewportScaleLimits, incognito: $incognito, initialScale: $initialScale, interceptOnlyAsyncAjaxRequests: $interceptOnlyAsyncAjaxRequests, isDirectionalLockEnabled: $isDirectionalLockEnabled, isElementFullscreenEnabled: $isElementFullscreenEnabled, isFindInteractionEnabled: $isFindInteractionEnabled, isFraudulentWebsiteWarningEnabled: $isFraudulentWebsiteWarningEnabled, isInspectable: $isInspectable, isPagingEnabled: $isPagingEnabled, isSiteSpecificQuirksModeEnabled: $isSiteSpecificQuirksModeEnabled, isTextInteractionEnabled: $isTextInteractionEnabled, javaScriptCanOpenWindowsAutomatically: $javaScriptCanOpenWindowsAutomatically, javaScriptEnabled: $javaScriptEnabled, layoutAlgorithm: $layoutAlgorithm, limitsNavigationsToAppBoundDomains: $limitsNavigationsToAppBoundDomains, loadWithOverviewMode: $loadWithOverviewMode, loadsImagesAutomatically: $loadsImagesAutomatically, maximumViewportInset: $maximumViewportInset, maximumZoomScale: $maximumZoomScale, mediaPlaybackRequiresUserGesture: $mediaPlaybackRequiresUserGesture, mediaType: $mediaType, minimumFontSize: $minimumFontSize, minimumLogicalFontSize: $minimumLogicalFontSize, minimumViewportInset: $minimumViewportInset, minimumZoomScale: $minimumZoomScale, mixedContentMode: $mixedContentMode, needInitialFocus: $needInitialFocus, networkAvailable: $networkAvailable, offscreenPreRaster: $offscreenPreRaster, overScrollMode: $overScrollMode, pageZoom: $pageZoom, preferredContentMode: $preferredContentMode, regexToCancelSubFramesLoading: $regexToCancelSubFramesLoading, rendererPriorityPolicy: $rendererPriorityPolicy, requestedWithHeaderOriginAllowList: $requestedWithHeaderOriginAllowList, resourceCustomSchemes: $resourceCustomSchemes, safeBrowsingEnabled: $safeBrowsingEnabled, sansSerifFontFamily: $sansSerifFontFamily, saveFormData: $saveFormData, scrollBarDefaultDelayBeforeFade: $scrollBarDefaultDelayBeforeFade, scrollBarFadeDuration: $scrollBarFadeDuration, scrollBarStyle: $scrollBarStyle, scrollbarFadingEnabled: $scrollbarFadingEnabled, scrollsToTop: $scrollsToTop, selectionGranularity: $selectionGranularity, serifFontFamily: $serifFontFamily, sharedCookiesEnabled: $sharedCookiesEnabled, shouldPrintBackgrounds: $shouldPrintBackgrounds, standardFontFamily: $standardFontFamily, supportMultipleWindows: $supportMultipleWindows, supportZoom: $supportZoom, suppressesIncrementalRendering: $suppressesIncrementalRendering, textZoom: $textZoom, thirdPartyCookiesEnabled: $thirdPartyCookiesEnabled, transparentBackground: $transparentBackground, underPageBackgroundColor: $underPageBackgroundColor, upgradeKnownHostsToHTTPS: $upgradeKnownHostsToHTTPS, useHybridComposition: $useHybridComposition, useOnDownloadStart: $useOnDownloadStart, useOnLoadResource: $useOnLoadResource, useOnNavigationResponse: $useOnNavigationResponse, useOnRenderProcessGone: $useOnRenderProcessGone, useShouldInterceptAjaxRequest: $useShouldInterceptAjaxRequest, useShouldInterceptFetchRequest: $useShouldInterceptFetchRequest, useShouldInterceptRequest: $useShouldInterceptRequest, useShouldOverrideUrlLoading: $useShouldOverrideUrlLoading, useWideViewPort: $useWideViewPort, userAgent: $userAgent, verticalScrollBarEnabled: $verticalScrollBarEnabled, verticalScrollbarPosition: $verticalScrollbarPosition, verticalScrollbarThumbColor: $verticalScrollbarThumbColor, verticalScrollbarTrackColor: $verticalScrollbarTrackColor, webViewAssetLoader: $webViewAssetLoader}'; + return 'InAppWebViewSettings{accessibilityIgnoresInvertColors: $accessibilityIgnoresInvertColors, algorithmicDarkeningAllowed: $algorithmicDarkeningAllowed, allowBackgroundAudioPlaying: $allowBackgroundAudioPlaying, allowContentAccess: $allowContentAccess, allowFileAccess: $allowFileAccess, allowFileAccessFromFileURLs: $allowFileAccessFromFileURLs, allowUniversalAccessFromFileURLs: $allowUniversalAccessFromFileURLs, allowingReadAccessTo: $allowingReadAccessTo, allowsAirPlayForMediaPlayback: $allowsAirPlayForMediaPlayback, allowsBackForwardNavigationGestures: $allowsBackForwardNavigationGestures, allowsInlineMediaPlayback: $allowsInlineMediaPlayback, allowsLinkPreview: $allowsLinkPreview, allowsPictureInPictureMediaPlayback: $allowsPictureInPictureMediaPlayback, alwaysBounceHorizontal: $alwaysBounceHorizontal, alwaysBounceVertical: $alwaysBounceVertical, appCachePath: $appCachePath, applePayAPIEnabled: $applePayAPIEnabled, applicationNameForUserAgent: $applicationNameForUserAgent, automaticallyAdjustsScrollIndicatorInsets: $automaticallyAdjustsScrollIndicatorInsets, blockNetworkImage: $blockNetworkImage, blockNetworkLoads: $blockNetworkLoads, builtInZoomControls: $builtInZoomControls, cacheEnabled: $cacheEnabled, cacheMode: $cacheMode, contentBlockers: $contentBlockers, contentInsetAdjustmentBehavior: $contentInsetAdjustmentBehavior, cursiveFontFamily: $cursiveFontFamily, dataDetectorTypes: $dataDetectorTypes, databaseEnabled: $databaseEnabled, decelerationRate: $decelerationRate, defaultFixedFontSize: $defaultFixedFontSize, defaultFontSize: $defaultFontSize, defaultTextEncodingName: $defaultTextEncodingName, defaultVideoPoster: $defaultVideoPoster, disableContextMenu: $disableContextMenu, disableDefaultErrorPage: $disableDefaultErrorPage, disableHorizontalScroll: $disableHorizontalScroll, disableInputAccessoryView: $disableInputAccessoryView, disableLongPressContextMenuOnLinks: $disableLongPressContextMenuOnLinks, disableVerticalScroll: $disableVerticalScroll, disabledActionModeMenuItems: $disabledActionModeMenuItems, disallowOverScroll: $disallowOverScroll, displayZoomControls: $displayZoomControls, domStorageEnabled: $domStorageEnabled, enableViewportScale: $enableViewportScale, enterpriseAuthenticationAppLinkPolicyEnabled: $enterpriseAuthenticationAppLinkPolicyEnabled, fantasyFontFamily: $fantasyFontFamily, fixedFontFamily: $fixedFontFamily, forceDark: $forceDark, forceDarkStrategy: $forceDarkStrategy, geolocationEnabled: $geolocationEnabled, hardwareAcceleration: $hardwareAcceleration, horizontalScrollBarEnabled: $horizontalScrollBarEnabled, horizontalScrollbarThumbColor: $horizontalScrollbarThumbColor, horizontalScrollbarTrackColor: $horizontalScrollbarTrackColor, iframeAllow: $iframeAllow, iframeAllowFullscreen: $iframeAllowFullscreen, iframeCsp: $iframeCsp, iframeName: $iframeName, iframeReferrerPolicy: $iframeReferrerPolicy, iframeSandbox: $iframeSandbox, ignoresViewportScaleLimits: $ignoresViewportScaleLimits, incognito: $incognito, initialScale: $initialScale, interceptOnlyAsyncAjaxRequests: $interceptOnlyAsyncAjaxRequests, isDirectionalLockEnabled: $isDirectionalLockEnabled, isElementFullscreenEnabled: $isElementFullscreenEnabled, isFindInteractionEnabled: $isFindInteractionEnabled, isFraudulentWebsiteWarningEnabled: $isFraudulentWebsiteWarningEnabled, isInspectable: $isInspectable, isPagingEnabled: $isPagingEnabled, isSiteSpecificQuirksModeEnabled: $isSiteSpecificQuirksModeEnabled, isTextInteractionEnabled: $isTextInteractionEnabled, javaScriptCanOpenWindowsAutomatically: $javaScriptCanOpenWindowsAutomatically, javaScriptEnabled: $javaScriptEnabled, layoutAlgorithm: $layoutAlgorithm, limitsNavigationsToAppBoundDomains: $limitsNavigationsToAppBoundDomains, loadWithOverviewMode: $loadWithOverviewMode, loadsImagesAutomatically: $loadsImagesAutomatically, maximumViewportInset: $maximumViewportInset, maximumZoomScale: $maximumZoomScale, mediaPlaybackRequiresUserGesture: $mediaPlaybackRequiresUserGesture, mediaType: $mediaType, minimumFontSize: $minimumFontSize, minimumLogicalFontSize: $minimumLogicalFontSize, minimumViewportInset: $minimumViewportInset, minimumZoomScale: $minimumZoomScale, mixedContentMode: $mixedContentMode, needInitialFocus: $needInitialFocus, networkAvailable: $networkAvailable, offscreenPreRaster: $offscreenPreRaster, overScrollMode: $overScrollMode, pageZoom: $pageZoom, preferredContentMode: $preferredContentMode, regexToCancelSubFramesLoading: $regexToCancelSubFramesLoading,regexToCancelOverrideUrlLoading: $regexToCancelOverrideUrlLoading, rendererPriorityPolicy: $rendererPriorityPolicy, requestedWithHeaderOriginAllowList: $requestedWithHeaderOriginAllowList, resourceCustomSchemes: $resourceCustomSchemes, safeBrowsingEnabled: $safeBrowsingEnabled, sansSerifFontFamily: $sansSerifFontFamily, saveFormData: $saveFormData, scrollBarDefaultDelayBeforeFade: $scrollBarDefaultDelayBeforeFade, scrollBarFadeDuration: $scrollBarFadeDuration, scrollBarStyle: $scrollBarStyle, scrollbarFadingEnabled: $scrollbarFadingEnabled, scrollsToTop: $scrollsToTop, selectionGranularity: $selectionGranularity, serifFontFamily: $serifFontFamily, sharedCookiesEnabled: $sharedCookiesEnabled, shouldPrintBackgrounds: $shouldPrintBackgrounds, standardFontFamily: $standardFontFamily, supportMultipleWindows: $supportMultipleWindows, supportZoom: $supportZoom, suppressesIncrementalRendering: $suppressesIncrementalRendering, textZoom: $textZoom, thirdPartyCookiesEnabled: $thirdPartyCookiesEnabled, transparentBackground: $transparentBackground, underPageBackgroundColor: $underPageBackgroundColor, upgradeKnownHostsToHTTPS: $upgradeKnownHostsToHTTPS, useHybridComposition: $useHybridComposition, useOnDownloadStart: $useOnDownloadStart, useOnLoadResource: $useOnLoadResource, useOnNavigationResponse: $useOnNavigationResponse, useOnRenderProcessGone: $useOnRenderProcessGone, useShouldInterceptAjaxRequest: $useShouldInterceptAjaxRequest, useShouldInterceptFetchRequest: $useShouldInterceptFetchRequest, useShouldInterceptRequest: $useShouldInterceptRequest, useShouldOverrideUrlLoading: $useShouldOverrideUrlLoading, useWideViewPort: $useWideViewPort, userAgent: $userAgent, verticalScrollBarEnabled: $verticalScrollBarEnabled, verticalScrollbarPosition: $verticalScrollbarPosition, verticalScrollbarThumbColor: $verticalScrollbarThumbColor, verticalScrollbarTrackColor: $verticalScrollbarTrackColor, webViewAssetLoader: $webViewAssetLoader}'; } } From 6f705b077b1b67c2d7133a6b85eaac17bf431586 Mon Sep 17 00:00:00 2001 From: liyuanbo Date: Fri, 23 Feb 2024 16:41:57 +0800 Subject: [PATCH 003/181] Update InAppWebViewClientCompat.java add WebViewClientCompat regex match --- .../InAppWebViewClientCompat.java | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java index 5aecaa5b4..137a1e362 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java @@ -56,6 +56,7 @@ import java.util.List; import java.util.Map; import java.util.regex.Matcher; +import java.util.regex.Pattern; public class InAppWebViewClientCompat extends WebViewClientCompat { @@ -74,6 +75,12 @@ public InAppWebViewClientCompat(InAppBrowserDelegate inAppBrowserDelegate) { public boolean shouldOverrideUrlLoading(@NonNull WebView view, @NonNull WebResourceRequest request) { InAppWebView webView = (InAppWebView) view; if (webView.customSettings.useShouldOverrideUrlLoading) { + if (webView.customSettings.regexToCancelOverrideUrlLoading != null) { + Pattern pattern = Pattern.compile(webView.customSettings.regexToCancelOverrideUrlLoading); + Matcher m = pattern.matcher(request.getUrl().toString()); + Log.i(LOG_TAG, request.getUrl().toString() + " isMatch " + m.matches()); + if (m.matches() == false) return false; + } boolean isRedirect = false; if (WebViewFeature.isFeatureSupported(WebViewFeature.WEB_RESOURCE_REQUEST_IS_REDIRECT)) { isRedirect = WebResourceRequestCompat.isRedirect(request); @@ -108,6 +115,12 @@ public boolean shouldOverrideUrlLoading(@NonNull WebView view, @NonNull WebResou public boolean shouldOverrideUrlLoading(WebView webView, String url) { InAppWebView inAppWebView = (InAppWebView) webView; if (inAppWebView.customSettings.useShouldOverrideUrlLoading) { + if (inAppWebView.customSettings.regexToCancelOverrideUrlLoading != null) { + Pattern pattern = Pattern.compile(inAppWebView.customSettings.regexToCancelOverrideUrlLoading); + Matcher m = pattern.matcher(url); + Log.i(LOG_TAG, url + " isMatch " + m.matches()); + if (m.matches() == false) return false; + } onShouldOverrideUrlLoading(inAppWebView, url, "GET", null,true, false, false); return true; } @@ -164,7 +177,7 @@ public void error(String errorCode, @Nullable String errorMessage, @Nullable Obj defaultBehaviour(null); } }; - + if (webView.channelDelegate != null) { webView.channelDelegate.shouldOverrideUrlLoading(navigationAction, callback); } else { @@ -216,7 +229,7 @@ public void onPageStarted(WebView view, String url, Bitmap favicon) { webView.channelDelegate.onLoadStart(url); } } - + public void onPageFinished(WebView view, String url) { final InAppWebView webView = (InAppWebView) view; webView.isLoading = false; @@ -260,13 +273,13 @@ public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) { if (inAppBrowserDelegate != null) { inAppBrowserDelegate.didUpdateVisitedHistory(url); } - + final InAppWebView webView = (InAppWebView) view; if (webView.channelDelegate != null) { webView.channelDelegate.onUpdateVisitedHistory(url, isReload); } } - + @RequiresApi(api = Build.VERSION_CODES.M) @Override public void onReceivedError(@NonNull WebView view, @@ -442,7 +455,7 @@ public void error(String errorCode, @Nullable String errorMessage, @Nullable Obj defaultBehaviour(null); } }; - + if (webView.channelDelegate != null) { webView.channelDelegate.onReceivedHttpAuthRequest(challenge, callback); } else { @@ -501,7 +514,7 @@ public void error(String errorCode, @Nullable String errorMessage, @Nullable Obj defaultBehaviour(null); } }; - + if (webView.channelDelegate != null) { webView.channelDelegate.onReceivedServerTrustAuthRequest(challenge, callback); } else { @@ -541,7 +554,7 @@ public boolean nonNullSuccess(@NonNull ClientCertResponse response) { String certificatePath = (String) response.getCertificatePath(); String certificatePassword = (String) response.getCertificatePassword(); String keyStoreType = (String) response.getKeyStoreType(); - Util.PrivateKeyAndCertificates privateKeyAndCertificates = + Util.PrivateKeyAndCertificates privateKeyAndCertificates = Util.loadPrivateKeyAndCertificate(webView.plugin, certificatePath, certificatePassword, keyStoreType); if (privateKeyAndCertificates != null) { request.proceed(privateKeyAndCertificates.privateKey, privateKeyAndCertificates.certificates); From e4d043d3a2d5fcc2e0f6a68297c7e3eca1d594ac Mon Sep 17 00:00:00 2001 From: yamaha252 Date: Thu, 18 Jan 2024 18:40:14 +0500 Subject: [PATCH 004/181] request focus --- .../lib/src/in_app_webview/in_app_webview_controller.dart | 3 +++ .../webview/WebViewChannelDelegate.java | 6 ++++++ .../webview/WebViewChannelDelegateMethods.java | 1 + .../lib/src/in_app_webview/in_app_webview_controller.dart | 6 ++++++ .../ios/Classes/InAppWebView/InAppWebView.swift | 4 ++++ .../ios/Classes/InAppWebView/WebViewChannelDelegate.swift | 4 ++++ .../InAppWebView/WebViewChannelDelegateMethods.swift | 1 + .../lib/src/in_app_webview/in_app_webview_controller.dart | 6 ++++++ .../in_app_webview/platform_inappwebview_controller.dart | 5 +++++ 9 files changed, 36 insertions(+) diff --git a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart index 1544754d3..871afe217 100644 --- a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart @@ -290,6 +290,9 @@ class InAppWebViewController { Future getHitTestResult() => platform.getHitTestResult(); + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.requestFocus} + Future requestFocus() => platform.requestFocus(); + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.clearFocus} Future clearFocus() => platform.clearFocus(); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java index 5f87b93c0..880d25f68 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java @@ -474,6 +474,12 @@ public void onReceiveValue(String value) { } result.success(true); break; + case requestFocus: + if (webView != null) { + webView.requestFocus(); + } + result.success(true); + break; case setContextMenu: if (webView != null) { Map contextMenu = (Map) call.argument("contextMenu"); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegateMethods.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegateMethods.java index 3c6d6ae1f..d2a4b5e8e 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegateMethods.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegateMethods.java @@ -62,6 +62,7 @@ public enum WebViewChannelDelegateMethods { saveWebArchive, zoomIn, zoomOut, + requestFocus, clearFocus, setContextMenu, requestFocusNodeHref, diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart index ceb4bc9a9..1d5c37408 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2241,6 +2241,12 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController return InAppWebViewHitTestResult(type: type, extra: extra); } + @override + Future requestFocus() async { + Map args = {}; + return await channel?.invokeMethod('requestFocus', args); + } + @override Future clearFocus() async { Map args = {}; diff --git a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift index 25dee18da..b69eb02a2 100755 --- a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift @@ -3129,6 +3129,10 @@ if(window.\(JAVASCRIPT_BRIDGE_NAME)[\(_callHandlerID)] != null) { public func clearFocus() { self.scrollView.subviews.first?.resignFirstResponder() } + + public func requestFocus() { + self.scrollView.subviews.first?.becomeFirstResponder() + } public func getCertificate() -> SslCertificate? { guard let scheme = url?.scheme, diff --git a/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift b/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift index 46bab6d05..6948d17c3 100644 --- a/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift @@ -348,6 +348,10 @@ public class WebViewChannelDelegate: ChannelDelegate { webView?.clearFocus() result(true) break + case .requestFocus: + webView?.requestFocus() + result(true) + break case .setContextMenu: if let webView = webView { let contextMenu = arguments!["contextMenu"] as? [String: Any] diff --git a/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegateMethods.swift b/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegateMethods.swift index 899cd769b..e05f37306 100644 --- a/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegateMethods.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegateMethods.swift @@ -59,6 +59,7 @@ public enum WebViewChannelDelegateMethods: String { case getSelectedText = "getSelectedText" case getHitTestResult = "getHitTestResult" case clearFocus = "clearFocus" + case requestFocus = "requestFocus" case setContextMenu = "setContextMenu" case requestFocusNodeHref = "requestFocusNodeHref" case requestImageRef = "requestImageRef" diff --git a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart index 7e847f14f..d9fb63dd1 100644 --- a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2234,6 +2234,12 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController return await channel?.invokeMethod('clearFocus', args); } + @override + Future requestFocus() async { + Map args = {}; + return await channel?.invokeMethod('requestFocus', args); + } + @override Future setContextMenu(ContextMenu? contextMenu) async { Map args = {}; diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart index b027eb8d9..631fe1428 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart @@ -1045,6 +1045,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface 'getHitTestResult is not implemented on the current platform'); } + Future requestFocus() { + throw UnimplementedError( + 'requestFocus is not implemented on the current platform'); + } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.clearFocus} ///Clears the current focus. On iOS and Android native WebView, it will clear also, for example, the current text selection. /// From 4f5919242155d7d3072302cecb9bf5c235b9b1cb Mon Sep 17 00:00:00 2001 From: Doflatango Date: Mon, 8 Jul 2024 23:03:39 +0800 Subject: [PATCH 005/181] Android: implemented PlatformPrintJobController.onComplete --- .../print_job/PrintJobChannelDelegate.java | 4 ++ .../print_job/PrintJobController.java | 15 ++++-- .../webview/in_app_webview/InAppWebView.java | 50 +++++++++++++++++-- .../src/print_job/print_job_controller.dart | 3 ++ .../platform_print_job_controller.dart | 1 + 5 files changed, 64 insertions(+), 9 deletions(-) diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/print_job/PrintJobChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/print_job/PrintJobChannelDelegate.java index 1a2165670..b15717f8c 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/print_job/PrintJobChannelDelegate.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/print_job/PrintJobChannelDelegate.java @@ -62,6 +62,10 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result } } + public void onComplete() { + getChannel().invokeMethod("onComplete", null); + } + @Override public void dispose() { super.dispose(); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/print_job/PrintJobController.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/print_job/PrintJobController.java index 2283e44f6..985dfd994 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/print_job/PrintJobController.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/print_job/PrintJobController.java @@ -28,16 +28,19 @@ public class PrintJobController implements Disposable { @Nullable public PrintJobSettings settings; - public PrintJobController(@NonNull String id, @NonNull android.print.PrintJob job, - @Nullable PrintJobSettings settings, @NonNull InAppWebViewFlutterPlugin plugin) { + public PrintJobController(@NonNull String id, @Nullable PrintJobSettings settings, + @NonNull InAppWebViewFlutterPlugin plugin) { this.id = id; this.plugin = plugin; - this.job = job; this.settings = settings; final MethodChannel channel = new MethodChannel(plugin.messenger, METHOD_CHANNEL_NAME_PREFIX + id); this.channelDelegate = new PrintJobChannelDelegate(this, channel); } - + + public void setJob(@Nullable android.print.PrintJob job) { + this.job = job; + } + public void cancel() { if (this.job != null) { this.job.cancel(); @@ -93,4 +96,8 @@ public void dispose() { } plugin = null; } + + public void onComplete() { + if (channelDelegate != null) channelDelegate.onComplete(); + } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java index bde634bb7..a5fe4ccab 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java @@ -17,9 +17,12 @@ import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.os.CancellationSignal; import android.os.Handler; import android.os.Looper; import android.os.Message; +import android.os.ParcelFileDescriptor; +import android.print.PageRange; import android.print.PrintAttributes; import android.print.PrintDocumentAdapter; import android.print.PrintManager; @@ -1403,6 +1406,37 @@ public void setDesktopMode(final boolean enabled) { webSettings.setBuiltInZoomControls(enabled); } + interface PrintDocumentAdapterWrapperCallback { + void onFinish(); + } + + @RequiresApi(api = Build.VERSION_CODES.KITKAT) + class PrintDocumentAdapterWrapper extends PrintDocumentAdapter { + @NonNull PrintDocumentAdapter delegate; + @Nullable PrintDocumentAdapterWrapperCallback callback; + + PrintDocumentAdapterWrapper(@NonNull PrintDocumentAdapter delegate, @Nullable PrintDocumentAdapterWrapperCallback callback) { + this.delegate = delegate; + this.callback = callback; + } + + @Override + public void onLayout(PrintAttributes oldAttributes, PrintAttributes newAttributes, CancellationSignal cancellationSignal, LayoutResultCallback callback, Bundle extras) { + this.delegate.onLayout(oldAttributes, newAttributes, cancellationSignal, callback, extras); + } + + @Override + public void onWrite(PageRange[] pages, ParcelFileDescriptor destination, CancellationSignal cancellationSignal, WriteResultCallback callback) { + this.delegate.onWrite(pages, destination, cancellationSignal, callback); + } + + @Override + public void onFinish() { + this.delegate.onFinish(); + if (this.callback != null) this.callback.onFinish(); + } + } + @RequiresApi(api = Build.VERSION_CODES.KITKAT) @Nullable public String printCurrentPage(@Nullable PrintJobSettings settings) { @@ -1458,15 +1492,21 @@ public String printCurrentPage(@Nullable PrintJobSettings settings) { printAdapter = createPrintDocumentAdapter(); } - // Create a printCurrentPage job with name and adapter instance - android.print.PrintJob job = printManager.print(jobName, printAdapter, builder.build()); + PrintJobController printJobController = null; + String id = null; if (settings != null && settings.handledByClient && plugin.printJobManager != null) { - String id = UUID.randomUUID().toString(); - PrintJobController printJobController = new PrintJobController(id, job, settings, plugin); + id = UUID.randomUUID().toString(); + printJobController = new PrintJobController(id, settings, plugin); plugin.printJobManager.jobs.put(printJobController.id, printJobController); - return id; + printAdapter = new PrintDocumentAdapterWrapper(printAdapter, printJobController::onComplete); } + + // Create a printCurrentPage job with name and adapter instance + android.print.PrintJob job = printManager.print(jobName, printAdapter, builder.build()); + if (printJobController != null) printJobController.setJob(job); + + return id; } else { Log.e(LOG_TAG, "No PrintManager available"); } diff --git a/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart b/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart index 768311549..4ed0acb58 100644 --- a/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart +++ b/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart @@ -43,6 +43,9 @@ class AndroidPrintJobController extends PlatformPrintJobController Future _handleMethod(MethodCall call) async { switch (call.method) { + case "onComplete": + onComplete?.call(true, null); + break; default: throw UnimplementedError("Unimplemented ${call.method} method"); } diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart index e2abce439..bd4ff6f8e 100644 --- a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart @@ -73,6 +73,7 @@ abstract class PlatformPrintJobController extends PlatformInterface ///A completion handler used to handle the conclusion of the print job (for instance, to reset state) and to handle any errors encountered in printing. /// ///**Officially Supported Platforms/Implementations**: + ///- Android ([Official API - PrintDocumentAdapter.onFinish](https://developer.android.com/reference/android/print/PrintDocumentAdapter#onFinish())) ///- iOS ([Official API - UIPrintInteractionController.CompletionHandler](https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/completionhandler)) ///- MacOS ([Official API - NSPrintOperation.runModal](https://developer.apple.com/documentation/appkit/nsprintoperation/1532065-runmodal)) ///{@endtemplate} From 36eb8cb7bf9eca75672ef8f54afb26408a857097 Mon Sep 17 00:00:00 2001 From: p-mazhnik Date: Thu, 16 May 2024 13:21:07 +0300 Subject: [PATCH 006/181] [web] support iframe role attribute --- .../src/in_app_webview/in_app_webview_settings.dart | 11 +++++++++++ .../in_app_webview/in_app_webview_settings.g.dart | 13 +++++++++++-- .../lib/web/in_app_web_view_web_element.dart | 4 ++++ 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart index f12b274ce..2d86c8268 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart @@ -1652,6 +1652,16 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri ]) String? iframeCsp; + ///A string that reflects the `role` HTML attribute, containing a WAI-ARIA role for the element. + @SupportedPlatforms(platforms: [ + WebPlatform( + requiresSameOrigin: false, + apiName: "iframe.role", + apiUrl: + "https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles") + ]) + String? iframeRole; + @ExchangeableObjectConstructor() InAppWebViewSettings_({ this.useShouldOverrideUrlLoading, @@ -1794,6 +1804,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri this.iframeReferrerPolicy, this.iframeName, this.iframeCsp, + this.iframeRole, }) { if (this.minimumFontSize == null) this.minimumFontSize = Util.isAndroid ? 8 : 0; diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart index 7c30031d1..311cc0017 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart @@ -557,6 +557,12 @@ class InAppWebViewSettings { ///- Web ([Official API - iframe.referrerpolicy](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-referrerpolicy)) ReferrerPolicy? iframeReferrerPolicy; + ///A string that reflects the `role` HTML attribute, containing a WAI-ARIA role for the element. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Web ([Official API - iframe.role](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles)) + String? iframeRole; + ///Applies extra restrictions to the content in the frame. /// ///**Officially Supported Platforms/Implementations**: @@ -1338,7 +1344,8 @@ class InAppWebViewSettings { this.iframeSandbox, this.iframeReferrerPolicy, this.iframeName, - this.iframeCsp}) { + this.iframeCsp, + this.iframeRole}) { if (this.minimumFontSize == null) this.minimumFontSize = Util.isAndroid ? 8 : 0; assert(this.resourceCustomSchemes == null || @@ -1389,6 +1396,7 @@ class InAppWebViewSettings { iframeName: map['iframeName'], iframeReferrerPolicy: ReferrerPolicy.fromNativeValue(map['iframeReferrerPolicy']), + iframeRole: map['iframeRole'], iframeSandbox: map['iframeSandbox'] != null ? Set.from( map['iframeSandbox'].map((e) => Sandbox.fromNativeValue(e)!)) @@ -1640,6 +1648,7 @@ class InAppWebViewSettings { "iframeCsp": iframeCsp, "iframeName": iframeName, "iframeReferrerPolicy": iframeReferrerPolicy?.toNativeValue(), + "iframeRole": iframeRole, "iframeSandbox": iframeSandbox?.map((e) => e.toNativeValue()).toList(), "ignoresViewportScaleLimits": ignoresViewportScaleLimits, "incognito": incognito, @@ -1732,6 +1741,6 @@ class InAppWebViewSettings { @override String toString() { - return 'InAppWebViewSettings{accessibilityIgnoresInvertColors: $accessibilityIgnoresInvertColors, algorithmicDarkeningAllowed: $algorithmicDarkeningAllowed, allowBackgroundAudioPlaying: $allowBackgroundAudioPlaying, allowContentAccess: $allowContentAccess, allowFileAccess: $allowFileAccess, allowFileAccessFromFileURLs: $allowFileAccessFromFileURLs, allowUniversalAccessFromFileURLs: $allowUniversalAccessFromFileURLs, allowingReadAccessTo: $allowingReadAccessTo, allowsAirPlayForMediaPlayback: $allowsAirPlayForMediaPlayback, allowsBackForwardNavigationGestures: $allowsBackForwardNavigationGestures, allowsInlineMediaPlayback: $allowsInlineMediaPlayback, allowsLinkPreview: $allowsLinkPreview, allowsPictureInPictureMediaPlayback: $allowsPictureInPictureMediaPlayback, alwaysBounceHorizontal: $alwaysBounceHorizontal, alwaysBounceVertical: $alwaysBounceVertical, appCachePath: $appCachePath, applePayAPIEnabled: $applePayAPIEnabled, applicationNameForUserAgent: $applicationNameForUserAgent, automaticallyAdjustsScrollIndicatorInsets: $automaticallyAdjustsScrollIndicatorInsets, blockNetworkImage: $blockNetworkImage, blockNetworkLoads: $blockNetworkLoads, builtInZoomControls: $builtInZoomControls, cacheEnabled: $cacheEnabled, cacheMode: $cacheMode, contentBlockers: $contentBlockers, contentInsetAdjustmentBehavior: $contentInsetAdjustmentBehavior, cursiveFontFamily: $cursiveFontFamily, dataDetectorTypes: $dataDetectorTypes, databaseEnabled: $databaseEnabled, decelerationRate: $decelerationRate, defaultFixedFontSize: $defaultFixedFontSize, defaultFontSize: $defaultFontSize, defaultTextEncodingName: $defaultTextEncodingName, defaultVideoPoster: $defaultVideoPoster, disableContextMenu: $disableContextMenu, disableDefaultErrorPage: $disableDefaultErrorPage, disableHorizontalScroll: $disableHorizontalScroll, disableInputAccessoryView: $disableInputAccessoryView, disableLongPressContextMenuOnLinks: $disableLongPressContextMenuOnLinks, disableVerticalScroll: $disableVerticalScroll, disabledActionModeMenuItems: $disabledActionModeMenuItems, disallowOverScroll: $disallowOverScroll, displayZoomControls: $displayZoomControls, domStorageEnabled: $domStorageEnabled, enableViewportScale: $enableViewportScale, enterpriseAuthenticationAppLinkPolicyEnabled: $enterpriseAuthenticationAppLinkPolicyEnabled, fantasyFontFamily: $fantasyFontFamily, fixedFontFamily: $fixedFontFamily, forceDark: $forceDark, forceDarkStrategy: $forceDarkStrategy, geolocationEnabled: $geolocationEnabled, hardwareAcceleration: $hardwareAcceleration, horizontalScrollBarEnabled: $horizontalScrollBarEnabled, horizontalScrollbarThumbColor: $horizontalScrollbarThumbColor, horizontalScrollbarTrackColor: $horizontalScrollbarTrackColor, iframeAllow: $iframeAllow, iframeAllowFullscreen: $iframeAllowFullscreen, iframeCsp: $iframeCsp, iframeName: $iframeName, iframeReferrerPolicy: $iframeReferrerPolicy, iframeSandbox: $iframeSandbox, ignoresViewportScaleLimits: $ignoresViewportScaleLimits, incognito: $incognito, initialScale: $initialScale, interceptOnlyAsyncAjaxRequests: $interceptOnlyAsyncAjaxRequests, isDirectionalLockEnabled: $isDirectionalLockEnabled, isElementFullscreenEnabled: $isElementFullscreenEnabled, isFindInteractionEnabled: $isFindInteractionEnabled, isFraudulentWebsiteWarningEnabled: $isFraudulentWebsiteWarningEnabled, isInspectable: $isInspectable, isPagingEnabled: $isPagingEnabled, isSiteSpecificQuirksModeEnabled: $isSiteSpecificQuirksModeEnabled, isTextInteractionEnabled: $isTextInteractionEnabled, javaScriptCanOpenWindowsAutomatically: $javaScriptCanOpenWindowsAutomatically, javaScriptEnabled: $javaScriptEnabled, layoutAlgorithm: $layoutAlgorithm, limitsNavigationsToAppBoundDomains: $limitsNavigationsToAppBoundDomains, loadWithOverviewMode: $loadWithOverviewMode, loadsImagesAutomatically: $loadsImagesAutomatically, maximumViewportInset: $maximumViewportInset, maximumZoomScale: $maximumZoomScale, mediaPlaybackRequiresUserGesture: $mediaPlaybackRequiresUserGesture, mediaType: $mediaType, minimumFontSize: $minimumFontSize, minimumLogicalFontSize: $minimumLogicalFontSize, minimumViewportInset: $minimumViewportInset, minimumZoomScale: $minimumZoomScale, mixedContentMode: $mixedContentMode, needInitialFocus: $needInitialFocus, networkAvailable: $networkAvailable, offscreenPreRaster: $offscreenPreRaster, overScrollMode: $overScrollMode, pageZoom: $pageZoom, preferredContentMode: $preferredContentMode, regexToCancelSubFramesLoading: $regexToCancelSubFramesLoading, rendererPriorityPolicy: $rendererPriorityPolicy, requestedWithHeaderOriginAllowList: $requestedWithHeaderOriginAllowList, resourceCustomSchemes: $resourceCustomSchemes, safeBrowsingEnabled: $safeBrowsingEnabled, sansSerifFontFamily: $sansSerifFontFamily, saveFormData: $saveFormData, scrollBarDefaultDelayBeforeFade: $scrollBarDefaultDelayBeforeFade, scrollBarFadeDuration: $scrollBarFadeDuration, scrollBarStyle: $scrollBarStyle, scrollbarFadingEnabled: $scrollbarFadingEnabled, scrollsToTop: $scrollsToTop, selectionGranularity: $selectionGranularity, serifFontFamily: $serifFontFamily, sharedCookiesEnabled: $sharedCookiesEnabled, shouldPrintBackgrounds: $shouldPrintBackgrounds, standardFontFamily: $standardFontFamily, supportMultipleWindows: $supportMultipleWindows, supportZoom: $supportZoom, suppressesIncrementalRendering: $suppressesIncrementalRendering, textZoom: $textZoom, thirdPartyCookiesEnabled: $thirdPartyCookiesEnabled, transparentBackground: $transparentBackground, underPageBackgroundColor: $underPageBackgroundColor, upgradeKnownHostsToHTTPS: $upgradeKnownHostsToHTTPS, useHybridComposition: $useHybridComposition, useOnDownloadStart: $useOnDownloadStart, useOnLoadResource: $useOnLoadResource, useOnNavigationResponse: $useOnNavigationResponse, useOnRenderProcessGone: $useOnRenderProcessGone, useShouldInterceptAjaxRequest: $useShouldInterceptAjaxRequest, useShouldInterceptFetchRequest: $useShouldInterceptFetchRequest, useShouldInterceptRequest: $useShouldInterceptRequest, useShouldOverrideUrlLoading: $useShouldOverrideUrlLoading, useWideViewPort: $useWideViewPort, userAgent: $userAgent, verticalScrollBarEnabled: $verticalScrollBarEnabled, verticalScrollbarPosition: $verticalScrollbarPosition, verticalScrollbarThumbColor: $verticalScrollbarThumbColor, verticalScrollbarTrackColor: $verticalScrollbarTrackColor, webViewAssetLoader: $webViewAssetLoader}'; + return 'InAppWebViewSettings{accessibilityIgnoresInvertColors: $accessibilityIgnoresInvertColors, algorithmicDarkeningAllowed: $algorithmicDarkeningAllowed, allowBackgroundAudioPlaying: $allowBackgroundAudioPlaying, allowContentAccess: $allowContentAccess, allowFileAccess: $allowFileAccess, allowFileAccessFromFileURLs: $allowFileAccessFromFileURLs, allowUniversalAccessFromFileURLs: $allowUniversalAccessFromFileURLs, allowingReadAccessTo: $allowingReadAccessTo, allowsAirPlayForMediaPlayback: $allowsAirPlayForMediaPlayback, allowsBackForwardNavigationGestures: $allowsBackForwardNavigationGestures, allowsInlineMediaPlayback: $allowsInlineMediaPlayback, allowsLinkPreview: $allowsLinkPreview, allowsPictureInPictureMediaPlayback: $allowsPictureInPictureMediaPlayback, alwaysBounceHorizontal: $alwaysBounceHorizontal, alwaysBounceVertical: $alwaysBounceVertical, appCachePath: $appCachePath, applePayAPIEnabled: $applePayAPIEnabled, applicationNameForUserAgent: $applicationNameForUserAgent, automaticallyAdjustsScrollIndicatorInsets: $automaticallyAdjustsScrollIndicatorInsets, blockNetworkImage: $blockNetworkImage, blockNetworkLoads: $blockNetworkLoads, builtInZoomControls: $builtInZoomControls, cacheEnabled: $cacheEnabled, cacheMode: $cacheMode, contentBlockers: $contentBlockers, contentInsetAdjustmentBehavior: $contentInsetAdjustmentBehavior, cursiveFontFamily: $cursiveFontFamily, dataDetectorTypes: $dataDetectorTypes, databaseEnabled: $databaseEnabled, decelerationRate: $decelerationRate, defaultFixedFontSize: $defaultFixedFontSize, defaultFontSize: $defaultFontSize, defaultTextEncodingName: $defaultTextEncodingName, defaultVideoPoster: $defaultVideoPoster, disableContextMenu: $disableContextMenu, disableDefaultErrorPage: $disableDefaultErrorPage, disableHorizontalScroll: $disableHorizontalScroll, disableInputAccessoryView: $disableInputAccessoryView, disableLongPressContextMenuOnLinks: $disableLongPressContextMenuOnLinks, disableVerticalScroll: $disableVerticalScroll, disabledActionModeMenuItems: $disabledActionModeMenuItems, disallowOverScroll: $disallowOverScroll, displayZoomControls: $displayZoomControls, domStorageEnabled: $domStorageEnabled, enableViewportScale: $enableViewportScale, enterpriseAuthenticationAppLinkPolicyEnabled: $enterpriseAuthenticationAppLinkPolicyEnabled, fantasyFontFamily: $fantasyFontFamily, fixedFontFamily: $fixedFontFamily, forceDark: $forceDark, forceDarkStrategy: $forceDarkStrategy, geolocationEnabled: $geolocationEnabled, hardwareAcceleration: $hardwareAcceleration, horizontalScrollBarEnabled: $horizontalScrollBarEnabled, horizontalScrollbarThumbColor: $horizontalScrollbarThumbColor, horizontalScrollbarTrackColor: $horizontalScrollbarTrackColor, iframeAllow: $iframeAllow, iframeAllowFullscreen: $iframeAllowFullscreen, iframeCsp: $iframeCsp, iframeName: $iframeName, iframeReferrerPolicy: $iframeReferrerPolicy, iframeRole: $iframeRole, iframeSandbox: $iframeSandbox, ignoresViewportScaleLimits: $ignoresViewportScaleLimits, incognito: $incognito, initialScale: $initialScale, interceptOnlyAsyncAjaxRequests: $interceptOnlyAsyncAjaxRequests, isDirectionalLockEnabled: $isDirectionalLockEnabled, isElementFullscreenEnabled: $isElementFullscreenEnabled, isFindInteractionEnabled: $isFindInteractionEnabled, isFraudulentWebsiteWarningEnabled: $isFraudulentWebsiteWarningEnabled, isInspectable: $isInspectable, isPagingEnabled: $isPagingEnabled, isSiteSpecificQuirksModeEnabled: $isSiteSpecificQuirksModeEnabled, isTextInteractionEnabled: $isTextInteractionEnabled, javaScriptCanOpenWindowsAutomatically: $javaScriptCanOpenWindowsAutomatically, javaScriptEnabled: $javaScriptEnabled, layoutAlgorithm: $layoutAlgorithm, limitsNavigationsToAppBoundDomains: $limitsNavigationsToAppBoundDomains, loadWithOverviewMode: $loadWithOverviewMode, loadsImagesAutomatically: $loadsImagesAutomatically, maximumViewportInset: $maximumViewportInset, maximumZoomScale: $maximumZoomScale, mediaPlaybackRequiresUserGesture: $mediaPlaybackRequiresUserGesture, mediaType: $mediaType, minimumFontSize: $minimumFontSize, minimumLogicalFontSize: $minimumLogicalFontSize, minimumViewportInset: $minimumViewportInset, minimumZoomScale: $minimumZoomScale, mixedContentMode: $mixedContentMode, needInitialFocus: $needInitialFocus, networkAvailable: $networkAvailable, offscreenPreRaster: $offscreenPreRaster, overScrollMode: $overScrollMode, pageZoom: $pageZoom, preferredContentMode: $preferredContentMode, regexToCancelSubFramesLoading: $regexToCancelSubFramesLoading, rendererPriorityPolicy: $rendererPriorityPolicy, requestedWithHeaderOriginAllowList: $requestedWithHeaderOriginAllowList, resourceCustomSchemes: $resourceCustomSchemes, safeBrowsingEnabled: $safeBrowsingEnabled, sansSerifFontFamily: $sansSerifFontFamily, saveFormData: $saveFormData, scrollBarDefaultDelayBeforeFade: $scrollBarDefaultDelayBeforeFade, scrollBarFadeDuration: $scrollBarFadeDuration, scrollBarStyle: $scrollBarStyle, scrollbarFadingEnabled: $scrollbarFadingEnabled, scrollsToTop: $scrollsToTop, selectionGranularity: $selectionGranularity, serifFontFamily: $serifFontFamily, sharedCookiesEnabled: $sharedCookiesEnabled, shouldPrintBackgrounds: $shouldPrintBackgrounds, standardFontFamily: $standardFontFamily, supportMultipleWindows: $supportMultipleWindows, supportZoom: $supportZoom, suppressesIncrementalRendering: $suppressesIncrementalRendering, textZoom: $textZoom, thirdPartyCookiesEnabled: $thirdPartyCookiesEnabled, transparentBackground: $transparentBackground, underPageBackgroundColor: $underPageBackgroundColor, upgradeKnownHostsToHTTPS: $upgradeKnownHostsToHTTPS, useHybridComposition: $useHybridComposition, useOnDownloadStart: $useOnDownloadStart, useOnLoadResource: $useOnLoadResource, useOnNavigationResponse: $useOnNavigationResponse, useOnRenderProcessGone: $useOnRenderProcessGone, useShouldInterceptAjaxRequest: $useShouldInterceptAjaxRequest, useShouldInterceptFetchRequest: $useShouldInterceptFetchRequest, useShouldInterceptRequest: $useShouldInterceptRequest, useShouldOverrideUrlLoading: $useShouldOverrideUrlLoading, useWideViewPort: $useWideViewPort, userAgent: $userAgent, verticalScrollBarEnabled: $verticalScrollBarEnabled, verticalScrollbarPosition: $verticalScrollbarPosition, verticalScrollbarThumbColor: $verticalScrollbarThumbColor, verticalScrollbarTrackColor: $verticalScrollbarTrackColor, webViewAssetLoader: $webViewAssetLoader}'; } } diff --git a/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart b/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart index 2e9a114f6..fb20618e7 100644 --- a/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart +++ b/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart @@ -230,6 +230,7 @@ class InAppWebViewWebElement implements Disposable { iframe.referrerPolicy; iframe.name = settings!.iframeName ?? iframe.name; iframe.csp = settings!.iframeCsp ?? iframe.csp; + iframe.role = settings!.iframeRole ?? iframe.role; if (settings!.iframeSandbox != null && settings!.iframeSandbox != Sandbox.ALLOW_ALL) { @@ -470,6 +471,9 @@ class InAppWebViewWebElement implements Disposable { if (settings!.iframeCsp != newSettings.iframeCsp) { iframe.csp = newSettings.iframeCsp; } + if (settings!.iframeRole != newSettings.iframeRole) { + iframe.role = newSettings.iframeRole; + } if (settings!.iframeSandbox != newSettings.iframeSandbox) { var sandbox = newSettings.iframeSandbox; From abb5eec9813bc733b0504949b69115fa69498df0 Mon Sep 17 00:00:00 2001 From: p-mazhnik Date: Tue, 28 May 2024 11:54:13 +0300 Subject: [PATCH 007/181] [web] support iframe aria-hidden attribute --- .../src/in_app_webview/in_app_webview_settings.dart | 10 ++++++++++ .../in_app_webview/in_app_webview_settings.g.dart | 12 ++++++++++-- .../lib/web/in_app_web_view_web_element.dart | 4 ++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart index 2d86c8268..08bd07c18 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart @@ -1662,6 +1662,15 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri ]) String? iframeRole; + @SupportedPlatforms(platforms: [ + WebPlatform( + requiresSameOrigin: false, + apiName: "iframe.ariaHidden", + apiUrl: + "https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden") + ]) + String? iframeAriaHidden; + @ExchangeableObjectConstructor() InAppWebViewSettings_({ this.useShouldOverrideUrlLoading, @@ -1805,6 +1814,7 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri this.iframeName, this.iframeCsp, this.iframeRole, + this.iframeAriaHidden, }) { if (this.minimumFontSize == null) this.minimumFontSize = Util.isAndroid ? 8 : 0; diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart index 311cc0017..bcaaed99f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart @@ -539,6 +539,11 @@ class InAppWebViewSettings { ///- Web ([Official API - iframe.allowfullscreen](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-allowfullscreen)) bool? iframeAllowFullscreen; + /// + ///**Officially Supported Platforms/Implementations**: + ///- Web ([Official API - iframe.ariaHidden](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-hidden)) + String? iframeAriaHidden; + ///A Content Security Policy enforced for the embedded resource. /// ///**Officially Supported Platforms/Implementations**: @@ -1345,7 +1350,8 @@ class InAppWebViewSettings { this.iframeReferrerPolicy, this.iframeName, this.iframeCsp, - this.iframeRole}) { + this.iframeRole, + this.iframeAriaHidden}) { if (this.minimumFontSize == null) this.minimumFontSize = Util.isAndroid ? 8 : 0; assert(this.resourceCustomSchemes == null || @@ -1392,6 +1398,7 @@ class InAppWebViewSettings { : null, iframeAllow: map['iframeAllow'], iframeAllowFullscreen: map['iframeAllowFullscreen'], + iframeAriaHidden: map['iframeAriaHidden'], iframeCsp: map['iframeCsp'], iframeName: map['iframeName'], iframeReferrerPolicy: @@ -1645,6 +1652,7 @@ class InAppWebViewSettings { "horizontalScrollbarTrackColor": horizontalScrollbarTrackColor?.toHex(), "iframeAllow": iframeAllow, "iframeAllowFullscreen": iframeAllowFullscreen, + "iframeAriaHidden": iframeAriaHidden, "iframeCsp": iframeCsp, "iframeName": iframeName, "iframeReferrerPolicy": iframeReferrerPolicy?.toNativeValue(), @@ -1741,6 +1749,6 @@ class InAppWebViewSettings { @override String toString() { - return 'InAppWebViewSettings{accessibilityIgnoresInvertColors: $accessibilityIgnoresInvertColors, algorithmicDarkeningAllowed: $algorithmicDarkeningAllowed, allowBackgroundAudioPlaying: $allowBackgroundAudioPlaying, allowContentAccess: $allowContentAccess, allowFileAccess: $allowFileAccess, allowFileAccessFromFileURLs: $allowFileAccessFromFileURLs, allowUniversalAccessFromFileURLs: $allowUniversalAccessFromFileURLs, allowingReadAccessTo: $allowingReadAccessTo, allowsAirPlayForMediaPlayback: $allowsAirPlayForMediaPlayback, allowsBackForwardNavigationGestures: $allowsBackForwardNavigationGestures, allowsInlineMediaPlayback: $allowsInlineMediaPlayback, allowsLinkPreview: $allowsLinkPreview, allowsPictureInPictureMediaPlayback: $allowsPictureInPictureMediaPlayback, alwaysBounceHorizontal: $alwaysBounceHorizontal, alwaysBounceVertical: $alwaysBounceVertical, appCachePath: $appCachePath, applePayAPIEnabled: $applePayAPIEnabled, applicationNameForUserAgent: $applicationNameForUserAgent, automaticallyAdjustsScrollIndicatorInsets: $automaticallyAdjustsScrollIndicatorInsets, blockNetworkImage: $blockNetworkImage, blockNetworkLoads: $blockNetworkLoads, builtInZoomControls: $builtInZoomControls, cacheEnabled: $cacheEnabled, cacheMode: $cacheMode, contentBlockers: $contentBlockers, contentInsetAdjustmentBehavior: $contentInsetAdjustmentBehavior, cursiveFontFamily: $cursiveFontFamily, dataDetectorTypes: $dataDetectorTypes, databaseEnabled: $databaseEnabled, decelerationRate: $decelerationRate, defaultFixedFontSize: $defaultFixedFontSize, defaultFontSize: $defaultFontSize, defaultTextEncodingName: $defaultTextEncodingName, defaultVideoPoster: $defaultVideoPoster, disableContextMenu: $disableContextMenu, disableDefaultErrorPage: $disableDefaultErrorPage, disableHorizontalScroll: $disableHorizontalScroll, disableInputAccessoryView: $disableInputAccessoryView, disableLongPressContextMenuOnLinks: $disableLongPressContextMenuOnLinks, disableVerticalScroll: $disableVerticalScroll, disabledActionModeMenuItems: $disabledActionModeMenuItems, disallowOverScroll: $disallowOverScroll, displayZoomControls: $displayZoomControls, domStorageEnabled: $domStorageEnabled, enableViewportScale: $enableViewportScale, enterpriseAuthenticationAppLinkPolicyEnabled: $enterpriseAuthenticationAppLinkPolicyEnabled, fantasyFontFamily: $fantasyFontFamily, fixedFontFamily: $fixedFontFamily, forceDark: $forceDark, forceDarkStrategy: $forceDarkStrategy, geolocationEnabled: $geolocationEnabled, hardwareAcceleration: $hardwareAcceleration, horizontalScrollBarEnabled: $horizontalScrollBarEnabled, horizontalScrollbarThumbColor: $horizontalScrollbarThumbColor, horizontalScrollbarTrackColor: $horizontalScrollbarTrackColor, iframeAllow: $iframeAllow, iframeAllowFullscreen: $iframeAllowFullscreen, iframeCsp: $iframeCsp, iframeName: $iframeName, iframeReferrerPolicy: $iframeReferrerPolicy, iframeRole: $iframeRole, iframeSandbox: $iframeSandbox, ignoresViewportScaleLimits: $ignoresViewportScaleLimits, incognito: $incognito, initialScale: $initialScale, interceptOnlyAsyncAjaxRequests: $interceptOnlyAsyncAjaxRequests, isDirectionalLockEnabled: $isDirectionalLockEnabled, isElementFullscreenEnabled: $isElementFullscreenEnabled, isFindInteractionEnabled: $isFindInteractionEnabled, isFraudulentWebsiteWarningEnabled: $isFraudulentWebsiteWarningEnabled, isInspectable: $isInspectable, isPagingEnabled: $isPagingEnabled, isSiteSpecificQuirksModeEnabled: $isSiteSpecificQuirksModeEnabled, isTextInteractionEnabled: $isTextInteractionEnabled, javaScriptCanOpenWindowsAutomatically: $javaScriptCanOpenWindowsAutomatically, javaScriptEnabled: $javaScriptEnabled, layoutAlgorithm: $layoutAlgorithm, limitsNavigationsToAppBoundDomains: $limitsNavigationsToAppBoundDomains, loadWithOverviewMode: $loadWithOverviewMode, loadsImagesAutomatically: $loadsImagesAutomatically, maximumViewportInset: $maximumViewportInset, maximumZoomScale: $maximumZoomScale, mediaPlaybackRequiresUserGesture: $mediaPlaybackRequiresUserGesture, mediaType: $mediaType, minimumFontSize: $minimumFontSize, minimumLogicalFontSize: $minimumLogicalFontSize, minimumViewportInset: $minimumViewportInset, minimumZoomScale: $minimumZoomScale, mixedContentMode: $mixedContentMode, needInitialFocus: $needInitialFocus, networkAvailable: $networkAvailable, offscreenPreRaster: $offscreenPreRaster, overScrollMode: $overScrollMode, pageZoom: $pageZoom, preferredContentMode: $preferredContentMode, regexToCancelSubFramesLoading: $regexToCancelSubFramesLoading, rendererPriorityPolicy: $rendererPriorityPolicy, requestedWithHeaderOriginAllowList: $requestedWithHeaderOriginAllowList, resourceCustomSchemes: $resourceCustomSchemes, safeBrowsingEnabled: $safeBrowsingEnabled, sansSerifFontFamily: $sansSerifFontFamily, saveFormData: $saveFormData, scrollBarDefaultDelayBeforeFade: $scrollBarDefaultDelayBeforeFade, scrollBarFadeDuration: $scrollBarFadeDuration, scrollBarStyle: $scrollBarStyle, scrollbarFadingEnabled: $scrollbarFadingEnabled, scrollsToTop: $scrollsToTop, selectionGranularity: $selectionGranularity, serifFontFamily: $serifFontFamily, sharedCookiesEnabled: $sharedCookiesEnabled, shouldPrintBackgrounds: $shouldPrintBackgrounds, standardFontFamily: $standardFontFamily, supportMultipleWindows: $supportMultipleWindows, supportZoom: $supportZoom, suppressesIncrementalRendering: $suppressesIncrementalRendering, textZoom: $textZoom, thirdPartyCookiesEnabled: $thirdPartyCookiesEnabled, transparentBackground: $transparentBackground, underPageBackgroundColor: $underPageBackgroundColor, upgradeKnownHostsToHTTPS: $upgradeKnownHostsToHTTPS, useHybridComposition: $useHybridComposition, useOnDownloadStart: $useOnDownloadStart, useOnLoadResource: $useOnLoadResource, useOnNavigationResponse: $useOnNavigationResponse, useOnRenderProcessGone: $useOnRenderProcessGone, useShouldInterceptAjaxRequest: $useShouldInterceptAjaxRequest, useShouldInterceptFetchRequest: $useShouldInterceptFetchRequest, useShouldInterceptRequest: $useShouldInterceptRequest, useShouldOverrideUrlLoading: $useShouldOverrideUrlLoading, useWideViewPort: $useWideViewPort, userAgent: $userAgent, verticalScrollBarEnabled: $verticalScrollBarEnabled, verticalScrollbarPosition: $verticalScrollbarPosition, verticalScrollbarThumbColor: $verticalScrollbarThumbColor, verticalScrollbarTrackColor: $verticalScrollbarTrackColor, webViewAssetLoader: $webViewAssetLoader}'; + return 'InAppWebViewSettings{accessibilityIgnoresInvertColors: $accessibilityIgnoresInvertColors, algorithmicDarkeningAllowed: $algorithmicDarkeningAllowed, allowBackgroundAudioPlaying: $allowBackgroundAudioPlaying, allowContentAccess: $allowContentAccess, allowFileAccess: $allowFileAccess, allowFileAccessFromFileURLs: $allowFileAccessFromFileURLs, allowUniversalAccessFromFileURLs: $allowUniversalAccessFromFileURLs, allowingReadAccessTo: $allowingReadAccessTo, allowsAirPlayForMediaPlayback: $allowsAirPlayForMediaPlayback, allowsBackForwardNavigationGestures: $allowsBackForwardNavigationGestures, allowsInlineMediaPlayback: $allowsInlineMediaPlayback, allowsLinkPreview: $allowsLinkPreview, allowsPictureInPictureMediaPlayback: $allowsPictureInPictureMediaPlayback, alwaysBounceHorizontal: $alwaysBounceHorizontal, alwaysBounceVertical: $alwaysBounceVertical, appCachePath: $appCachePath, applePayAPIEnabled: $applePayAPIEnabled, applicationNameForUserAgent: $applicationNameForUserAgent, automaticallyAdjustsScrollIndicatorInsets: $automaticallyAdjustsScrollIndicatorInsets, blockNetworkImage: $blockNetworkImage, blockNetworkLoads: $blockNetworkLoads, builtInZoomControls: $builtInZoomControls, cacheEnabled: $cacheEnabled, cacheMode: $cacheMode, contentBlockers: $contentBlockers, contentInsetAdjustmentBehavior: $contentInsetAdjustmentBehavior, cursiveFontFamily: $cursiveFontFamily, dataDetectorTypes: $dataDetectorTypes, databaseEnabled: $databaseEnabled, decelerationRate: $decelerationRate, defaultFixedFontSize: $defaultFixedFontSize, defaultFontSize: $defaultFontSize, defaultTextEncodingName: $defaultTextEncodingName, defaultVideoPoster: $defaultVideoPoster, disableContextMenu: $disableContextMenu, disableDefaultErrorPage: $disableDefaultErrorPage, disableHorizontalScroll: $disableHorizontalScroll, disableInputAccessoryView: $disableInputAccessoryView, disableLongPressContextMenuOnLinks: $disableLongPressContextMenuOnLinks, disableVerticalScroll: $disableVerticalScroll, disabledActionModeMenuItems: $disabledActionModeMenuItems, disallowOverScroll: $disallowOverScroll, displayZoomControls: $displayZoomControls, domStorageEnabled: $domStorageEnabled, enableViewportScale: $enableViewportScale, enterpriseAuthenticationAppLinkPolicyEnabled: $enterpriseAuthenticationAppLinkPolicyEnabled, fantasyFontFamily: $fantasyFontFamily, fixedFontFamily: $fixedFontFamily, forceDark: $forceDark, forceDarkStrategy: $forceDarkStrategy, geolocationEnabled: $geolocationEnabled, hardwareAcceleration: $hardwareAcceleration, horizontalScrollBarEnabled: $horizontalScrollBarEnabled, horizontalScrollbarThumbColor: $horizontalScrollbarThumbColor, horizontalScrollbarTrackColor: $horizontalScrollbarTrackColor, iframeAllow: $iframeAllow, iframeAllowFullscreen: $iframeAllowFullscreen, iframeAriaHidden: $iframeAriaHidden, iframeCsp: $iframeCsp, iframeName: $iframeName, iframeReferrerPolicy: $iframeReferrerPolicy, iframeRole: $iframeRole, iframeSandbox: $iframeSandbox, ignoresViewportScaleLimits: $ignoresViewportScaleLimits, incognito: $incognito, initialScale: $initialScale, interceptOnlyAsyncAjaxRequests: $interceptOnlyAsyncAjaxRequests, isDirectionalLockEnabled: $isDirectionalLockEnabled, isElementFullscreenEnabled: $isElementFullscreenEnabled, isFindInteractionEnabled: $isFindInteractionEnabled, isFraudulentWebsiteWarningEnabled: $isFraudulentWebsiteWarningEnabled, isInspectable: $isInspectable, isPagingEnabled: $isPagingEnabled, isSiteSpecificQuirksModeEnabled: $isSiteSpecificQuirksModeEnabled, isTextInteractionEnabled: $isTextInteractionEnabled, javaScriptCanOpenWindowsAutomatically: $javaScriptCanOpenWindowsAutomatically, javaScriptEnabled: $javaScriptEnabled, layoutAlgorithm: $layoutAlgorithm, limitsNavigationsToAppBoundDomains: $limitsNavigationsToAppBoundDomains, loadWithOverviewMode: $loadWithOverviewMode, loadsImagesAutomatically: $loadsImagesAutomatically, maximumViewportInset: $maximumViewportInset, maximumZoomScale: $maximumZoomScale, mediaPlaybackRequiresUserGesture: $mediaPlaybackRequiresUserGesture, mediaType: $mediaType, minimumFontSize: $minimumFontSize, minimumLogicalFontSize: $minimumLogicalFontSize, minimumViewportInset: $minimumViewportInset, minimumZoomScale: $minimumZoomScale, mixedContentMode: $mixedContentMode, needInitialFocus: $needInitialFocus, networkAvailable: $networkAvailable, offscreenPreRaster: $offscreenPreRaster, overScrollMode: $overScrollMode, pageZoom: $pageZoom, preferredContentMode: $preferredContentMode, regexToCancelSubFramesLoading: $regexToCancelSubFramesLoading, rendererPriorityPolicy: $rendererPriorityPolicy, requestedWithHeaderOriginAllowList: $requestedWithHeaderOriginAllowList, resourceCustomSchemes: $resourceCustomSchemes, safeBrowsingEnabled: $safeBrowsingEnabled, sansSerifFontFamily: $sansSerifFontFamily, saveFormData: $saveFormData, scrollBarDefaultDelayBeforeFade: $scrollBarDefaultDelayBeforeFade, scrollBarFadeDuration: $scrollBarFadeDuration, scrollBarStyle: $scrollBarStyle, scrollbarFadingEnabled: $scrollbarFadingEnabled, scrollsToTop: $scrollsToTop, selectionGranularity: $selectionGranularity, serifFontFamily: $serifFontFamily, sharedCookiesEnabled: $sharedCookiesEnabled, shouldPrintBackgrounds: $shouldPrintBackgrounds, standardFontFamily: $standardFontFamily, supportMultipleWindows: $supportMultipleWindows, supportZoom: $supportZoom, suppressesIncrementalRendering: $suppressesIncrementalRendering, textZoom: $textZoom, thirdPartyCookiesEnabled: $thirdPartyCookiesEnabled, transparentBackground: $transparentBackground, underPageBackgroundColor: $underPageBackgroundColor, upgradeKnownHostsToHTTPS: $upgradeKnownHostsToHTTPS, useHybridComposition: $useHybridComposition, useOnDownloadStart: $useOnDownloadStart, useOnLoadResource: $useOnLoadResource, useOnNavigationResponse: $useOnNavigationResponse, useOnRenderProcessGone: $useOnRenderProcessGone, useShouldInterceptAjaxRequest: $useShouldInterceptAjaxRequest, useShouldInterceptFetchRequest: $useShouldInterceptFetchRequest, useShouldInterceptRequest: $useShouldInterceptRequest, useShouldOverrideUrlLoading: $useShouldOverrideUrlLoading, useWideViewPort: $useWideViewPort, userAgent: $userAgent, verticalScrollBarEnabled: $verticalScrollBarEnabled, verticalScrollbarPosition: $verticalScrollbarPosition, verticalScrollbarThumbColor: $verticalScrollbarThumbColor, verticalScrollbarTrackColor: $verticalScrollbarTrackColor, webViewAssetLoader: $webViewAssetLoader}'; } } diff --git a/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart b/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart index fb20618e7..3bf38f34c 100644 --- a/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart +++ b/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart @@ -231,6 +231,7 @@ class InAppWebViewWebElement implements Disposable { iframe.name = settings!.iframeName ?? iframe.name; iframe.csp = settings!.iframeCsp ?? iframe.csp; iframe.role = settings!.iframeRole ?? iframe.role; + iframe.ariaHidden = settings!.iframeAriaHidden ?? iframe.ariaHidden; if (settings!.iframeSandbox != null && settings!.iframeSandbox != Sandbox.ALLOW_ALL) { @@ -474,6 +475,9 @@ class InAppWebViewWebElement implements Disposable { if (settings!.iframeRole != newSettings.iframeRole) { iframe.role = newSettings.iframeRole; } + if (settings!.iframeAriaHidden != newSettings.iframeAriaHidden) { + iframe.ariaHidden = newSettings.iframeAriaHidden; + } if (settings!.iframeSandbox != newSettings.iframeSandbox) { var sandbox = newSettings.iframeSandbox; From 6a0c1927bd439ee206b6222a0d6ab2cd25b14a6f Mon Sep 17 00:00:00 2001 From: nnnlog Date: Thu, 3 Oct 2024 23:50:44 +0900 Subject: [PATCH 008/181] change priority of DispatchQueue --- .../ios/Classes/InAppWebView/InAppWebView.swift | 4 ++-- .../ios/Classes/InAppWebView/WebViewChannelDelegate.swift | 8 ++++---- .../macos/Classes/InAppWebView/InAppWebView.swift | 4 ++-- .../Classes/InAppWebView/WebViewChannelDelegate.swift | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift index 43ac03776..788795159 100755 --- a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift @@ -2072,7 +2072,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, if let scheme = challenge.protectionSpace.protocol, scheme == "https" { // workaround for ProtectionSpace SSL Certificate // https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { if let sslCertificate = challenge.protectionSpace.sslCertificate { DispatchQueue.main.async { InAppWebView.sslCertificatesMap[challenge.protectionSpace.host] = sslCertificate @@ -2092,7 +2092,7 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, break case 1: // workaround for https://github.com/pichillilorenzo/flutter_inappwebview/issues/1924 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { let exceptions = SecTrustCopyExceptions(serverTrust) SecTrustSetExceptions(serverTrust, exceptions) let credential = URLCredential(trust: serverTrust) diff --git a/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift b/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift index 46bab6d05..0f389de04 100644 --- a/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift @@ -965,7 +965,7 @@ public class WebViewChannelDelegate: ChannelDelegate { } // workaround for ProtectionSpace.toMap() SSL Certificate // https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { let arguments = challenge.toMap() DispatchQueue.main.async { [weak self] in if self?.channel == nil { @@ -997,7 +997,7 @@ public class WebViewChannelDelegate: ChannelDelegate { } // workaround for ProtectionSpace.toMap() SSL Certificate // https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { let arguments = challenge.toMap() DispatchQueue.main.async { [weak self] in if self?.channel == nil { @@ -1029,7 +1029,7 @@ public class WebViewChannelDelegate: ChannelDelegate { } // workaround for ProtectionSpace.toMap() SSL Certificate // https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { let arguments = challenge.toMap() DispatchQueue.main.async { [weak self] in if self?.channel == nil { @@ -1142,7 +1142,7 @@ public class WebViewChannelDelegate: ChannelDelegate { } // workaround for ProtectionSpace.toMap() SSL Certificate // https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { let arguments = challenge.toMap() DispatchQueue.main.async { [weak self] in if self?.channel == nil { diff --git a/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift b/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift index 5e73f981c..3d3e36f40 100755 --- a/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift @@ -1455,7 +1455,7 @@ public class InAppWebView: WKWebView, WKUIDelegate, if let scheme = challenge.protectionSpace.protocol, scheme == "https" { // workaround for ProtectionSpace SSL Certificate // https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { if let sslCertificate = challenge.protectionSpace.sslCertificate { DispatchQueue.main.async { InAppWebView.sslCertificatesMap[challenge.protectionSpace.host] = sslCertificate @@ -1475,7 +1475,7 @@ public class InAppWebView: WKWebView, WKUIDelegate, break case 1: // workaround for https://github.com/pichillilorenzo/flutter_inappwebview/issues/1924 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { let exceptions = SecTrustCopyExceptions(serverTrust) SecTrustSetExceptions(serverTrust, exceptions) let credential = URLCredential(trust: serverTrust) diff --git a/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegate.swift b/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegate.swift index 9eb906e57..ff36c597d 100644 --- a/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegate.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegate.swift @@ -928,7 +928,7 @@ public class WebViewChannelDelegate: ChannelDelegate { } // workaround for ProtectionSpace.toMap() SSL Certificate // https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { let arguments = challenge.toMap() DispatchQueue.main.async { [weak self] in if self?.channel == nil { @@ -960,7 +960,7 @@ public class WebViewChannelDelegate: ChannelDelegate { } // workaround for ProtectionSpace.toMap() SSL Certificate // https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { let arguments = challenge.toMap() DispatchQueue.main.async { [weak self] in if self?.channel == nil { @@ -992,7 +992,7 @@ public class WebViewChannelDelegate: ChannelDelegate { } // workaround for ProtectionSpace.toMap() SSL Certificate // https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { let arguments = challenge.toMap() DispatchQueue.main.async { [weak self] in if self?.channel == nil { @@ -1105,7 +1105,7 @@ public class WebViewChannelDelegate: ChannelDelegate { } // workaround for ProtectionSpace.toMap() SSL Certificate // https://github.com/pichillilorenzo/flutter_inappwebview/issues/1678 - DispatchQueue.global(qos: .background).async { + DispatchQueue.global().async { let arguments = challenge.toMap() DispatchQueue.main.async { [weak self] in if self?.channel == nil { From 952aa783912c9b0fd98d01e3c2c707d97512cd63 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Oct 2024 00:00:48 +0200 Subject: [PATCH 009/181] windows: Updated code to support multiple flutter windows --- flutter_inappwebview_windows/CHANGELOG.md | 4 ++ flutter_inappwebview_windows/pubspec.yaml | 2 +- .../windows/cookie_manager.cpp | 2 +- .../custom_platform_view.cc | 13 ++++- .../custom_platform_view.h | 2 + .../flutter_inappwebview_windows_plugin.cpp | 8 ++- .../headless_in_app_webview_manager.cpp | 7 ++- .../headless_webview_channel_delegate.cpp | 6 ++ .../windows/in_app_browser/in_app_browser.cpp | 10 +++- .../in_app_browser/in_app_browser_manager.cpp | 10 +++- .../in_app_webview/in_app_webview_manager.cpp | 58 ++++++++++++------- .../in_app_webview/in_app_webview_manager.h | 12 ++-- .../windows/types/channel_delegate.cpp | 10 +++- .../windows/types/channel_delegate.h | 2 + 14 files changed, 106 insertions(+), 40 deletions(-) diff --git a/flutter_inappwebview_windows/CHANGELOG.md b/flutter_inappwebview_windows/CHANGELOG.md index a1051a195..dd1cc41a6 100644 --- a/flutter_inappwebview_windows/CHANGELOG.md +++ b/flutter_inappwebview_windows/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.0 + +- Updated code to support multiple flutter windows + ## 0.5.0+2 - Fixed `InAppWebViewController.callAsyncJavaScript` not working with JSON objects diff --git a/flutter_inappwebview_windows/pubspec.yaml b/flutter_inappwebview_windows/pubspec.yaml index ed5710fcb..d1c3ce45d 100644 --- a/flutter_inappwebview_windows/pubspec.yaml +++ b/flutter_inappwebview_windows/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_windows description: Windows implementation of the flutter_inappwebview plugin. -version: 0.5.0+2 +version: 0.6.0 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_windows issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues diff --git a/flutter_inappwebview_windows/windows/cookie_manager.cpp b/flutter_inappwebview_windows/windows/cookie_manager.cpp index 2fa0eb5d3..7ea8750c6 100644 --- a/flutter_inappwebview_windows/windows/cookie_manager.cpp +++ b/flutter_inappwebview_windows/windows/cookie_manager.cpp @@ -25,7 +25,7 @@ namespace flutter_inappwebview_plugin auto webViewEnvironmentId = get_optional_fl_map_value(arguments, "webViewEnvironmentId"); - auto webViewEnvironment = webViewEnvironmentId.has_value() && map_contains(plugin->webViewEnvironmentManager->webViewEnvironments, webViewEnvironmentId.value()) + auto webViewEnvironment = plugin && webViewEnvironmentId.has_value() && map_contains(plugin->webViewEnvironmentManager->webViewEnvironments, webViewEnvironmentId.value()) ? plugin->webViewEnvironmentManager->webViewEnvironments.at(webViewEnvironmentId.value()).get() : nullptr; auto result_ = std::shared_ptr>(std::move(result)); diff --git a/flutter_inappwebview_windows/windows/custom_platform_view/custom_platform_view.cc b/flutter_inappwebview_windows/windows/custom_platform_view/custom_platform_view.cc index 1b6a3ff88..8ce649f4b 100644 --- a/flutter_inappwebview_windows/windows/custom_platform_view/custom_platform_view.cc +++ b/flutter_inappwebview_windows/windows/custom_platform_view/custom_platform_view.cc @@ -186,12 +186,21 @@ namespace flutter_inappwebview_plugin event_channel_->SetStreamHandler(std::move(handler)); } + void CustomPlatformView::UnregisterMethodCallHandler() const + { + if (method_channel_) { + method_channel_->SetMethodCallHandler(nullptr); + if (view && view->channelDelegate) { + view->channelDelegate->UnregisterMethodCallHandler(); + } + } + } + CustomPlatformView::~CustomPlatformView() { debugLog("dealloc CustomPlatformView"); - method_channel_->SetMethodCallHandler(nullptr); event_sink_ = nullptr; - texture_registrar_->UnregisterTexture(texture_id_); + texture_registrar_->UnregisterTexture(texture_id_, nullptr); } void CustomPlatformView::RegisterEventHandlers() diff --git a/flutter_inappwebview_windows/windows/custom_platform_view/custom_platform_view.h b/flutter_inappwebview_windows/windows/custom_platform_view/custom_platform_view.h index 35946f340..65db5476a 100644 --- a/flutter_inappwebview_windows/windows/custom_platform_view/custom_platform_view.h +++ b/flutter_inappwebview_windows/windows/custom_platform_view/custom_platform_view.h @@ -29,6 +29,8 @@ namespace flutter_inappwebview_plugin TextureBridge* texture_bridge() const { return texture_bridge_.get(); } int64_t texture_id() const { return texture_id_; } + + void UnregisterMethodCallHandler() const; private: HWND hwnd_; std::unique_ptr flutter_texture_; diff --git a/flutter_inappwebview_windows/windows/flutter_inappwebview_windows_plugin.cpp b/flutter_inappwebview_windows/windows/flutter_inappwebview_windows_plugin.cpp index a616a89bd..ed1f29fea 100644 --- a/flutter_inappwebview_windows/windows/flutter_inappwebview_windows_plugin.cpp +++ b/flutter_inappwebview_windows/windows/flutter_inappwebview_windows_plugin.cpp @@ -33,5 +33,11 @@ namespace flutter_inappwebview_plugin } FlutterInappwebviewWindowsPlugin::~FlutterInappwebviewWindowsPlugin() - {} + { + webViewEnvironmentManager = nullptr; + inAppWebViewManager = nullptr; + inAppBrowserManager = nullptr; + headlessInAppWebViewManager = nullptr; + cookieManager = nullptr; + } } \ No newline at end of file diff --git a/flutter_inappwebview_windows/windows/headless_in_app_webview/headless_in_app_webview_manager.cpp b/flutter_inappwebview_windows/windows/headless_in_app_webview/headless_in_app_webview_manager.cpp index e5ff4c447..a74587d59 100644 --- a/flutter_inappwebview_windows/windows/headless_in_app_webview/headless_in_app_webview_manager.cpp +++ b/flutter_inappwebview_windows/windows/headless_in_app_webview/headless_in_app_webview_manager.cpp @@ -46,6 +46,11 @@ namespace flutter_inappwebview_plugin { auto result_ = std::shared_ptr>(std::move(result)); + if (!plugin) { + result_->Error("0", "Cannot create the HeadlessInAppWebView instance!"); + return; + } + auto id = get_fl_map_value(*arguments, "id"); auto params = get_fl_map_value(*arguments, "params"); @@ -80,7 +85,7 @@ namespace flutter_inappwebview_plugin wil::com_ptr webViewController, wil::com_ptr webViewCompositionController) { - if (webViewEnv && webViewController) { + if (plugin && webViewEnv && webViewController) { std::optional>> initialUserScripts = initialUserScriptList.has_value() ? functional_map(initialUserScriptList.value(), [](const flutter::EncodableValue& map) { return std::make_shared(std::get(map)); }) : std::optional>>{}; diff --git a/flutter_inappwebview_windows/windows/headless_in_app_webview/headless_webview_channel_delegate.cpp b/flutter_inappwebview_windows/windows/headless_in_app_webview/headless_webview_channel_delegate.cpp index 5aadab56c..95099be68 100644 --- a/flutter_inappwebview_windows/windows/headless_in_app_webview/headless_webview_channel_delegate.cpp +++ b/flutter_inappwebview_windows/windows/headless_in_app_webview/headless_webview_channel_delegate.cpp @@ -29,6 +29,12 @@ namespace flutter_inappwebview_plugin std::map>& webViews = webView->plugin->headlessInAppWebViewManager->webViews; auto& id = webView->id; if (map_contains(webViews, id)) { + if (webView->channelDelegate) { + webView->channelDelegate->UnregisterMethodCallHandler(); + if (webView->webView && webView->webView->channelDelegate) { + webView->webView->channelDelegate->UnregisterMethodCallHandler(); + } + } webViews.erase(id); } } diff --git a/flutter_inappwebview_windows/windows/in_app_browser/in_app_browser.cpp b/flutter_inappwebview_windows/windows/in_app_browser/in_app_browser.cpp index ec9ad3900..d85f11102 100644 --- a/flutter_inappwebview_windows/windows/in_app_browser/in_app_browser.cpp +++ b/flutter_inappwebview_windows/windows/in_app_browser/in_app_browser.cpp @@ -200,12 +200,18 @@ namespace flutter_inappwebview_plugin if (!destroyed_) { destroyed_ = true; - webView.reset(); - if (channelDelegate) { channelDelegate->onExit(); } + if (channelDelegate) { + channelDelegate->UnregisterMethodCallHandler(); + if (webView && webView->channelDelegate) { + webView->channelDelegate->UnregisterMethodCallHandler(); + } + } + webView.reset(); + if (plugin && plugin->inAppBrowserManager) { plugin->inAppBrowserManager->browsers.erase(id); } diff --git a/flutter_inappwebview_windows/windows/in_app_browser/in_app_browser_manager.cpp b/flutter_inappwebview_windows/windows/in_app_browser/in_app_browser_manager.cpp index 461300679..7f210f7bb 100644 --- a/flutter_inappwebview_windows/windows/in_app_browser/in_app_browser_manager.cpp +++ b/flutter_inappwebview_windows/windows/in_app_browser/in_app_browser_manager.cpp @@ -25,8 +25,14 @@ namespace flutter_inappwebview_plugin auto& methodName = method_call.method_name(); if (string_equals(methodName, "open")) { - createInAppBrowser(arguments); - result->Success(true); + if (plugin) { + createInAppBrowser(arguments); + result->Success(true); + } + else { + result->Error("0", "Cannot create the InAppBrowser instance!"); + + } } else if (string_equals(methodName, "openWithSystemBrowser")) { auto url = get_fl_map_value(*arguments, "url"); diff --git a/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.cpp b/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.cpp index 9b6850930..5f025c678 100644 --- a/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.cpp +++ b/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.cpp @@ -18,29 +18,32 @@ namespace flutter_inappwebview_plugin { InAppWebViewManager::InAppWebViewManager(const FlutterInappwebviewWindowsPlugin* plugin) : plugin(plugin), - ChannelDelegate(plugin->registrar->messenger(), InAppWebViewManager::METHOD_CHANNEL_NAME), - rohelper_(std::make_unique(RO_INIT_SINGLETHREADED)) + ChannelDelegate(plugin->registrar->messenger(), InAppWebViewManager::METHOD_CHANNEL_NAME) { - if (rohelper_->WinRtAvailable()) { - DispatcherQueueOptions options{ sizeof(DispatcherQueueOptions), - DQTYPE_THREAD_CURRENT, DQTAT_COM_STA }; - - if (FAILED(rohelper_->CreateDispatcherQueueController( - options, dispatcher_queue_controller_.put()))) { - std::cerr << "Creating DispatcherQueueController failed." << std::endl; - return; - } + if (!rohelper_) { + rohelper_ = std::make_unique(RO_INIT_SINGLETHREADED); - if (!isGraphicsCaptureSessionSupported()) { - std::cerr << "Windows::Graphics::Capture::GraphicsCaptureSession is not " - "supported." - << std::endl; - return; - } + if (rohelper_->WinRtAvailable()) { + DispatcherQueueOptions options{ sizeof(DispatcherQueueOptions), + DQTYPE_THREAD_CURRENT, DQTAT_COM_STA }; + + if (FAILED(rohelper_->CreateDispatcherQueueController( + options, dispatcher_queue_controller_.put()))) { + std::cerr << "Creating DispatcherQueueController failed." << std::endl; + return; + } + + if (!isGraphicsCaptureSessionSupported()) { + std::cerr << "Windows::Graphics::Capture::GraphicsCaptureSession is not " + "supported." + << std::endl; + return; + } - graphics_context_ = std::make_unique(rohelper_.get()); - compositor_ = graphics_context_->CreateCompositor(); - valid_ = graphics_context_->IsValid(); + graphics_context_ = std::make_unique(rohelper_.get()); + compositor_ = graphics_context_->CreateCompositor(); + valid_ = graphics_context_->IsValid(); + } } windowClass_.lpszClassName = CustomPlatformView::CLASS_NAME; @@ -66,6 +69,10 @@ namespace flutter_inappwebview_plugin else if (string_equals(methodName, "dispose")) { auto id = get_fl_map_value(*arguments, "id"); if (map_contains(webViews, (uint64_t)id)) { + auto platformView = webViews.at(id).get(); + if (platformView) { + platformView->UnregisterMethodCallHandler(); + } webViews.erase(id); } result->Success(); @@ -84,6 +91,11 @@ namespace flutter_inappwebview_plugin { auto result_ = std::shared_ptr>(std::move(result)); + if (!plugin) { + result_->Error("0", "Cannot create the InAppWebView instance!"); + return; + } + auto settingsMap = get_fl_map_value(*arguments, "initialSettings"); auto urlRequestMap = get_optional_fl_map_value(*arguments, "initialUrlRequest"); auto initialFile = get_optional_fl_map_value(*arguments, "initialFile"); @@ -126,7 +138,7 @@ namespace flutter_inappwebview_plugin wil::com_ptr webViewController, wil::com_ptr webViewCompositionController) { - if (webViewEnv && webViewController && webViewCompositionController) { + if (plugin && webViewEnv && webViewController && webViewCompositionController) { std::optional>> initialUserScripts = initialUserScriptList.has_value() ? functional_map(initialUserScriptList.value(), [](const flutter::EncodableValue& map) { return std::make_shared(std::get(map)); }) : std::optional>>{}; @@ -186,6 +198,10 @@ namespace flutter_inappwebview_plugin void InAppWebViewManager::disposeKeepAlive(const std::string& keepAliveId) { if (map_contains(keepAliveWebViews, keepAliveId)) { + auto platformView = keepAliveWebViews.at(keepAliveId).get(); + if (platformView) { + platformView->UnregisterMethodCallHandler(); + } keepAliveWebViews.erase(keepAliveId); } } diff --git a/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.h b/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.h index f48c799e7..f66d649dd 100644 --- a/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.h +++ b/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.h @@ -52,13 +52,13 @@ namespace flutter_inappwebview_plugin void createInAppWebView(const flutter::EncodableMap* arguments, std::unique_ptr> result); void disposeKeepAlive(const std::string& keepAliveId); private: - std::unique_ptr rohelper_; - winrt::com_ptr - dispatcher_queue_controller_; - std::unique_ptr graphics_context_; - winrt::com_ptr compositor_; + inline static std::shared_ptr rohelper_ = nullptr; + inline static winrt::com_ptr + dispatcher_queue_controller_ = nullptr; + inline static std::unique_ptr graphics_context_ = nullptr; + inline static winrt::com_ptr compositor_ = nullptr; WNDCLASS windowClass_ = {}; - bool valid_ = false; + inline static bool valid_ = false; }; } #endif //FLUTTER_INAPPWEBVIEW_PLUGIN_IN_APP_WEBVIEW_MANAGER_H_ \ No newline at end of file diff --git a/flutter_inappwebview_windows/windows/types/channel_delegate.cpp b/flutter_inappwebview_windows/windows/types/channel_delegate.cpp index 983a2366f..b5db15048 100644 --- a/flutter_inappwebview_windows/windows/types/channel_delegate.cpp +++ b/flutter_inappwebview_windows/windows/types/channel_delegate.cpp @@ -24,12 +24,16 @@ namespace flutter_inappwebview_plugin std::unique_ptr> result) {} - ChannelDelegate::~ChannelDelegate() + void ChannelDelegate::UnregisterMethodCallHandler() const { - messenger = nullptr; - if (channel != nullptr) { + if (channel) { channel->SetMethodCallHandler(nullptr); } + } + + ChannelDelegate::~ChannelDelegate() + { + messenger = nullptr; channel.reset(); } } \ No newline at end of file diff --git a/flutter_inappwebview_windows/windows/types/channel_delegate.h b/flutter_inappwebview_windows/windows/types/channel_delegate.h index a412b7d10..5ccfdfa12 100644 --- a/flutter_inappwebview_windows/windows/types/channel_delegate.h +++ b/flutter_inappwebview_windows/windows/types/channel_delegate.h @@ -19,6 +19,8 @@ namespace flutter_inappwebview_plugin virtual void HandleMethodCall( const flutter::MethodCall& method_call, std::unique_ptr> result); + + void UnregisterMethodCallHandler() const; }; } From f67ae1f34868c7660c16a2473f53a7a7bfb6f784 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Wed, 9 Oct 2024 00:10:50 +0200 Subject: [PATCH 010/181] updated flutter_inappwebview_windows version to ^0.6.0 --- flutter_inappwebview/CHANGELOG.md | 10 ++++++++++ flutter_inappwebview/pubspec.yaml | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index c74465f00..e9b43100f 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -1,3 +1,13 @@ +## 6.1.5 + +- Updated dependencies to the latest versions for all platform implementations: + - `flutter_inappwebview_windows`: `^0.5.0` -> `^0.6.0` + +#### Windows Platform +- Updated code to support multiple flutter windows +- Fixed `InAppWebViewController.callAsyncJavaScript` not working with JSON objects +- Fixed `onLoadResourceWithCustomScheme` WebView event called every time + ## 6.1.4 - Updated dependencies to the latest versions for all platform implementations: diff --git a/flutter_inappwebview/pubspec.yaml b/flutter_inappwebview/pubspec.yaml index 35b7f83d5..2684b7dae 100755 --- a/flutter_inappwebview/pubspec.yaml +++ b/flutter_inappwebview/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. -version: 6.1.4 +version: 6.1.5 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -25,7 +25,7 @@ dependencies: flutter_inappwebview_ios: ^1.1.2 flutter_inappwebview_macos: ^1.1.2 flutter_inappwebview_web: ^1.1.2 - flutter_inappwebview_windows: ^0.5.0 + flutter_inappwebview_windows: ^0.6.0 dev_dependencies: flutter_test: From 22e492d823ee8d5bbef76d4b15420cb903cb7fa1 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Wed, 23 Oct 2024 12:03:39 +0200 Subject: [PATCH 011/181] platform_interface: Updated static fromMap implementation for some classes, ios and macos: Moved WKUserContentController initialization on preWKWebViewConfiguration to fix possible undefined is not an object (evaluating 'window.webkit.messageHandlers') javascript error --- .../src/exchangeable_object_generator.dart | 8 +++++ flutter_inappwebview/CHANGELOG.md | 19 ++++++++++++ .../example/test/widget_test.dart | 30 ------------------- flutter_inappwebview/pubspec.yaml | 4 +-- flutter_inappwebview_android/CHANGELOG.md | 4 +++ flutter_inappwebview_android/pubspec.yaml | 4 +-- flutter_inappwebview_ios/CHANGELOG.md | 5 ++++ .../Classes/InAppWebView/InAppWebView.swift | 4 +-- flutter_inappwebview_ios/pubspec.yaml | 4 +-- flutter_inappwebview_macos/CHANGELOG.md | 5 ++++ .../Classes/InAppWebView/InAppWebView.swift | 4 +-- flutter_inappwebview_macos/pubspec.yaml | 4 +-- .../CHANGELOG.md | 4 +++ .../chrome_safari_action_button.g.dart | 4 ++- ...me_safari_browser_secondary_toolbar.g.dart | 12 ++++---- .../context_menu/context_menu_settings.g.dart | 6 ++-- .../in_app_browser_menu_item.g.dart | 4 ++- .../lib/src/platform_proxy_controller.g.dart | 20 +++++++++---- .../src/platform_tracing_controller.g.dart | 4 ++- .../lib/src/types/console_message.g.dart | 10 +++++-- .../lib/src/types/content_world.dart | 8 +++++ .../src/types/custom_scheme_response.g.dart | 4 ++- ...ion_permission_show_prompt_response.g.dart | 4 ++- .../lib/src/types/http_auth_response.g.dart | 12 ++++++-- .../types/in_app_webview_initial_data.g.dart | 8 +++-- .../lib/src/types/js_alert_response.g.dart | 12 ++++++-- .../types/js_before_unload_response.g.dart | 16 +++++++--- .../lib/src/types/js_confirm_response.g.dart | 16 +++++++--- .../lib/src/types/js_prompt_response.g.dart | 20 +++++++++---- .../lib/src/types/permission_request.g.dart | 6 ++-- .../lib/src/types/permission_response.g.dart | 10 +++++-- .../src/types/safe_browsing_response.g.dart | 4 ++- .../src/types/screenshot_configuration.g.dart | 14 ++++++--- .../types/script_html_tag_attributes.g.dart | 4 ++- ...web_activity_immersive_display_mode.g.dart | 6 ++-- .../lib/src/types/user_script.g.dart | 15 +++++++--- .../pubspec.yaml | 2 +- flutter_inappwebview_web/CHANGELOG.md | 4 +++ flutter_inappwebview_web/pubspec.yaml | 4 +-- flutter_inappwebview_windows/CHANGELOG.md | 4 +++ .../example/pubspec.lock | 2 +- flutter_inappwebview_windows/pubspec.yaml | 4 +-- 42 files changed, 231 insertions(+), 107 deletions(-) diff --git a/dev_packages/generators/lib/src/exchangeable_object_generator.dart b/dev_packages/generators/lib/src/exchangeable_object_generator.dart index d399aaa12..ed5cb23e9 100644 --- a/dev_packages/generators/lib/src/exchangeable_object_generator.dart +++ b/dev_packages/generators/lib/src/exchangeable_object_generator.dart @@ -335,6 +335,7 @@ class ExchangeableObjectGenerator .trim(); value = "map['$newFieldName']"; } + final mapValue = value; final customDeserializer = _coreCheckerObjectProperty .firstAnnotationOf(fieldElement) @@ -361,7 +362,14 @@ class ExchangeableObjectGenerator if (isRequiredParameter || fieldElement.isFinal || annotation.read("fromMapForceAllInline").boolValue) { requiredFields.add('$fieldName: $value,'); } else { + final isFieldNullable = Util.typeIsNullable(fieldElement.type); + if (!isFieldNullable) { + nonRequiredFields.add("if ($mapValue != null) {"); + } nonRequiredFields.add("instance.$fieldName = $value;"); + if (!isFieldNullable) { + nonRequiredFields.add("}"); + } } } } diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index e9b43100f..631373fae 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -1,3 +1,22 @@ +## 6.2.0 + +- Updated dependencies to the latest versions for all platform implementations: + - `flutter_inappwebview_platform_interface`: `^1.3.0` -> `^1.4.0` + - `flutter_inappwebview_android`: `^1.1.3` -> `^1.2.0` + - `flutter_inappwebview_ios`: `^1.1.2` -> `^1.2.0` + - `flutter_inappwebview_macos`: `^1.1.2` -> `^1.2.0` + - `flutter_inappwebview_web`: `^1.1.2` -> `^1.2.0` + - `flutter_inappwebview_windows`: `^0.6.0` -> `^0.7.0` + +#### Platform Interface +- Updated static `fromMap` implementation for some classes + +#### iOS Platform +- Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error + +#### macOS Platform +- Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error + ## 6.1.5 - Updated dependencies to the latest versions for all platform implementations: diff --git a/flutter_inappwebview/example/test/widget_test.dart b/flutter_inappwebview/example/test/widget_test.dart index 092d222f7..e69de29bb 100644 --- a/flutter_inappwebview/example/test/widget_test.dart +++ b/flutter_inappwebview/example/test/widget_test.dart @@ -1,30 +0,0 @@ -// This is a basic Flutter widget test. -// -// To perform an interaction with a widget in your test, use the WidgetTester -// utility in the flutter_test package. For example, you can send tap and scroll -// gestures. You can also use WidgetTester to find child widgets in the widget -// tree, read text, and verify that the values of widget properties are correct. - -import 'package:flutter/material.dart'; -import 'package:flutter_test/flutter_test.dart'; - -import 'package:example/main.dart'; - -void main() { - testWidgets('Counter increments smoke test', (WidgetTester tester) async { - // Build our app and trigger a frame. - await tester.pumpWidget(const MyApp()); - - // Verify that our counter starts at 0. - expect(find.text('0'), findsOneWidget); - expect(find.text('1'), findsNothing); - - // Tap the '+' icon and trigger a frame. - await tester.tap(find.byIcon(Icons.add)); - await tester.pump(); - - // Verify that our counter has incremented. - expect(find.text('0'), findsNothing); - expect(find.text('1'), findsOneWidget); - }); -} diff --git a/flutter_inappwebview/pubspec.yaml b/flutter_inappwebview/pubspec.yaml index 2684b7dae..80e20c8df 100755 --- a/flutter_inappwebview/pubspec.yaml +++ b/flutter_inappwebview/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. -version: 6.1.5 +version: 6.2.0 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -20,7 +20,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.3.0 + flutter_inappwebview_platform_interface: ^1.4.0 flutter_inappwebview_android: ^1.1.3 flutter_inappwebview_ios: ^1.1.2 flutter_inappwebview_macos: ^1.1.2 diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md index 3170f86a5..5fd6e2117 100644 --- a/flutter_inappwebview_android/CHANGELOG.md +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.0 + +- Updated flutter_inappwebview_platform_interface version to ^1.4.0 + ## 1.1.3 - Updated flutter_inappwebview_platform_interface version to ^1.3.0 diff --git a/flutter_inappwebview_android/pubspec.yaml b/flutter_inappwebview_android/pubspec.yaml index 912f92eef..f9fd161a3 100644 --- a/flutter_inappwebview_android/pubspec.yaml +++ b/flutter_inappwebview_android/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_android description: Android implementation of the flutter_inappwebview plugin. -version: 1.1.3 +version: 1.2.0 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_android issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -20,7 +20,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.3.0 + flutter_inappwebview_platform_interface: ^1.4.0 dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_ios/CHANGELOG.md b/flutter_inappwebview_ios/CHANGELOG.md index 60e2bffdb..e164af8fc 100644 --- a/flutter_inappwebview_ios/CHANGELOG.md +++ b/flutter_inappwebview_ios/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.2.0 + +- Updated flutter_inappwebview_platform_interface version to ^1.4.0 +- Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error + ## 1.1.2 - Updated flutter_inappwebview_platform_interface version to ^1.3.0 diff --git a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift index 43ac03776..12ff2a1a3 100755 --- a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift @@ -546,7 +546,6 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, // This is a limitation of the official WebKit API. return } - configuration.userContentController = WKUserContentController() configuration.userContentController.initialize() if let applePayAPIEnabled = settings?.applePayAPIEnabled, applePayAPIEnabled { @@ -595,7 +594,8 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, public static func preWKWebViewConfiguration(settings: InAppWebViewSettings?) -> WKWebViewConfiguration { let configuration = WKWebViewConfiguration() - + // initialzie WKUserContentController here to fix possible "undefined is not an object (evaluating 'window.webkit.messageHandlers')" javascript error + configuration.userContentController = WKUserContentController() configuration.processPool = WKProcessPoolManager.sharedProcessPool if let settings = settings { diff --git a/flutter_inappwebview_ios/pubspec.yaml b/flutter_inappwebview_ios/pubspec.yaml index 06afb905a..1608e685a 100644 --- a/flutter_inappwebview_ios/pubspec.yaml +++ b/flutter_inappwebview_ios/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_ios description: iOS implementation of the flutter_inappwebview plugin. -version: 1.1.2 +version: 1.2.0 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_ios issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -20,7 +20,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.3.0 + flutter_inappwebview_platform_interface: ^1.4.0 dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_macos/CHANGELOG.md b/flutter_inappwebview_macos/CHANGELOG.md index 7bd1ae744..de4edabbb 100644 --- a/flutter_inappwebview_macos/CHANGELOG.md +++ b/flutter_inappwebview_macos/CHANGELOG.md @@ -1,3 +1,8 @@ +## 1.2.0 + +- Updated flutter_inappwebview_platform_interface version to ^1.4.0 +- Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error + ## 1.1.2 - Updated flutter_inappwebview_platform_interface version to ^1.3.0 diff --git a/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift b/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift index 5e73f981c..d1cda14d3 100755 --- a/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift @@ -193,7 +193,6 @@ public class InAppWebView: WKWebView, WKUIDelegate, // This is a limitation of the official WebKit API. return } - configuration.userContentController = WKUserContentController() configuration.userContentController.initialize() if let applePayAPIEnabled = settings?.applePayAPIEnabled, applePayAPIEnabled { @@ -242,7 +241,8 @@ public class InAppWebView: WKWebView, WKUIDelegate, public static func preWKWebViewConfiguration(settings: InAppWebViewSettings?) -> WKWebViewConfiguration { let configuration = WKWebViewConfiguration() - + // initialzie WKUserContentController here to fix possible "undefined is not an object (evaluating 'window.webkit.messageHandlers')" javascript error + configuration.userContentController = WKUserContentController() configuration.processPool = WKProcessPoolManager.sharedProcessPool if let settings = settings { diff --git a/flutter_inappwebview_macos/pubspec.yaml b/flutter_inappwebview_macos/pubspec.yaml index 0c7f6d6be..2e22bee5a 100644 --- a/flutter_inappwebview_macos/pubspec.yaml +++ b/flutter_inappwebview_macos/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_macos description: macOS implementation of the flutter_inappwebview plugin. -version: 1.1.2 +version: 1.2.0 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_macos issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -20,7 +20,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.3.0 + flutter_inappwebview_platform_interface: ^1.4.0 dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_platform_interface/CHANGELOG.md b/flutter_inappwebview_platform_interface/CHANGELOG.md index 1ff5e50ac..8f5781b7f 100644 --- a/flutter_inappwebview_platform_interface/CHANGELOG.md +++ b/flutter_inappwebview_platform_interface/CHANGELOG.md @@ -1,3 +1,7 @@ +#### 1.4.0 + +- Updated static `fromMap` implementation for some classes + ## 1.3.0+1 - Fixed `X509Certificate.toMap` method diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart index 5080fec54..3383a065f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart @@ -55,7 +55,9 @@ class ChromeSafariBrowserActionButton { icon: Uint8List.fromList(map['icon'].cast()), id: map['id'], ); - instance.shouldTint = map['shouldTint']; + if (map['shouldTint'] != null) { + instance.shouldTint = map['shouldTint']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart index 7b1a7a3e8..453ac9aee 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart @@ -43,11 +43,13 @@ class ChromeSafariBrowserSecondaryToolbar { final instance = ChromeSafariBrowserSecondaryToolbar( layout: AndroidResource.fromMap(map['layout']?.cast())!, ); - instance.clickableIDs = - List.from( - map['clickableIDs'].map((e) => - ChromeSafariBrowserSecondaryToolbarClickableID.fromMap( - e?.cast())!)); + if (map['clickableIDs'] != null) { + instance.clickableIDs = + List.from( + map['clickableIDs'].map((e) => + ChromeSafariBrowserSecondaryToolbarClickableID.fromMap( + e?.cast())!)); + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.g.dart index 046460726..1c91e9eca 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.g.dart @@ -18,8 +18,10 @@ class ContextMenuSettings { return null; } final instance = ContextMenuSettings(); - instance.hideDefaultSystemContextMenuItems = - map['hideDefaultSystemContextMenuItems']; + if (map['hideDefaultSystemContextMenuItems'] != null) { + instance.hideDefaultSystemContextMenuItems = + map['hideDefaultSystemContextMenuItems']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart index 90620b746..8409511bf 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_menu_item.g.dart @@ -67,7 +67,9 @@ class InAppBrowserMenuItem { order: map['order'], title: map['title'], ); - instance.showAsAction = map['showAsAction']; + if (map['showAsAction'] != null) { + instance.showAsAction = map['showAsAction']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart index 07f9de6cb..663fa52aa 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart @@ -76,12 +76,20 @@ class ProxySettings { bypassSimpleHostnames: map['bypassSimpleHostnames'], removeImplicitRules: map['removeImplicitRules'], ); - instance.bypassRules = - List.from(map['bypassRules']!.cast()); - instance.directs = List.from(map['directs']!.cast()); - instance.proxyRules = List.from(map['proxyRules'] - .map((e) => ProxyRule.fromMap(e?.cast())!)); - instance.reverseBypassEnabled = map['reverseBypassEnabled']; + if (map['bypassRules'] != null) { + instance.bypassRules = + List.from(map['bypassRules']!.cast()); + } + if (map['directs'] != null) { + instance.directs = List.from(map['directs']!.cast()); + } + if (map['proxyRules'] != null) { + instance.proxyRules = List.from(map['proxyRules'] + .map((e) => ProxyRule.fromMap(e?.cast())!)); + } + if (map['reverseBypassEnabled'] != null) { + instance.reverseBypassEnabled = map['reverseBypassEnabled']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart index 9279c5e63..18345146c 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart @@ -42,7 +42,9 @@ class TracingSettings { final instance = TracingSettings( tracingMode: TracingMode.fromNativeValue(map['tracingMode']), ); - instance.categories = _deserializeCategories(map['categories']); + if (map['categories'] != null) { + instance.categories = _deserializeCategories(map['categories']); + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/console_message.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/console_message.g.dart index cf1192116..bd3870313 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/console_message.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/console_message.g.dart @@ -25,9 +25,13 @@ class ConsoleMessage { return null; } final instance = ConsoleMessage(); - instance.message = map['message']; - instance.messageLevel = - ConsoleMessageLevel.fromNativeValue(map['messageLevel'])!; + if (map['message'] != null) { + instance.message = map['message']; + } + if (map['messageLevel'] != null) { + instance.messageLevel = + ConsoleMessageLevel.fromNativeValue(map['messageLevel'])!; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/content_world.dart b/flutter_inappwebview_platform_interface/lib/src/types/content_world.dart index 84bfa35ef..5a788a706 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/content_world.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/content_world.dart @@ -33,6 +33,14 @@ class ContentWorld { ///If you modify a variable with the same name as one the webpage uses, you may unintentionally disrupt the normal operation of that page. static final ContentWorld PAGE = ContentWorld.world(name: "page"); + ///Gets a possible [ContentWorld] instance from a [Map] value. + static ContentWorld? fromMap(Map? map) { + if (map == null) { + return null; + } + return ContentWorld.world(name: map["name"]); + } + ///Converts instance to a map. Map toMap() { return {"name": name}; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/custom_scheme_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/custom_scheme_response.g.dart index c9bcfed65..cba4346b7 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/custom_scheme_response.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/custom_scheme_response.g.dart @@ -31,7 +31,9 @@ class CustomSchemeResponse { contentType: map['contentType'], data: Uint8List.fromList(map['data'].cast()), ); - instance.contentEncoding = map['contentEncoding']; + if (map['contentEncoding'] != null) { + instance.contentEncoding = map['contentEncoding']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/geolocation_permission_show_prompt_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/geolocation_permission_show_prompt_response.g.dart index 37be906a5..1c31d1ecf 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/geolocation_permission_show_prompt_response.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/geolocation_permission_show_prompt_response.g.dart @@ -30,7 +30,9 @@ class GeolocationPermissionShowPromptResponse { allow: map['allow'], origin: map['origin'], ); - instance.retain = map['retain']; + if (map['retain'] != null) { + instance.retain = map['retain']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response.g.dart index dfa18193a..bbfea393f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response.g.dart @@ -32,9 +32,15 @@ class HttpAuthResponse { } final instance = HttpAuthResponse(); instance.action = HttpAuthResponseAction.fromNativeValue(map['action']); - instance.password = map['password']; - instance.permanentPersistence = map['permanentPersistence']; - instance.username = map['username']; + if (map['password'] != null) { + instance.password = map['password']; + } + if (map['permanentPersistence'] != null) { + instance.permanentPersistence = map['permanentPersistence']; + } + if (map['username'] != null) { + instance.username = map['username']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart index 4cfd6cc9f..d0495c21f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart @@ -52,8 +52,12 @@ class InAppWebViewInitialData { data: map['data'], historyUrl: map['historyUrl'] != null ? WebUri(map['historyUrl']) : null, ); - instance.encoding = map['encoding']; - instance.mimeType = map['mimeType']; + if (map['encoding'] != null) { + instance.encoding = map['encoding']; + } + if (map['mimeType'] != null) { + instance.mimeType = map['mimeType']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response.g.dart index d6903df7c..7ebeed328 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response.g.dart @@ -32,9 +32,15 @@ class JsAlertResponse { } final instance = JsAlertResponse(); instance.action = JsAlertResponseAction.fromNativeValue(map['action']); - instance.confirmButtonTitle = map['confirmButtonTitle']; - instance.handledByClient = map['handledByClient']; - instance.message = map['message']; + if (map['confirmButtonTitle'] != null) { + instance.confirmButtonTitle = map['confirmButtonTitle']; + } + if (map['handledByClient'] != null) { + instance.handledByClient = map['handledByClient']; + } + if (map['message'] != null) { + instance.message = map['message']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response.g.dart index 885f2f573..cc7a3f268 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response.g.dart @@ -37,10 +37,18 @@ class JsBeforeUnloadResponse { final instance = JsBeforeUnloadResponse(); instance.action = JsBeforeUnloadResponseAction.fromNativeValue(map['action']); - instance.cancelButtonTitle = map['cancelButtonTitle']; - instance.confirmButtonTitle = map['confirmButtonTitle']; - instance.handledByClient = map['handledByClient']; - instance.message = map['message']; + if (map['cancelButtonTitle'] != null) { + instance.cancelButtonTitle = map['cancelButtonTitle']; + } + if (map['confirmButtonTitle'] != null) { + instance.confirmButtonTitle = map['confirmButtonTitle']; + } + if (map['handledByClient'] != null) { + instance.handledByClient = map['handledByClient']; + } + if (map['message'] != null) { + instance.message = map['message']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response.g.dart index ddd0bc9be..ab090462b 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response.g.dart @@ -36,10 +36,18 @@ class JsConfirmResponse { } final instance = JsConfirmResponse(); instance.action = JsConfirmResponseAction.fromNativeValue(map['action']); - instance.cancelButtonTitle = map['cancelButtonTitle']; - instance.confirmButtonTitle = map['confirmButtonTitle']; - instance.handledByClient = map['handledByClient']; - instance.message = map['message']; + if (map['cancelButtonTitle'] != null) { + instance.cancelButtonTitle = map['cancelButtonTitle']; + } + if (map['confirmButtonTitle'] != null) { + instance.confirmButtonTitle = map['confirmButtonTitle']; + } + if (map['handledByClient'] != null) { + instance.handledByClient = map['handledByClient']; + } + if (map['message'] != null) { + instance.message = map['message']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response.g.dart index abea1745f..90ace79ea 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response.g.dart @@ -46,11 +46,21 @@ class JsPromptResponse { value: map['value'], ); instance.action = JsPromptResponseAction.fromNativeValue(map['action']); - instance.cancelButtonTitle = map['cancelButtonTitle']; - instance.confirmButtonTitle = map['confirmButtonTitle']; - instance.defaultValue = map['defaultValue']; - instance.handledByClient = map['handledByClient']; - instance.message = map['message']; + if (map['cancelButtonTitle'] != null) { + instance.cancelButtonTitle = map['cancelButtonTitle']; + } + if (map['confirmButtonTitle'] != null) { + instance.confirmButtonTitle = map['confirmButtonTitle']; + } + if (map['defaultValue'] != null) { + instance.defaultValue = map['defaultValue']; + } + if (map['handledByClient'] != null) { + instance.handledByClient = map['handledByClient']; + } + if (map['message'] != null) { + instance.message = map['message']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/permission_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_request.g.dart index a52ea4d80..2f328253f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/permission_request.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/permission_request.g.dart @@ -31,8 +31,10 @@ class PermissionRequest { frame: FrameInfo.fromMap(map['frame']?.cast()), origin: WebUri(map['origin']), ); - instance.resources = List.from(map['resources'] - .map((e) => PermissionResourceType.fromNativeValue(e)!)); + if (map['resources'] != null) { + instance.resources = List.from(map['resources'] + .map((e) => PermissionResourceType.fromNativeValue(e)!)); + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/permission_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_response.g.dart index 1cd597f28..76e3f60db 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/permission_response.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/permission_response.g.dart @@ -25,8 +25,10 @@ class PermissionResponse { } final instance = PermissionResponse(); instance.action = PermissionResponseAction.fromNativeValue(map['action']); - instance.resources = List.from(map['resources'] - .map((e) => PermissionResourceType.fromNativeValue(e)!)); + if (map['resources'] != null) { + instance.resources = List.from(map['resources'] + .map((e) => PermissionResourceType.fromNativeValue(e)!)); + } return instance; } @@ -70,7 +72,9 @@ class PermissionRequestResponse { final instance = PermissionRequestResponse(); instance.action = PermissionRequestResponseAction.fromNativeValue(map['action']); - instance.resources = List.from(map['resources']!.cast()); + if (map['resources'] != null) { + instance.resources = List.from(map['resources']!.cast()); + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response.g.dart index 4c24640e5..0b1ec0af3 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response.g.dart @@ -25,7 +25,9 @@ class SafeBrowsingResponse { } final instance = SafeBrowsingResponse(); instance.action = SafeBrowsingResponseAction.fromNativeValue(map['action']); - instance.report = map['report']; + if (map['report'] != null) { + instance.report = map['report']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart index 460c7890d..edb541957 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart @@ -86,10 +86,16 @@ class ScreenshotConfiguration { rect: InAppWebViewRect.fromMap(map['rect']?.cast()), snapshotWidth: map['snapshotWidth'], ); - instance.afterScreenUpdates = map['afterScreenUpdates']; - instance.compressFormat = - CompressFormat.fromNativeValue(map['compressFormat'])!; - instance.quality = map['quality']; + if (map['afterScreenUpdates'] != null) { + instance.afterScreenUpdates = map['afterScreenUpdates']; + } + if (map['compressFormat'] != null) { + instance.compressFormat = + CompressFormat.fromNativeValue(map['compressFormat'])!; + } + if (map['quality'] != null) { + instance.quality = map['quality']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/script_html_tag_attributes.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/script_html_tag_attributes.g.dart index 4ca725079..25476b4cf 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/script_html_tag_attributes.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/script_html_tag_attributes.g.dart @@ -100,7 +100,9 @@ class ScriptHtmlTagAttributes { nonce: map['nonce'], referrerPolicy: ReferrerPolicy.fromNativeValue(map['referrerPolicy']), ); - instance.type = map['type']; + if (map['type'] != null) { + instance.type = map['type']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/trusted_web_activity_immersive_display_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/trusted_web_activity_immersive_display_mode.g.dart index a5370c9eb..ad5ff7583 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/trusted_web_activity_immersive_display_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/trusted_web_activity_immersive_display_mode.g.dart @@ -43,8 +43,10 @@ class TrustedWebActivityImmersiveDisplayMode AndroidLayoutInDisplayCutoutMode.fromNativeValue( map['displayCutoutMode']), ); - instance.displayCutoutMode = - LayoutInDisplayCutoutMode.fromNativeValue(map['displayCutoutMode'])!; + if (map['displayCutoutMode'] != null) { + instance.displayCutoutMode = + LayoutInDisplayCutoutMode.fromNativeValue(map['displayCutoutMode'])!; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart index 99f114be0..eef04c111 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart @@ -64,10 +64,17 @@ class UserScript { iosForMainFrameOnly: map['forMainFrameOnly'], source: map['source'], ); - instance.allowedOriginRules = - Set.from(map['allowedOriginRules']!.cast()); - instance.contentWorld = map['contentWorld']; - instance.forMainFrameOnly = map['forMainFrameOnly']; + if (map['allowedOriginRules'] != null) { + instance.allowedOriginRules = + Set.from(map['allowedOriginRules']!.cast()); + } + if (map['contentWorld'] != null) { + instance.contentWorld = + ContentWorld.fromMap(map['contentWorld']?.cast())!; + } + if (map['forMainFrameOnly'] != null) { + instance.forMainFrameOnly = map['forMainFrameOnly']; + } return instance; } diff --git a/flutter_inappwebview_platform_interface/pubspec.yaml b/flutter_inappwebview_platform_interface/pubspec.yaml index 16a58f358..78131c8e7 100644 --- a/flutter_inappwebview_platform_interface/pubspec.yaml +++ b/flutter_inappwebview_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_platform_interface description: A common platform interface for the flutter_inappwebview plugin. -version: 1.3.0+1 +version: 1.4.0 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_platform_interface issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues diff --git a/flutter_inappwebview_web/CHANGELOG.md b/flutter_inappwebview_web/CHANGELOG.md index c02525fc0..6a1c66e2a 100644 --- a/flutter_inappwebview_web/CHANGELOG.md +++ b/flutter_inappwebview_web/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.0 + +- Updated flutter_inappwebview_platform_interface version to ^1.4.0 + ## 1.1.2 - Updated flutter_inappwebview_platform_interface version to ^1.3.0 diff --git a/flutter_inappwebview_web/pubspec.yaml b/flutter_inappwebview_web/pubspec.yaml index d6557020c..212c24f96 100644 --- a/flutter_inappwebview_web/pubspec.yaml +++ b/flutter_inappwebview_web/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_web description: Web implementation of the flutter_inappwebview plugin. -version: 1.1.2 +version: 1.2.0 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_web issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -23,7 +23,7 @@ dependencies: flutter_web_plugins: sdk: flutter web: ^1.0.0 - flutter_inappwebview_platform_interface: ^1.3.0 + flutter_inappwebview_platform_interface: ^1.4.0 dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_windows/CHANGELOG.md b/flutter_inappwebview_windows/CHANGELOG.md index dd1cc41a6..5776df728 100644 --- a/flutter_inappwebview_windows/CHANGELOG.md +++ b/flutter_inappwebview_windows/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.7.0 + +- Updated flutter_inappwebview_platform_interface version to ^1.4.0 + ## 0.6.0 - Updated code to support multiple flutter windows diff --git a/flutter_inappwebview_windows/example/pubspec.lock b/flutter_inappwebview_windows/example/pubspec.lock index 83bd88ac0..2f5993cf3 100644 --- a/flutter_inappwebview_windows/example/pubspec.lock +++ b/flutter_inappwebview_windows/example/pubspec.lock @@ -97,7 +97,7 @@ packages: path: ".." relative: true source: path - version: "0.5.0" + version: "0.6.0" flutter_lints: dependency: "direct dev" description: diff --git a/flutter_inappwebview_windows/pubspec.yaml b/flutter_inappwebview_windows/pubspec.yaml index d1c3ce45d..87282c4c5 100644 --- a/flutter_inappwebview_windows/pubspec.yaml +++ b/flutter_inappwebview_windows/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_windows description: Windows implementation of the flutter_inappwebview plugin. -version: 0.6.0 +version: 0.7.0 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_windows issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -20,7 +20,7 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.3.0 + flutter_inappwebview_platform_interface: ^1.4.0 dev_dependencies: flutter_test: From dc7bc505e42cedb1129202cde686985d966568a6 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Wed, 23 Oct 2024 19:19:41 +0200 Subject: [PATCH 012/181] android: Added InAppWebViewController.enableSlowWholeDocumentDraw static method, Added CookieManager.flush method, Updated InAppWebViewController.takeScreenshot implementation to support screenshot out of visible viewport when InAppWebViewController.enableSlowWholeDocumentDraw is called, fix #2354 --- flutter_inappwebview/CHANGELOG.md | 5 + .../lib/src/cookie_manager.dart | 3 + .../in_app_webview_controller.dart | 5 + flutter_inappwebview_android/CHANGELOG.md | 3 + .../MyCookieManager.java | 17 +++ .../webview/InAppWebViewManager.java | 8 ++ .../webview/in_app_webview/InAppWebView.java | 104 ++++++++++-------- .../lib/src/cookie_manager.dart | 6 + .../in_app_webview_controller.dart | 6 + .../platform_in_app_browser.dart | 3 + .../platform_inappwebview_controller.dart | 23 ++++ .../src/in_app_webview/platform_webview.dart | 3 + .../lib/src/platform_cookie_manager.dart | 12 ++ 13 files changed, 151 insertions(+), 47 deletions(-) diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index 631373fae..3adb5cf62 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -11,6 +11,11 @@ #### Platform Interface - Updated static `fromMap` implementation for some classes +#### Android Platform +- Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method +- Added `CookieManager.flush` method +- Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called + #### iOS Platform - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error diff --git a/flutter_inappwebview/lib/src/cookie_manager.dart b/flutter_inappwebview/lib/src/cookie_manager.dart index 3ab49df1e..bebf0f303 100755 --- a/flutter_inappwebview/lib/src/cookie_manager.dart +++ b/flutter_inappwebview/lib/src/cookie_manager.dart @@ -143,6 +143,9 @@ class CookieManager { ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.removeSessionCookies} Future removeSessionCookies() => platform.removeSessionCookies(); + + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.flush} + Future flush() => platform.flush(); } ///Class that contains only iOS-specific methods of [CookieManager]. diff --git a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart index 1544754d3..0232fac93 100644 --- a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart @@ -565,6 +565,11 @@ class InAppWebViewController { PlatformInAppWebViewController.static() .clearAllCache(includeDiskFiles: includeDiskFiles); + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.enableSlowWholeDocumentDraw} + static Future enableSlowWholeDocumentDraw() => + PlatformInAppWebViewController.static() + .enableSlowWholeDocumentDraw(); + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.tRexRunnerHtml} static Future get tRexRunnerHtml => PlatformInAppWebViewController.static().tRexRunnerHtml; diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md index 5fd6e2117..4f9458f85 100644 --- a/flutter_inappwebview_android/CHANGELOG.md +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -1,6 +1,9 @@ ## 1.2.0 - Updated flutter_inappwebview_platform_interface version to ^1.4.0 +- Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method +- Added `CookieManager.flush` method +- Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called ## 1.1.3 diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/MyCookieManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/MyCookieManager.java index ff4247e7e..e45b2789e 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/MyCookieManager.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/MyCookieManager.java @@ -103,6 +103,9 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result case "removeSessionCookies": removeSessionCookies(result); break; + case "flush": + flush(result); + break; default: result.notImplemented(); } @@ -423,6 +426,20 @@ else if (plugin != null) { } } + public void flush(MethodChannel.Result result) { + cookieManager = getCookieManager(); + if (cookieManager == null) { + result.success(false); + return; + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + cookieManager.flush(); + } else if (plugin != null) { + CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(plugin.applicationContext); + cookieSyncMngr.sync(); + } + } + public static String getCookieExpirationDate(Long timestamp) { final SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss z", Locale.US); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java index 623354aef..27a624ad2 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java @@ -162,6 +162,14 @@ public void onReceiveValue(Boolean value) { } result.success(true); break; + case "enableSlowWholeDocumentDraw": + { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WebView.enableSlowWholeDocumentDraw(); + } + } + result.success(true); + break; default: result.notImplemented(); } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java index b0bfd5509..fbabab3d4 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java @@ -215,8 +215,8 @@ public WebViewClient createWebViewClient(InAppBrowserDelegate inAppBrowserDelega } boolean isChromiumWebView = "com.android.webview".equals(packageInfo.packageName) || - "com.google.android.webview".equals(packageInfo.packageName) || - "com.android.chrome".equals(packageInfo.packageName); + "com.google.android.webview".equals(packageInfo.packageName) || + "com.android.chrome".equals(packageInfo.packageName); boolean isChromiumWebViewBugFixed = false; if (isChromiumWebView) { String versionName = packageInfo.versionName != null ? packageInfo.versionName : ""; @@ -224,7 +224,8 @@ public WebViewClient createWebViewClient(InAppBrowserDelegate inAppBrowserDelega int majorVersion = versionName.contains(".") ? Integer.parseInt(versionName.split("\\.")[0]) : 0; isChromiumWebViewBugFixed = majorVersion >= 73; - } catch (NumberFormatException ignored) {} + } catch (NumberFormatException ignored) { + } } if (isChromiumWebViewBugFixed || !isChromiumWebView) { @@ -704,36 +705,21 @@ public void takeScreenshot(final @Nullable Map screenshotConfigu @Override public void run() { try { - Bitmap screenshotBitmap = Bitmap.createBitmap(getMeasuredWidth(), getMeasuredHeight(), Bitmap.Config.ARGB_8888); - Canvas c = new Canvas(screenshotBitmap); - c.translate(-getScrollX(), -getScrollY()); - draw(c); + int bitmapWidth = getMeasuredWidth(); + int bitmapHeight = getMeasuredHeight(); + int bitmapScrollX = getScrollX(); + int bitmapScrollY = getScrollY(); - ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); Bitmap.CompressFormat compressFormat = Bitmap.CompressFormat.PNG; int quality = 100; if (screenshotConfiguration != null) { Map rect = (Map) screenshotConfiguration.get("rect"); if (rect != null) { - int rectX = (int) Math.floor(rect.get("x") * pixelDensity + 0.5); - int rectY = (int) Math.floor(rect.get("y") * pixelDensity + 0.5); - int rectWidth = Math.min(screenshotBitmap.getWidth(), (int) Math.floor(rect.get("width") * pixelDensity + 0.5)); - int rectHeight = Math.min(screenshotBitmap.getHeight(), (int) Math.floor(rect.get("height") * pixelDensity + 0.5)); - screenshotBitmap = Bitmap.createBitmap( - screenshotBitmap, - rectX, - rectY, - rectWidth, - rectHeight); - } - - Double snapshotWidth = (Double) screenshotConfiguration.get("snapshotWidth"); - if (snapshotWidth != null) { - int dstWidth = (int) Math.floor(snapshotWidth * pixelDensity + 0.5); - float ratioBitmap = (float) screenshotBitmap.getWidth() / (float) screenshotBitmap.getHeight(); - int dstHeight = (int) ((float) dstWidth / ratioBitmap); - screenshotBitmap = Bitmap.createScaledBitmap(screenshotBitmap, dstWidth, dstHeight, true); + bitmapScrollX = (int) Math.floor(rect.get("x") * pixelDensity + 0.5); + bitmapScrollY = (int) Math.floor(rect.get("y") * pixelDensity + 0.5); + bitmapWidth = (int) Math.floor(rect.get("width") * pixelDensity + 0.5); + bitmapHeight = (int) Math.floor(rect.get("height") * pixelDensity + 0.5); } try { @@ -745,10 +731,31 @@ public void run() { quality = (Integer) screenshotConfiguration.get("quality"); } - screenshotBitmap.compress( + Bitmap screenshotBitmap = Bitmap.createBitmap(bitmapWidth, bitmapHeight, Bitmap.Config.ARGB_8888); + Canvas c = new Canvas(screenshotBitmap); + c.translate(-bitmapScrollX, -bitmapScrollY); + draw(c); + + ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); + + if (screenshotConfiguration != null) { + Double snapshotWidth = (Double) screenshotConfiguration.get("snapshotWidth"); + if (snapshotWidth != null) { + int dstWidth = (int) Math.floor(snapshotWidth * pixelDensity + 0.5); + float ratioBitmap = (float) screenshotBitmap.getWidth() / (float) screenshotBitmap.getHeight(); + int dstHeight = (int) ((float) dstWidth / ratioBitmap); + screenshotBitmap = Bitmap.createScaledBitmap(screenshotBitmap, dstWidth, dstHeight, true); + } + } + + final boolean compressed = screenshotBitmap.compress( compressFormat, quality, byteArrayOutputStream); + if (!compressed) { + Log.e(LOG_TAG, "Screenshot cannot be compressed using compressFormat " + + compressFormat.name() + " with quality " + quality, null); + } try { byteArrayOutputStream.close(); @@ -932,7 +939,7 @@ else if (newSettingsMap.get("clearSessionCache") != null && newCustomSettings.cl if (newSettingsMap.get("disabledActionModeMenuItems") != null && (customSettings.disabledActionModeMenuItems == null || - !customSettings.disabledActionModeMenuItems.equals(newCustomSettings.disabledActionModeMenuItems))) { + !customSettings.disabledActionModeMenuItems.equals(newCustomSettings.disabledActionModeMenuItems))) { if (WebViewFeature.isFeatureSupported(WebViewFeature.DISABLED_ACTION_MODE_MENU_ITEMS)) WebSettingsCompat.setDisabledActionModeMenuItems(settings, newCustomSettings.disabledActionModeMenuItems); else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) @@ -1164,7 +1171,7 @@ public void injectDeferredObject(String source, @Nullable final ContentWorld con if (resultUuid != null && resultCallback != null) { evaluateJavaScriptContentWorldCallbacks.put(resultUuid, resultCallback); scriptToInject = Util.replaceAll(PluginScriptsUtil.EVALUATE_JAVASCRIPT_WITH_CONTENT_WORLD_WRAPPER_JS_SOURCE, - PluginScriptsUtil.VAR_RANDOM_NAME, "_" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "_" + Math.round(Math.random() * 1000000)) + PluginScriptsUtil.VAR_RANDOM_NAME, "_" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "_" + Math.round(Math.random() * 1000000)) .replace(PluginScriptsUtil.VAR_PLACEHOLDER_VALUE, UserContentController.escapeCode(source)) .replace(PluginScriptsUtil.VAR_RESULT_UUID, resultUuid); } @@ -1209,15 +1216,15 @@ public void injectJavascriptFileFromUrl(String urlFile, @Nullable Map flush() async { + Map args = {}; + await channel?.invokeMethod('flush', args); + } + @override void dispose() { // empty diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart index ceb4bc9a9..0d269dc2e 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2738,6 +2738,12 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await _staticChannel.invokeMethod('clearAllCache', args); } + @override + Future enableSlowWholeDocumentDraw() async { + Map args = {}; + await _staticChannel.invokeMethod('enableSlowWholeDocumentDraw', args); + } + @override Future get tRexRunnerHtml async => await rootBundle.loadString( 'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.html'); diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart index 6c14c7180..45c9e24c7 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart @@ -1218,6 +1218,9 @@ abstract class PlatformInAppBrowserEvents { ///The application's implementation of this callback should only attempt to clean up the WebView. ///The WebView should be removed from the view hierarchy, all references to it should be cleaned up. /// + ///To cause an render process crash for test purpose, the application can call load url `"chrome://crash"` on the WebView. + ///Note that multiple WebView instances may be affected if they share a render process, not just the specific WebView which loaded `"chrome://crash"`. + /// ///[detail] the reason why it exited. /// ///**NOTE**: available only on Android 26+. diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart index 4026e6162..cc2c49176 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart @@ -749,6 +749,9 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///**NOTE for MacOS**: available on MacOS 10.13+. /// + ///**NOTE for Android**: To be able to take screenshots outside the visible viewport, + ///you must call [PlatformInAppWebViewController.enableSlowWholeDocumentDraw] before any WebViews are created. + /// ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ///- iOS ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot)) @@ -2335,6 +2338,26 @@ abstract class PlatformInAppWebViewController extends PlatformInterface 'clearAllCache is not implemented on the current platform'); } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.enableSlowWholeDocumentDraw} + ///For apps targeting the L release, WebView has a new default behavior that reduces memory footprint and increases + ///performance by intelligently choosing the portion of the HTML document that needs to be drawn. + ///These optimizations are transparent to the developers. + ///However, under certain circumstances, an App developer may want to disable them, for example + ///when an app draws and accesses portions of the page that is way outside the visible portion of the page. + ///Enabling drawing the entire HTML document has a significant performance cost. + /// + ///**NOTE**: This method should be called before any WebViews are created. + /// + ///**NOTE for Android**: available only on Android 21+. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.getUrl](https://developer.android.com/reference/android/webkit/WebView#enableSlowWholeDocumentDraw())) + ///{@endtemplate} + Future enableSlowWholeDocumentDraw() { + throw UnimplementedError( + 'enableSlowWholeDocumentDraw is not implemented on the current platform'); + } + ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.tRexRunnerHtml} ///Gets the html (with javascript) of the Chromium's t-rex runner game. Used in combination with [tRexRunnerCss]. /// diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart index 838911d2d..36d923eb7 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart @@ -812,6 +812,9 @@ class PlatformWebViewCreationParams { ///The application's implementation of this callback should only attempt to clean up the WebView. ///The WebView should be removed from the view hierarchy, all references to it should be cleaned up. /// + ///To cause an render process crash for test purpose, the application can call load url `"chrome://crash"` on the WebView. + ///Note that multiple WebView instances may be affected if they share a render process, not just the specific WebView which loaded `"chrome://crash"`. + /// ///[detail] the reason why it exited. /// ///**NOTE**: available only on Android 26+. diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart index 700cc487c..9bb693320 100755 --- a/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart @@ -302,4 +302,16 @@ abstract class PlatformCookieManager extends PlatformInterface { throw UnimplementedError( 'removeSessionCookies is not implemented on the current platform'); } + + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.flush} + ///Ensures all cookies currently accessible through the getCookie API are written to persistent storage. + ///This call will block the caller until it is done and may perform I/O. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - CookieManager.flush](https://developer.android.com/reference/android/webkit/CookieManager#flush())) + ///{@endtemplate} + Future flush() { + throw UnimplementedError( + 'flush is not implemented on the current platform'); + } } From b1ada7eb639e36f95178de152ee307ab7a9e9ae0 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 22:35:01 +0000 Subject: [PATCH 013/181] update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fe2d03493..3326cf668 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-84-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-85-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -191,6 +191,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Gray Mackall
Gray Mackall

💻 Pavel Mazhnik
Pavel Mazhnik

💻 + + nlog (solrin)
nlog (solrin)

💻 + From 10d6b4f21027584f7aaaa0bcbc84a2610c03e21a Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Wed, 23 Oct 2024 22:35:02 +0000 Subject: [PATCH 014/181] update .all-contributorsrc --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 27fa03dad..3188af3a3 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -766,6 +766,15 @@ "contributions": [ "code" ] + }, + { + "login": "nnnlog", + "name": "nlog (solrin)", + "avatar_url": "https://avatars.githubusercontent.com/u/20399222?v=4", + "profile": "https://nlog.dev", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, From b96fe38082bd68e4224f96360964ff2d4693041b Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Thu, 24 Oct 2024 00:38:40 +0200 Subject: [PATCH 015/181] updated CHANGELOG files --- flutter_inappwebview/CHANGELOG.md | 6 ++---- flutter_inappwebview/README.md | 5 ++++- .../example/ios/Runner.xcodeproj/project.pbxproj | 8 ++++---- flutter_inappwebview_ios/CHANGELOG.md | 1 + flutter_inappwebview_macos/CHANGELOG.md | 1 + 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index 3adb5cf62..46030aae7 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -16,11 +16,9 @@ - Added `CookieManager.flush` method - Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called -#### iOS Platform -- Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error - -#### macOS Platform +#### macOS and iOS Platforms - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error +- Merged "change priority of DispatchQueue" [#2322](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2322) (thanks to [nnnlog](https://github.com/nnnlog)) ## 6.1.5 diff --git a/flutter_inappwebview/README.md b/flutter_inappwebview/README.md index fe2d03493..3326cf668 100755 --- a/flutter_inappwebview/README.md +++ b/flutter_inappwebview/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-84-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-85-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -191,6 +191,9 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Gray Mackall
Gray Mackall

💻 Pavel Mazhnik
Pavel Mazhnik

💻 + + nlog (solrin)
nlog (solrin)

💻 + diff --git a/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj b/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj index 6e356e166..bef2e71bd 100644 --- a/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj +++ b/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj @@ -481,7 +481,7 @@ MARKETING_VERSION = 1.0; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example2.test"; + PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example3.test"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; @@ -518,7 +518,7 @@ ); MARKETING_VERSION = 1.0; MTL_FAST_MATH = YES; - PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example2.test"; + PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example3.test"; PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_EMIT_LOC_STRINGS = YES; @@ -667,7 +667,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example2"; + PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example3"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; @@ -702,7 +702,7 @@ "$(inherited)", "$(PROJECT_DIR)/Flutter", ); - PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example2"; + PRODUCT_BUNDLE_IDENTIFIER = "com.pichillilorenzo.flutterinappwebview-ios-example3"; PRODUCT_NAME = "$(TARGET_NAME)"; PROVISIONING_PROFILE_SPECIFIER = ""; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; diff --git a/flutter_inappwebview_ios/CHANGELOG.md b/flutter_inappwebview_ios/CHANGELOG.md index e164af8fc..38838414f 100644 --- a/flutter_inappwebview_ios/CHANGELOG.md +++ b/flutter_inappwebview_ios/CHANGELOG.md @@ -2,6 +2,7 @@ - Updated flutter_inappwebview_platform_interface version to ^1.4.0 - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error +- Merged "change priority of DispatchQueue" [#2322](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2322) (thanks to [nnnlog](https://github.com/nnnlog)) ## 1.1.2 diff --git a/flutter_inappwebview_macos/CHANGELOG.md b/flutter_inappwebview_macos/CHANGELOG.md index de4edabbb..c364077c8 100644 --- a/flutter_inappwebview_macos/CHANGELOG.md +++ b/flutter_inappwebview_macos/CHANGELOG.md @@ -2,6 +2,7 @@ - Updated flutter_inappwebview_platform_interface version to ^1.4.0 - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error +- Merged "change priority of DispatchQueue" [#2322](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2322) (thanks to [nnnlog](https://github.com/nnnlog)) ## 1.1.2 From 4ba6e22848aae9c2ca16bc784023b7fa98cf61e3 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 25 Oct 2024 16:54:41 +0200 Subject: [PATCH 016/181] fix #2025 --- flutter_inappwebview/CHANGELOG.md | 1 + flutter_inappwebview_android/CHANGELOG.md | 1 + .../webview/InAppWebViewManager.java | 8 +++++--- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index 46030aae7..afed9dc21 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -15,6 +15,7 @@ - Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method - Added `CookieManager.flush` method - Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called +- Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025) #### macOS and iOS Platforms - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md index 4f9458f85..fec6738d9 100644 --- a/flutter_inappwebview_android/CHANGELOG.md +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -4,6 +4,7 @@ - Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method - Added `CookieManager.flush` method - Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called +- Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025) ## 1.1.3 diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java index 27a624ad2..7463c5a9a 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java @@ -215,9 +215,11 @@ public void dispose() { super.dispose(); Collection flutterWebViews = keepAliveWebViews.values(); for (FlutterWebView flutterWebView : flutterWebViews) { - String keepAliveId = flutterWebView.keepAliveId; - if (keepAliveId != null) { - disposeKeepAlive(flutterWebView.keepAliveId); + if (flutterWebView != null) { + String keepAliveId = flutterWebView.keepAliveId; + if (keepAliveId != null) { + disposeKeepAlive(keepAliveId); + } } } keepAliveWebViews.clear(); From 2f2a86e96c3a7c860a8f33b70d7098f73f613572 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:57:47 +0000 Subject: [PATCH 017/181] update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3326cf668..fb5173719 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-85-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-86-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -193,6 +193,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d nlog (solrin)
nlog (solrin)

💻 + Murmurl912
Murmurl912

💻 From 83ee929c288ac2c749642f5f1048177859acc50e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:57:48 +0000 Subject: [PATCH 018/181] update .all-contributorsrc --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 3188af3a3..8e9972114 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -775,6 +775,15 @@ "contributions": [ "code" ] + }, + { + "login": "Murmurl912", + "name": "Murmurl912", + "avatar_url": "https://avatars.githubusercontent.com/u/36264246?v=4", + "profile": "https://github.com/Murmurl912", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, From ecebeefd953082121ed34dc30c4dd6bd5e11a488 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:38:28 +0000 Subject: [PATCH 019/181] update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fb5173719..413b1099f 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-86-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-87-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -194,6 +194,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d nlog (solrin)
nlog (solrin)

💻 Murmurl912
Murmurl912

💻 + Benjamin Schulz
Benjamin Schulz

🤔 From 56f79d6ced2ed3c5bee5597cdcdb82d230f3f3bc Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 16:38:29 +0000 Subject: [PATCH 020/181] update .all-contributorsrc --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 8e9972114..3de04dfc7 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -784,6 +784,15 @@ "contributions": [ "code" ] + }, + { + "login": "bschulz87", + "name": "Benjamin Schulz", + "avatar_url": "https://avatars.githubusercontent.com/u/30199362?v=4", + "profile": "https://github.com/bschulz87", + "contributions": [ + "ideas" + ] } ], "contributorsPerLine": 7, From b2b1ddda57a86aff28cbd31234244f409da1fae6 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 25 Oct 2024 18:42:17 +0200 Subject: [PATCH 021/181] Added PlatformInAppLocalhostServer.onData parameter to set a custom on data server callback #2188 --- flutter_inappwebview/CHANGELOG.md | 4 +++ flutter_inappwebview/README.md | 4 ++- flutter_inappwebview/example/lib/main.dart | 5 +-- .../lib/src/in_app_localhost_server.dart | 8 ++++- .../CHANGELOG.md | 1 + .../lib/src/in_app_localhost_server.dart | 32 ++++++++++++++++--- .../src/platform_in_app_localhost_server.dart | 14 ++++++++ flutter_inappwebview_web/CHANGELOG.md | 1 + 8 files changed, 60 insertions(+), 9 deletions(-) diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index afed9dc21..bb06d1818 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -10,6 +10,7 @@ #### Platform Interface - Updated static `fromMap` implementation for some classes +- Added `PlatformInAppLocalhostServer.onData` parameter to set a custom on data server callback #### Android Platform - Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method @@ -21,6 +22,9 @@ - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error - Merged "change priority of DispatchQueue" [#2322](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2322) (thanks to [nnnlog](https://github.com/nnnlog)) +#### Web Platform +- Merged "[web] support iframe role and aria-hidden attributes" [2293](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2293) (thanks to [p-mazhnik](https://github.com/p-mazhnik)) + ## 6.1.5 - Updated dependencies to the latest versions for all platform implementations: diff --git a/flutter_inappwebview/README.md b/flutter_inappwebview/README.md index 3326cf668..413b1099f 100755 --- a/flutter_inappwebview/README.md +++ b/flutter_inappwebview/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-85-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-87-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -193,6 +193,8 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d nlog (solrin)
nlog (solrin)

💻 + Murmurl912
Murmurl912

💻 + Benjamin Schulz
Benjamin Schulz

🤔 diff --git a/flutter_inappwebview/example/lib/main.dart b/flutter_inappwebview/example/lib/main.dart index ebb77618f..737612fcf 100755 --- a/flutter_inappwebview/example/lib/main.dart +++ b/flutter_inappwebview/example/lib/main.dart @@ -3,11 +3,10 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; - import 'package:flutter_inappwebview_example/chrome_safari_browser_example.screen.dart'; import 'package:flutter_inappwebview_example/headless_in_app_webview.screen.dart'; -import 'package:flutter_inappwebview_example/in_app_webiew_example.screen.dart'; import 'package:flutter_inappwebview_example/in_app_browser_example.screen.dart'; +import 'package:flutter_inappwebview_example/in_app_webiew_example.screen.dart'; import 'package:flutter_inappwebview_example/web_authentication_session_example.screen.dart'; import 'package:pointer_interceptor/pointer_interceptor.dart'; @@ -23,6 +22,8 @@ Future main() async { // await Permission.microphone.request(); // await Permission.storage.request(); + await localhostServer.start(); + if (!kIsWeb && defaultTargetPlatform == TargetPlatform.windows) { final availableVersion = await WebViewEnvironment.getAvailableVersion(); assert(availableVersion != null, diff --git a/flutter_inappwebview/lib/src/in_app_localhost_server.dart b/flutter_inappwebview/lib/src/in_app_localhost_server.dart index daae11b7b..841f0cc29 100755 --- a/flutter_inappwebview/lib/src/in_app_localhost_server.dart +++ b/flutter_inappwebview/lib/src/in_app_localhost_server.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer} @@ -9,12 +10,14 @@ class InAppLocalhostServer { String directoryIndex = 'index.html', String documentRoot = './', bool shared = false, + Future Function(HttpRequest request)? onData, }) : this.fromPlatformCreationParams( PlatformInAppLocalhostServerCreationParams( port: port, directoryIndex: directoryIndex, documentRoot: documentRoot, - shared: shared), + shared: shared, + onData: onData), ); /// Constructs a [InAppLocalhostServer] from creation params for a specific @@ -42,6 +45,9 @@ class InAppLocalhostServer { ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.shared} bool get shared => platform.shared; + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.onData} + Future Function(HttpRequest request)? get onData => platform.onData; + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.start} Future start() => platform.start(); diff --git a/flutter_inappwebview_platform_interface/CHANGELOG.md b/flutter_inappwebview_platform_interface/CHANGELOG.md index 8f5781b7f..18e127b0c 100644 --- a/flutter_inappwebview_platform_interface/CHANGELOG.md +++ b/flutter_inappwebview_platform_interface/CHANGELOG.md @@ -1,6 +1,7 @@ #### 1.4.0 - Updated static `fromMap` implementation for some classes +- Added `PlatformInAppLocalhostServer.onData` parameter to set a custom on data server callback ## 1.3.0+1 diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart index f1805c109..3cd048b90 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_localhost_server.dart @@ -38,6 +38,7 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { bool _shared = false; String _directoryIndex = 'index.html'; String _documentRoot = './'; + Future Function(HttpRequest)? _customOnData; /// Creates a new [DefaultInAppLocalhostServer]. DefaultInAppLocalhostServer(PlatformInAppLocalhostServerCreationParams params) @@ -53,6 +54,7 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { ? params.documentRoot : '${params.documentRoot}/'; this._shared = params.shared; + this._customOnData = params.onData; } @override @@ -67,6 +69,9 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { @override bool get shared => _shared; + @override + Future Function(HttpRequest request)? get onData => _customOnData; + @override Future start() async { if (this._started) { @@ -78,11 +83,19 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { runZonedGuarded(() { HttpServer.bind('127.0.0.1', _port, shared: _shared).then((server) { - print('Server running on http://localhost:' + _port.toString()); + if (kDebugMode) { + print('Server running on http://localhost:' + _port.toString()); + } this._server = server; server.listen((HttpRequest request) async { + if (await _customOnData?.call(request) ?? false) { + // if _customOnData returns true, + // it means that the request has been handled + return; + } + Uint8List body = Uint8List(0); var path = request.requestedUri.path; @@ -99,8 +112,10 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { .buffer .asUint8List(); } catch (e) { - print(Uri.decodeFull(path)); - print(e.toString()); + if (kDebugMode) { + print(Uri.decodeFull(path)); + print(e.toString()); + } request.response.close(); return; } @@ -115,13 +130,18 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { } request.response.headers.contentType = contentType; + print(request.response.headers); request.response.add(body); request.response.close(); }); completer.complete(); }); - }, (e, stackTrace) => print('Error: $e $stackTrace')); + }, (e, stackTrace) { + if (kDebugMode) { + print('Error: $e $stackTrace'); + } + }); return completer.future; } @@ -132,7 +152,9 @@ class DefaultInAppLocalhostServer extends PlatformInAppLocalhostServer { return; } await this._server!.close(force: true); - print('Server running on http://localhost:$_port closed'); + if (kDebugMode) { + print('Server running on http://localhost:$_port closed'); + } this._started = false; this._server = null; } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_in_app_localhost_server.dart b/flutter_inappwebview_platform_interface/lib/src/platform_in_app_localhost_server.dart index 39e004d4d..72a60dc8c 100755 --- a/flutter_inappwebview_platform_interface/lib/src/platform_in_app_localhost_server.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_in_app_localhost_server.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; @@ -16,6 +17,7 @@ class PlatformInAppLocalhostServerCreationParams { this.directoryIndex = 'index.html', this.documentRoot = './', this.shared = false, + this.onData = null, }); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.port} @@ -29,6 +31,9 @@ class PlatformInAppLocalhostServerCreationParams { ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.shared} final bool shared; + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.onData} + final Future Function(HttpRequest request)? onData; } ///{@template flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer} @@ -40,6 +45,7 @@ class PlatformInAppLocalhostServerCreationParams { ///- Android native WebView ///- iOS ///- MacOS +///- Windows ///{@endtemplate} abstract class PlatformInAppLocalhostServer extends PlatformInterface { /// Creates a new [PlatformInAppLocalhostServer] @@ -98,6 +104,14 @@ abstract class PlatformInAppLocalhostServer extends PlatformInterface { ///{@endtemplate} bool get shared => params.shared; + ///{@template flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.onData} + ///A custom callback that is called when a new request is received by the server + ///that can be used to send or modify the response, for example adding custom headers. + ///If this callback returns `true`, it means that the request has been handled by this callback. + ///Otherwise, if this callback returns `false`, the server will continue to process the request using the default implementation. + ///{@endtemplate} + Future Function(HttpRequest request)? get onData => params.onData; + ///{@template flutter_inappwebview_platform_interface.PlatformInAppLocalhostServer.start} ///Starts the server on `http://localhost:[port]/`. /// diff --git a/flutter_inappwebview_web/CHANGELOG.md b/flutter_inappwebview_web/CHANGELOG.md index 6a1c66e2a..01f42810f 100644 --- a/flutter_inappwebview_web/CHANGELOG.md +++ b/flutter_inappwebview_web/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.2.0 - Updated flutter_inappwebview_platform_interface version to ^1.4.0 +- Merged "[web] support iframe role and aria-hidden attributes" [2293](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2293) (thanks to [p-mazhnik](https://github.com/p-mazhnik)) ## 1.1.2 From bd80276e4c31886e7169173a81b823758d0f2bd3 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:20:11 +0000 Subject: [PATCH 022/181] update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 413b1099f..40b6a54d6 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-87-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-88-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -195,6 +195,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d nlog (solrin)
nlog (solrin)

💻 Murmurl912
Murmurl912

💻 Benjamin Schulz
Benjamin Schulz

🤔 + seal-app
seal-app

🤔 From b0938cac1e2d190b8ad151a039103a0b2c08451e Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:20:12 +0000 Subject: [PATCH 023/181] update .all-contributorsrc --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 3de04dfc7..02b905b32 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -793,6 +793,15 @@ "contributions": [ "ideas" ] + }, + { + "login": "ShuheiSuzuki-07", + "name": "seal-app", + "avatar_url": "https://avatars.githubusercontent.com/u/118415919?v=4", + "profile": "https://github.com/ShuheiSuzuki-07", + "contributions": [ + "ideas" + ] } ], "contributorsPerLine": 7, From 64c507247b0769037068e8c04b5e6b3d14c7f23a Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:20:56 +0000 Subject: [PATCH 024/181] update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 40b6a54d6..60c5094c6 100755 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d nlog (solrin)
nlog (solrin)

💻 Murmurl912
Murmurl912

💻 Benjamin Schulz
Benjamin Schulz

🤔 - seal-app
seal-app

🤔 + seal-app
seal-app

🤔 💻 From 4342a0154b804ab59e7c6a28118061afe290d1dc Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 25 Oct 2024 17:20:57 +0000 Subject: [PATCH 025/181] update .all-contributorsrc --- .all-contributorsrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 02b905b32..657a7e112 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -800,7 +800,8 @@ "avatar_url": "https://avatars.githubusercontent.com/u/118415919?v=4", "profile": "https://github.com/ShuheiSuzuki-07", "contributions": [ - "ideas" + "ideas", + "code" ] } ], From 8813830b78d9878eb6a6e289a1479c81a72a5b9d Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 25 Oct 2024 19:24:09 +0200 Subject: [PATCH 026/181] Update .all-contributorsrc --- .all-contributorsrc | 1 - 1 file changed, 1 deletion(-) diff --git a/.all-contributorsrc b/.all-contributorsrc index 657a7e112..b62b3eaa3 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -800,7 +800,6 @@ "avatar_url": "https://avatars.githubusercontent.com/u/118415919?v=4", "profile": "https://github.com/ShuheiSuzuki-07", "contributions": [ - "ideas", "code" ] } From 261e6a652c9e3662c7fd8f7e0dd3c4131843755f Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 25 Oct 2024 19:25:17 +0200 Subject: [PATCH 027/181] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60c5094c6..5ddfc4b01 100755 --- a/README.md +++ b/README.md @@ -195,7 +195,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d nlog (solrin)
nlog (solrin)

💻 Murmurl912
Murmurl912

💻 Benjamin Schulz
Benjamin Schulz

🤔 - seal-app
seal-app

🤔 💻 + seal-app
seal-app

💻 From fa1ee68a284ce47cc1d0359fbb80e4becf1ee10e Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 25 Oct 2024 22:30:20 +0200 Subject: [PATCH 028/181] androi: Fixed crash when trying to open InAppBrowser with R.menu.menu_main on release mode, updated android activities restore from savedInstanceState --- flutter_inappwebview/CHANGELOG.md | 2 + .../example/android/app/build.gradle | 4 ++ flutter_inappwebview/example/lib/main.dart | 2 - flutter_inappwebview/pubspec.yaml | 10 ++-- flutter_inappwebview_android/CHANGELOG.md | 2 + .../ChromeCustomTabsActivity.java | 14 +++++- .../in_app_browser/InAppBrowserActivity.java | 46 +++++++++++-------- 7 files changed, 53 insertions(+), 27 deletions(-) diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index bb06d1818..43076a33c 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -17,6 +17,8 @@ - Added `CookieManager.flush` method - Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called - Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025) +- Fixed crash when trying to open InAppBrowser with R.menu.menu_main on release mode +- Merged "Prevent blank InAppBrowser Activity from being restored" [#1984](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1984) (thanks to [ShuheiSuzuki-07](https://github.com/ShuheiSuzuki-07)) #### macOS and iOS Platforms - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error diff --git a/flutter_inappwebview/example/android/app/build.gradle b/flutter_inappwebview/example/android/app/build.gradle index 50bdc4636..a50a94003 100755 --- a/flutter_inappwebview/example/android/app/build.gradle +++ b/flutter_inappwebview/example/android/app/build.gradle @@ -45,6 +45,10 @@ android { buildTypes { release { + // only for com.pichillilorenzo.flutter_inappwebview_android.R.menu.menu_main + minifyEnabled false + shrinkResources false + // TODO: Add your own signing config for the release build. // Signing with the debug keys for now, so `flutter run --release` works. signingConfig signingConfigs.debug diff --git a/flutter_inappwebview/example/lib/main.dart b/flutter_inappwebview/example/lib/main.dart index 737612fcf..b6c8efec9 100755 --- a/flutter_inappwebview/example/lib/main.dart +++ b/flutter_inappwebview/example/lib/main.dart @@ -22,8 +22,6 @@ Future main() async { // await Permission.microphone.request(); // await Permission.storage.request(); - await localhostServer.start(); - if (!kIsWeb && defaultTargetPlatform == TargetPlatform.windows) { final availableVersion = await WebViewEnvironment.getAvailableVersion(); assert(availableVersion != null, diff --git a/flutter_inappwebview/pubspec.yaml b/flutter_inappwebview/pubspec.yaml index 80e20c8df..a1306454b 100755 --- a/flutter_inappwebview/pubspec.yaml +++ b/flutter_inappwebview/pubspec.yaml @@ -21,11 +21,11 @@ dependencies: flutter: sdk: flutter flutter_inappwebview_platform_interface: ^1.4.0 - flutter_inappwebview_android: ^1.1.3 - flutter_inappwebview_ios: ^1.1.2 - flutter_inappwebview_macos: ^1.1.2 - flutter_inappwebview_web: ^1.1.2 - flutter_inappwebview_windows: ^0.6.0 + flutter_inappwebview_android: ^1.2.0 + flutter_inappwebview_ios: ^1.2.0 + flutter_inappwebview_macos: ^1.2.0 + flutter_inappwebview_web: ^1.2.0 + flutter_inappwebview_windows: ^0.7.0 dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md index fec6738d9..6c7cb27ab 100644 --- a/flutter_inappwebview_android/CHANGELOG.md +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -5,6 +5,8 @@ - Added `CookieManager.flush` method - Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called - Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025) +- Fixed crash when trying to open InAppBrowser with R.menu.menu_main on release mode +- Merged "Prevent blank InAppBrowser Activity from being restored" [#1984](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1984) (thanks to [ShuheiSuzuki-07](https://github.com/ShuheiSuzuki-07)) ## 1.1.3 diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/chrome_custom_tabs/ChromeCustomTabsActivity.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/chrome_custom_tabs/ChromeCustomTabsActivity.java index 444bc25d5..aae335ebb 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/chrome_custom_tabs/ChromeCustomTabsActivity.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/chrome_custom_tabs/ChromeCustomTabsActivity.java @@ -78,13 +78,23 @@ protected void onCreate(Bundle savedInstanceState) { setContentView(R.layout.chrome_custom_tabs_layout); Bundle b = getIntent().getExtras(); - if (b == null) return; + if (b == null) { + if (savedInstanceState != null) { + close(); + } + return; + } id = b.getString("id"); String managerId = b.getString("managerId"); manager = ChromeSafariBrowserManager.shared.get(managerId); - if (manager == null || manager.plugin == null || manager.plugin.messenger == null) return; + if (manager == null || manager.plugin == null || manager.plugin.messenger == null) { + if (savedInstanceState != null) { + close(); + } + return; + } manager.browsers.put(id, this); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java index d2c193b4b..78c763661 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java @@ -51,7 +51,7 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrowserDelegate, Disposable { protected static final String LOG_TAG = "InAppBrowserActivity"; public static final String METHOD_CHANNEL_NAME_PREFIX = "com.pichillilorenzo/flutter_inappbrowser_"; - + @Nullable public Integer windowId; public String id; @@ -77,24 +77,29 @@ public class InAppBrowserActivity extends AppCompatActivity implements InAppBrow @Nullable public InAppBrowserChannelDelegate channelDelegate; public List menuItems = new ArrayList<>(); - + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - if (savedInstanceState != null) { - finish(); + Bundle b = getIntent().getExtras(); + if (b == null) { + if (savedInstanceState != null) { + finish(); + } return; } - Bundle b = getIntent().getExtras(); - if (b == null) return; - id = b.getString("id"); String managerId = b.getString("managerId"); manager = InAppBrowserManager.shared.get(managerId); - if (manager == null || manager.plugin == null|| manager.plugin.messenger == null) return; + if (manager == null || manager.plugin == null || manager.plugin.messenger == null) { + if (savedInstanceState != null) { + finish(); + } + return; + } Map settingsMap = (Map) b.getSerializable("settings"); customSettings.parse(settingsMap); @@ -111,7 +116,7 @@ protected void onCreate(Bundle savedInstanceState) { pullToRefreshLayout.channelDelegate = new PullToRefreshChannelDelegate(pullToRefreshLayout, pullToRefreshLayoutChannel); pullToRefreshLayout.settings = pullToRefreshSettings; pullToRefreshLayout.prepare(); - + webView = findViewById(R.id.webView); webView.id = id; webView.windowId = windowId; @@ -171,15 +176,13 @@ protected void onCreate(Bundle savedInstanceState) { Log.e(LOG_TAG, initialFile + " asset file cannot be found!", e); return; } - } - else if (initialData != null) { + } else if (initialData != null) { String mimeType = b.getString("initialMimeType"); String encoding = b.getString("initialEncoding"); String baseUrl = b.getString("initialBaseUrl"); String historyUrl = b.getString("initialHistoryUrl"); webView.loadDataWithBaseURL(baseUrl, initialData, mimeType, encoding, historyUrl); - } - else if (initialUrlRequest != null) { + } else if (initialUrlRequest != null) { URLRequest urlRequest = URLRequest.fromMap(initialUrlRequest); if (urlRequest != null) { webView.loadUrl(urlRequest); @@ -242,8 +245,15 @@ public boolean onCreateOptionsMenu(Menu m) { } MenuInflater inflater = getMenuInflater(); - // Inflate menu to add items to action bar if it is present. - inflater.inflate(R.menu.menu_main, menu); + try { + // Inflate menu to add items to action bar if it is present. + inflater.inflate(R.menu.menu_main, menu); + } catch (Exception e) { + e.printStackTrace(); + Log.e(LOG_TAG, "Cannot inflate com.pichillilorenzo.flutter_inappwebview_android.R.menu.menu_main." + + "To make it work, you need to set minifyEnabled false and shrinkResources false in your build.gradle file."); + return super.onCreateOptionsMenu(m); + } MenuItem menuSearchItem = menu.findItem(R.id.menu_search); if (menuSearchItem != null) { @@ -607,9 +617,9 @@ public List getActivityResultListeners() { } @Override - protected void onActivityResult (int requestCode, - int resultCode, - Intent data) { + protected void onActivityResult(int requestCode, + int resultCode, + Intent data) { for (ActivityResultListener listener : activityResultListeners) { if (listener.onActivityResult(requestCode, resultCode, data)) { return; From 33af65b1d77d80bd7890e0ed02c5ae3d7a8d3c73 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Sun, 27 Oct 2024 00:55:22 +0200 Subject: [PATCH 029/181] Added javaScriptHandlerOriginAllowList, pluginScriptsOriginAllowList, pluginScriptsForMainFrameOnly InAppWebViewSettings parameters, Added setJavaScriptBridgeName, getJavaScriptBridgeName static WebView controller methods, Added JavaScriptHandlerFunctionData type, Deprecated JavaScriptHandlerCallback type in favor of JavaScriptHandlerFunction type, android: Added support for UserScript.forMainFrameOnly parameter, Updated UserScript at document end implementation --- flutter_inappwebview/CHANGELOG.md | 6 + .../lib/in_app_webiew_example.screen.dart | 22 +- flutter_inappwebview/example/lib/main.dart | 2 + .../Flutter/GeneratedPluginRegistrant.swift | 2 - flutter_inappwebview/example/pubspec.yaml | 16 +- .../flutter/generated_plugin_registrant.cc | 3 - .../windows/flutter/generated_plugins.cmake | 1 - .../in_app_webview_controller.dart | 14 +- flutter_inappwebview/pubspec.yaml | 14 +- flutter_inappwebview_android/CHANGELOG.md | 2 + .../ContentBlockerHandler.java | 4 +- .../in_app_browser/InAppBrowserActivity.java | 4 +- .../InterceptAjaxRequestJS.java | 513 +++++++++-------- .../InterceptFetchRequestJS.java | 298 +++++----- .../plugin_scripts_js/JavaScriptBridgeJS.java | 544 ++++++++++-------- .../plugin_scripts_js/OnLoadResourceJS.java | 67 ++- .../OnWindowBlurEventJS.java | 38 +- .../OnWindowFocusEventJS.java | 38 +- .../plugin_scripts_js/PluginScriptsUtil.java | 78 ++- .../plugin_scripts_js/PrintJS.java | 42 +- .../plugin_scripts_js/PromisePolyfillJS.java | 24 +- .../types/JavaScriptHandlerFunctionData.java | 92 +++ .../types/PluginScript.java | 5 +- .../types/UserContentController.java | 185 ++++-- .../types/UserScript.java | 28 +- .../types/WebMessagePort.java | 10 +- .../webview/InAppWebViewInterface.java | 3 +- .../webview/InAppWebViewManager.java | 24 +- .../webview/JavaScriptBridgeInterface.java | 66 ++- .../webview/WebViewChannelDelegate.java | 9 +- .../webview/in_app_webview/InAppWebView.java | 76 ++- .../in_app_webview/InAppWebViewClient.java | 15 +- .../InAppWebViewClientCompat.java | 15 +- .../in_app_webview/InAppWebViewSettings.java | 30 +- .../web_message/WebMessageChannel.java | 2 +- .../web_message/WebMessageListener.java | 5 +- .../example/pubspec.lock | 11 +- .../in_app_webview_controller.dart | 71 ++- flutter_inappwebview_android/pubspec.yaml | 3 +- .../CHANGELOG.md | 3 + .../in_app_webview_keep_alive.dart | 2 +- .../in_app_webview_settings.dart | 38 ++ .../in_app_webview_settings.g.dart | 54 +- .../platform_inappwebview_controller.dart | 32 +- .../types/javascript_handler_callback.dart | 19 +- .../types/javascript_handler_callback.g.dart | 50 ++ .../lib/src/types/main.dart | 9 +- .../lib/src/types/user_script.dart | 12 +- .../lib/src/types/user_script.g.dart | 8 +- 49 files changed, 1652 insertions(+), 957 deletions(-) create mode 100644 flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/JavaScriptHandlerFunctionData.java create mode 100644 flutter_inappwebview_platform_interface/lib/src/types/javascript_handler_callback.g.dart diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index 43076a33c..8e1f2980f 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -11,10 +11,16 @@ #### Platform Interface - Updated static `fromMap` implementation for some classes - Added `PlatformInAppLocalhostServer.onData` parameter to set a custom on data server callback +- Added `javaScriptHandlerOriginAllowList`, `pluginScriptsOriginAllowList`, `pluginScriptsForMainFrameOnly` InAppWebViewSettings parameters +- Added `setJavaScriptBridgeName`, `getJavaScriptBridgeName` static WebView controller methods +- Added `JavaScriptHandlerFunctionData` type +- Deprecated `JavaScriptHandlerCallback` type in favor of `JavaScriptHandlerFunction` type #### Android Platform - Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method - Added `CookieManager.flush` method +- Added support for `UserScript.forMainFrameOnly` parameter +- Updated UserScript at document end implementation - Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called - Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025) - Fixed crash when trying to open InAppBrowser with R.menu.menu_main on release mode diff --git a/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart b/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart index ce3dbcfd5..48ff62f11 100755 --- a/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart +++ b/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart @@ -21,6 +21,9 @@ class _InAppWebViewExampleScreenState extends State { mediaPlaybackRequiresUserGesture: false, allowsInlineMediaPlayback: true, iframeAllow: "camera; microphone", + javaScriptHandlerOriginAllowList: {".*"}, + pluginScriptsForMainFrameOnly: false, + pluginScriptsOriginAllowList: {"*"}, iframeAllowFullscreen: true); PullToRefreshController? pullToRefreshController; @@ -116,16 +119,31 @@ class _InAppWebViewExampleScreenState extends State { key: webViewKey, webViewEnvironment: webViewEnvironment, initialUrlRequest: - URLRequest(url: WebUri('https://flutter.dev')), + URLRequest(url: WebUri('https://www.w3schools.com/tags/tryit.asp?filename=tryhtml_iframe')), // initialUrlRequest: // URLRequest(url: WebUri(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')), // initialFile: "assets/index.html", - initialUserScripts: UnmodifiableListView([]), + // initialUserScripts: UnmodifiableListView([]), initialSettings: settings, contextMenu: contextMenu, pullToRefreshController: pullToRefreshController, + initialUserScripts: UnmodifiableListView([ + UserScript( + source: "console.log('loaded'); window.custom_js_bridge.callHandler('handlerName', 1, 4, true, {\"foo\": \"bar\"});", + injectionTime: UserScriptInjectionTime.AT_DOCUMENT_END, + allowedOriginRules: {"https://www.w3schools.com", "https://www.example.com"}, + forMainFrameOnly: false), + ]), onWebViewCreated: (controller) async { webViewController = controller; + controller.addJavaScriptHandler(handlerName: 'handlerName', callback: (JavaScriptHandlerFunctionData handlerData) { + print(handlerData); + return handlerData.args; + }); + controller.addJavaScriptHandler(handlerName: 'handlerName2', callback: (arguments) { + print(arguments); + return arguments; + }); }, onLoadStart: (controller, url) async { setState(() { diff --git a/flutter_inappwebview/example/lib/main.dart b/flutter_inappwebview/example/lib/main.dart index b6c8efec9..70ef5ae02 100755 --- a/flutter_inappwebview/example/lib/main.dart +++ b/flutter_inappwebview/example/lib/main.dart @@ -35,6 +35,8 @@ Future main() async { await InAppWebViewController.setWebContentsDebuggingEnabled(kDebugMode); } + await InAppWebViewController.setJavaScriptBridgeName('custom_js_bridge'); + runApp(MyApp()); } diff --git a/flutter_inappwebview/example/macos/Flutter/GeneratedPluginRegistrant.swift b/flutter_inappwebview/example/macos/Flutter/GeneratedPluginRegistrant.swift index 959e5aa02..a1cdfd0cd 100644 --- a/flutter_inappwebview/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/flutter_inappwebview/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,12 +5,10 @@ import FlutterMacOS import Foundation -import flutter_inappwebview_macos import path_provider_foundation import url_launcher_macos func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { - InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin")) PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) } diff --git a/flutter_inappwebview/example/pubspec.yaml b/flutter_inappwebview/example/pubspec.yaml index 0efca4a07..60f326604 100755 --- a/flutter_inappwebview/example/pubspec.yaml +++ b/flutter_inappwebview/example/pubspec.yaml @@ -37,14 +37,14 @@ dependency_overrides: path: ../../flutter_inappwebview_platform_interface flutter_inappwebview_android: path: ../../flutter_inappwebview_android - flutter_inappwebview_ios: - path: ../../flutter_inappwebview_ios - flutter_inappwebview_macos: - path: ../../flutter_inappwebview_macos - flutter_inappwebview_web: - path: ../../flutter_inappwebview_web - flutter_inappwebview_windows: - path: ../../flutter_inappwebview_windows +# flutter_inappwebview_ios: +# path: ../../flutter_inappwebview_ios +# flutter_inappwebview_macos: +# path: ../../flutter_inappwebview_macos +# flutter_inappwebview_web: +# path: ../../flutter_inappwebview_web +# flutter_inappwebview_windows: +# path: ../../flutter_inappwebview_windows dev_dependencies: flutter_test: diff --git a/flutter_inappwebview/example/windows/flutter/generated_plugin_registrant.cc b/flutter_inappwebview/example/windows/flutter/generated_plugin_registrant.cc index 031b86957..a0d0bbebf 100644 --- a/flutter_inappwebview/example/windows/flutter/generated_plugin_registrant.cc +++ b/flutter_inappwebview/example/windows/flutter/generated_plugin_registrant.cc @@ -6,13 +6,10 @@ #include "generated_plugin_registrant.h" -#include #include #include void RegisterPlugins(flutter::PluginRegistry* registry) { - FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar( - registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi")); PermissionHandlerWindowsPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); UrlLauncherWindowsRegisterWithRegistrar( diff --git a/flutter_inappwebview/example/windows/flutter/generated_plugins.cmake b/flutter_inappwebview/example/windows/flutter/generated_plugins.cmake index 997d0b803..c20a586d1 100644 --- a/flutter_inappwebview/example/windows/flutter/generated_plugins.cmake +++ b/flutter_inappwebview/example/windows/flutter/generated_plugins.cmake @@ -3,7 +3,6 @@ # list(APPEND FLUTTER_PLUGIN_LIST - flutter_inappwebview_windows permission_handler_windows url_launcher_windows ) diff --git a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart index 0232fac93..12d3efa97 100644 --- a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart @@ -167,12 +167,12 @@ class InAppWebViewController { ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.addJavaScriptHandler} void addJavaScriptHandler( {required String handlerName, - required JavaScriptHandlerCallback callback}) => + required Function callback}) => platform.addJavaScriptHandler( handlerName: handlerName, callback: callback); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.removeJavaScriptHandler} - JavaScriptHandlerCallback? removeJavaScriptHandler( + Function? removeJavaScriptHandler( {required String handlerName}) => platform.removeJavaScriptHandler(handlerName: handlerName); @@ -570,6 +570,16 @@ class InAppWebViewController { PlatformInAppWebViewController.static() .enableSlowWholeDocumentDraw(); + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.setJavaScriptBridgeName} + static Future setJavaScriptBridgeName(String bridgeName) => + PlatformInAppWebViewController.static() + .setJavaScriptBridgeName(bridgeName); + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getJavaScriptBridgeName} + static Future getJavaScriptBridgeName() => + PlatformInAppWebViewController.static() + .getJavaScriptBridgeName(); + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.tRexRunnerHtml} static Future get tRexRunnerHtml => PlatformInAppWebViewController.static().tRexRunnerHtml; diff --git a/flutter_inappwebview/pubspec.yaml b/flutter_inappwebview/pubspec.yaml index a1306454b..b498bbfed 100755 --- a/flutter_inappwebview/pubspec.yaml +++ b/flutter_inappwebview/pubspec.yaml @@ -20,12 +20,14 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.4.0 - flutter_inappwebview_android: ^1.2.0 - flutter_inappwebview_ios: ^1.2.0 - flutter_inappwebview_macos: ^1.2.0 - flutter_inappwebview_web: ^1.2.0 - flutter_inappwebview_windows: ^0.7.0 + flutter_inappwebview_platform_interface: #^1.4.0 + path: ../flutter_inappwebview_platform_interface + flutter_inappwebview_android: #^1.2.0 + path: ../flutter_inappwebview_android +# flutter_inappwebview_ios: ^1.2.0 +# flutter_inappwebview_macos: ^1.2.0 +# flutter_inappwebview_web: ^1.2.0 +# flutter_inappwebview_windows: ^0.7.0 dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md index 6c7cb27ab..7de8e4034 100644 --- a/flutter_inappwebview_android/CHANGELOG.md +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -3,6 +3,8 @@ - Updated flutter_inappwebview_platform_interface version to ^1.4.0 - Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method - Added `CookieManager.flush` method +- Added support for `UserScript.forMainFrameOnly` parameter +- Updated UserScript at document end implementation - Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called - Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025) - Fixed crash when trying to open InAppBrowser with R.menu.menu_main on release mode diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/content_blocker/ContentBlockerHandler.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/content_blocker/ContentBlockerHandler.java index 8564dbe82..8a3e862a8 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/content_blocker/ContentBlockerHandler.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/content_blocker/ContentBlockerHandler.java @@ -157,9 +157,9 @@ public void run() { final String cssSelector = action.getSelector(); final String jsScript = "(function(d) { " + " function hide () { " + - " if (d.body != null && !d.getElementById('" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "-css-display-none-style')) { " + + " if (d.body != null && !d.getElementById('" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "-css-display-none-style')) { " + " var c = d.createElement('style'); " + - " c.id = '" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "-css-display-none-style'; " + + " c.id = '" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "-css-display-none-style'; " + " c.innerHTML = '" + cssSelector + " { display: none !important; }'; " + " d.body.appendChild(c); " + " }" + diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java index 78c763661..0fee8e3cf 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/in_app_browser/InAppBrowserActivity.java @@ -541,8 +541,8 @@ public void setSettings(InAppBrowserSettings newSettings, HashMap getCustomSettings() { - Map webViewSettingsMap = webView != null ? webView.getCustomSettings() : null; + public Map getCustomSettingsMap() { + Map webViewSettingsMap = webView != null ? webView.getCustomSettingsMap() : null; if (customSettings == null || webViewSettingsMap == null) return null; diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptAjaxRequestJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptAjaxRequestJS.java index 2ec2e0178..c1b26fb40 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptAjaxRequestJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptAjaxRequestJS.java @@ -1,266 +1,285 @@ package com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js; +import androidx.annotation.Nullable; + import com.pichillilorenzo.flutter_inappwebview_android.types.PluginScript; import com.pichillilorenzo.flutter_inappwebview_android.types.UserScriptInjectionTime; +import java.util.Set; + public class InterceptAjaxRequestJS { public static final String INTERCEPT_AJAX_REQUEST_JS_PLUGIN_SCRIPT_GROUP_NAME = "IN_APP_WEBVIEW_INTERCEPT_AJAX_REQUEST_JS_PLUGIN_SCRIPT"; - public static final String FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE = JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._useShouldInterceptAjaxRequest"; - public static final String FLAG_VARIABLE_FOR_INTERCEPT_ONLY_ASYNC_AJAX_REQUESTS_JS_SOURCE = JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._interceptOnlyAsyncAjaxRequests"; - public static final PluginScript INTERCEPT_AJAX_REQUEST_JS_PLUGIN_SCRIPT = new PluginScript( - InterceptAjaxRequestJS.INTERCEPT_AJAX_REQUEST_JS_PLUGIN_SCRIPT_GROUP_NAME, - InterceptAjaxRequestJS.INTERCEPT_AJAX_REQUEST_JS_SOURCE, - UserScriptInjectionTime.AT_DOCUMENT_START, - null, - true, - null - ); + public static String FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE() { + return + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._useShouldInterceptAjaxRequest"; + } + public static String FLAG_VARIABLE_FOR_INTERCEPT_ONLY_ASYNC_AJAX_REQUESTS_JS_SOURCE() { + return + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._interceptOnlyAsyncAjaxRequests"; + } + public static PluginScript INTERCEPT_AJAX_REQUEST_JS_PLUGIN_SCRIPT(@Nullable Set allowedOriginRules, + boolean forMainFrameOnly) { + return + new PluginScript( + InterceptAjaxRequestJS.INTERCEPT_AJAX_REQUEST_JS_PLUGIN_SCRIPT_GROUP_NAME, + InterceptAjaxRequestJS.INTERCEPT_AJAX_REQUEST_JS_SOURCE(), + UserScriptInjectionTime.AT_DOCUMENT_START, + null, + true, + allowedOriginRules, + forMainFrameOnly + ); + } public static PluginScript createInterceptOnlyAsyncAjaxRequestsPluginScript(boolean onlyAsync) { return new PluginScript( InterceptAjaxRequestJS.INTERCEPT_AJAX_REQUEST_JS_PLUGIN_SCRIPT_GROUP_NAME, - "window." + FLAG_VARIABLE_FOR_INTERCEPT_ONLY_ASYNC_AJAX_REQUESTS_JS_SOURCE + " = " + onlyAsync +";", + "window." + FLAG_VARIABLE_FOR_INTERCEPT_ONLY_ASYNC_AJAX_REQUESTS_JS_SOURCE() + " = " + onlyAsync +";", UserScriptInjectionTime.AT_DOCUMENT_START, null, true, - null + null, + false ); } - public static final String INTERCEPT_AJAX_REQUEST_JS_SOURCE = "(function(ajax) {" + - " var w = (window.top == null || window.top === window) ? window : window.top;" + - " w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE + " = true;" + - " var send = ajax.prototype.send;" + - " var open = ajax.prototype.open;" + - " var setRequestHeader = ajax.prototype.setRequestHeader;" + - " ajax.prototype._flutter_inappwebview_url = null;" + - " ajax.prototype._flutter_inappwebview_method = null;" + - " ajax.prototype._flutter_inappwebview_isAsync = null;" + - " ajax.prototype._flutter_inappwebview_user = null;" + - " ajax.prototype._flutter_inappwebview_password = null;" + - " ajax.prototype._flutter_inappwebview_password = null;" + - " ajax.prototype._flutter_inappwebview_already_onreadystatechange_wrapped = false;" + - " ajax.prototype._flutter_inappwebview_request_headers = {};" + - " function convertRequestResponse(request, callback) {" + - " if (request.response != null && request.responseType != null) {" + - " switch (request.responseType) {" + - " case 'arraybuffer':" + - " callback(new Uint8Array(request.response));" + - " return;" + - " case 'blob':" + - " const reader = new FileReader();" + - " reader.addEventListener('loadend', function() { " + - " callback(new Uint8Array(reader.result));" + - " });" + - " reader.readAsArrayBuffer(blob);" + - " return;" + - " case 'document':" + - " callback(request.response.documentElement.outerHTML);" + - " return;" + - " case 'json':" + - " callback(request.response);" + - " return;" + - " };" + - " }" + - " callback(null);" + - " };" + - " ajax.prototype.open = function(method, url, isAsync, user, password) {" + - " isAsync = (isAsync != null) ? isAsync : true;" + - " this._flutter_inappwebview_url = url;" + - " this._flutter_inappwebview_method = method;" + - " this._flutter_inappwebview_isAsync = isAsync;" + - " this._flutter_inappwebview_user = user;" + - " this._flutter_inappwebview_password = password;" + - " this._flutter_inappwebview_request_headers = {};" + - " open.call(this, method, url, isAsync, user, password);" + - " };" + - " ajax.prototype.setRequestHeader = function(header, value) {" + - " this._flutter_inappwebview_request_headers[header] = value;" + - " setRequestHeader.call(this, header, value);" + - " };" + - " function handleEvent(e) {" + - " var self = this;" + - " var w = (window.top == null || window.top === window) ? window : window.top;" + - " if (w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE + " == null || w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE + " == true) {" + - " var headers = this.getAllResponseHeaders();" + - " var responseHeaders = {};" + - " if (headers != null) {" + - " var arr = headers.trim().split(/[\\r\\n]+/);" + - " arr.forEach(function (line) {" + - " var parts = line.split(': ');" + - " var header = parts.shift();" + - " var value = parts.join(': ');" + - " responseHeaders[header] = value;" + - " });" + - " }" + - " convertRequestResponse(this, function(response) {" + - " var ajaxRequest = {" + - " method: self._flutter_inappwebview_method," + - " url: self._flutter_inappwebview_url," + - " isAsync: self._flutter_inappwebview_isAsync," + - " user: self._flutter_inappwebview_user," + - " password: self._flutter_inappwebview_password," + - " withCredentials: self.withCredentials," + - " headers: self._flutter_inappwebview_request_headers," + - " readyState: self.readyState," + - " status: self.status," + - " responseURL: self.responseURL," + - " responseType: self.responseType," + - " response: response," + - " responseText: (self.responseType == 'text' || self.responseType == '') ? self.responseText : null," + - " responseXML: (self.responseType == 'document' && self.responseXML != null) ? self.responseXML.documentElement.outerHTML : null," + - " statusText: self.statusText," + - " responseHeaders, responseHeaders," + - " event: {" + - " type: e.type," + - " loaded: e.loaded," + - " lengthComputable: e.lengthComputable," + - " total: e.total" + - " }" + - " };" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('onAjaxProgress', ajaxRequest).then(function(result) {" + - " if (result != null) {" + - " switch (result) {" + - " case 0:" + - " self.abort();" + - " return;" + - " };" + - " }" + - " });" + - " });" + - " }" + - " };" + - " ajax.prototype.send = function(data) {" + - " var self = this;" + - " var w = (window.top == null || window.top === window) ? window : window.top;" + - " var canBeIntercepted = self._flutter_inappwebview_isAsync || w." + FLAG_VARIABLE_FOR_INTERCEPT_ONLY_ASYNC_AJAX_REQUESTS_JS_SOURCE + " === false;" + - " if (canBeIntercepted && (w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE + " == null || w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE + " == true)) {" + - " if (!this._flutter_inappwebview_already_onreadystatechange_wrapped) {" + - " this._flutter_inappwebview_already_onreadystatechange_wrapped = true;" + - " var onreadystatechange = this.onreadystatechange;" + - " this.onreadystatechange = function() {" + - " var w = (window.top == null || window.top === window) ? window : window.top;" + - " if (w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE + " == null || w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE + " == true) {" + - " var headers = this.getAllResponseHeaders();" + - " var responseHeaders = {};" + - " if (headers != null) {" + - " var arr = headers.trim().split(/[\\r\\n]+/);" + - " arr.forEach(function (line) {" + - " var parts = line.split(': ');" + - " var header = parts.shift();" + - " var value = parts.join(': ');" + - " responseHeaders[header] = value;" + - " });" + - " }" + - " convertRequestResponse(this, function(response) {" + - " var ajaxRequest = {" + - " method: self._flutter_inappwebview_method," + - " url: self._flutter_inappwebview_url," + - " isAsync: self._flutter_inappwebview_isAsync," + - " user: self._flutter_inappwebview_user," + - " password: self._flutter_inappwebview_password," + - " withCredentials: self.withCredentials," + - " headers: self._flutter_inappwebview_request_headers," + - " readyState: self.readyState," + - " status: self.status," + - " responseURL: self.responseURL," + - " responseType: self.responseType," + - " response: response," + - " responseText: (self.responseType == 'text' || self.responseType == '') ? self.responseText : null," + - " responseXML: (self.responseType == 'document' && self.responseXML != null) ? self.responseXML.documentElement.outerHTML : null," + - " statusText: self.statusText," + - " responseHeaders: responseHeaders" + - " };" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('onAjaxReadyStateChange', ajaxRequest).then(function(result) {" + - " if (result != null) {" + - " switch (result) {" + - " case 0:" + - " self.abort();" + - " return;" + - " };" + - " }" + - " if (onreadystatechange != null) {" + - " onreadystatechange();" + - " }" + - " });" + - " });" + - " } else if (onreadystatechange != null) {" + - " onreadystatechange();" + - " }" + - " };" + - " }" + - " this.addEventListener('loadstart', handleEvent);" + - " this.addEventListener('load', handleEvent);" + - " this.addEventListener('loadend', handleEvent);" + - " this.addEventListener('progress', handleEvent);" + - " this.addEventListener('error', handleEvent);" + - " this.addEventListener('abort', handleEvent);" + - " this.addEventListener('timeout', handleEvent);" + - " " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".convertBodyRequest(data).then(function(data) {" + - " var ajaxRequest = {" + - " data: data," + - " method: self._flutter_inappwebview_method," + - " url: self._flutter_inappwebview_url," + - " isAsync: self._flutter_inappwebview_isAsync," + - " user: self._flutter_inappwebview_user," + - " password: self._flutter_inappwebview_password," + - " withCredentials: self.withCredentials," + - " headers: self._flutter_inappwebview_request_headers," + - " responseType: self.responseType" + - " };" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('shouldInterceptAjaxRequest', ajaxRequest).then(function(result) {" + - " if (result != null) {" + - " switch (result) {" + - " case 0:" + - " self.abort();" + - " return;" + - " };" + - " if (result.data != null && !" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".isString(result.data) && result.data.length > 0) {" + - " var bodyString = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".arrayBufferToString(result.data);" + - " if (" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".isBodyFormData(bodyString)) {" + - " var formDataContentType = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".getFormDataContentType(bodyString);" + - " if (result.headers != null) {" + - " result.headers['Content-Type'] = result.headers['Content-Type'] == null ? formDataContentType : result.headers['Content-Type'];" + - " } else {" + - " result.headers = { 'Content-Type': formDataContentType };" + - " }" + - " }" + - " }" + - " if (" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".isString(result.data) || result.data == null) {" + - " data = result.data;" + - " } else if (result.data.length > 0) {" + - " data = new Uint8Array(result.data);" + - " }" + - " self.withCredentials = result.withCredentials;" + - " if (result.responseType != null && self._flutter_inappwebview_isAsync) {" + - " self.responseType = result.responseType;" + - " };" + - " for (var header in result.headers) {" + - " var value = result.headers[header];" + - " var flutter_inappwebview_value = self._flutter_inappwebview_request_headers[header];" + - " if (flutter_inappwebview_value == null) {" + - " self._flutter_inappwebview_request_headers[header] = value;" + - " } else {" + - " self._flutter_inappwebview_request_headers[header] += ', ' + value;" + - " }" + - " setRequestHeader.call(self, header, value);" + - " };" + - " if ((self._flutter_inappwebview_method != result.method && result.method != null) ||" + - " (self._flutter_inappwebview_url != result.url && result.url != null) ||" + - " (self._flutter_inappwebview_isAsync != result.isAsync && result.isAsync != null) ||" + - " (self._flutter_inappwebview_user != result.user && result.user != null) ||" + - " (self._flutter_inappwebview_password != result.password && result.password != null)) {" + - " self.abort();" + - " self.open(result.method, result.url, result.isAsync, result.user, result.password);" + - " }" + - " }" + - " send.call(self, data);" + - " });" + - " });" + - " } else {" + - " send.call(this, data);" + - " }" + - " };" + - "})(window.XMLHttpRequest);"; + public static String INTERCEPT_AJAX_REQUEST_JS_SOURCE() { + return + "(function(ajax) {" + + " var w = (window.top == null || window.top === window) ? window : window.top;" + + " w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE() + " = true;" + + " var send = ajax.prototype.send;" + + " var open = ajax.prototype.open;" + + " var setRequestHeader = ajax.prototype.setRequestHeader;" + + " ajax.prototype._flutter_inappwebview_url = null;" + + " ajax.prototype._flutter_inappwebview_method = null;" + + " ajax.prototype._flutter_inappwebview_isAsync = null;" + + " ajax.prototype._flutter_inappwebview_user = null;" + + " ajax.prototype._flutter_inappwebview_password = null;" + + " ajax.prototype._flutter_inappwebview_password = null;" + + " ajax.prototype._flutter_inappwebview_already_onreadystatechange_wrapped = false;" + + " ajax.prototype._flutter_inappwebview_request_headers = {};" + + " function convertRequestResponse(request, callback) {" + + " if (request.response != null && request.responseType != null) {" + + " switch (request.responseType) {" + + " case 'arraybuffer':" + + " callback(new Uint8Array(request.response));" + + " return;" + + " case 'blob':" + + " const reader = new FileReader();" + + " reader.addEventListener('loadend', function() { " + + " callback(new Uint8Array(reader.result));" + + " });" + + " reader.readAsArrayBuffer(blob);" + + " return;" + + " case 'document':" + + " callback(request.response.documentElement.outerHTML);" + + " return;" + + " case 'json':" + + " callback(request.response);" + + " return;" + + " };" + + " }" + + " callback(null);" + + " };" + + " ajax.prototype.open = function(method, url, isAsync, user, password) {" + + " isAsync = (isAsync != null) ? isAsync : true;" + + " this._flutter_inappwebview_url = url;" + + " this._flutter_inappwebview_method = method;" + + " this._flutter_inappwebview_isAsync = isAsync;" + + " this._flutter_inappwebview_user = user;" + + " this._flutter_inappwebview_password = password;" + + " this._flutter_inappwebview_request_headers = {};" + + " open.call(this, method, url, isAsync, user, password);" + + " };" + + " ajax.prototype.setRequestHeader = function(header, value) {" + + " this._flutter_inappwebview_request_headers[header] = value;" + + " setRequestHeader.call(this, header, value);" + + " };" + + " function handleEvent(e) {" + + " var self = this;" + + " var w = (window.top == null || window.top === window) ? window : window.top;" + + " if (w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE() + " == null || w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE() + " == true) {" + + " var headers = this.getAllResponseHeaders();" + + " var responseHeaders = {};" + + " if (headers != null) {" + + " var arr = headers.trim().split(/[\\r\\n]+/);" + + " arr.forEach(function (line) {" + + " var parts = line.split(': ');" + + " var header = parts.shift();" + + " var value = parts.join(': ');" + + " responseHeaders[header] = value;" + + " });" + + " }" + + " convertRequestResponse(this, function(response) {" + + " var ajaxRequest = {" + + " method: self._flutter_inappwebview_method," + + " url: self._flutter_inappwebview_url," + + " isAsync: self._flutter_inappwebview_isAsync," + + " user: self._flutter_inappwebview_user," + + " password: self._flutter_inappwebview_password," + + " withCredentials: self.withCredentials," + + " headers: self._flutter_inappwebview_request_headers," + + " readyState: self.readyState," + + " status: self.status," + + " responseURL: self.responseURL," + + " responseType: self.responseType," + + " response: response," + + " responseText: (self.responseType == 'text' || self.responseType == '') ? self.responseText : null," + + " responseXML: (self.responseType == 'document' && self.responseXML != null) ? self.responseXML.documentElement.outerHTML : null," + + " statusText: self.statusText," + + " responseHeaders, responseHeaders," + + " event: {" + + " type: e.type," + + " loaded: e.loaded," + + " lengthComputable: e.lengthComputable," + + " total: e.total" + + " }" + + " };" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('onAjaxProgress', ajaxRequest).then(function(result) {" + + " if (result != null) {" + + " switch (result) {" + + " case 0:" + + " self.abort();" + + " return;" + + " };" + + " }" + + " });" + + " });" + + " }" + + " };" + + " ajax.prototype.send = function(data) {" + + " var self = this;" + + " var w = (window.top == null || window.top === window) ? window : window.top;" + + " var canBeIntercepted = self._flutter_inappwebview_isAsync || w." + FLAG_VARIABLE_FOR_INTERCEPT_ONLY_ASYNC_AJAX_REQUESTS_JS_SOURCE() + " === false;" + + " if (canBeIntercepted && (w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE() + " == null || w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE() + " == true)) {" + + " if (!this._flutter_inappwebview_already_onreadystatechange_wrapped) {" + + " this._flutter_inappwebview_already_onreadystatechange_wrapped = true;" + + " var onreadystatechange = this.onreadystatechange;" + + " this.onreadystatechange = function() {" + + " var w = (window.top == null || window.top === window) ? window : window.top;" + + " if (w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE() + " == null || w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_AJAX_REQUEST_JS_SOURCE() + " == true) {" + + " var headers = this.getAllResponseHeaders();" + + " var responseHeaders = {};" + + " if (headers != null) {" + + " var arr = headers.trim().split(/[\\r\\n]+/);" + + " arr.forEach(function (line) {" + + " var parts = line.split(': ');" + + " var header = parts.shift();" + + " var value = parts.join(': ');" + + " responseHeaders[header] = value;" + + " });" + + " }" + + " convertRequestResponse(this, function(response) {" + + " var ajaxRequest = {" + + " method: self._flutter_inappwebview_method," + + " url: self._flutter_inappwebview_url," + + " isAsync: self._flutter_inappwebview_isAsync," + + " user: self._flutter_inappwebview_user," + + " password: self._flutter_inappwebview_password," + + " withCredentials: self.withCredentials," + + " headers: self._flutter_inappwebview_request_headers," + + " readyState: self.readyState," + + " status: self.status," + + " responseURL: self.responseURL," + + " responseType: self.responseType," + + " response: response," + + " responseText: (self.responseType == 'text' || self.responseType == '') ? self.responseText : null," + + " responseXML: (self.responseType == 'document' && self.responseXML != null) ? self.responseXML.documentElement.outerHTML : null," + + " statusText: self.statusText," + + " responseHeaders: responseHeaders" + + " };" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('onAjaxReadyStateChange', ajaxRequest).then(function(result) {" + + " if (result != null) {" + + " switch (result) {" + + " case 0:" + + " self.abort();" + + " return;" + + " };" + + " }" + + " if (onreadystatechange != null) {" + + " onreadystatechange();" + + " }" + + " });" + + " });" + + " } else if (onreadystatechange != null) {" + + " onreadystatechange();" + + " }" + + " };" + + " }" + + " this.addEventListener('loadstart', handleEvent);" + + " this.addEventListener('load', handleEvent);" + + " this.addEventListener('loadend', handleEvent);" + + " this.addEventListener('progress', handleEvent);" + + " this.addEventListener('error', handleEvent);" + + " this.addEventListener('abort', handleEvent);" + + " this.addEventListener('timeout', handleEvent);" + + " " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".convertBodyRequest(data).then(function(data) {" + + " var ajaxRequest = {" + + " data: data," + + " method: self._flutter_inappwebview_method," + + " url: self._flutter_inappwebview_url," + + " isAsync: self._flutter_inappwebview_isAsync," + + " user: self._flutter_inappwebview_user," + + " password: self._flutter_inappwebview_password," + + " withCredentials: self.withCredentials," + + " headers: self._flutter_inappwebview_request_headers," + + " responseType: self.responseType" + + " };" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('shouldInterceptAjaxRequest', ajaxRequest).then(function(result) {" + + " if (result != null) {" + + " switch (result) {" + + " case 0:" + + " self.abort();" + + " return;" + + " };" + + " if (result.data != null && !" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".isString(result.data) && result.data.length > 0) {" + + " var bodyString = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".arrayBufferToString(result.data);" + + " if (" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".isBodyFormData(bodyString)) {" + + " var formDataContentType = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".getFormDataContentType(bodyString);" + + " if (result.headers != null) {" + + " result.headers['Content-Type'] = result.headers['Content-Type'] == null ? formDataContentType : result.headers['Content-Type'];" + + " } else {" + + " result.headers = { 'Content-Type': formDataContentType };" + + " }" + + " }" + + " }" + + " if (" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".isString(result.data) || result.data == null) {" + + " data = result.data;" + + " } else if (result.data.length > 0) {" + + " data = new Uint8Array(result.data);" + + " }" + + " self.withCredentials = result.withCredentials;" + + " if (result.responseType != null && self._flutter_inappwebview_isAsync) {" + + " self.responseType = result.responseType;" + + " };" + + " for (var header in result.headers) {" + + " var value = result.headers[header];" + + " var flutter_inappwebview_value = self._flutter_inappwebview_request_headers[header];" + + " if (flutter_inappwebview_value == null) {" + + " self._flutter_inappwebview_request_headers[header] = value;" + + " } else {" + + " self._flutter_inappwebview_request_headers[header] += ', ' + value;" + + " }" + + " setRequestHeader.call(self, header, value);" + + " };" + + " if ((self._flutter_inappwebview_method != result.method && result.method != null) ||" + + " (self._flutter_inappwebview_url != result.url && result.url != null) ||" + + " (self._flutter_inappwebview_isAsync != result.isAsync && result.isAsync != null) ||" + + " (self._flutter_inappwebview_user != result.user && result.user != null) ||" + + " (self._flutter_inappwebview_password != result.password && result.password != null)) {" + + " self.abort();" + + " self.open(result.method, result.url, result.isAsync, result.user, result.password);" + + " }" + + " }" + + " send.call(self, data);" + + " });" + + " });" + + " } else {" + + " send.call(this, data);" + + " }" + + " };" + + "})(window.XMLHttpRequest);"; + } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptFetchRequestJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptFetchRequestJS.java index eebff12cb..316f62244 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptFetchRequestJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/InterceptFetchRequestJS.java @@ -1,152 +1,166 @@ package com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js; +import androidx.annotation.Nullable; + import com.pichillilorenzo.flutter_inappwebview_android.types.PluginScript; import com.pichillilorenzo.flutter_inappwebview_android.types.UserScriptInjectionTime; +import java.util.Set; + public class InterceptFetchRequestJS { public static final String INTERCEPT_FETCH_REQUEST_JS_PLUGIN_SCRIPT_GROUP_NAME = "IN_APP_WEBVIEW_INTERCEPT_FETCH_REQUEST_JS_PLUGIN_SCRIPT"; - public static final String FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_FETCH_REQUEST_JS_SOURCE = JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._useShouldInterceptFetchRequest"; - public static final PluginScript INTERCEPT_FETCH_REQUEST_JS_PLUGIN_SCRIPT = new PluginScript( - InterceptFetchRequestJS.INTERCEPT_FETCH_REQUEST_JS_PLUGIN_SCRIPT_GROUP_NAME, - InterceptFetchRequestJS.INTERCEPT_FETCH_REQUEST_JS_SOURCE, - UserScriptInjectionTime.AT_DOCUMENT_START, - null, - true, - null - ); - public static final String INTERCEPT_FETCH_REQUEST_JS_SOURCE = "(function(fetch) {" + - " var w = (window.top == null || window.top === window) ? window : window.top;" + - " w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_FETCH_REQUEST_JS_SOURCE + " = true;" + - " if (fetch == null) {" + - " return;" + - " }" + - " window.fetch = async function(resource, init) {" + - " var w = (window.top == null || window.top === window) ? window : window.top;" + - " if (w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_FETCH_REQUEST_JS_SOURCE + " == null || w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_FETCH_REQUEST_JS_SOURCE + " == true) {" + - " var fetchRequest = {" + - " url: null," + - " method: null," + - " headers: null," + - " body: null," + - " mode: null," + - " credentials: null," + - " cache: null," + - " redirect: null," + - " referrer: null," + - " referrerPolicy: null," + - " integrity: null," + - " keepalive: null" + - " };" + - " if (resource instanceof Request) {" + - " fetchRequest.url = resource.url;" + - " fetchRequest.method = resource.method;" + - " fetchRequest.headers = resource.headers;" + - " fetchRequest.body = resource.body;" + - " fetchRequest.mode = resource.mode;" + - " fetchRequest.credentials = resource.credentials;" + - " fetchRequest.cache = resource.cache;" + - " fetchRequest.redirect = resource.redirect;" + - " fetchRequest.referrer = resource.referrer;" + - " fetchRequest.referrerPolicy = resource.referrerPolicy;" + - " fetchRequest.integrity = resource.integrity;" + - " fetchRequest.keepalive = resource.keepalive;" + - " } else {" + - " fetchRequest.url = resource != null ? resource.toString() : null;" + - " if (init != null) {" + - " fetchRequest.method = init.method;" + - " fetchRequest.headers = init.headers;" + - " fetchRequest.body = init.body;" + - " fetchRequest.mode = init.mode;" + - " fetchRequest.credentials = init.credentials;" + - " fetchRequest.cache = init.cache;" + - " fetchRequest.redirect = init.redirect;" + - " fetchRequest.referrer = init.referrer;" + - " fetchRequest.referrerPolicy = init.referrerPolicy;" + - " fetchRequest.integrity = init.integrity;" + - " fetchRequest.keepalive = init.keepalive;" + - " }" + - " }" + - " if (fetchRequest.headers instanceof Headers) {" + - " fetchRequest.headers = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".convertHeadersToJson(fetchRequest.headers);" + - " }" + - " fetchRequest.credentials = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".convertCredentialsToJson(fetchRequest.credentials);" + - " return " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".convertBodyRequest(fetchRequest.body).then(function(body) {" + - " fetchRequest.body = body;" + - " return window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('shouldInterceptFetchRequest', fetchRequest).then(function(result) {" + - " if (result != null) {" + - " switch (result.action) {" + - " case 0:" + - " var controller = new AbortController();" + - " if (init != null) {" + - " init.signal = controller.signal;" + - " } else {" + - " init = {" + - " signal: controller.signal" + - " };" + - " }" + - " controller.abort();" + - " break;" + - " }" + - " if (result.body != null && !" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".isString(result.body) && result.body.length > 0) {" + - " var bodyString = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".arrayBufferToString(result.body);" + - " if (" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".isBodyFormData(bodyString)) {" + - " var formDataContentType = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".getFormDataContentType(bodyString);" + - " if (result.headers != null) {" + - " result.headers['Content-Type'] = result.headers['Content-Type'] == null ? formDataContentType : result.headers['Content-Type'];" + - " } else {" + - " result.headers = { 'Content-Type': formDataContentType };" + - " }" + - " }" + - " }" + - " resource = result.url;" + - " if (init == null) {" + - " init = {};" + - " }" + - " if (result.method != null && result.method.length > 0) {" + - " init.method = result.method;" + - " }" + - " if (result.headers != null && Object.keys(result.headers).length > 0) {" + - " init.headers = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".convertJsonToHeaders(result.headers);" + - " }" + - " if (" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".isString(result.body) || result.body == null) {" + - " init.body = result.body;" + - " } else if (result.body.length > 0) {" + - " init.body = new Uint8Array(result.body);" + - " }" + - " if (result.mode != null && result.mode.length > 0) {" + - " init.mode = result.mode;" + - " }" + - " if (result.credentials != null) {" + - " init.credentials = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME + ".convertJsonToCredential(result.credentials);" + - " }" + - " if (result.cache != null && result.cache.length > 0) {" + - " init.cache = result.cache;" + - " }" + - " if (result.redirect != null && result.redirect.length > 0) {" + - " init.redirect = result.redirect;" + - " }" + - " if (result.referrer != null && result.referrer.length > 0) {" + - " init.referrer = result.referrer;" + - " }" + - " if (result.referrerPolicy != null && result.referrerPolicy.length > 0) {" + - " init.referrerPolicy = result.referrerPolicy;" + - " }" + - " if (result.integrity != null && result.integrity.length > 0) {" + - " init.integrity = result.integrity;" + - " }" + - " if (result.keepalive != null) {" + - " init.keepalive = result.keepalive;" + - " }" + - " return fetch(resource, init);" + - " }" + - " return fetch(resource, init);" + - " });" + - " });" + - " } else {" + - " return fetch(resource, init);" + - " }" + - " };" + - "})(window.fetch);"; + public static String FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_FETCH_REQUEST_JS_SOURCE() { + return JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._useShouldInterceptFetchRequest"; + } + + public static PluginScript INTERCEPT_FETCH_REQUEST_JS_PLUGIN_SCRIPT(@Nullable Set allowedOriginRules, + boolean forMainFrameOnly) { + return new PluginScript( + InterceptFetchRequestJS.INTERCEPT_FETCH_REQUEST_JS_PLUGIN_SCRIPT_GROUP_NAME, + InterceptFetchRequestJS.INTERCEPT_FETCH_REQUEST_JS_SOURCE(), + UserScriptInjectionTime.AT_DOCUMENT_START, + null, + true, + allowedOriginRules, + forMainFrameOnly + ); + } + + public static String INTERCEPT_FETCH_REQUEST_JS_SOURCE() { + return "(function(fetch) {" + + " var w = (window.top == null || window.top === window) ? window : window.top;" + + " w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_FETCH_REQUEST_JS_SOURCE() + " = true;" + + " if (fetch == null) {" + + " return;" + + " }" + + " window.fetch = async function(resource, init) {" + + " var w = (window.top == null || window.top === window) ? window : window.top;" + + " if (w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_FETCH_REQUEST_JS_SOURCE() + " == null || w." + FLAG_VARIABLE_FOR_SHOULD_INTERCEPT_FETCH_REQUEST_JS_SOURCE() + " == true) {" + + " var fetchRequest = {" + + " url: null," + + " method: null," + + " headers: null," + + " body: null," + + " mode: null," + + " credentials: null," + + " cache: null," + + " redirect: null," + + " referrer: null," + + " referrerPolicy: null," + + " integrity: null," + + " keepalive: null" + + " };" + + " if (resource instanceof Request) {" + + " fetchRequest.url = resource.url;" + + " fetchRequest.method = resource.method;" + + " fetchRequest.headers = resource.headers;" + + " fetchRequest.body = resource.body;" + + " fetchRequest.mode = resource.mode;" + + " fetchRequest.credentials = resource.credentials;" + + " fetchRequest.cache = resource.cache;" + + " fetchRequest.redirect = resource.redirect;" + + " fetchRequest.referrer = resource.referrer;" + + " fetchRequest.referrerPolicy = resource.referrerPolicy;" + + " fetchRequest.integrity = resource.integrity;" + + " fetchRequest.keepalive = resource.keepalive;" + + " } else {" + + " fetchRequest.url = resource != null ? resource.toString() : null;" + + " if (init != null) {" + + " fetchRequest.method = init.method;" + + " fetchRequest.headers = init.headers;" + + " fetchRequest.body = init.body;" + + " fetchRequest.mode = init.mode;" + + " fetchRequest.credentials = init.credentials;" + + " fetchRequest.cache = init.cache;" + + " fetchRequest.redirect = init.redirect;" + + " fetchRequest.referrer = init.referrer;" + + " fetchRequest.referrerPolicy = init.referrerPolicy;" + + " fetchRequest.integrity = init.integrity;" + + " fetchRequest.keepalive = init.keepalive;" + + " }" + + " }" + + " if (fetchRequest.headers instanceof Headers) {" + + " fetchRequest.headers = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".convertHeadersToJson(fetchRequest.headers);" + + " }" + + " fetchRequest.credentials = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".convertCredentialsToJson(fetchRequest.credentials);" + + " return " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".convertBodyRequest(fetchRequest.body).then(function(body) {" + + " fetchRequest.body = body;" + + " return window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('shouldInterceptFetchRequest', fetchRequest).then(function(result) {" + + " if (result != null) {" + + " switch (result.action) {" + + " case 0:" + + " var controller = new AbortController();" + + " if (init != null) {" + + " init.signal = controller.signal;" + + " } else {" + + " init = {" + + " signal: controller.signal" + + " };" + + " }" + + " controller.abort();" + + " break;" + + " }" + + " if (result.body != null && !" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".isString(result.body) && result.body.length > 0) {" + + " var bodyString = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".arrayBufferToString(result.body);" + + " if (" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".isBodyFormData(bodyString)) {" + + " var formDataContentType = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".getFormDataContentType(bodyString);" + + " if (result.headers != null) {" + + " result.headers['Content-Type'] = result.headers['Content-Type'] == null ? formDataContentType : result.headers['Content-Type'];" + + " } else {" + + " result.headers = { 'Content-Type': formDataContentType };" + + " }" + + " }" + + " }" + + " resource = result.url;" + + " if (init == null) {" + + " init = {};" + + " }" + + " if (result.method != null && result.method.length > 0) {" + + " init.method = result.method;" + + " }" + + " if (result.headers != null && Object.keys(result.headers).length > 0) {" + + " init.headers = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".convertJsonToHeaders(result.headers);" + + " }" + + " if (" + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".isString(result.body) || result.body == null) {" + + " init.body = result.body;" + + " } else if (result.body.length > 0) {" + + " init.body = new Uint8Array(result.body);" + + " }" + + " if (result.mode != null && result.mode.length > 0) {" + + " init.mode = result.mode;" + + " }" + + " if (result.credentials != null) {" + + " init.credentials = " + JavaScriptBridgeJS.JAVASCRIPT_UTIL_VAR_NAME() + ".convertJsonToCredential(result.credentials);" + + " }" + + " if (result.cache != null && result.cache.length > 0) {" + + " init.cache = result.cache;" + + " }" + + " if (result.redirect != null && result.redirect.length > 0) {" + + " init.redirect = result.redirect;" + + " }" + + " if (result.referrer != null && result.referrer.length > 0) {" + + " init.referrer = result.referrer;" + + " }" + + " if (result.referrerPolicy != null && result.referrerPolicy.length > 0) {" + + " init.referrerPolicy = result.referrerPolicy;" + + " }" + + " if (result.integrity != null && result.integrity.length > 0) {" + + " init.integrity = result.integrity;" + + " }" + + " if (result.keepalive != null) {" + + " init.keepalive = result.keepalive;" + + " }" + + " return fetch(resource, init);" + + " }" + + " return fetch(resource, init);" + + " });" + + " });" + + " } else {" + + " return fetch(resource, init);" + + " }" + + " };" + + "})(window.fetch);"; + } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/JavaScriptBridgeJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/JavaScriptBridgeJS.java index 55659d479..58c58517e 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/JavaScriptBridgeJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/JavaScriptBridgeJS.java @@ -1,250 +1,318 @@ package com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import com.pichillilorenzo.flutter_inappwebview_android.Util; import com.pichillilorenzo.flutter_inappwebview_android.types.PluginScript; import com.pichillilorenzo.flutter_inappwebview_android.types.UserScriptInjectionTime; +import java.util.Set; + public class JavaScriptBridgeJS { - public static final String JAVASCRIPT_BRIDGE_NAME = "flutter_inappwebview"; + @NonNull + private static String _JAVASCRIPT_BRIDGE_NAME = "flutter_inappwebview"; + + public static void set_JAVASCRIPT_BRIDGE_NAME(@NonNull String bridgeName) { + _JAVASCRIPT_BRIDGE_NAME = bridgeName; + } + + @NonNull + public static String JAVASCRIPT_BRIDGE_NAME() { + return _JAVASCRIPT_BRIDGE_NAME; + } + public static final String JAVASCRIPT_BRIDGE_JS_PLUGIN_SCRIPT_GROUP_NAME = "IN_APP_WEBVIEW_JAVASCRIPT_BRIDGE_JS_PLUGIN_SCRIPT"; - public static final PluginScript JAVASCRIPT_BRIDGE_JS_PLUGIN_SCRIPT = new PluginScript( - JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_JS_PLUGIN_SCRIPT_GROUP_NAME, - JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_JS_SOURCE, - UserScriptInjectionTime.AT_DOCUMENT_START, - null, - true, - null - ); - public static final String JAVASCRIPT_UTIL_VAR_NAME = "window." + JAVASCRIPT_BRIDGE_NAME + "._Util"; - public static final String WEB_MESSAGE_CHANNELS_VARIABLE_NAME = "window." + JAVASCRIPT_BRIDGE_NAME + "._webMessageChannels"; + private static final String VAR_JAVASCRIPT_BRIDGE_BRIDGE_SECRET = "$IN_APP_WEBVIEW_JAVASCRIPT_BRIDGE_BRIDGE_SECRET"; + + public static PluginScript JAVASCRIPT_BRIDGE_JS_PLUGIN_SCRIPT(@NonNull String expectedBridgeSecret, + @Nullable Set allowedOriginRules, + boolean forMainFrameOnly) { + String source = Util.replaceAll(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_JS_SOURCE(), VAR_JAVASCRIPT_BRIDGE_BRIDGE_SECRET, expectedBridgeSecret); + return new PluginScript( + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_JS_PLUGIN_SCRIPT_GROUP_NAME, + source, + UserScriptInjectionTime.AT_DOCUMENT_START, + null, + true, + allowedOriginRules, + forMainFrameOnly + ); + } + + public static String JAVASCRIPT_UTIL_VAR_NAME() { + return "window." + JAVASCRIPT_BRIDGE_NAME() + "._Util"; + } + + public static String WEB_MESSAGE_CHANNELS_VARIABLE_NAME() { + return "window." + JAVASCRIPT_BRIDGE_NAME() + "._webMessageChannels"; + } - public static final String UTIL_JS_SOURCE = JAVASCRIPT_UTIL_VAR_NAME + " = {" + - " support: {" + - " searchParams: 'URLSearchParams' in window," + - " iterable: 'Symbol' in window && 'iterator' in Symbol," + - " blob:" + - " 'FileReader' in window &&" + - " 'Blob' in window &&" + - " (function() {" + - " try {" + - " new Blob();" + - " return true;" + - " } catch (e) {" + - " return false;" + - " }" + - " })()," + - " formData: 'FormData' in window," + - " arrayBuffer: 'ArrayBuffer' in window" + - " }," + - " isDataView: function(obj) {" + - " return obj && DataView.prototype.isPrototypeOf(obj);" + - " }," + - " fileReaderReady: function(reader) {" + - " return new Promise(function(resolve, reject) {" + - " reader.onload = function() {" + - " resolve(reader.result);" + - " };" + - " reader.onerror = function() {" + - " reject(reader.error);" + - " };" + - " });" + - " }," + - " readBlobAsArrayBuffer: function(blob) {" + - " var reader = new FileReader();" + - " var promise = " + JAVASCRIPT_UTIL_VAR_NAME + ".fileReaderReady(reader);" + - " reader.readAsArrayBuffer(blob);" + - " return promise;" + - " }," + - " convertBodyToArrayBuffer: function(body) {" + - " var viewClasses = [" + - " '[object Int8Array]'," + - " '[object Uint8Array]'," + - " '[object Uint8ClampedArray]'," + - " '[object Int16Array]'," + - " '[object Uint16Array]'," + - " '[object Int32Array]'," + - " '[object Uint32Array]'," + - " '[object Float32Array]'," + - " '[object Float64Array]'" + - " ];" + - " var isArrayBufferView = null;" + - " if (" + JAVASCRIPT_UTIL_VAR_NAME + ".support.arrayBuffer) {" + - " isArrayBufferView =" + - " ArrayBuffer.isView ||" + - " function(obj) {" + - " return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;" + - " };" + - " }" + - " var bodyUsed = false;" + - " this._bodyInit = body;" + - " if (!body) {" + - " this._bodyText = '';" + - " } else if (typeof body === 'string') {" + - " this._bodyText = body;" + - " } else if (" + JAVASCRIPT_UTIL_VAR_NAME + ".support.blob && Blob.prototype.isPrototypeOf(body)) {" + - " this._bodyBlob = body;" + - " } else if (" + JAVASCRIPT_UTIL_VAR_NAME + ".support.formData && FormData.prototype.isPrototypeOf(body)) {" + - " this._bodyFormData = body;" + - " } else if (" + JAVASCRIPT_UTIL_VAR_NAME + ".support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {" + - " this._bodyText = body.toString();" + - " } else if (" + JAVASCRIPT_UTIL_VAR_NAME + ".support.arrayBuffer && " + JAVASCRIPT_UTIL_VAR_NAME + ".support.blob && " + JAVASCRIPT_UTIL_VAR_NAME + ".isDataView(body)) {" + - " this._bodyArrayBuffer = bufferClone(body.buffer);" + - " this._bodyInit = new Blob([this._bodyArrayBuffer]);" + - " } else if (" + JAVASCRIPT_UTIL_VAR_NAME + ".support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {" + - " this._bodyArrayBuffer = bufferClone(body);" + - " } else {" + - " this._bodyText = body = Object.prototype.toString.call(body);" + - " }" + - " this.blob = function () {" + - " if (bodyUsed) {" + - " return Promise.reject(new TypeError('Already read'));" + - " }" + - " bodyUsed = true;" + - " if (this._bodyBlob) {" + - " return Promise.resolve(this._bodyBlob);" + - " } else if (this._bodyArrayBuffer) {" + - " return Promise.resolve(new Blob([this._bodyArrayBuffer]));" + - " } else if (this._bodyFormData) {" + - " throw new Error('could not read FormData body as blob');" + - " } else {" + - " return Promise.resolve(new Blob([this._bodyText]));" + - " }" + - " };" + - " if (this._bodyArrayBuffer) {" + - " if (bodyUsed) {" + - " return Promise.reject(new TypeError('Already read'));" + - " }" + - " bodyUsed = true;" + - " if (ArrayBuffer.isView(this._bodyArrayBuffer)) {" + - " return Promise.resolve(" + - " this._bodyArrayBuffer.buffer.slice(" + - " this._bodyArrayBuffer.byteOffset," + - " this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength" + - " )" + - " );" + - " } else {" + - " return Promise.resolve(this._bodyArrayBuffer);" + - " }" + - " }" + - " return this.blob().then(" + JAVASCRIPT_UTIL_VAR_NAME + ".readBlobAsArrayBuffer);" + - " }," + - " isString: function(variable) {" + - " return typeof variable === 'string' || variable instanceof String;" + - " }," + - " convertBodyRequest: function(body) {" + - " if (body == null) {" + - " return new Promise(function(resolve, reject) { resolve(null); });" + - " }" + - " if (" + JAVASCRIPT_UTIL_VAR_NAME + ".isString(body) || (" + JAVASCRIPT_UTIL_VAR_NAME + ".support.searchParams && body instanceof URLSearchParams)) {" + - " return new Promise(function(resolve, reject) { resolve(body.toString()); });" + - " }" + - " if (window.Response != null) {" + - " return new Response(body).arrayBuffer().then(function(arrayBuffer) {" + - " return Array.from(new Uint8Array(arrayBuffer));" + - " });" + - " }" + - " return " + JAVASCRIPT_UTIL_VAR_NAME + ".convertBodyToArrayBuffer(body).then(function(arrayBuffer) {" + - " return Array.from(new Uint8Array(arrayBuffer));" + - " });" + - " }," + - " arrayBufferToString: function(arrayBuffer) {" + - " var uint8Array = new Uint8Array(arrayBuffer);" + - " return uint8Array.reduce(function(acc, i) { return acc += String.fromCharCode.apply(null, [i]); }, '');" + - " }," + - " isBodyFormData: function(bodyString) {" + - " return bodyString.indexOf('------WebKitFormBoundary') >= 0;" + - " }," + - " getFormDataContentType: function(bodyString) {" + - " var boundary = bodyString.substr(2, 40);" + - " return 'multipart/form-data; boundary=' + boundary;" + - " }," + - " convertHeadersToJson: function(headers) {" + - " var headersObj = {};" + - " for (var header of headers.keys()) {" + - " var value = headers.get(header);" + - " headersObj[header] = value;" + - " }" + - " return headersObj;" + - " }," + - " convertJsonToHeaders: function(headersJson) {" + - " return new Headers(headersJson);" + - " }," + - " convertCredentialsToJson: function(credentials) {" + - " var credentialsObj = {};" + - " if (window.FederatedCredential != null && credentials instanceof FederatedCredential) {" + - " credentialsObj.type = credentials.type;" + - " credentialsObj.id = credentials.id;" + - " credentialsObj.name = credentials.name;" + - " credentialsObj.protocol = credentials.protocol;" + - " credentialsObj.provider = credentials.provider;" + - " credentialsObj.iconURL = credentials.iconURL;" + - " } else if (window.PasswordCredential != null && credentials instanceof PasswordCredential) {" + - " credentialsObj.type = credentials.type;" + - " credentialsObj.id = credentials.id;" + - " credentialsObj.name = credentials.name;" + - " credentialsObj.password = credentials.password;" + - " credentialsObj.iconURL = credentials.iconURL;" + - " } else {" + - " credentialsObj.type = 'default';" + - " credentialsObj.value = credentials;" + - " }" + - " return credentialsObj;" + - " }," + - " convertJsonToCredential: function(credentialsJson) {" + - " var credentials;" + - " if (window.FederatedCredential != null && credentialsJson.type === 'federated') {" + - " credentials = new FederatedCredential({" + - " id: credentialsJson.id," + - " name: credentialsJson.name," + - " protocol: credentialsJson.protocol," + - " provider: credentialsJson.provider," + - " iconURL: credentialsJson.iconURL" + - " });" + - " } else if (window.PasswordCredential != null && credentialsJson.type === 'password') {" + - " credentials = new PasswordCredential({" + - " id: credentialsJson.id," + - " name: credentialsJson.name," + - " password: credentialsJson.password," + - " iconURL: credentialsJson.iconURL" + - " });" + - " } else {" + - " credentials = credentialsJson.value == null ? undefined : credentialsJson.value;" + - " }" + - " return credentials;" + - " }" + - "};"; + public static String UTIL_JS_SOURCE() { + return JAVASCRIPT_UTIL_VAR_NAME() + " = {" + + " support: {" + + " searchParams: 'URLSearchParams' in window," + + " iterable: 'Symbol' in window && 'iterator' in Symbol," + + " blob:" + + " 'FileReader' in window &&" + + " 'Blob' in window &&" + + " (function() {" + + " try {" + + " new Blob();" + + " return true;" + + " } catch (e) {" + + " return false;" + + " }" + + " })()," + + " formData: 'FormData' in window," + + " arrayBuffer: 'ArrayBuffer' in window" + + " }," + + " isDataView: function(obj) {" + + " return obj && DataView.prototype.isPrototypeOf(obj);" + + " }," + + " fileReaderReady: function(reader) {" + + " return new Promise(function(resolve, reject) {" + + " reader.onload = function() {" + + " resolve(reader.result);" + + " };" + + " reader.onerror = function() {" + + " reject(reader.error);" + + " };" + + " });" + + " }," + + " readBlobAsArrayBuffer: function(blob) {" + + " var reader = new FileReader();" + + " var promise = " + JAVASCRIPT_UTIL_VAR_NAME() + ".fileReaderReady(reader);" + + " reader.readAsArrayBuffer(blob);" + + " return promise;" + + " }," + + " convertBodyToArrayBuffer: function(body) {" + + " var viewClasses = [" + + " '[object Int8Array]'," + + " '[object Uint8Array]'," + + " '[object Uint8ClampedArray]'," + + " '[object Int16Array]'," + + " '[object Uint16Array]'," + + " '[object Int32Array]'," + + " '[object Uint32Array]'," + + " '[object Float32Array]'," + + " '[object Float64Array]'" + + " ];" + + " var isArrayBufferView = null;" + + " if (" + JAVASCRIPT_UTIL_VAR_NAME() + ".support.arrayBuffer) {" + + " isArrayBufferView =" + + " ArrayBuffer.isView ||" + + " function(obj) {" + + " return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;" + + " };" + + " }" + + " var bodyUsed = false;" + + " this._bodyInit = body;" + + " if (!body) {" + + " this._bodyText = '';" + + " } else if (typeof body === 'string') {" + + " this._bodyText = body;" + + " } else if (" + JAVASCRIPT_UTIL_VAR_NAME() + ".support.blob && Blob.prototype.isPrototypeOf(body)) {" + + " this._bodyBlob = body;" + + " } else if (" + JAVASCRIPT_UTIL_VAR_NAME() + ".support.formData && FormData.prototype.isPrototypeOf(body)) {" + + " this._bodyFormData = body;" + + " } else if (" + JAVASCRIPT_UTIL_VAR_NAME() + ".support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {" + + " this._bodyText = body.toString();" + + " } else if (" + JAVASCRIPT_UTIL_VAR_NAME() + ".support.arrayBuffer && " + JAVASCRIPT_UTIL_VAR_NAME() + ".support.blob && " + JAVASCRIPT_UTIL_VAR_NAME() + ".isDataView(body)) {" + + " this._bodyArrayBuffer = bufferClone(body.buffer);" + + " this._bodyInit = new Blob([this._bodyArrayBuffer]);" + + " } else if (" + JAVASCRIPT_UTIL_VAR_NAME() + ".support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {" + + " this._bodyArrayBuffer = bufferClone(body);" + + " } else {" + + " this._bodyText = body = Object.prototype.toString.call(body);" + + " }" + + " this.blob = function () {" + + " if (bodyUsed) {" + + " return Promise.reject(new TypeError('Already read'));" + + " }" + + " bodyUsed = true;" + + " if (this._bodyBlob) {" + + " return Promise.resolve(this._bodyBlob);" + + " } else if (this._bodyArrayBuffer) {" + + " return Promise.resolve(new Blob([this._bodyArrayBuffer]));" + + " } else if (this._bodyFormData) {" + + " throw new Error('could not read FormData body as blob');" + + " } else {" + + " return Promise.resolve(new Blob([this._bodyText]));" + + " }" + + " };" + + " if (this._bodyArrayBuffer) {" + + " if (bodyUsed) {" + + " return Promise.reject(new TypeError('Already read'));" + + " }" + + " bodyUsed = true;" + + " if (ArrayBuffer.isView(this._bodyArrayBuffer)) {" + + " return Promise.resolve(" + + " this._bodyArrayBuffer.buffer.slice(" + + " this._bodyArrayBuffer.byteOffset," + + " this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength" + + " )" + + " );" + + " } else {" + + " return Promise.resolve(this._bodyArrayBuffer);" + + " }" + + " }" + + " return this.blob().then(" + JAVASCRIPT_UTIL_VAR_NAME() + ".readBlobAsArrayBuffer);" + + " }," + + " isString: function(variable) {" + + " return typeof variable === 'string' || variable instanceof String;" + + " }," + + " convertBodyRequest: function(body) {" + + " if (body == null) {" + + " return new Promise(function(resolve, reject) { resolve(null); });" + + " }" + + " if (" + JAVASCRIPT_UTIL_VAR_NAME() + ".isString(body) || (" + JAVASCRIPT_UTIL_VAR_NAME() + ".support.searchParams && body instanceof URLSearchParams)) {" + + " return new Promise(function(resolve, reject) { resolve(body.toString()); });" + + " }" + + " if (window.Response != null) {" + + " return new Response(body).arrayBuffer().then(function(arrayBuffer) {" + + " return Array.from(new Uint8Array(arrayBuffer));" + + " });" + + " }" + + " return " + JAVASCRIPT_UTIL_VAR_NAME() + ".convertBodyToArrayBuffer(body).then(function(arrayBuffer) {" + + " return Array.from(new Uint8Array(arrayBuffer));" + + " });" + + " }," + + " arrayBufferToString: function(arrayBuffer) {" + + " var uint8Array = new Uint8Array(arrayBuffer);" + + " return uint8Array.reduce(function(acc, i) { return acc += String.fromCharCode.apply(null, [i]); }, '');" + + " }," + + " isBodyFormData: function(bodyString) {" + + " return bodyString.indexOf('------WebKitFormBoundary') >= 0;" + + " }," + + " getFormDataContentType: function(bodyString) {" + + " var boundary = bodyString.substr(2, 40);" + + " return 'multipart/form-data; boundary=' + boundary;" + + " }," + + " convertHeadersToJson: function(headers) {" + + " var headersObj = {};" + + " for (var header of headers.keys()) {" + + " var value = headers.get(header);" + + " headersObj[header] = value;" + + " }" + + " return headersObj;" + + " }," + + " convertJsonToHeaders: function(headersJson) {" + + " return new Headers(headersJson);" + + " }," + + " convertCredentialsToJson: function(credentials) {" + + " var credentialsObj = {};" + + " if (window.FederatedCredential != null && credentials instanceof FederatedCredential) {" + + " credentialsObj.type = credentials.type;" + + " credentialsObj.id = credentials.id;" + + " credentialsObj.name = credentials.name;" + + " credentialsObj.protocol = credentials.protocol;" + + " credentialsObj.provider = credentials.provider;" + + " credentialsObj.iconURL = credentials.iconURL;" + + " } else if (window.PasswordCredential != null && credentials instanceof PasswordCredential) {" + + " credentialsObj.type = credentials.type;" + + " credentialsObj.id = credentials.id;" + + " credentialsObj.name = credentials.name;" + + " credentialsObj.password = credentials.password;" + + " credentialsObj.iconURL = credentials.iconURL;" + + " } else {" + + " credentialsObj.type = 'default';" + + " credentialsObj.value = credentials;" + + " }" + + " return credentialsObj;" + + " }," + + " convertJsonToCredential: function(credentialsJson) {" + + " var credentials;" + + " if (window.FederatedCredential != null && credentialsJson.type === 'federated') {" + + " credentials = new FederatedCredential({" + + " id: credentialsJson.id," + + " name: credentialsJson.name," + + " protocol: credentialsJson.protocol," + + " provider: credentialsJson.provider," + + " iconURL: credentialsJson.iconURL" + + " });" + + " } else if (window.PasswordCredential != null && credentialsJson.type === 'password') {" + + " credentials = new PasswordCredential({" + + " id: credentialsJson.id," + + " name: credentialsJson.name," + + " password: credentialsJson.password," + + " iconURL: credentialsJson.iconURL" + + " });" + + " } else {" + + " credentials = credentialsJson.value == null ? undefined : credentialsJson.value;" + + " }" + + " return credentials;" + + " }" + + "};"; + } - public static final String JAVASCRIPT_BRIDGE_JS_SOURCE = "if (window." + JAVASCRIPT_BRIDGE_NAME + " != null) {" + - " window." + JAVASCRIPT_BRIDGE_NAME + ".callHandler = function() {" + - " var _callHandlerID = setTimeout(function(){});" + - " window." + JAVASCRIPT_BRIDGE_NAME + "._callHandler(arguments[0], _callHandlerID, JSON.stringify(Array.prototype.slice.call(arguments, 1)));" + - " return new Promise(function(resolve, reject) {" + - " window." + JAVASCRIPT_BRIDGE_NAME + "[_callHandlerID] = {resolve: resolve, reject: reject};" + - " });" + - " };" + - "}"+ - "if (window.top != null && window.top !== window && window." + JAVASCRIPT_BRIDGE_NAME + " == null) {" + - " window." + JAVASCRIPT_BRIDGE_NAME + " = {};" + - " window." + JAVASCRIPT_BRIDGE_NAME + ".callHandler = function() {" + - " var _callHandlerID = setTimeout(function(){});" + - " try {" + - " window.top." + JAVASCRIPT_BRIDGE_NAME + "._callHandler(arguments[0], _callHandlerID, JSON.stringify(Array.prototype.slice.call(arguments, 1)));" + - " return new Promise(function(resolve, reject) {" + - " window.top." + JAVASCRIPT_BRIDGE_NAME + "[_callHandlerID] = {resolve: resolve, reject: reject};" + - " });" + - " } catch (error) {" + - " return new Promise(function(resolve, reject) { reject(error); });" + - " }" + - " };" + - "}" + - "if (window." + JAVASCRIPT_BRIDGE_NAME + " != null) {" + - " " + UTIL_JS_SOURCE + - "}"; + public static String JAVASCRIPT_BRIDGE_JS_SOURCE() { + return "if (window." + JAVASCRIPT_BRIDGE_NAME() + " != null) {" + + " (function (window) {" + + " var bridgeSecret = '" + VAR_JAVASCRIPT_BRIDGE_BRIDGE_SECRET + "';" + + " var origin = '';" + + " var isMainFrame = false;" + + " try {" + + " origin = window.location.origin;" + + " } catch (_) {}" + + " try {" + + " isMainFrame = window.self === window.top;" + + " } catch (_) {}" + + " window." + JAVASCRIPT_BRIDGE_NAME() + ".callHandler = function() {" + + " if (arguments == null || arguments[0] == null || arguments[0] === '') {" + + " return new Promise(function(resolve, reject) { reject('Handler name is undefined, null or empty'); });" + + " }" + + " var _callHandlerID = setTimeout(function(){});" + + " window." + JAVASCRIPT_BRIDGE_NAME() + "._callHandler(arguments[0], _callHandlerID, bridgeSecret, origin, isMainFrame, JSON.stringify(Array.prototype.slice.call(arguments, 1)));" + + " return new Promise(function(resolve, reject) {" + + " try {" + + " (isMainFrame ? window : window.top)." + JAVASCRIPT_BRIDGE_NAME() + "[_callHandlerID] = {resolve: resolve, reject: reject};" + + " } catch(e) { reject(e); }" + + " });" + + " };" + + " })(window);" + + "}" + + "if (window.top != null && window.top !== window && window." + JAVASCRIPT_BRIDGE_NAME() + " == null) {" + + " window." + JAVASCRIPT_BRIDGE_NAME() + " = {};" + + " (function (window) {" + + " var bridgeSecret = '" + VAR_JAVASCRIPT_BRIDGE_BRIDGE_SECRET + "';" + + " var origin = '';" + + " var isMainFrame = false;" + + " try {" + + " origin = window.location.origin;" + + " } catch (_) {}" + + " try {" + + " isMainFrame = window.self === window.top;" + + " } catch (_) {}" + + " window." + JAVASCRIPT_BRIDGE_NAME() + ".callHandler = function() {" + + " if (arguments == null || arguments[0] == null || arguments[0] === '') {" + + " return new Promise(function(resolve, reject) { reject('Handler name is undefined, null or empty'); });" + + " }" + + " var _callHandlerID = setTimeout(function(){});" + + " console.log(window.self === window.top, window.location.href, 'TEST TEST', window.top." + JAVASCRIPT_BRIDGE_NAME() + ");" + + " try {" + + " window.top." + JAVASCRIPT_BRIDGE_NAME() + "._callHandler(arguments[0], _callHandlerID, bridgeSecret, origin, isMainFrame, JSON.stringify(Array.prototype.slice.call(arguments, 1)));" + + " return new Promise(function(resolve, reject) {" + + " window.top." + JAVASCRIPT_BRIDGE_NAME() + "[_callHandlerID] = {resolve: resolve, reject: reject};" + + " });" + + " } catch (error) {" + + " return new Promise(function(resolve, reject) { reject(error); });" + + " }" + + " };" + + " })(window);" + + "}" + + "if (window." + JAVASCRIPT_BRIDGE_NAME() + " != null) {" + + " " + UTIL_JS_SOURCE() + + "}"; + } - public static final String PLATFORM_READY_JS_SOURCE = "(function() {" + - " if ((window.top == null || window.top === window) && window." + JAVASCRIPT_BRIDGE_NAME + " != null && window." + JAVASCRIPT_BRIDGE_NAME + "._platformReady == null) {" + - " window.dispatchEvent(new Event('flutterInAppWebViewPlatformReady'));" + - " window." + JAVASCRIPT_BRIDGE_NAME + "._platformReady = true;" + - " }" + - "})();"; + public static String PLATFORM_READY_JS_SOURCE() { + return "(function() {" + + " if ((window.top == null || window.top === window) && window." + JAVASCRIPT_BRIDGE_NAME() + " != null && window." + JAVASCRIPT_BRIDGE_NAME() + "._platformReady == null) {" + + " window.dispatchEvent(new Event('flutterInAppWebViewPlatformReady'));" + + " window." + JAVASCRIPT_BRIDGE_NAME() + "._platformReady = true;" + + " }" + + "})();"; + } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnLoadResourceJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnLoadResourceJS.java index b386bd7de..c7501031a 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnLoadResourceJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnLoadResourceJS.java @@ -1,35 +1,50 @@ package com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js; +import androidx.annotation.Nullable; + import com.pichillilorenzo.flutter_inappwebview_android.types.PluginScript; import com.pichillilorenzo.flutter_inappwebview_android.types.UserScriptInjectionTime; +import java.util.Set; + public class OnLoadResourceJS { public static final String ON_LOAD_RESOURCE_JS_PLUGIN_SCRIPT_GROUP_NAME = "IN_APP_WEBVIEW_ON_LOAD_RESOURCE_JS_PLUGIN_SCRIPT"; - public static final String FLAG_VARIABLE_FOR_ON_LOAD_RESOURCE_JS_SOURCE = JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._useOnLoadResource"; - public static final PluginScript ON_LOAD_RESOURCE_JS_PLUGIN_SCRIPT = new PluginScript( - OnLoadResourceJS.ON_LOAD_RESOURCE_JS_PLUGIN_SCRIPT_GROUP_NAME, - OnLoadResourceJS.ON_LOAD_RESOURCE_JS_SOURCE, - UserScriptInjectionTime.AT_DOCUMENT_START, - null, - false, - null - ); + public static String FLAG_VARIABLE_FOR_ON_LOAD_RESOURCE_JS_SOURCE() { + return + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._useOnLoadResource"; + } + public static PluginScript ON_LOAD_RESOURCE_JS_PLUGIN_SCRIPT(@Nullable Set allowedOriginRules, + boolean forMainFrameOnly) { + return + new PluginScript( + OnLoadResourceJS.ON_LOAD_RESOURCE_JS_PLUGIN_SCRIPT_GROUP_NAME, + OnLoadResourceJS.ON_LOAD_RESOURCE_JS_SOURCE(), + UserScriptInjectionTime.AT_DOCUMENT_START, + null, + false, + allowedOriginRules, + forMainFrameOnly + ); + } - public static final String ON_LOAD_RESOURCE_JS_SOURCE = "window." + FLAG_VARIABLE_FOR_ON_LOAD_RESOURCE_JS_SOURCE + " = true;" + - "(function() {" + - " var observer = new PerformanceObserver(function(list) {" + - " list.getEntries().forEach(function(entry) {" + - " if (" + FLAG_VARIABLE_FOR_ON_LOAD_RESOURCE_JS_SOURCE + " == null || " + FLAG_VARIABLE_FOR_ON_LOAD_RESOURCE_JS_SOURCE + " == true) {" + - " var resource = {" + - " 'url': entry.name," + - " 'initiatorType': entry.initiatorType," + - " 'startTime': entry.startTime," + - " 'duration': entry.duration" + - " };" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('onLoadResource', resource);" + - " }" + - " });" + - " });" + - " observer.observe({entryTypes: ['resource']});" + - "})();"; + public static String ON_LOAD_RESOURCE_JS_SOURCE() { + return + "window." + FLAG_VARIABLE_FOR_ON_LOAD_RESOURCE_JS_SOURCE() + " = true;" + + "(function() {" + + " var observer = new PerformanceObserver(function(list) {" + + " list.getEntries().forEach(function(entry) {" + + " if (" + FLAG_VARIABLE_FOR_ON_LOAD_RESOURCE_JS_SOURCE() + " == null || " + FLAG_VARIABLE_FOR_ON_LOAD_RESOURCE_JS_SOURCE() + " == true) {" + + " var resource = {" + + " 'url': entry.name," + + " 'initiatorType': entry.initiatorType," + + " 'startTime': entry.startTime," + + " 'duration': entry.duration" + + " };" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('onLoadResource', resource);" + + " }" + + " });" + + " });" + + " observer.observe({entryTypes: ['resource']});" + + "})();"; + } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnWindowBlurEventJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnWindowBlurEventJS.java index 746f8782a..35a25d704 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnWindowBlurEventJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnWindowBlurEventJS.java @@ -1,22 +1,34 @@ package com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js; +import androidx.annotation.Nullable; + import com.pichillilorenzo.flutter_inappwebview_android.types.PluginScript; import com.pichillilorenzo.flutter_inappwebview_android.types.UserScriptInjectionTime; +import java.util.Set; + public class OnWindowBlurEventJS { public static final String ON_WINDOW_BLUR_EVENT_JS_PLUGIN_SCRIPT_GROUP_NAME = "IN_APP_WEBVIEW_ON_WINDOW_BLUR_EVENT_JS_PLUGIN_SCRIPT"; - public static final PluginScript ON_WINDOW_BLUR_EVENT_JS_PLUGIN_SCRIPT = new PluginScript( - OnWindowBlurEventJS.ON_WINDOW_BLUR_EVENT_JS_PLUGIN_SCRIPT_GROUP_NAME, - OnWindowBlurEventJS.ON_WINDOW_BLUR_EVENT_JS_SOURCE, - UserScriptInjectionTime.AT_DOCUMENT_START, - null, - false, - null - ); + public static PluginScript ON_WINDOW_BLUR_EVENT_JS_PLUGIN_SCRIPT(@Nullable Set allowedOriginRules, + boolean forMainFrameOnly) { + return + new PluginScript( + OnWindowBlurEventJS.ON_WINDOW_BLUR_EVENT_JS_PLUGIN_SCRIPT_GROUP_NAME, + OnWindowBlurEventJS.ON_WINDOW_BLUR_EVENT_JS_SOURCE(), + UserScriptInjectionTime.AT_DOCUMENT_START, + null, + false, + allowedOriginRules, + forMainFrameOnly + ); + } - public static final String ON_WINDOW_BLUR_EVENT_JS_SOURCE = "(function(){" + - " window.addEventListener('blur', function(e) {" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('onWindowBlur');" + - " });" + - "})();"; + public static String ON_WINDOW_BLUR_EVENT_JS_SOURCE() { + return + "(function(){" + + " window.addEventListener('blur', function(e) {" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('onWindowBlur');" + + " });" + + "})();"; + } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnWindowFocusEventJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnWindowFocusEventJS.java index cfdae9a26..7cf3bfe97 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnWindowFocusEventJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/OnWindowFocusEventJS.java @@ -1,22 +1,34 @@ package com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js; +import androidx.annotation.Nullable; + import com.pichillilorenzo.flutter_inappwebview_android.types.PluginScript; import com.pichillilorenzo.flutter_inappwebview_android.types.UserScriptInjectionTime; +import java.util.Set; + public class OnWindowFocusEventJS { public static final String ON_WINDOW_FOCUS_EVENT_JS_PLUGIN_SCRIPT_GROUP_NAME = "IN_APP_WEBVIEW_ON_WINDOW_FOCUS_EVENT_JS_PLUGIN_SCRIPT"; - public static final PluginScript ON_WINDOW_FOCUS_EVENT_JS_PLUGIN_SCRIPT = new PluginScript( - OnWindowFocusEventJS.ON_WINDOW_FOCUS_EVENT_JS_PLUGIN_SCRIPT_GROUP_NAME, - OnWindowFocusEventJS.ON_WINDOW_FOCUS_EVENT_JS_SOURCE, - UserScriptInjectionTime.AT_DOCUMENT_START, - null, - false, - null - ); + public static PluginScript ON_WINDOW_FOCUS_EVENT_JS_PLUGIN_SCRIPT(@Nullable Set allowedOriginRules, + boolean forMainFrameOnly) { + return + new PluginScript( + OnWindowFocusEventJS.ON_WINDOW_FOCUS_EVENT_JS_PLUGIN_SCRIPT_GROUP_NAME, + OnWindowFocusEventJS.ON_WINDOW_FOCUS_EVENT_JS_SOURCE(), + UserScriptInjectionTime.AT_DOCUMENT_START, + null, + false, + allowedOriginRules, + forMainFrameOnly + ); + } - public static final String ON_WINDOW_FOCUS_EVENT_JS_SOURCE = "(function(){" + - " window.addEventListener('focus', function(e) {" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('onWindowFocus');" + - " });" + - "})();"; + public static String ON_WINDOW_FOCUS_EVENT_JS_SOURCE() { + return + "(function(){" + + " window.addEventListener('focus', function(e) {" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('onWindowFocus');" + + " });" + + "})();"; + } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PluginScriptsUtil.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PluginScriptsUtil.java index 91af1fdd1..362378e76 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PluginScriptsUtil.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PluginScriptsUtil.java @@ -1,8 +1,12 @@ package com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js; +import androidx.annotation.Nullable; + import com.pichillilorenzo.flutter_inappwebview_android.types.PluginScript; import com.pichillilorenzo.flutter_inappwebview_android.types.UserScriptInjectionTime; +import java.util.Set; + public class PluginScriptsUtil { public static final String VAR_PLACEHOLDER_VALUE = "$IN_APP_WEBVIEW_PLACEHOLDER_VALUE"; @@ -16,24 +20,30 @@ public class PluginScriptsUtil { public static final String VAR_RESULT_UUID = "$IN_APP_WEBVIEW_RESULT_UUID"; public static final String VAR_RANDOM_NAME = "$IN_APP_WEBVIEW_VARIABLE_RANDOM_NAME"; - public static final String CALL_ASYNC_JAVA_SCRIPT_WRAPPER_JS_SOURCE = "(function(obj) {" + - " (async function(" + VAR_FUNCTION_ARGUMENT_NAMES + ") {" + - " \n" + VAR_FUNCTION_BODY + "\n" + - " })(" + VAR_FUNCTION_ARGUMENT_VALUES + ").then(function(value) {" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('callAsyncJavaScript', {'value': value, 'error': null, 'resultUuid': '" + VAR_RESULT_UUID + "'});" + - " }).catch(function(error) {" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('callAsyncJavaScript', {'value': null, 'error': error + '', 'resultUuid': '" + VAR_RESULT_UUID + "'});" + - " });" + - " return null;" + - "})(" + VAR_FUNCTION_ARGUMENTS_OBJ + ");"; + public static String CALL_ASYNC_JAVA_SCRIPT_WRAPPER_JS_SOURCE() { + return + "(function(obj) {" + + " (async function(" + VAR_FUNCTION_ARGUMENT_NAMES + ") {" + + " \n" + VAR_FUNCTION_BODY + "\n" + + " })(" + VAR_FUNCTION_ARGUMENT_VALUES + ").then(function(value) {" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('callAsyncJavaScript', {'value': value, 'error': null, 'resultUuid': '" + VAR_RESULT_UUID + "'});" + + " }).catch(function(error) {" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('callAsyncJavaScript', {'value': null, 'error': error + '', 'resultUuid': '" + VAR_RESULT_UUID + "'});" + + " });" + + " return null;" + + "})(" + VAR_FUNCTION_ARGUMENTS_OBJ + ");"; + } - public static final String EVALUATE_JAVASCRIPT_WITH_CONTENT_WORLD_WRAPPER_JS_SOURCE = "var $IN_APP_WEBVIEW_VARIABLE_RANDOM_NAME = null;" + - "try {" + - " $IN_APP_WEBVIEW_VARIABLE_RANDOM_NAME = eval(" + VAR_PLACEHOLDER_VALUE + ");" + - "} catch(e) {" + - " console.error(e);" + - "}" + - "window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('evaluateJavaScriptWithContentWorld', {'value': $IN_APP_WEBVIEW_VARIABLE_RANDOM_NAME, 'resultUuid': '" + VAR_RESULT_UUID + "'});"; + public static String EVALUATE_JAVASCRIPT_WITH_CONTENT_WORLD_WRAPPER_JS_SOURCE() { + return + "var $IN_APP_WEBVIEW_VARIABLE_RANDOM_NAME = null;" + + "try {" + + " $IN_APP_WEBVIEW_VARIABLE_RANDOM_NAME = eval(" + VAR_PLACEHOLDER_VALUE + ");" + + "} catch(e) {" + + " console.error(e);" + + "}" + + "window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('evaluateJavaScriptWithContentWorld', {'value': $IN_APP_WEBVIEW_VARIABLE_RANDOM_NAME, 'resultUuid': '" + VAR_RESULT_UUID + "'});"; + } public static final String IS_ACTIVE_ELEMENT_INPUT_EDITABLE_JS_SOURCE = "var activeEl = document.activeElement;" + @@ -71,19 +81,27 @@ public class PluginScriptsUtil { "})();"; public static final String CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_PLUGIN_SCRIPT_GROUP_NAME = "CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_PLUGIN_SCRIPT"; - public static final PluginScript CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_PLUGIN_SCRIPT = new PluginScript( - PluginScriptsUtil.CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_PLUGIN_SCRIPT_GROUP_NAME, - PluginScriptsUtil.CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_SOURCE, - UserScriptInjectionTime.AT_DOCUMENT_START, - null, - false, - null - ); + public static PluginScript CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_PLUGIN_SCRIPT(@Nullable Set allowedOriginRules, + boolean forMainFrameOnly) { + return + new PluginScript( + PluginScriptsUtil.CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_PLUGIN_SCRIPT_GROUP_NAME, + PluginScriptsUtil.CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_SOURCE(), + UserScriptInjectionTime.AT_DOCUMENT_START, + null, + false, + allowedOriginRules, + forMainFrameOnly + ); + } // android Workaround to hide context menu when user emit a keydown event - public static final String CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_SOURCE = "(function(){" + - " document.addEventListener('keydown', function(e) {" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._hideContextMenu();" + - " });" + - "})();"; + public static String CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_SOURCE() { + return + "(function(){" + + " document.addEventListener('keydown', function(e) {" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._hideContextMenu();" + + " });" + + "})();"; + } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PrintJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PrintJS.java index bb1084815..c20eeea05 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PrintJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PrintJS.java @@ -1,24 +1,36 @@ package com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js; +import androidx.annotation.Nullable; + import com.pichillilorenzo.flutter_inappwebview_android.types.PluginScript; import com.pichillilorenzo.flutter_inappwebview_android.types.UserScriptInjectionTime; +import java.util.Set; + public class PrintJS { public static final String PRINT_JS_PLUGIN_SCRIPT_GROUP_NAME = "IN_APP_WEBVIEW_PRINT_JS_PLUGIN_SCRIPT"; - public static final PluginScript PRINT_JS_PLUGIN_SCRIPT = new PluginScript( - PrintJS.PRINT_JS_PLUGIN_SCRIPT_GROUP_NAME, - PrintJS.PRINT_JS_SOURCE, - UserScriptInjectionTime.AT_DOCUMENT_START, - null, - false, - null - ); + public static PluginScript PRINT_JS_PLUGIN_SCRIPT(@Nullable Set allowedOriginRules, + boolean forMainFrameOnly) { + return + new PluginScript( + PrintJS.PRINT_JS_PLUGIN_SCRIPT_GROUP_NAME, + PrintJS.PRINT_JS_SOURCE(), + UserScriptInjectionTime.AT_DOCUMENT_START, + null, + false, + allowedOriginRules, + forMainFrameOnly + ); + } - public static final String PRINT_JS_SOURCE = "window.print = function() {" + - " if (window.top == null || window.top === window) {" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('onPrintRequest', window.location.href);" + - " } else {" + - " window.top.print();" + - " }" + - "};"; + public static String PRINT_JS_SOURCE() { + return + "window.print = function() {" + + " if (window.top == null || window.top === window) {" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('onPrintRequest', window.location.href);" + + " } else {" + + " window.top.print();" + + " }" + + "};"; + } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PromisePolyfillJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PromisePolyfillJS.java index af10c5d84..3331c63a0 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PromisePolyfillJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/PromisePolyfillJS.java @@ -1,18 +1,26 @@ package com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js; +import androidx.annotation.Nullable; + import com.pichillilorenzo.flutter_inappwebview_android.types.PluginScript; import com.pichillilorenzo.flutter_inappwebview_android.types.UserScriptInjectionTime; +import java.util.Set; + public class PromisePolyfillJS { public static final String PROMISE_POLYFILL_JS_PLUGIN_SCRIPT_GROUP_NAME = "IN_APP_WEBVIEW_PROMISE_POLYFILL_JS_PLUGIN_SCRIPT"; - public static final PluginScript PROMISE_POLYFILL_JS_PLUGIN_SCRIPT = new PluginScript( - PromisePolyfillJS.PROMISE_POLYFILL_JS_PLUGIN_SCRIPT_GROUP_NAME, - PromisePolyfillJS.PROMISE_POLYFILL_JS_SOURCE, - UserScriptInjectionTime.AT_DOCUMENT_START, - null, - true, - null - ); + public static final PluginScript PROMISE_POLYFILL_JS_PLUGIN_SCRIPT(@Nullable Set allowedOriginRules, + boolean forMainFrameOnly) { + return new PluginScript( + PromisePolyfillJS.PROMISE_POLYFILL_JS_PLUGIN_SCRIPT_GROUP_NAME, + PromisePolyfillJS.PROMISE_POLYFILL_JS_SOURCE, + UserScriptInjectionTime.AT_DOCUMENT_START, + null, + true, + allowedOriginRules, + forMainFrameOnly + ); + } // https://github.com/tildeio/rsvp.js public static final String PROMISE_POLYFILL_JS_SOURCE = "if (window.Promise == null) {" + diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/JavaScriptHandlerFunctionData.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/JavaScriptHandlerFunctionData.java new file mode 100644 index 000000000..feccffe2e --- /dev/null +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/JavaScriptHandlerFunctionData.java @@ -0,0 +1,92 @@ +package com.pichillilorenzo.flutter_inappwebview_android.types; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; + +import java.util.HashMap; +import java.util.Map; + +public class JavaScriptHandlerFunctionData { + @NonNull + private String origin; + private boolean isMainFrame; + @NonNull + private String args; + + public JavaScriptHandlerFunctionData(@NonNull String origin, boolean isMainFrame, @NonNull String args) { + this.origin = origin; + this.isMainFrame = isMainFrame; + this.args = args; + } + + @Nullable + public static JavaScriptHandlerFunctionData fromMap(@Nullable Map map) { + if (map == null) { + return null; + } + String origin = (String) map.get("origin"); + boolean isMainFrame = (boolean) map.get("isMainFrame"); + String args = (String) map.get("args"); + return new JavaScriptHandlerFunctionData(origin, isMainFrame, args); + } + + public Map toMap() { + Map map = new HashMap<>(); + map.put("origin", origin); + map.put("isMainFrame", isMainFrame); + map.put("args", args); + return map; + } + + @NonNull + public String getOrigin() { + return origin; + } + + public void setOrigin(@NonNull String origin) { + this.origin = origin; + } + + public boolean isMainFrame() { + return isMainFrame; + } + + public void setMainFrame(boolean mainFrame) { + isMainFrame = mainFrame; + } + + @NonNull + public String getArgs() { + return args; + } + + public void setArgs(@NonNull String args) { + this.args = args; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + JavaScriptHandlerFunctionData that = (JavaScriptHandlerFunctionData) o; + return isMainFrame == that.isMainFrame && origin.equals(that.origin) && args.equals(that.args); + } + + @Override + public int hashCode() { + int result = origin.hashCode(); + result = 31 * result + Boolean.hashCode(isMainFrame); + result = 31 * result + args.hashCode(); + return result; + } + + @Override + public String toString() { + return "JavaScriptHandlerFunctionData{" + + "origin='" + origin + '\'' + + ", isMainFrame=" + isMainFrame + + ", args='" + args + '\'' + + '}'; + } +} diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/PluginScript.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/PluginScript.java index b16f22803..a5a95e4ea 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/PluginScript.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/PluginScript.java @@ -8,8 +8,9 @@ public class PluginScript extends UserScript { private boolean requiredInAllContentWorlds; - public PluginScript(@Nullable String groupName, @NonNull String source, @NonNull UserScriptInjectionTime injectionTime, @Nullable ContentWorld contentWorld, boolean requiredInAllContentWorlds, @Nullable Set allowedOriginRules) { - super(groupName, source, injectionTime, contentWorld, allowedOriginRules); + public PluginScript(@Nullable String groupName, @NonNull String source, @NonNull UserScriptInjectionTime injectionTime, + @Nullable ContentWorld contentWorld, boolean requiredInAllContentWorlds, @Nullable Set allowedOriginRules, boolean forMainFrameOnly) { + super(groupName, source, injectionTime, contentWorld, allowedOriginRules, forMainFrameOnly); this.requiredInAllContentWorlds = requiredInAllContentWorlds; } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserContentController.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserContentController.java index f51dd1b93..c392fe6fc 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserContentController.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserContentController.java @@ -2,6 +2,7 @@ import android.annotation.SuppressLint; import android.text.TextUtils; +import android.util.Log; import android.webkit.WebView; import androidx.annotation.NonNull; @@ -18,6 +19,7 @@ import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedHashSet; @@ -73,7 +75,7 @@ public String generateWrappedCodeForDocumentEnd() { } js += generatePluginScriptsCodeAt(injectionTime); js += generateUserOnlyScriptsCodeAt(injectionTime); - js = USER_SCRIPTS_AT_DOCUMENT_END_WRAPPER_JS_SOURCE.replace(PluginScriptsUtil.VAR_PLACEHOLDER_VALUE, js); + js = USER_SCRIPTS_AT_DOCUMENT_END_WRAPPER_JS_SOURCE().replace(PluginScriptsUtil.VAR_PLACEHOLDER_VALUE, js); return js; } @@ -83,7 +85,7 @@ public String generateCodeForDocumentStart() { js += generatePluginScriptsCodeAt(injectionTime); js += generateContentWorldsCreatorCode(); js += generateUserOnlyScriptsCodeAt(injectionTime); - js = USER_SCRIPTS_AT_DOCUMENT_START_WRAPPER_JS_SOURCE.replace(PluginScriptsUtil.VAR_PLACEHOLDER_VALUE, js); + js = USER_SCRIPTS_AT_DOCUMENT_START_WRAPPER_JS_SOURCE().replace(PluginScriptsUtil.VAR_PLACEHOLDER_VALUE, js); return js; } @@ -105,7 +107,7 @@ public String generateContentWorldsCreatorCode() { contentWorldsNames.add("'" + escapeContentWorldName(contentWorld.getName()) + "'"); } - return CONTENT_WORLDS_GENERATOR_JS_SOURCE + return CONTENT_WORLDS_GENERATOR_JS_SOURCE() .replace(PluginScriptsUtil.VAR_CONTENT_WORLD_NAME_ARRAY, TextUtils.join(", ", contentWorldsNames)) .replace(PluginScriptsUtil.VAR_JSON_SOURCE_ENCODED, escapeCode(source.toString())); @@ -116,6 +118,7 @@ public String generatePluginScriptsCodeAt(UserScriptInjectionTime injectionTime) LinkedHashSet scripts = this.getPluginScriptsAt(injectionTime); for (PluginScript script : scripts) { String source = ";" + script.getSource(); + source = wrapSourceCodeAddChecks(script, source); source = wrapSourceCodeInContentWorld(script.getContentWorld(), source); js.append(source); } @@ -127,12 +130,38 @@ public String generateUserOnlyScriptsCodeAt(UserScriptInjectionTime injectionTim LinkedHashSet scripts = this.getUserOnlyScriptsAt(injectionTime); for (UserScript script : scripts) { String source = ";" + script.getSource(); + source = wrapSourceCodeAddChecks(script, source); source = wrapSourceCodeInContentWorld(script.getContentWorld(), source); js.append(source); } return js.toString(); } + private String wrapSourceCodeAddChecks(UserScript script, String source) { + Set allowedOriginRules = script.getAllowedOriginRules(); + StringBuilder ifStatement = new StringBuilder("if ("); + if (!WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT) && (!allowedOriginRules.isEmpty() && !allowedOriginRules.contains("*"))) { + StringBuilder jsRegExpArray = new StringBuilder("["); + for (String allowedOriginRule : allowedOriginRules) { + if (jsRegExpArray.length() > 1) { + jsRegExpArray.append(", "); + } + jsRegExpArray.append("new RegExp(").append(escapeCode(allowedOriginRule)).append(")"); + } + if (jsRegExpArray.length() > 1) { + jsRegExpArray.append("]"); + ifStatement.append(jsRegExpArray).append(".some(function(rx) { return rx.test(window.location.origin); })"); + } + } + if (script.isForMainFrameOnly()) { + if (ifStatement.length() > 4) { + ifStatement.append(" && "); + } + ifStatement.append("window.self === window.top"); + } + return ifStatement.length() > 4 ? ifStatement.append(") {").append(source).append("}").toString() : source; + } + public String generateCodeForScriptEvaluation(String source, @Nullable ContentWorld contentWorld) { if (contentWorld != null && !contentWorld.equals(ContentWorld.PAGE)) { StringBuilder sourceWrapped = new StringBuilder(); @@ -144,7 +173,7 @@ public String generateCodeForScriptEvaluation(String source, @Nullable ContentWo for (PluginScript script : pluginScriptsRequired) { pluginScriptsSource.append(script.getSource()); } - String contentWorldCreatorCode = CONTENT_WORLDS_GENERATOR_JS_SOURCE + String contentWorldCreatorCode = CONTENT_WORLDS_GENERATOR_JS_SOURCE() .replace(PluginScriptsUtil.VAR_CONTENT_WORLD_NAME_ARRAY, "'" + escapeContentWorldName(contentWorld.getName()) + "'") .replace(PluginScriptsUtil.VAR_JSON_SOURCE_ENCODED, escapeCode(pluginScriptsSource.toString())); sourceWrapped.append(contentWorldCreatorCode).append(";"); @@ -156,7 +185,7 @@ public String generateCodeForScriptEvaluation(String source, @Nullable ContentWo public String wrapSourceCodeInContentWorld(@Nullable ContentWorld contentWorld, String source) { String sourceWrapped = contentWorld == null || contentWorld.equals(ContentWorld.PAGE) ? source : - CONTENT_WORLD_WRAPPER_JS_SOURCE + CONTENT_WORLD_WRAPPER_JS_SOURCE() .replace(PluginScriptsUtil.VAR_CONTENT_WORLD_NAME, escapeContentWorldName(contentWorld.getName())) .replace(PluginScriptsUtil.VAR_JSON_SOURCE_ENCODED, escapeCode(source)); @@ -201,8 +230,14 @@ public boolean addUserOnlyScript(UserScript userOnlyScript) { contentWorlds.add(contentWorld); } this.updateContentWorldsCreatorScript(); - if (webView != null && userOnlyScript.getInjectionTime() == UserScriptInjectionTime.AT_DOCUMENT_START - && WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) { + if (webView != null && WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) { + String source = userOnlyScript.getSource(); + if (userOnlyScript.getInjectionTime() == UserScriptInjectionTime.AT_DOCUMENT_END) { + source = "if (document.readyState === 'complete') { " + source + "} else { window.addEventListener('load', function() { " + source + " }); }"; + } + source = wrapSourceCodeAddChecks(userOnlyScript, source); + userOnlyScript.setSource(source); + ScriptHandler scriptHandler = WebViewCompat.addDocumentStartJavaScript( webView, wrapSourceCodeInContentWorld(userOnlyScript.getContentWorld(), userOnlyScript.getSource()), @@ -245,6 +280,13 @@ public void removeAllUserOnlyScripts() { this.scriptHandlerMap.remove(userOnlyScript); } } + for (UserScript userOnlyScript : this.userOnlyScripts.get(UserScriptInjectionTime.AT_DOCUMENT_END)) { + ScriptHandler scriptHandler = this.scriptHandlerMap.get(userOnlyScript); + if (scriptHandler != null) { + scriptHandler.remove(); + this.scriptHandlerMap.remove(userOnlyScript); + } + } } this.userOnlyScripts.get(UserScriptInjectionTime.AT_DOCUMENT_START).clear(); this.userOnlyScripts.get(UserScriptInjectionTime.AT_DOCUMENT_END).clear(); @@ -271,8 +313,14 @@ public boolean addPluginScript(PluginScript pluginScript) { contentWorlds.add(contentWorld); } this.updateContentWorldsCreatorScript(); - if (webView != null && pluginScript.getInjectionTime() == UserScriptInjectionTime.AT_DOCUMENT_START - && WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) { + if (webView != null && WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) { + String source = pluginScript.getSource(); + if (pluginScript.getInjectionTime() == UserScriptInjectionTime.AT_DOCUMENT_END) { + source = "if (document.readyState === 'complete') { " + source + "} else { window.addEventListener('load', function() { " + source + " }); }"; + } + source = wrapSourceCodeAddChecks(pluginScript, source); + pluginScript.setSource(source); + ScriptHandler scriptHandler = WebViewCompat.addDocumentStartJavaScript( webView, wrapSourceCodeInContentWorld(pluginScript.getContentWorld(), pluginScript.getSource()), @@ -310,6 +358,13 @@ public void removeAllPluginScripts() { this.scriptHandlerMap.remove(pluginScript); } } + for (PluginScript pluginScript : this.pluginScripts.get(UserScriptInjectionTime.AT_DOCUMENT_END)) { + ScriptHandler scriptHandler = this.scriptHandlerMap.get(pluginScript); + if (scriptHandler != null) { + scriptHandler.remove(); + this.scriptHandlerMap.remove(pluginScript); + } + } } this.pluginScripts.get(UserScriptInjectionTime.AT_DOCUMENT_START).clear(); this.pluginScripts.get(UserScriptInjectionTime.AT_DOCUMENT_END).clear(); @@ -402,60 +457,68 @@ public LinkedHashSet getContentWorlds() { return new LinkedHashSet<>(this.contentWorlds); } - private static final String USER_SCRIPTS_AT_DOCUMENT_START_WRAPPER_JS_SOURCE = "if (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + " != null && (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._userScriptsAtDocumentStartLoaded == null || !window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._userScriptsAtDocumentStartLoaded)) {" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._userScriptsAtDocumentStartLoaded = true;" + - " " + PluginScriptsUtil.VAR_PLACEHOLDER_VALUE + - "}"; + private static String USER_SCRIPTS_AT_DOCUMENT_START_WRAPPER_JS_SOURCE() { + return "if (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + " != null && (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._userScriptsAtDocumentStartLoaded == null || !window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._userScriptsAtDocumentStartLoaded)) {" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._userScriptsAtDocumentStartLoaded = true;" + + " " + PluginScriptsUtil.VAR_PLACEHOLDER_VALUE + + "}"; + } - private static final String USER_SCRIPTS_AT_DOCUMENT_END_WRAPPER_JS_SOURCE = "if (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + " != null && (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._userScriptsAtDocumentEndLoaded == null || !window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._userScriptsAtDocumentEndLoaded)) {" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._userScriptsAtDocumentEndLoaded = true;" + - " " + PluginScriptsUtil.VAR_PLACEHOLDER_VALUE + - "}"; + private static String USER_SCRIPTS_AT_DOCUMENT_END_WRAPPER_JS_SOURCE() { + return "if (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + " != null && (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._userScriptsAtDocumentEndLoaded == null || !window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._userScriptsAtDocumentEndLoaded)) {" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._userScriptsAtDocumentEndLoaded = true;" + + " " + PluginScriptsUtil.VAR_PLACEHOLDER_VALUE + + "}"; + } + + private static String CONTENT_WORLDS_GENERATOR_JS_SOURCE() { + return "(function() {" + + " var interval = setInterval(function() {" + + " if (document.body == null) {return;}" + + " var contentWorldNames = [" + PluginScriptsUtil.VAR_CONTENT_WORLD_NAME_ARRAY + "];" + + " for (var contentWorldName of contentWorldNames) {" + + " var iframeId = '" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "_' + contentWorldName;" + + " var iframe = document.getElementById(iframeId);" + + " if (iframe == null) {" + + " iframe = document.createElement('iframe');" + + " iframe.id = iframeId;" + + " iframe.style = 'display: none; z-index: 0; position: absolute; width: 0px; height: 0px';" + + " document.body.append(iframe);" + + " }" + + " if (iframe.contentWindow.document.getElementById('" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "_plugin_scripts') == null) {" + + " var script = iframe.contentWindow.document.createElement('script');" + + " script.id = '" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "_plugin_scripts';" + + " script.innerHTML = " + PluginScriptsUtil.VAR_JSON_SOURCE_ENCODED + ";" + + " iframe.contentWindow.document.body.append(script);" + + " }" + + " }" + + " clearInterval(interval);" + + " });" + + "})();"; + } - private static final String CONTENT_WORLDS_GENERATOR_JS_SOURCE = "(function() {" + - " var interval = setInterval(function() {" + - " if (document.body == null) {return;}" + - " var contentWorldNames = [" + PluginScriptsUtil.VAR_CONTENT_WORLD_NAME_ARRAY + "];" + - " for (var contentWorldName of contentWorldNames) {" + - " var iframeId = '" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "_' + contentWorldName;" + - " var iframe = document.getElementById(iframeId);" + - " if (iframe == null) {" + - " iframe = document.createElement('iframe');" + - " iframe.id = iframeId;" + - " iframe.style = 'display: none; z-index: 0; position: absolute; width: 0px; height: 0px';" + - " document.body.append(iframe);" + - " }" + - " if (iframe.contentWindow.document.getElementById('" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "_plugin_scripts') == null) {" + - " var script = iframe.contentWindow.document.createElement('script');" + - " script.id = '" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "_plugin_scripts';" + - " script.innerHTML = " + PluginScriptsUtil.VAR_JSON_SOURCE_ENCODED + ";" + - " iframe.contentWindow.document.body.append(script);" + - " }" + - " }" + - " clearInterval(interval);" + - " });" + - "})();"; - - private static final String CONTENT_WORLD_WRAPPER_JS_SOURCE = "(function() {" + - " var interval = setInterval(function() {" + - " if (document.body == null) {return;}" + - " var iframeId = '" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "_" + PluginScriptsUtil.VAR_CONTENT_WORLD_NAME + "';" + - " var iframe = document.getElementById(iframeId);" + - " if (iframe == null) {" + - " iframe = document.createElement('iframe');" + - " iframe.id = iframeId;" + - " iframe.style = 'display: none; z-index: 0; position: absolute; width: 0px; height: 0px';" + - " document.body.append(iframe);" + - " }" + - " if (iframe.contentWindow.document.querySelector('#" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "_plugin_scripts') == null) {" + - " return;" + - " }" + - " var script = iframe.contentWindow.document.createElement('script');" + - " script.innerHTML = " + PluginScriptsUtil.VAR_JSON_SOURCE_ENCODED + ";" + - " iframe.contentWindow.document.body.append(script);" + - " clearInterval(interval);" + - " });" + - "})();"; + private static String CONTENT_WORLD_WRAPPER_JS_SOURCE() { + return "(function() {" + + " var interval = setInterval(function() {" + + " if (document.body == null) {return;}" + + " var iframeId = '" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "_" + PluginScriptsUtil.VAR_CONTENT_WORLD_NAME + "';" + + " var iframe = document.getElementById(iframeId);" + + " if (iframe == null) {" + + " iframe = document.createElement('iframe');" + + " iframe.id = iframeId;" + + " iframe.style = 'display: none; z-index: 0; position: absolute; width: 0px; height: 0px';" + + " document.body.append(iframe);" + + " }" + + " if (iframe.contentWindow.document.querySelector('#" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "_plugin_scripts') == null) {" + + " return;" + + " }" + + " var script = iframe.contentWindow.document.createElement('script');" + + " script.innerHTML = " + PluginScriptsUtil.VAR_JSON_SOURCE_ENCODED + ";" + + " iframe.contentWindow.document.body.append(script);" + + " clearInterval(interval);" + + " });" + + "})();"; + } private static final String DOCUMENT_READY_WRAPPER_JS_SOURCE = "if (document.readyState === 'interactive' || document.readyState === 'complete') { " + " " + PluginScriptsUtil.VAR_PLACEHOLDER_VALUE + diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserScript.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserScript.java index 1f8e5604b..19ecdf5da 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserScript.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserScript.java @@ -6,6 +6,7 @@ import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Objects; import java.util.Set; public class UserScript { @@ -19,10 +20,11 @@ public class UserScript { private ContentWorld contentWorld; @NonNull private Set allowedOriginRules = new HashSet<>(); + private boolean forMainFrameOnly = true; public UserScript(@Nullable String groupName, @NonNull String source, @NonNull UserScriptInjectionTime injectionTime, @Nullable ContentWorld contentWorld, - @Nullable Set allowedOriginRules) { + @Nullable Set allowedOriginRules, boolean forMainFrameOnly) { this.groupName = groupName; this.source = source; this.injectionTime = injectionTime; @@ -30,6 +32,7 @@ public UserScript(@Nullable String groupName, @NonNull String source, this.allowedOriginRules = allowedOriginRules == null ? new HashSet() {{ add("*"); }} : allowedOriginRules; + this.forMainFrameOnly = forMainFrameOnly; } @Nullable @@ -42,8 +45,9 @@ public static UserScript fromMap(@Nullable Map map) { UserScriptInjectionTime injectionTime = UserScriptInjectionTime.fromValue((int) map.get("injectionTime")); ContentWorld contentWorld = ContentWorld.fromMap((Map) map.get("contentWorld")); Set allowedOriginRules = new HashSet<>((List) map.get("allowedOriginRules")); + boolean forMainFrameOnly = (boolean) map.get("forMainFrameOnly"); assert source != null; - return new UserScript(groupName, source, injectionTime, contentWorld, allowedOriginRules); + return new UserScript(groupName, source, injectionTime, contentWorld, allowedOriginRules, forMainFrameOnly); } @Nullable @@ -91,28 +95,31 @@ public void setAllowedOriginRules(@NonNull Set allowedOriginRules) { this.allowedOriginRules = allowedOriginRules; } + public boolean isForMainFrameOnly() { + return forMainFrameOnly; + } + + public void setForMainFrameOnly(boolean forMainFrameOnly) { + this.forMainFrameOnly = forMainFrameOnly; + } + @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; UserScript that = (UserScript) o; - - if (groupName != null ? !groupName.equals(that.groupName) : that.groupName != null) - return false; - if (!source.equals(that.source)) return false; - if (injectionTime != that.injectionTime) return false; - if (!contentWorld.equals(that.contentWorld)) return false; - return allowedOriginRules.equals(that.allowedOriginRules); + return forMainFrameOnly == that.forMainFrameOnly && Objects.equals(groupName, that.groupName) && source.equals(that.source) && injectionTime == that.injectionTime && contentWorld.equals(that.contentWorld) && allowedOriginRules.equals(that.allowedOriginRules); } @Override public int hashCode() { - int result = groupName != null ? groupName.hashCode() : 0; + int result = Objects.hashCode(groupName); result = 31 * result + source.hashCode(); result = 31 * result + injectionTime.hashCode(); result = 31 * result + contentWorld.hashCode(); result = 31 * result + allowedOriginRules.hashCode(); + result = 31 * result + Boolean.hashCode(forMainFrameOnly); return result; } @@ -124,6 +131,7 @@ public String toString() { ", injectionTime=" + injectionTime + ", contentWorld=" + contentWorld + ", allowedOriginRules=" + allowedOriginRules + + ", forMainFrameOnly=" + forMainFrameOnly + '}'; } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/WebMessagePort.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/WebMessagePort.java index a9b6cdf2e..d8bdc5649 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/WebMessagePort.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/WebMessagePort.java @@ -36,10 +36,10 @@ public void setWebMessageCallback(final ValueCallback callback) throws Exc if (webView != null) { int index = name.equals("port1") ? 0 : 1; webView.evaluateJavascript("(function() {" + - " var webMessageChannel = " + JavaScriptBridgeJS.WEB_MESSAGE_CHANNELS_VARIABLE_NAME + "['" + webMessageChannel.id + "'];" + + " var webMessageChannel = " + JavaScriptBridgeJS.WEB_MESSAGE_CHANNELS_VARIABLE_NAME() + "['" + webMessageChannel.id + "'];" + " if (webMessageChannel != null) {" + " webMessageChannel." + this.name + ".onmessage = function (event) {" + - " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + ".callHandler('onWebMessagePortMessageReceived', {" + + " window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + ".callHandler('onWebMessagePortMessageReceived', {" + " 'webMessageChannelId': '" + webMessageChannel.id + "'," + " 'index': " + index + "," + " 'message': event.data" + @@ -82,13 +82,13 @@ public void postMessage(WebMessage message, final ValueCallback callback) throw new Exception("Port is already closed or transferred"); } port.isTransferred = true; - portArrayString.add(JavaScriptBridgeJS.WEB_MESSAGE_CHANNELS_VARIABLE_NAME + "['" + webMessageChannel.id + "']." + port.name); + portArrayString.add(JavaScriptBridgeJS.WEB_MESSAGE_CHANNELS_VARIABLE_NAME() + "['" + webMessageChannel.id + "']." + port.name); } portsString = "[" + TextUtils.join(", ", portArrayString) + "]"; } String data = message.data != null ? Util.replaceAll(message.data, "\'", "\\'") : "null"; String source = "(function() {" + - " var webMessageChannel = " + JavaScriptBridgeJS.WEB_MESSAGE_CHANNELS_VARIABLE_NAME + "['" + webMessageChannel.id + "'];" + + " var webMessageChannel = " + JavaScriptBridgeJS.WEB_MESSAGE_CHANNELS_VARIABLE_NAME() + "['" + webMessageChannel.id + "'];" + " if (webMessageChannel != null) {" + " webMessageChannel." + this.name + ".postMessage('" + data + "', " + portsString + ");" + " }" + @@ -113,7 +113,7 @@ public void close(final ValueCallback callback) throws Exception { InAppWebViewInterface webView = webMessageChannel != null && webMessageChannel.webView != null ? webMessageChannel.webView : null; if (webView != null) { String source = "(function() {" + - " var webMessageChannel = " + JavaScriptBridgeJS.WEB_MESSAGE_CHANNELS_VARIABLE_NAME + "['" + webMessageChannel.id + "'];" + + " var webMessageChannel = " + JavaScriptBridgeJS.WEB_MESSAGE_CHANNELS_VARIABLE_NAME() + "['" + webMessageChannel.id + "'];" + " if (webMessageChannel != null) {" + " webMessageChannel." + this.name + ".close();" + " }" + diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewInterface.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewInterface.java index ece312921..1f88e9f26 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewInterface.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewInterface.java @@ -52,7 +52,8 @@ void loadDataWithBaseURL(String baseUrl, String data, boolean isLoading(); void takeScreenshot(Map screenshotConfiguration, MethodChannel.Result result); void setSettings(InAppWebViewSettings newSettings, HashMap newSettingsMap); - Map getCustomSettings(); + InAppWebViewSettings getCustomSettings(); + Map getCustomSettingsMap(); HashMap getCopyBackForwardList(); void clearAllCache(); void clearSslPreferences(); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java index 7463c5a9a..ed2530cbc 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/InAppWebViewManager.java @@ -16,6 +16,7 @@ import androidx.webkit.WebViewFeature; import com.pichillilorenzo.flutter_inappwebview_android.InAppWebViewFlutterPlugin; +import com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js.JavaScriptBridgeJS; import com.pichillilorenzo.flutter_inappwebview_android.types.ChannelDelegateImpl; import com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.FlutterWebView; @@ -32,7 +33,7 @@ public class InAppWebViewManager extends ChannelDelegateImpl { protected static final String LOG_TAG = "InAppWebViewManager"; public static final String METHOD_CHANNEL_NAME = "com.pichillilorenzo/flutter_inappwebview_manager"; - + @Nullable public InAppWebViewFlutterPlugin plugin; @@ -163,13 +164,22 @@ public void onReceiveValue(Boolean value) { result.success(true); break; case "enableSlowWholeDocumentDraw": - { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { - WebView.enableSlowWholeDocumentDraw(); + { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { + WebView.enableSlowWholeDocumentDraw(); + } } - } - result.success(true); - break; + result.success(true); + break; + case "setJavaScriptBridgeName": + JavaScriptBridgeJS.set_JAVASCRIPT_BRIDGE_NAME((String) call.argument("bridgeName")); + result.success(true); + break; + case "getJavaScriptBridgeName": + { + result.success(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME()); + } + break; default: result.notImplemented(); } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/JavaScriptBridgeInterface.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/JavaScriptBridgeInterface.java index 615a1f86e..4e5ff4112 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/JavaScriptBridgeInterface.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/JavaScriptBridgeInterface.java @@ -9,21 +9,27 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js.JavaScriptBridgeJS; import com.pichillilorenzo.flutter_inappwebview_android.print_job.PrintJobController; import com.pichillilorenzo.flutter_inappwebview_android.print_job.PrintJobSettings; +import com.pichillilorenzo.flutter_inappwebview_android.types.JavaScriptHandlerFunctionData; import com.pichillilorenzo.flutter_inappwebview_android.webview.in_app_webview.InAppWebView; -import com.pichillilorenzo.flutter_inappwebview_android.plugin_scripts_js.JavaScriptBridgeJS; import org.json.JSONArray; import org.json.JSONException; import org.json.JSONObject; +import java.util.regex.Pattern; + public class JavaScriptBridgeInterface { private static final String LOG_TAG = "JSBridgeInterface"; private InAppWebView inAppWebView; - - public JavaScriptBridgeInterface(InAppWebView inAppWebView) { + @NonNull + private final String expectedBridgeSecret; + + public JavaScriptBridgeInterface(InAppWebView inAppWebView, @NonNull String expectedBridgeSecret) { this.inAppWebView = inAppWebView; + this.expectedBridgeSecret = expectedBridgeSecret; } @JavascriptInterface @@ -44,11 +50,40 @@ public void run() { } @JavascriptInterface - public void _callHandler(final String handlerName, final String _callHandlerID, final String args) { + public void _callHandler(final String handlerName, final String _callHandlerID, + final String bridgeSecret, final String origin, final boolean isMainFrame, + final String args) { if (inAppWebView == null) { return; } + if (handlerName == null || handlerName.isEmpty()) { + Log.d(LOG_TAG, "handlerName is null or empty"); + return; + } + + if (!expectedBridgeSecret.equals(bridgeSecret)) { + Log.e(LOG_TAG, "Bridge access attempt with wrong secret token, possibly from malicious code!"); + return; + } + + boolean isOriginAllowed = false; + if (inAppWebView.customSettings.javaScriptHandlerOriginAllowList != null) { + for (Pattern allowedOrigin : inAppWebView.customSettings.javaScriptHandlerOriginAllowList) { + if (allowedOrigin.matcher(origin).matches()) { + isOriginAllowed = true; + break; + } + } + } else { + // origin is by default allowed if the allow list is null + isOriginAllowed = true; + } + if (!isOriginAllowed) { + Log.e(LOG_TAG, "Bridge access attempt from an origin not allowed: " + origin); + return; + } + // java.lang.RuntimeException: Methods marked with @UiThread must be executed on the main thread. // https://github.com/pichillilorenzo/flutter_inappwebview/issues/98 final Handler handler = new Handler(inAppWebView.getWebViewLooper()); @@ -120,22 +155,22 @@ public void error(String errorCode, @Nullable String errorMessage, @Nullable Obj } if (inAppWebView.channelDelegate != null) { + JavaScriptHandlerFunctionData data = new JavaScriptHandlerFunctionData(origin, isMainFrame, args); // invoke flutter javascript handler and send back flutter data as a JSON Object to javascript - inAppWebView.channelDelegate.onCallJsHandler(handlerName, args, new WebViewChannelDelegate.CallJsHandlerCallback() { + inAppWebView.channelDelegate.onCallJsHandler(handlerName, data, new WebViewChannelDelegate.CallJsHandlerCallback() { @Override public void defaultBehaviour(@Nullable Object json) { if (inAppWebView == null) { // The webview has already been disposed, ignore. return; } - String sourceCode = "if (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "[" + _callHandlerID + "] != null) { " + - "window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "[" + _callHandlerID + "].resolve(" + json + "); " + - "delete window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "[" + _callHandlerID + "]; " + - "}"; + String sourceCode = "if (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "[" + _callHandlerID + "] != null) { " + + "window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "[" + _callHandlerID + "].resolve(" + json + "); " + + "delete window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "[" + _callHandlerID + "]; " + + "}"; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { inAppWebView.evaluateJavascript(sourceCode, (ValueCallback) null); - } - else { + } else { inAppWebView.loadUrl("javascript:" + sourceCode); } } @@ -150,14 +185,13 @@ public void error(String errorCode, @Nullable String errorMessage, @Nullable Obj return; } - String sourceCode = "if (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "[" + _callHandlerID + "] != null) { " + - "window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "[" + _callHandlerID + "].reject(new Error(" + JSONObject.quote(message) + ")); " + - "delete window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "[" + _callHandlerID + "]; " + + String sourceCode = "if (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "[" + _callHandlerID + "] != null) { " + + "window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "[" + _callHandlerID + "].reject(new Error(" + JSONObject.quote(message) + ")); " + + "delete window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "[" + _callHandlerID + "]; " + "}"; if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { inAppWebView.evaluateJavascript(sourceCode, (ValueCallback) null); - } - else { + } else { inAppWebView.loadUrl("javascript:" + sourceCode); } } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java index 5f87b93c0..9d2e76eb7 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java @@ -29,6 +29,7 @@ import com.pichillilorenzo.flutter_inappwebview_android.types.HitTestResult; import com.pichillilorenzo.flutter_inappwebview_android.types.HttpAuthResponse; import com.pichillilorenzo.flutter_inappwebview_android.types.HttpAuthenticationChallenge; +import com.pichillilorenzo.flutter_inappwebview_android.types.JavaScriptHandlerFunctionData; import com.pichillilorenzo.flutter_inappwebview_android.types.JsAlertResponse; import com.pichillilorenzo.flutter_inappwebview_android.types.JsBeforeUnloadResponse; import com.pichillilorenzo.flutter_inappwebview_android.types.JsConfirmResponse; @@ -231,9 +232,9 @@ public void onReceiveValue(String value) { case getSettings: if (webView != null && webView.getInAppBrowserDelegate() instanceof InAppBrowserActivity) { InAppBrowserActivity inAppBrowserActivity = (InAppBrowserActivity) webView.getInAppBrowserDelegate(); - result.success(inAppBrowserActivity.getCustomSettings()); + result.success(inAppBrowserActivity.getCustomSettingsMap()); } else { - result.success((webView != null) ? webView.getCustomSettings() : null); + result.success((webView != null) ? webView.getCustomSettingsMap() : null); } break; case close: @@ -1271,7 +1272,7 @@ public Object decodeResult(@Nullable Object obj) { } } - public void onCallJsHandler(String handlerName, String args, @NonNull CallJsHandlerCallback callback) { + public void onCallJsHandler(String handlerName, JavaScriptHandlerFunctionData data, @NonNull CallJsHandlerCallback callback) { MethodChannel channel = getChannel(); if (channel == null) { callback.defaultBehaviour(null); @@ -1279,7 +1280,7 @@ public void onCallJsHandler(String handlerName, String args, @NonNull CallJsHand } Map obj = new HashMap<>(); obj.put("handlerName", handlerName); - obj.put("args", args); + obj.put("data", data.toMap()); channel.invokeMethod("onCallJsHandler", obj, callback); } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java index fbabab3d4..2033e0b60 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java @@ -102,6 +102,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; +import java.security.SecureRandom; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; @@ -188,6 +189,9 @@ public InAppWebView(Context context, AttributeSet attrs, int defaultStyle) { super(context, attrs, defaultStyle); } + @NonNull + private final String expectedBridgeSecret = UUID.randomUUID().toString(); + public InAppWebView(Context context, @NonNull InAppWebViewFlutterPlugin plugin, @NonNull Object id, @Nullable Integer windowId, InAppWebViewSettings customSettings, @Nullable Map contextMenu, View containerView, @@ -243,8 +247,8 @@ public void prepare() { webViewAssetLoaderExt = WebViewAssetLoaderExt.fromMap(customSettings.webViewAssetLoader, plugin, getContext()); } - javaScriptBridgeInterface = new JavaScriptBridgeInterface(this); - addJavascriptInterface(javaScriptBridgeInterface, JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME); + javaScriptBridgeInterface = new JavaScriptBridgeInterface(this, expectedBridgeSecret); + addJavascriptInterface(javaScriptBridgeInterface, JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME()); inAppWebViewChromeClient = new InAppWebViewChromeClient(plugin, this, inAppBrowserDelegate); setWebChromeClient(inAppWebViewChromeClient); @@ -561,24 +565,34 @@ public boolean onLongClick(View v) { } public void prepareAndAddUserScripts() { - userContentController.addPluginScript(PromisePolyfillJS.PROMISE_POLYFILL_JS_PLUGIN_SCRIPT); - userContentController.addPluginScript(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_JS_PLUGIN_SCRIPT); - userContentController.addPluginScript(PrintJS.PRINT_JS_PLUGIN_SCRIPT); - userContentController.addPluginScript(OnWindowBlurEventJS.ON_WINDOW_BLUR_EVENT_JS_PLUGIN_SCRIPT); - userContentController.addPluginScript(OnWindowFocusEventJS.ON_WINDOW_FOCUS_EVENT_JS_PLUGIN_SCRIPT); + userContentController.addPluginScript(PromisePolyfillJS.PROMISE_POLYFILL_JS_PLUGIN_SCRIPT(customSettings.pluginScriptsOriginAllowList, + customSettings.pluginScriptsForMainFrameOnly)); + userContentController.addPluginScript(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_JS_PLUGIN_SCRIPT(expectedBridgeSecret, + customSettings.pluginScriptsOriginAllowList, + customSettings.pluginScriptsForMainFrameOnly)); + userContentController.addPluginScript(PrintJS.PRINT_JS_PLUGIN_SCRIPT(customSettings.pluginScriptsOriginAllowList, + customSettings.pluginScriptsForMainFrameOnly)); + userContentController.addPluginScript(OnWindowBlurEventJS.ON_WINDOW_BLUR_EVENT_JS_PLUGIN_SCRIPT(customSettings.pluginScriptsOriginAllowList, + customSettings.pluginScriptsForMainFrameOnly)); + userContentController.addPluginScript(OnWindowFocusEventJS.ON_WINDOW_FOCUS_EVENT_JS_PLUGIN_SCRIPT(customSettings.pluginScriptsOriginAllowList, + customSettings.pluginScriptsForMainFrameOnly)); interceptOnlyAsyncAjaxRequestsPluginScript = InterceptAjaxRequestJS.createInterceptOnlyAsyncAjaxRequestsPluginScript(customSettings.interceptOnlyAsyncAjaxRequests); if (customSettings.useShouldInterceptAjaxRequest) { userContentController.addPluginScript(interceptOnlyAsyncAjaxRequestsPluginScript); - userContentController.addPluginScript(InterceptAjaxRequestJS.INTERCEPT_AJAX_REQUEST_JS_PLUGIN_SCRIPT); + userContentController.addPluginScript(InterceptAjaxRequestJS.INTERCEPT_AJAX_REQUEST_JS_PLUGIN_SCRIPT(customSettings.pluginScriptsOriginAllowList, + customSettings.pluginScriptsForMainFrameOnly)); } if (customSettings.useShouldInterceptFetchRequest) { - userContentController.addPluginScript(InterceptFetchRequestJS.INTERCEPT_FETCH_REQUEST_JS_PLUGIN_SCRIPT); + userContentController.addPluginScript(InterceptFetchRequestJS.INTERCEPT_FETCH_REQUEST_JS_PLUGIN_SCRIPT(customSettings.pluginScriptsOriginAllowList, + customSettings.pluginScriptsForMainFrameOnly)); } if (customSettings.useOnLoadResource) { - userContentController.addPluginScript(OnLoadResourceJS.ON_LOAD_RESOURCE_JS_PLUGIN_SCRIPT); + userContentController.addPluginScript(OnLoadResourceJS.ON_LOAD_RESOURCE_JS_PLUGIN_SCRIPT(customSettings.pluginScriptsOriginAllowList, + customSettings.pluginScriptsForMainFrameOnly)); } if (!customSettings.useHybridComposition) { - userContentController.addPluginScript(PluginScriptsUtil.CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_PLUGIN_SCRIPT); + userContentController.addPluginScript(PluginScriptsUtil.CHECK_GLOBAL_KEY_DOWN_EVENT_TO_HIDE_CONTEXT_MENU_JS_PLUGIN_SCRIPT(customSettings.pluginScriptsOriginAllowList, + customSettings.pluginScriptsForMainFrameOnly)); } this.userContentController.addUserOnlyScripts(this.initialUserOnlyScripts); } @@ -783,15 +797,16 @@ public void setSettings(InAppWebViewSettings newCustomSettings, HashMap= Build.VERSION_CODES.M) customSettings = newCustomSettings; } - public Map getCustomSettings() { + public Map getCustomSettingsMap() { return (customSettings != null) ? customSettings.getRealSettings(this) : null; } @@ -1170,8 +1187,8 @@ public void injectDeferredObject(String source, @Nullable final ContentWorld con } if (resultUuid != null && resultCallback != null) { evaluateJavaScriptContentWorldCallbacks.put(resultUuid, resultCallback); - scriptToInject = Util.replaceAll(PluginScriptsUtil.EVALUATE_JAVASCRIPT_WITH_CONTENT_WORLD_WRAPPER_JS_SOURCE, - PluginScriptsUtil.VAR_RANDOM_NAME, "_" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "_" + Math.round(Math.random() * 1000000)) + scriptToInject = Util.replaceAll(PluginScriptsUtil.EVALUATE_JAVASCRIPT_WITH_CONTENT_WORLD_WRAPPER_JS_SOURCE(), + PluginScriptsUtil.VAR_RANDOM_NAME, "_" + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "_" + Math.round(Math.random() * 1000000)) .replace(PluginScriptsUtil.VAR_PLACEHOLDER_VALUE, UserContentController.escapeCode(source)) .replace(PluginScriptsUtil.VAR_RESULT_UUID, resultUuid); } @@ -1216,13 +1233,13 @@ public void injectJavascriptFileFromUrl(String urlFile, @Nullable Map argumen String functionArgumentValues = TextUtils.join(", ", functionArgumentValuesList); String functionArgumentsObj = Util.JSONStringify(arguments); - String sourceToInject = PluginScriptsUtil.CALL_ASYNC_JAVA_SCRIPT_WRAPPER_JS_SOURCE + String sourceToInject = PluginScriptsUtil.CALL_ASYNC_JAVA_SCRIPT_WRAPPER_JS_SOURCE() .replace(PluginScriptsUtil.VAR_FUNCTION_ARGUMENT_NAMES, functionArgumentNames) .replace(PluginScriptsUtil.VAR_FUNCTION_ARGUMENT_VALUES, functionArgumentValues) .replace(PluginScriptsUtil.VAR_FUNCTION_ARGUMENTS_OBJ, functionArgumentsObj) @@ -2036,6 +2053,11 @@ public void setChannelDelegate(@Nullable WebViewChannelDelegate channelDelegate) this.channelDelegate = channelDelegate; } + @Override + public InAppWebViewSettings getCustomSettings() { + return customSettings; + } + @Override public void dispose() { if (channelDelegate != null) { @@ -2045,7 +2067,7 @@ public void dispose() { super.dispose(); WebSettings settings = getSettings(); settings.setJavaScriptEnabled(false); - removeJavascriptInterface(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME); + removeJavascriptInterface(JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q && WebViewFeature.isFeatureSupported(WebViewFeature.WEB_VIEW_RENDERER_CLIENT_BASIC_USAGE)) { WebViewCompat.setWebViewRenderProcessClient(this, null); } diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java index c964c0327..f410b2eae 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClient.java @@ -189,12 +189,13 @@ public void loadCustomJavaScriptOnPageStarted(WebView view) { public void loadCustomJavaScriptOnPageFinished(WebView view) { InAppWebView webView = (InAppWebView) view; - String source = webView.userContentController.generateWrappedCodeForDocumentEnd(); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - webView.evaluateJavascript(source, (ValueCallback) null); - } else { - webView.loadUrl("javascript:" + source.replaceAll("[\r\n]+", "")); + if (!WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) { + String source = webView.userContentController.generateWrappedCodeForDocumentEnd(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + webView.evaluateJavascript(source, (ValueCallback) null); + } else { + webView.loadUrl("javascript:" + source.replaceAll("[\r\n]+", "")); + } } } @@ -237,7 +238,7 @@ public void onPageFinished(WebView view, String url) { CookieSyncManager.getInstance().sync(); } - String js = JavaScriptBridgeJS.PLATFORM_READY_JS_SOURCE; + String js = JavaScriptBridgeJS.PLATFORM_READY_JS_SOURCE(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { webView.evaluateJavascript(js, (ValueCallback) null); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java index f00af4149..36b34195f 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewClientCompat.java @@ -189,12 +189,13 @@ public void loadCustomJavaScriptOnPageStarted(WebView view) { public void loadCustomJavaScriptOnPageFinished(WebView view) { InAppWebView webView = (InAppWebView) view; - String source = webView.userContentController.generateWrappedCodeForDocumentEnd(); - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { - webView.evaluateJavascript(source, (ValueCallback) null); - } else { - webView.loadUrl("javascript:" + source.replaceAll("[\r\n]+", "")); + if (!WebViewFeature.isFeatureSupported(WebViewFeature.DOCUMENT_START_SCRIPT)) { + String source = webView.userContentController.generateWrappedCodeForDocumentEnd(); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + webView.evaluateJavascript(source, (ValueCallback) null); + } else { + webView.loadUrl("javascript:" + source.replaceAll("[\r\n]+", "")); + } } } @@ -237,7 +238,7 @@ public void onPageFinished(WebView view, String url) { CookieSyncManager.getInstance().sync(); } - String js = JavaScriptBridgeJS.PLATFORM_READY_JS_SOURCE; + String js = JavaScriptBridgeJS.PLATFORM_READY_JS_SOURCE(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { webView.evaluateJavascript(js, (ValueCallback) null); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java index 91c13ea36..ed1fa5123 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java @@ -23,6 +23,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.regex.Pattern; public class InAppWebViewSettings implements ISettings { @@ -133,6 +134,11 @@ public class InAppWebViewSettings implements ISettings { public byte[] defaultVideoPoster; @Nullable public Set requestedWithHeaderOriginAllowList; + @Nullable + public Set javaScriptHandlerOriginAllowList; + @Nullable + public Set pluginScriptsOriginAllowList; + public Boolean pluginScriptsForMainFrameOnly = false; @NonNull @Override @@ -412,6 +418,18 @@ public InAppWebViewSettings parse(@NonNull Map settings) { case "requestedWithHeaderOriginAllowList": requestedWithHeaderOriginAllowList = new HashSet<>((List) value); break; + case "javaScriptHandlerOriginAllowList": + javaScriptHandlerOriginAllowList = new HashSet<>(); + for (String pattern : (List) value) { + javaScriptHandlerOriginAllowList.add(Pattern.compile(pattern)); + } + break; + case "pluginScriptsOriginAllowList": + pluginScriptsOriginAllowList = new HashSet<>((List) value); + break; + case "pluginScriptsForMainFrameOnly": + pluginScriptsForMainFrameOnly = (Boolean) value; + break; } } @@ -511,6 +529,15 @@ public Map toMap() { settings.put("defaultVideoPoster", defaultVideoPoster); settings.put("requestedWithHeaderOriginAllowList", requestedWithHeaderOriginAllowList != null ? new ArrayList<>(requestedWithHeaderOriginAllowList) : null); + settings.put("javaScriptHandlerOriginAllowList", + javaScriptHandlerOriginAllowList != null ? new ArrayList() {{ + for (Pattern pattern : javaScriptHandlerOriginAllowList) { + add(pattern.pattern()); + } + }} : null); + settings.put("pluginScriptsOriginAllowList", + pluginScriptsOriginAllowList != null ? new ArrayList<>(pluginScriptsOriginAllowList) : null); + settings.put("pluginScriptsForMainFrameOnly", pluginScriptsForMainFrameOnly); return settings; } @@ -557,7 +584,8 @@ public Map getRealSettings(@NonNull InAppWebViewInterface inAppW realSettings.put("defaultTextEncodingName", settings.getDefaultTextEncodingName()); if (WebViewFeature.isFeatureSupported(WebViewFeature.DISABLED_ACTION_MODE_MENU_ITEMS)) { realSettings.put("disabledActionModeMenuItems", WebSettingsCompat.getDisabledActionModeMenuItems(settings)); - } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { + } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { realSettings.put("disabledActionModeMenuItems", settings.getDisabledActionModeMenuItems()); } realSettings.put("fantasyFontFamily", settings.getFantasyFontFamily()); diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/web_message/WebMessageChannel.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/web_message/WebMessageChannel.java index b7d059c27..54230d09c 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/web_message/WebMessageChannel.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/web_message/WebMessageChannel.java @@ -56,7 +56,7 @@ public void initJsInstance(InAppWebViewInterface webView, final ValueCallback() { @Override public void onReceiveValue(String value) { diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/web_message/WebMessageListener.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/web_message/WebMessageListener.java index fe7326f70..42e0ee9f4 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/web_message/WebMessageListener.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/web_message/WebMessageListener.java @@ -91,7 +91,7 @@ public void initJsInstance() { " var scheme = !isPageBlank ? window.location.protocol.replace(':', '') : null;" + " var host = !isPageBlank ? window.location.hostname : null;" + " var port = !isPageBlank ? window.location.port : null;" + - " if (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME + "._isOriginAllowed(allowedOriginRules, scheme, host, port)) {" + + " if (window." + JavaScriptBridgeJS.JAVASCRIPT_BRIDGE_NAME() + "._isOriginAllowed(allowedOriginRules, scheme, host, port)) {" + " window['" + jsObjectNameEscaped + "'] = new FlutterInAppWebViewWebMessageListener('" + jsObjectNameEscaped + "');" + " }" + "})();"; @@ -101,7 +101,8 @@ public void initJsInstance() { UserScriptInjectionTime.AT_DOCUMENT_START, null, false, - null + webView.getCustomSettings().pluginScriptsOriginAllowList, + webView.getCustomSettings().pluginScriptsForMainFrameOnly )); } } diff --git a/flutter_inappwebview_android/example/pubspec.lock b/flutter_inappwebview_android/example/pubspec.lock index 8603227e7..dfb7281eb 100644 --- a/flutter_inappwebview_android/example/pubspec.lock +++ b/flutter_inappwebview_android/example/pubspec.lock @@ -81,7 +81,7 @@ packages: path: ".." relative: true source: path - version: "1.1.3" + version: "1.2.0" flutter_inappwebview_internal_annotations: dependency: transitive description: @@ -93,11 +93,10 @@ packages: flutter_inappwebview_platform_interface: dependency: transitive description: - name: flutter_inappwebview_platform_interface - sha256: "6862f4e08aa8f6136762e022c9c1edafb18c1dc3beb03052f2f3f2a48605a182" - url: "https://pub.dev" - source: hosted - version: "1.3.0" + path: "../../flutter_inappwebview_platform_interface" + relative: true + source: path + version: "1.4.0" flutter_lints: dependency: "direct dev" description: diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart index 0d269dc2e..5dee24ef6 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1,24 +1,19 @@ -import 'dart:io'; import 'dart:collection'; import 'dart:convert'; import 'dart:core'; import 'dart:developer' as developer; -import 'dart:typed_data'; -import 'dart:ui'; +import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; -import '../web_message/main.dart'; - import '../in_app_browser/in_app_browser.dart'; +import '../print_job/main.dart'; +import '../web_message/main.dart'; import '../web_storage/web_storage.dart'; - -import 'headless_in_app_webview.dart'; import '_static_channel.dart'; - -import '../print_job/main.dart'; +import 'headless_in_app_webview.dart'; ///List of forbidden names for JavaScript handlers. // ignore: non_constant_identifier_names @@ -66,8 +61,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController static final MethodChannel _staticChannel = IN_APP_WEBVIEW_STATIC_CHANNEL; // List of properties to be saved and restored for keep alive feature - Map _javaScriptHandlersMap = - HashMap(); + Map _javaScriptHandlersMap = HashMap(); Map> _userScripts = { UserScriptInjectionTime.AT_DOCUMENT_START: [], UserScriptInjectionTime.AT_DOCUMENT_END: [] @@ -1408,17 +1402,19 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController break; case "onCallJsHandler": String handlerName = call.arguments["handlerName"]; + Map handlerDataMap = call.arguments["data"].cast(); // decode args to json - List args = jsonDecode(call.arguments["args"]); + handlerDataMap["args"] = jsonDecode(handlerDataMap["args"]); + final handlerData = JavaScriptHandlerFunctionData.fromMap(handlerDataMap)!; - _debugLog(handlerName, args); + _debugLog(handlerName, handlerData); switch (handlerName) { case "onLoadResource": if ((webviewParams != null && webviewParams!.onLoadResource != null) || _inAppBrowserEventHandler != null) { - Map arguments = args[0].cast(); + Map arguments = handlerData.args[0].cast(); arguments["startTime"] = arguments["startTime"] is int ? arguments["startTime"].toDouble() : arguments["startTime"]; @@ -1440,7 +1436,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && webviewParams!.shouldInterceptAjaxRequest != null) || _inAppBrowserEventHandler != null) { - Map arguments = args[0].cast(); + Map arguments = handlerData.args[0].cast(); AjaxRequest request = AjaxRequest.fromMap(arguments)!; if (webviewParams != null && @@ -1457,7 +1453,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && webviewParams!.onAjaxReadyStateChange != null) || _inAppBrowserEventHandler != null) { - Map arguments = args[0].cast(); + Map arguments = handlerData.args[0].cast(); AjaxRequest request = AjaxRequest.fromMap(arguments)!; if (webviewParams != null && @@ -1475,7 +1471,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && webviewParams!.onAjaxProgress != null) || _inAppBrowserEventHandler != null) { - Map arguments = args[0].cast(); + Map arguments = handlerData.args[0].cast(); AjaxRequest request = AjaxRequest.fromMap(arguments)!; if (webviewParams != null && @@ -1493,7 +1489,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if ((webviewParams != null && webviewParams!.shouldInterceptFetchRequest != null) || _inAppBrowserEventHandler != null) { - Map arguments = args[0].cast(); + Map arguments = handlerData.args[0].cast(); FetchRequest request = FetchRequest.fromMap(arguments)!; if (webviewParams != null && @@ -1519,7 +1515,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController _inAppBrowserEventHandler!.onWindowBlur(); return null; case "onInjectedScriptLoaded": - String id = args[0]; + String id = handlerData.args[0]; var onLoadCallback = _injectedScriptsFromURL[id]?.onLoad; if ((webviewParams != null || _inAppBrowserEventHandler != null) && onLoadCallback != null) { @@ -1527,7 +1523,7 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController } return null; case "onInjectedScriptError": - String id = args[0]; + String id = handlerData.args[0]; var onErrorCallback = _injectedScriptsFromURL[id]?.onError; if ((webviewParams != null || _inAppBrowserEventHandler != null) && onErrorCallback != null) { @@ -1539,7 +1535,19 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController if (_javaScriptHandlersMap.containsKey(handlerName)) { // convert result to json try { - return jsonEncode(await _javaScriptHandlersMap[handlerName]!(args)); + var jsHandlerResult = null; + if (_javaScriptHandlersMap[handlerName] + is JavaScriptHandlerCallback) { + jsHandlerResult = await (_javaScriptHandlersMap[handlerName] + as JavaScriptHandlerCallback)(handlerData.args); + } else if (_javaScriptHandlersMap[handlerName] + is JavaScriptHandlerFunction) { + jsHandlerResult = await (_javaScriptHandlersMap[handlerName] + as JavaScriptHandlerFunction)(handlerData); + } else { + jsHandlerResult = await _javaScriptHandlersMap[handlerName]!(); + } + return jsonEncode(jsHandlerResult); } catch (error, stacktrace) { developer.log(error.toString() + '\n' + stacktrace.toString(), name: 'JavaScript Handler "$handlerName"'); @@ -1986,16 +1994,14 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController @override void addJavaScriptHandler( - {required String handlerName, - required JavaScriptHandlerCallback callback}) { + {required String handlerName, required Function callback}) { assert(!_JAVASCRIPT_HANDLER_FORBIDDEN_NAMES.contains(handlerName), '"$handlerName" is a forbidden name!'); this._javaScriptHandlersMap[handlerName] = (callback); } @override - JavaScriptHandlerCallback? removeJavaScriptHandler( - {required String handlerName}) { + Function? removeJavaScriptHandler({required String handlerName}) { return this._javaScriptHandlersMap.remove(handlerName); } @@ -2744,6 +2750,21 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController await _staticChannel.invokeMethod('enableSlowWholeDocumentDraw', args); } + @override + Future setJavaScriptBridgeName(String bridgeName) async { + Map args = {}; + args.putIfAbsent('bridgeName', () => bridgeName); + await _staticChannel.invokeMethod('setJavaScriptBridgeName', args); + } + + @override + Future getJavaScriptBridgeName() async { + Map args = {}; + return await _staticChannel.invokeMethod( + 'getJavaScriptBridgeName', args) ?? + ''; + } + @override Future get tRexRunnerHtml async => await rootBundle.loadString( 'packages/flutter_inappwebview/assets/t_rex_runner/t-rex.html'); diff --git a/flutter_inappwebview_android/pubspec.yaml b/flutter_inappwebview_android/pubspec.yaml index f9fd161a3..83dba2a37 100644 --- a/flutter_inappwebview_android/pubspec.yaml +++ b/flutter_inappwebview_android/pubspec.yaml @@ -20,7 +20,8 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: ^1.4.0 + flutter_inappwebview_platform_interface: # ^1.4.0 + path: ../flutter_inappwebview_platform_interface dev_dependencies: flutter_test: diff --git a/flutter_inappwebview_platform_interface/CHANGELOG.md b/flutter_inappwebview_platform_interface/CHANGELOG.md index 18e127b0c..efc16294c 100644 --- a/flutter_inappwebview_platform_interface/CHANGELOG.md +++ b/flutter_inappwebview_platform_interface/CHANGELOG.md @@ -2,6 +2,9 @@ - Updated static `fromMap` implementation for some classes - Added `PlatformInAppLocalhostServer.onData` parameter to set a custom on data server callback +- Added `javaScriptHandlerOriginAllowList`, `pluginScriptsOriginAllowList`, `pluginScriptsForMainFrameOnly` InAppWebViewSettings parameters +- Added `JavaScriptHandlerFunctionData` type +- Deprecated `JavaScriptHandlerCallback` type in favor of `JavaScriptHandlerFunction` type ## 1.3.0+1 diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_keep_alive.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_keep_alive.dart index 0cf7800e8..cd7cff328 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_keep_alive.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_keep_alive.dart @@ -22,7 +22,7 @@ extension InternalInAppWebViewKeepAlive on InAppWebViewKeepAlive { ///Used internally to save and restore [PlatformInAppWebViewController] properties ///for the keep alive feature. class InAppWebViewControllerKeepAliveProps { - Map javaScriptHandlersMap; + Map javaScriptHandlersMap; Map> userScripts; Set webMessageListenerObjNames; Map injectedScriptsFromURL; diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart index 34f9e9e0b..a7555b4e3 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart @@ -21,6 +21,7 @@ import '../types/scrollview_deceleration_rate.dart'; import '../types/selection_granularity.dart'; import '../types/user_preferred_content_mode.dart'; import '../types/vertical_scrollbar_position.dart'; +import '../types/user_script.dart'; import '../web_uri.dart'; import 'android/in_app_webview_options.dart'; import 'apple/in_app_webview_options.dart'; @@ -1594,6 +1595,39 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri ]) bool? shouldPrintBackgrounds; + ///A list of patterns that will be used to match the allowed origins + ///that are able to execute the JavaScript Handlers defined for the current WebView. + ///This will affect also the internal JavaScript Handlers used by the plugin itself. + ///The default value is `null` and will allow every origin. + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform(), + ]) + Set? javaScriptHandlerOriginAllowList; + + ///A list of patterns that will be used to match the allowed origins + ///that are able to load all the internal plugin [UserScript]s used by the plugin itself. + ///The default value is `null` and will allow every origin. + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform(), + ]) + Set? pluginScriptsOriginAllowList; + + ///Set to `true` to allow internal plugin [UserScript]s only on the main frame. + ///The default value is `false`. + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform(), + ]) + bool? pluginScriptsForMainFrameOnly; + ///Specifies a feature policy for the `. + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + String? name; + + ///The unique identifier of the frame associated with the current [FrameInfo]. + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + int? frameId; + + ///The kind of the frame. + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + FrameKind_? kind; + FrameInfo_( - {required this.isMainFrame, required this.request, this.securityOrigin}); + {required this.isMainFrame, required this.request, this.securityOrigin, + this.name, this.frameId, this.kind}); } ///An object that contains information about a frame on a webpage. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/frame_info.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/frame_info.g.dart index 71f0402a5..f568ad466 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/frame_info.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/frame_info.g.dart @@ -8,15 +8,54 @@ part of 'frame_info.dart'; ///An object that contains information about a frame on a webpage. class FrameInfo { + ///The unique identifier of the frame associated with the current [FrameInfo]. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows + int? frameId; + ///A Boolean value indicating whether the frame is the web site's main frame or a subframe. + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + ///- Windows bool isMainFrame; + ///The kind of the frame. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows + FrameKind? kind; + + ///Gets the name attribute of the frame, as in . + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows + String? name; + ///The frame’s current request. + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + ///- Windows URLRequest? request; ///The frame’s security origin. + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS + ///- MacOS + ///- Windows SecurityOrigin? securityOrigin; - FrameInfo({required this.isMainFrame, this.request, this.securityOrigin}); + FrameInfo( + {this.frameId, + required this.isMainFrame, + this.kind, + this.name, + this.request, + this.securityOrigin}); ///Gets a possible [FrameInfo] instance from a [Map] value. static FrameInfo? fromMap(Map? map) { @@ -24,7 +63,10 @@ class FrameInfo { return null; } final instance = FrameInfo( + frameId: map['frameId'], isMainFrame: map['isMainFrame'], + kind: FrameKind.fromNativeValue(map['kind']), + name: map['name'], request: URLRequest.fromMap(map['request']?.cast()), securityOrigin: SecurityOrigin.fromMap( map['securityOrigin']?.cast()), @@ -35,7 +77,10 @@ class FrameInfo { ///Converts instance to a map. Map toMap() { return { + "frameId": frameId, "isMainFrame": isMainFrame, + "kind": kind?.toNativeValue(), + "name": name, "request": request?.toMap(), "securityOrigin": securityOrigin?.toMap(), }; @@ -48,7 +93,7 @@ class FrameInfo { @override String toString() { - return 'FrameInfo{isMainFrame: $isMainFrame, request: $request, securityOrigin: $securityOrigin}'; + return 'FrameInfo{frameId: $frameId, isMainFrame: $isMainFrame, kind: $kind, name: $name, request: $request, securityOrigin: $securityOrigin}'; } } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart b/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart new file mode 100644 index 000000000..8b3a19cda --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart @@ -0,0 +1,64 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'frame_kind.g.dart'; + +///Class used to indicate the the frame kind. +@ExchangeableEnum() +class FrameKind_ { + // ignore: unused_field + final String _value; + // ignore: unused_field + final dynamic _nativeValue = null; + const FrameKind_._internal(this._value); + + ///Indicates that the frame is an unknown type frame. We may extend this enum type to identify more frame kinds in the future. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_FRAME_KIND_UNKNOWN', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', + value: 0 + ), + ]) + static const UNKNOWN = const FrameKind_._internal('UNKNOWN'); + + ///Indicates that the frame is a primary main frame(webview). + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_FRAME_KIND_MAIN_FRAME', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', + value: 1 + ), + ]) + static const MAIN_FRAME = const FrameKind_._internal('MAIN_FRAME'); + + ///Indicates that the frame is an iframe. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_FRAME_KIND_IFRAME', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', + value: 2 + ), + ]) + static const IFRAME = const FrameKind_._internal('IFRAME'); + + ///Indicates that the frame is an embed element. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_FRAME_KIND_EMBED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', + value: 3 + ), + ]) + static const EMBED = const FrameKind_._internal('EMBED'); + + ///Indicates that the frame is an object element. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_FRAME_KIND_OBJECT', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', + value: 4 + ), + ]) + static const OBJECT = const FrameKind_._internal('OBJECT'); +} \ No newline at end of file diff --git a/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.g.dart new file mode 100644 index 000000000..727b15aab --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.g.dart @@ -0,0 +1,140 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'frame_kind.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to indicate the the frame kind. +class FrameKind { + final String _value; + final dynamic _nativeValue; + const FrameKind._internal(this._value, this._nativeValue); +// ignore: unused_element + factory FrameKind._internalMultiPlatform( + String value, Function nativeValue) => + FrameKind._internal(value, nativeValue()); + + ///Indicates that the frame is an embed element. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_FRAME_KIND_EMBED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) + static final EMBED = FrameKind._internalMultiPlatform('EMBED', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 3; + default: + break; + } + return null; + }); + + ///Indicates that the frame is an iframe. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_FRAME_KIND_IFRAME](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) + static final IFRAME = FrameKind._internalMultiPlatform('IFRAME', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 2; + default: + break; + } + return null; + }); + + ///Indicates that the frame is a primary main frame(webview). + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_FRAME_KIND_MAIN_FRAME](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) + static final MAIN_FRAME = FrameKind._internalMultiPlatform('MAIN_FRAME', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 1; + default: + break; + } + return null; + }); + + ///Indicates that the frame is an object element. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_FRAME_KIND_OBJECT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) + static final OBJECT = FrameKind._internalMultiPlatform('OBJECT', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 4; + default: + break; + } + return null; + }); + + ///Indicates that the frame is an unknown type frame. We may extend this enum type to identify more frame kinds in the future. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_FRAME_KIND_UNKNOWN](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) + static final UNKNOWN = FrameKind._internalMultiPlatform('UNKNOWN', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 0; + default: + break; + } + return null; + }); + + ///Set of all values of [FrameKind]. + static final Set values = [ + FrameKind.EMBED, + FrameKind.IFRAME, + FrameKind.MAIN_FRAME, + FrameKind.OBJECT, + FrameKind.UNKNOWN, + ].toSet(); + + ///Gets a possible [FrameKind] instance from [String] value. + static FrameKind? fromValue(String? value) { + if (value != null) { + try { + return FrameKind.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [FrameKind] instance from a native value. + static FrameKind? fromNativeValue(dynamic value) { + if (value != null) { + try { + return FrameKind.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [dynamic] native value. + dynamic toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/main.dart b/flutter_inappwebview_platform_interface/lib/src/types/main.dart index ba2c2efb2..738df7950 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/main.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/main.dart @@ -231,3 +231,7 @@ export 'custom_tabs_post_message_result_type.dart' show CustomTabsPostMessageResultType; export 'custom_scheme_registration.dart' show CustomSchemeRegistration; export 'disposable.dart'; +export 'frame_kind.dart' show FrameKind; +export 'process_failed_kind.dart' show ProcessFailedKind; +export 'process_failed_reason.dart' show ProcessFailedReason; +export 'process_failed_detail.dart' show ProcessFailedDetail; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.dart new file mode 100644 index 000000000..7f865fd28 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.dart @@ -0,0 +1,76 @@ +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +import 'frame_info.dart'; +import 'process_failed_kind.dart'; +import 'process_failed_reason.dart'; + +part 'process_failed_detail.g.dart'; + +///An object that contains information about a frame on a webpage. +@ExchangeableObject() +class ProcessFailedDetail_ { + ///The kind of process failure that has occurred. + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + ProcessFailedKind_ kind; + + ///The exit code of the failing process, for telemetry purposes. + /// + ///The exit code is always STILL_ACTIVE (259) when [ProcessFailedKind.RENDER_PROCESS_UNRESPONSIVE]. + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + int? exitCode; + + ///Description of the process assigned by the WebView2 Runtime. + /// + ///This is a technical English term appropriate for logging or development purposes, and not localized for the end user. + ///It applies to utility processes (for example, "Audio Service", "Video Capture") and plugin processes (for example, "Flash"). + ///The returned [processDescription] is empty if the WebView2 Runtime did not assign a description to the process. + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + String? processDescription; + + ///The reason for the process failure. + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + ProcessFailedReason_? reason; + + ///This property is the full path of the module that caused the crash in cases of Windows Code Integrity failures. + /// + ///Windows Code Integrity is a feature that verifies the integrity and authenticity of dynamic-link libraries (DLLs) on Windows systems. + ///It ensures that only trusted code can run on the system and prevents unauthorized or malicious modifications. + ///When ProcessFailed occurred due to a failed Code Integrity check, this property returns the full path of the file that was prevented from loading on the system. + ///The webview2 process which tried to load the DLL will fail with exit code STATUS_INVALID_IMAGE_HASH(-1073740760). + ///A file can fail integrity check for various reasons, such as: + ///- It has an invalid or missing signature that does not match the publisher or signer of the file. + ///- It has been tampered with or corrupted by malware or other software. + ///- It has been blocked by an administrator or a security policy. This property always will be the empty string if failure is not caused by STATUS_INVALID_IMAGE_HASH. + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + String? failureSourceModulePath; + + ///The collection of [FrameInfo]s for frames in the WebView that were being rendered by the failed process. + /// + ///The content in these frames is replaced with an error page. + ///This is only available when [ProcessFailedKind] is [ProcessFailedKind.FRAME_RENDER_PROCESS_EXITED]; + ///frames is null for all other process failure kinds, including the case in which the failed process was the renderer + ///for the main frame and subframes within it, for which the failure kind is [ProcessFailedKind.RENDER_PROCESS_EXITED]. + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + List? frameInfos; + + ProcessFailedDetail_( + {required this.kind, + this.exitCode, + this.processDescription, + this.reason, + this.failureSourceModulePath, + this.frameInfos, + }); +} \ No newline at end of file diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.g.dart new file mode 100644 index 000000000..9c5841db0 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.g.dart @@ -0,0 +1,114 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'process_failed_detail.dart'; + +// ************************************************************************** +// ExchangeableObjectGenerator +// ************************************************************************** + +///An object that contains information about a frame on a webpage. +class ProcessFailedDetail { + ///The exit code of the failing process, for telemetry purposes. + /// + ///The exit code is always STILL_ACTIVE (259) when [ProcessFailedKind.RENDER_PROCESS_UNRESPONSIVE]. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows + int? exitCode; + + ///This property is the full path of the module that caused the crash in cases of Windows Code Integrity failures. + /// + ///Windows Code Integrity is a feature that verifies the integrity and authenticity of dynamic-link libraries (DLLs) on Windows systems. + ///It ensures that only trusted code can run on the system and prevents unauthorized or malicious modifications. + ///When ProcessFailed occurred due to a failed Code Integrity check, this property returns the full path of the file that was prevented from loading on the system. + ///The webview2 process which tried to load the DLL will fail with exit code STATUS_INVALID_IMAGE_HASH(-1073740760). + ///A file can fail integrity check for various reasons, such as: + ///- It has an invalid or missing signature that does not match the publisher or signer of the file. + ///- It has been tampered with or corrupted by malware or other software. + ///- It has been blocked by an administrator or a security policy. This property always will be the empty string if failure is not caused by STATUS_INVALID_IMAGE_HASH. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows + String? failureSourceModulePath; + + ///The collection of [FrameInfo]s for frames in the WebView that were being rendered by the failed process. + /// + ///The content in these frames is replaced with an error page. + ///This is only available when [ProcessFailedKind] is [ProcessFailedKind.FRAME_RENDER_PROCESS_EXITED]; + ///frames is null for all other process failure kinds, including the case in which the failed process was the renderer + ///for the main frame and subframes within it, for which the failure kind is [ProcessFailedKind.RENDER_PROCESS_EXITED]. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows + List? frameInfos; + + ///The kind of process failure that has occurred. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows + ProcessFailedKind kind; + + ///Description of the process assigned by the WebView2 Runtime. + /// + ///This is a technical English term appropriate for logging or development purposes, and not localized for the end user. + ///It applies to utility processes (for example, "Audio Service", "Video Capture") and plugin processes (for example, "Flash"). + ///The returned [processDescription] is empty if the WebView2 Runtime did not assign a description to the process. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows + String? processDescription; + + ///The reason for the process failure. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows + ProcessFailedReason? reason; + ProcessFailedDetail( + {this.exitCode, + this.failureSourceModulePath, + this.frameInfos, + required this.kind, + this.processDescription, + this.reason}); + + ///Gets a possible [ProcessFailedDetail] instance from a [Map] value. + static ProcessFailedDetail? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = ProcessFailedDetail( + exitCode: map['exitCode'], + failureSourceModulePath: map['failureSourceModulePath'], + frameInfos: map['frameInfos'] != null + ? List.from(map['frameInfos'] + .map((e) => FrameInfo.fromMap(e?.cast())!)) + : null, + kind: ProcessFailedKind.fromNativeValue(map['kind'])!, + processDescription: map['processDescription'], + reason: ProcessFailedReason.fromNativeValue(map['reason']), + ); + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "exitCode": exitCode, + "failureSourceModulePath": failureSourceModulePath, + "frameInfos": frameInfos?.map((e) => e.toMap()).toList(), + "kind": kind.toNativeValue(), + "processDescription": processDescription, + "reason": reason?.toNativeValue(), + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + @override + String toString() { + return 'ProcessFailedDetail{exitCode: $exitCode, failureSourceModulePath: $failureSourceModulePath, frameInfos: $frameInfos, kind: $kind, processDescription: $processDescription, reason: $reason}'; + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart new file mode 100644 index 000000000..2e3d1db73 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart @@ -0,0 +1,141 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'process_failed_kind.g.dart'; + +///Class used to indicate the kind of process failure that has occurred. +@ExchangeableEnum() +class ProcessFailedKind_ { + // ignore: unused_field + final String _value; + // ignore: unused_field + final dynamic _nativeValue = null; + const ProcessFailedKind_._internal(this._value); + + ///Indicates that the browser process ended unexpectedly. The WebView automatically moves to the Closed state. + ///The app has to recreate a new WebView to recover from this failure. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 0 + ), + ]) + static const BROWSER_PROCESS_EXITED = const ProcessFailedKind_._internal('BROWSER_PROCESS_EXITED'); + + ///Indicates that the main frame's render process ended unexpectedly. Any subframes in the WebView will be gone too. + ///A new render process is created automatically and navigated to an error page. + ///You can use the reload method to try to recover from this failure. Alternatively, you can close and recreate the WebView. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 1 + ), + ]) + static const RENDER_PROCESS_EXITED = const ProcessFailedKind_._internal('RENDER_PROCESS_EXITED'); + + ///Indicates that the main frame's render process is unresponsive. + ///Renderer process unresponsiveness can happen for the following reasons: + /// + ///* There is a **long-running script** being executed. For example, the + ///web content in your WebView might be performing a synchronous XHR, or have + ///entered an infinite loop. + ///* The **system is busy**. + /// + ///The process failed event will continue to be raised every few seconds + ///until the renderer process has become responsive again. The application + ///can consider taking action if the event keeps being raised. For example, + ///the application might show UI for the user to decide to keep waiting or + ///reload the page, or navigate away. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 2 + ), + ]) + static const RENDER_PROCESS_UNRESPONSIVE = const ProcessFailedKind_._internal('RENDER_PROCESS_UNRESPONSIVE'); + + ///Indicates that a frame-only render process ended unexpectedly. + ///The process exit does not affect the top-level document, only a subset of the subframes within it. + ///The content in these frames is replaced with an error page in the frame. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_FRAME_RENDER_PROCESS_EXITED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 3 + ), + ]) + static const FRAME_RENDER_PROCESS_EXITED = const ProcessFailedKind_._internal('FRAME_RENDER_PROCESS_EXITED'); + + ///Indicates that a utility process ended unexpectedly. + ///The failed process is recreated automatically. + ///Your application does not need to handle recovery for this event. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_UTILITY_PROCESS_EXITED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 4 + ), + ]) + static const UTILITY_PROCESS_EXITED = const ProcessFailedKind_._internal('UTILITY_PROCESS_EXITED'); + + ///Indicates that a sandbox helper process ended unexpectedly. + ///This failure is not fatal. + ///Your application does not need to handle recovery for this event. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_SANDBOX_HELPER_PROCESS_EXITED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 5 + ), + ]) + static const SANDBOX_HELPER_PROCESS_EXITED = const ProcessFailedKind_._internal('SANDBOX_HELPER_PROCESS_EXITED'); + + ///Indicates that the GPU process ended unexpectedly. + ///The failed process is recreated automatically. + ///Your application does not need to handle recovery for this event. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_GPU_PROCESS_EXITED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 6 + ), + ]) + static const GPU_PROCESS_EXITED = const ProcessFailedKind_._internal('GPU_PROCESS_EXITED'); + + ///Indicates that a PPAPI plugin process ended unexpectedly. + ///This failure is not fatal. + ///Your application does not need to handle recovery for this event. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_PLUGIN_PROCESS_EXITED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 7 + ), + ]) + static const PPAPI_PLUGIN_PROCESS_EXITED = const ProcessFailedKind_._internal('PPAPI_PLUGIN_PROCESS_EXITED'); + + ///Indicates that a PPAPI plugin broker process ended unexpectedly. + ///This failure is not fatal. + ///Your application does not need to handle recovery for this event. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_BROKER_PROCESS_EXITED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 8 + ), + ]) + static const PPAPI_BROKER_PROCESS_EXITED = const ProcessFailedKind_._internal('PPAPI_BROKER_PROCESS_EXITED'); + + ///Indicates that a process of unspecified kind ended unexpectedly. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_UNKNOWN_PROCESS_EXITED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 9 + ), + ]) + static const UNKNOWN_PROCESS_EXITED = const ProcessFailedKind_._internal('UNKNOWN_PROCESS_EXITED'); +} \ No newline at end of file diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.g.dart new file mode 100644 index 000000000..4c1203d06 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.g.dart @@ -0,0 +1,257 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'process_failed_kind.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to indicate the kind of process failure that has occurred. +class ProcessFailedKind { + final String _value; + final dynamic _nativeValue; + const ProcessFailedKind._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ProcessFailedKind._internalMultiPlatform( + String value, Function nativeValue) => + ProcessFailedKind._internal(value, nativeValue()); + + ///Indicates that the browser process ended unexpectedly. The WebView automatically moves to the Closed state. + ///The app has to recreate a new WebView to recover from this failure. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + static final BROWSER_PROCESS_EXITED = + ProcessFailedKind._internalMultiPlatform('BROWSER_PROCESS_EXITED', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 0; + default: + break; + } + return null; + }); + + ///Indicates that a frame-only render process ended unexpectedly. + ///The process exit does not affect the top-level document, only a subset of the subframes within it. + ///The content in these frames is replaced with an error page in the frame. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_FRAME_RENDER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + static final FRAME_RENDER_PROCESS_EXITED = + ProcessFailedKind._internalMultiPlatform('FRAME_RENDER_PROCESS_EXITED', + () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 3; + default: + break; + } + return null; + }); + + ///Indicates that the GPU process ended unexpectedly. + ///The failed process is recreated automatically. + ///Your application does not need to handle recovery for this event. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_GPU_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + static final GPU_PROCESS_EXITED = + ProcessFailedKind._internalMultiPlatform('GPU_PROCESS_EXITED', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 6; + default: + break; + } + return null; + }); + + ///Indicates that a PPAPI plugin broker process ended unexpectedly. + ///This failure is not fatal. + ///Your application does not need to handle recovery for this event. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_BROKER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + static final PPAPI_BROKER_PROCESS_EXITED = + ProcessFailedKind._internalMultiPlatform('PPAPI_BROKER_PROCESS_EXITED', + () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 8; + default: + break; + } + return null; + }); + + ///Indicates that a PPAPI plugin process ended unexpectedly. + ///This failure is not fatal. + ///Your application does not need to handle recovery for this event. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_PLUGIN_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + static final PPAPI_PLUGIN_PROCESS_EXITED = + ProcessFailedKind._internalMultiPlatform('PPAPI_PLUGIN_PROCESS_EXITED', + () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 7; + default: + break; + } + return null; + }); + + ///Indicates that the main frame's render process ended unexpectedly. Any subframes in the WebView will be gone too. + ///A new render process is created automatically and navigated to an error page. + ///You can use the reload method to try to recover from this failure. Alternatively, you can close and recreate the WebView. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + static final RENDER_PROCESS_EXITED = + ProcessFailedKind._internalMultiPlatform('RENDER_PROCESS_EXITED', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 1; + default: + break; + } + return null; + }); + + ///Indicates that the main frame's render process is unresponsive. + ///Renderer process unresponsiveness can happen for the following reasons: + /// + ///* There is a **long-running script** being executed. For example, the + ///web content in your WebView might be performing a synchronous XHR, or have + ///entered an infinite loop. + ///* The **system is busy**. + /// + ///The process failed event will continue to be raised every few seconds + ///until the renderer process has become responsive again. The application + ///can consider taking action if the event keeps being raised. For example, + ///the application might show UI for the user to decide to keep waiting or + ///reload the page, or navigate away. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + static final RENDER_PROCESS_UNRESPONSIVE = + ProcessFailedKind._internalMultiPlatform('RENDER_PROCESS_UNRESPONSIVE', + () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 2; + default: + break; + } + return null; + }); + + ///Indicates that a sandbox helper process ended unexpectedly. + ///This failure is not fatal. + ///Your application does not need to handle recovery for this event. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_SANDBOX_HELPER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + static final SANDBOX_HELPER_PROCESS_EXITED = + ProcessFailedKind._internalMultiPlatform('SANDBOX_HELPER_PROCESS_EXITED', + () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 5; + default: + break; + } + return null; + }); + + ///Indicates that a process of unspecified kind ended unexpectedly. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_UNKNOWN_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + static final UNKNOWN_PROCESS_EXITED = + ProcessFailedKind._internalMultiPlatform('UNKNOWN_PROCESS_EXITED', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 9; + default: + break; + } + return null; + }); + + ///Indicates that a utility process ended unexpectedly. + ///The failed process is recreated automatically. + ///Your application does not need to handle recovery for this event. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_UTILITY_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + static final UTILITY_PROCESS_EXITED = + ProcessFailedKind._internalMultiPlatform('UTILITY_PROCESS_EXITED', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 4; + default: + break; + } + return null; + }); + + ///Set of all values of [ProcessFailedKind]. + static final Set values = [ + ProcessFailedKind.BROWSER_PROCESS_EXITED, + ProcessFailedKind.FRAME_RENDER_PROCESS_EXITED, + ProcessFailedKind.GPU_PROCESS_EXITED, + ProcessFailedKind.PPAPI_BROKER_PROCESS_EXITED, + ProcessFailedKind.PPAPI_PLUGIN_PROCESS_EXITED, + ProcessFailedKind.RENDER_PROCESS_EXITED, + ProcessFailedKind.RENDER_PROCESS_UNRESPONSIVE, + ProcessFailedKind.SANDBOX_HELPER_PROCESS_EXITED, + ProcessFailedKind.UNKNOWN_PROCESS_EXITED, + ProcessFailedKind.UTILITY_PROCESS_EXITED, + ].toSet(); + + ///Gets a possible [ProcessFailedKind] instance from [String] value. + static ProcessFailedKind? fromValue(String? value) { + if (value != null) { + try { + return ProcessFailedKind.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ProcessFailedKind] instance from a native value. + static ProcessFailedKind? fromNativeValue(dynamic value) { + if (value != null) { + try { + return ProcessFailedKind.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [dynamic] native value. + dynamic toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart new file mode 100644 index 000000000..b21afbc4b --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart @@ -0,0 +1,74 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'process_failed_reason.g.dart'; + +///Class used to indicate the kind of process failure that has occurred. +@ExchangeableEnum() +class ProcessFailedReason_ { + // ignore: unused_field + final String _value; + // ignore: unused_field + final dynamic _nativeValue = null; + const ProcessFailedReason_._internal(this._value); + + ///An unexpected process failure occurred. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_UNEXPECTED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 0 + ), + ]) + static const UNEXPECTED = const ProcessFailedReason_._internal('UNEXPECTED'); + + ///The process became unresponsive. This only applies to the main frame's render process. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_UNRESPONSIVE', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 1 + ), + ]) + static const UNRESPONSIVE = const ProcessFailedReason_._internal('UNRESPONSIVE'); + + ///The process was terminated. For example, from Task Manager. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_TERMINATED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 2 + ), + ]) + static const TERMINATED = const ProcessFailedReason_._internal('TERMINATED'); + + ///The process crashed. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_CRASHED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 3 + ), + ]) + static const CRASHED = const ProcessFailedReason_._internal('CRASHED'); + + ///The process failed to launch. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_LAUNCH_FAILED', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 4 + ), + ]) + static const LAUNCH_FAILED = const ProcessFailedReason_._internal('LAUNCH_FAILED'); + + ///The process terminated due to running out of memory. + @EnumSupportedPlatforms(platforms: [ + EnumWindowsPlatform( + apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_OUT_OF_MEMORY', + apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 5 + ), + ]) + static const OUT_OF_MEMORY = const ProcessFailedReason_._internal('OUT_OF_MEMORY'); +} \ No newline at end of file diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.g.dart new file mode 100644 index 000000000..58e9425ef --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.g.dart @@ -0,0 +1,161 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'process_failed_reason.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to indicate the kind of process failure that has occurred. +class ProcessFailedReason { + final String _value; + final dynamic _nativeValue; + const ProcessFailedReason._internal(this._value, this._nativeValue); +// ignore: unused_element + factory ProcessFailedReason._internalMultiPlatform( + String value, Function nativeValue) => + ProcessFailedReason._internal(value, nativeValue()); + + ///The process crashed. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_CRASHED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + static final CRASHED = + ProcessFailedReason._internalMultiPlatform('CRASHED', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 3; + default: + break; + } + return null; + }); + + ///The process failed to launch. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_LAUNCH_FAILED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + static final LAUNCH_FAILED = + ProcessFailedReason._internalMultiPlatform('LAUNCH_FAILED', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 4; + default: + break; + } + return null; + }); + + ///The process terminated due to running out of memory. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_OUT_OF_MEMORY](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + static final OUT_OF_MEMORY = + ProcessFailedReason._internalMultiPlatform('OUT_OF_MEMORY', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 5; + default: + break; + } + return null; + }); + + ///The process was terminated. For example, from Task Manager. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_TERMINATED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + static final TERMINATED = + ProcessFailedReason._internalMultiPlatform('TERMINATED', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 2; + default: + break; + } + return null; + }); + + ///An unexpected process failure occurred. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_UNEXPECTED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + static final UNEXPECTED = + ProcessFailedReason._internalMultiPlatform('UNEXPECTED', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 0; + default: + break; + } + return null; + }); + + ///The process became unresponsive. This only applies to the main frame's render process. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_UNRESPONSIVE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + static final UNRESPONSIVE = + ProcessFailedReason._internalMultiPlatform('UNRESPONSIVE', () { + switch (defaultTargetPlatform) { + case TargetPlatform.windows: + return 1; + default: + break; + } + return null; + }); + + ///Set of all values of [ProcessFailedReason]. + static final Set values = [ + ProcessFailedReason.CRASHED, + ProcessFailedReason.LAUNCH_FAILED, + ProcessFailedReason.OUT_OF_MEMORY, + ProcessFailedReason.TERMINATED, + ProcessFailedReason.UNEXPECTED, + ProcessFailedReason.UNRESPONSIVE, + ].toSet(); + + ///Gets a possible [ProcessFailedReason] instance from [String] value. + static ProcessFailedReason? fromValue(String? value) { + if (value != null) { + try { + return ProcessFailedReason.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [ProcessFailedReason] instance from a native value. + static ProcessFailedReason? fromNativeValue(dynamic value) { + if (value != null) { + try { + return ProcessFailedReason.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [dynamic] native value. + dynamic toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.dart b/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.dart index 1fca268bf..f88d02916 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.dart @@ -11,5 +11,8 @@ class WebViewRenderProcessAction_ { const WebViewRenderProcessAction_._internal(this._value); ///Cause this renderer to terminate. + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform(), + ]) static const TERMINATE = const WebViewRenderProcessAction_._internal(0); } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.g.dart index 15542077b..ce81d5818 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.g.dart @@ -18,6 +18,9 @@ class WebViewRenderProcessAction { WebViewRenderProcessAction._internal(value, nativeValue()); ///Cause this renderer to terminate. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android native WebView static const TERMINATE = WebViewRenderProcessAction._internal(0, 0); ///Set of all values of [WebViewRenderProcessAction]. diff --git a/flutter_inappwebview_windows/CHANGELOG.md b/flutter_inappwebview_windows/CHANGELOG.md index 76a0528e5..67fe54c6f 100644 --- a/flutter_inappwebview_windows/CHANGELOG.md +++ b/flutter_inappwebview_windows/CHANGELOG.md @@ -3,7 +3,7 @@ - Updated flutter_inappwebview_platform_interface version to ^1.4.0 - Updated `scrollMultiplier` default value from 6 to 1 - Added support for `UserScript.allowedOriginRules` and `UserScript.forMainFrameOnly` parameters -- Implemented `onReceivedHttpAuthRequest`, `onReceivedClientCertRequest`, `onReceivedServerTrustAuthRequest` WebView events +- Implemented `onReceivedHttpAuthRequest`, `onReceivedClientCertRequest`, `onReceivedServerTrustAuthRequest`, `onRenderProcessGone`, `onRenderProcessUnresponsive`, `onWebContentProcessDidTerminate`, `onProcessFailed` WebView events - Implemented `clearSslPreferences` WebView method - Fixed `get_optional_fl_map_value` implementation in `utils/flutter.h` - Fixed "Error in transparentBackground handling in Windows" [#2391](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2391) diff --git a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart index e342c4670..084d6e3b7 100644 --- a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1427,6 +1427,21 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController this._devToolsProtocolEventListenerMap[eventName]!.call(data); } break; + case "onProcessFailed": + if ((webviewParams != null && + webviewParams!.onProcessFailed != null) || + _inAppBrowserEventHandler != null) { + Map arguments = call.arguments.cast(); + final detail = ProcessFailedDetail.fromMap(arguments)!; + + if (webviewParams != null && + webviewParams!.onProcessFailed != null) + webviewParams!.onProcessFailed!(_controllerFromPlatform, detail); + else + _inAppBrowserEventHandler! + .onProcessFailed(detail); + } + break; case "onCallJsHandler": String handlerName = call.arguments["handlerName"]; Map handlerDataMap = diff --git a/flutter_inappwebview_windows/windows/CMakeLists.txt b/flutter_inappwebview_windows/windows/CMakeLists.txt index 5e7034401..30a321527 100644 --- a/flutter_inappwebview_windows/windows/CMakeLists.txt +++ b/flutter_inappwebview_windows/windows/CMakeLists.txt @@ -119,6 +119,14 @@ list(APPEND PLUGIN_SOURCES "types/server_trust_challenge.h" "types/server_trust_auth_response.cpp" "types/server_trust_auth_response.h" + "types/security_origin.cpp" + "types/security_origin.h" + "types/frame_info.cpp" + "types/frame_info.h" + "types/process_failed_detail.cpp" + "types/process_failed_detail.h" + "types/render_process_gone_detail.cpp" + "types/render_process_gone_detail.h" "custom_platform_view/custom_platform_view.cc" "custom_platform_view/custom_platform_view.h" "custom_platform_view/texture_bridge.cc" diff --git a/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview.cpp b/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview.cpp index 190533f0f..e58951fec 100644 --- a/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview.cpp +++ b/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview.cpp @@ -896,6 +896,74 @@ namespace flutter_inappwebview_plugin ).Get(), nullptr); failedLog(add_WebResourceRequested_HResult); + auto add_ProcessFailed_HResult = webView->add_ProcessFailed( + Callback( + [this](ICoreWebView2* sender, ICoreWebView2ProcessFailedEventArgs* argsRaw) + { + if (!channelDelegate) { + return S_OK; + } + + wil::com_ptr args = argsRaw; + auto args2 = args.try_query(); + auto args3 = args.try_query(); + + COREWEBVIEW2_PROCESS_FAILED_REASON reason = COREWEBVIEW2_PROCESS_FAILED_REASON_UNEXPECTED; + if (args2) { + args2->get_Reason(&reason); + } + + COREWEBVIEW2_PROCESS_FAILED_KIND kind; + if (succeededOrLog(args->get_ProcessFailedKind(&kind))) { + if (kind == COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED) { + auto didCrash = reason == COREWEBVIEW2_PROCESS_FAILED_REASON_CRASHED; + auto detail = std::make_unique( + didCrash + ); + channelDelegate->onRenderProcessGone(std::move(detail)); + } + else if (kind == COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE) { + channelDelegate->onRenderProcessUnresponsive(getUrl()); + } + else if (kind == COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED) { + channelDelegate->onWebContentProcessDidTerminate(); + } + + auto frameInfos = std::optional>>{}; + wil::com_ptr frameInfoCollection; + wil::com_ptr frameIterator; + if (args2 && succeededOrLog(args2->get_FrameInfosForFailedProcess(&frameInfoCollection)) && frameInfoCollection && succeededOrLog(frameInfoCollection->GetIterator(&frameIterator))) { + frameInfos = std::vector>{}; + BOOL hasCurrent = FALSE; + while (SUCCEEDED(frameIterator->MoveNext(&hasCurrent)) && hasCurrent) { + wil::com_ptr frameInfo; + if (SUCCEEDED(frameIterator->GetCurrent(&frameInfo))) { + frameInfos.value().push_back(std::move(FrameInfo::fromICoreWebView2FrameInfo(frameInfo))); + } + BOOL hasNext = FALSE; + failedLog(frameIterator->MoveNext(&hasNext)); + } + } + + wil::unique_cotaskmem_string processDescription; + int exitCode; + wil::unique_cotaskmem_string failedModule; + + auto detail = std::make_unique( + (int64_t)kind, + args2 && succeededOrLog(args2->get_ExitCode(&exitCode)) ? exitCode : std::optional{}, + args2 && succeededOrLog(args2->get_ProcessDescription(&processDescription)) ? wide_to_utf8(processDescription.get()) : std::optional{}, + args2 ? (int64_t)reason : std::optional{}, + args3 && succeededOrLog(args3->get_FailureSourceModulePath(&failedModule)) ? wide_to_utf8(failedModule.get()) : std::optional{}, + frameInfos + ); + channelDelegate->onProcessFailed(std::move(detail)); + } + return S_OK; + } + ).Get(), nullptr); + failedLog(add_ProcessFailed_HResult); + wil::com_ptr webView2; if (SUCCEEDED(webView->QueryInterface(IID_PPV_ARGS(&webView2)))) { auto add_DOMContentLoaded_HResult = webView2->add_DOMContentLoaded( diff --git a/flutter_inappwebview_windows/windows/in_app_webview/webview_channel_delegate.cpp b/flutter_inappwebview_windows/windows/in_app_webview/webview_channel_delegate.cpp index b548aacfd..5ef3e11f9 100644 --- a/flutter_inappwebview_windows/windows/in_app_webview/webview_channel_delegate.cpp +++ b/flutter_inappwebview_windows/windows/in_app_webview/webview_channel_delegate.cpp @@ -552,6 +552,47 @@ namespace flutter_inappwebview_plugin channel->InvokeMethod("onReceivedServerTrustAuthRequest", std::move(arguments), std::move(callback)); } + void WebViewChannelDelegate::onRenderProcessGone(const std::shared_ptr detail) const + { + if (!channel) { + return; + } + + auto arguments = std::make_unique(detail->toEncodableMap()); + channel->InvokeMethod("onDevToolsProtocolEventReceived", std::move(arguments)); + } + + void WebViewChannelDelegate::onRenderProcessUnresponsive(const std::optional& url) const + { + if (!channel) { + return; + } + + auto arguments = std::make_unique(flutter::EncodableMap{ + {"url", make_fl_value(url)}, + }); + channel->InvokeMethod("onRenderProcessUnresponsive", std::move(arguments)); + } + void WebViewChannelDelegate::onWebContentProcessDidTerminate() const + { + if (!channel) { + return; + } + + auto arguments = std::make_unique(); + channel->InvokeMethod("onWebContentProcessDidTerminate", std::move(arguments)); + } + + void WebViewChannelDelegate::onProcessFailed(const std::shared_ptr detail) const + { + if (!channel) { + return; + } + + auto arguments = std::make_unique(detail->toEncodableMap()); + channel->InvokeMethod("onProcessFailed", std::move(arguments)); + } + WebViewChannelDelegate::~WebViewChannelDelegate() { debugLog("dealloc WebViewChannelDelegate"); diff --git a/flutter_inappwebview_windows/windows/in_app_webview/webview_channel_delegate.h b/flutter_inappwebview_windows/windows/in_app_webview/webview_channel_delegate.h index dfe68c238..dfd4a3395 100644 --- a/flutter_inappwebview_windows/windows/in_app_webview/webview_channel_delegate.h +++ b/flutter_inappwebview_windows/windows/in_app_webview/webview_channel_delegate.h @@ -15,6 +15,8 @@ #include "../types/javascript_handler_function_data.h" #include "../types/navigation_action.h" #include "../types/permission_response.h" +#include "../types/process_failed_detail.h" +#include "../types/render_process_gone_detail.h" #include "../types/server_trust_auth_response.h" #include "../types/server_trust_challenge.h" #include "../types/web_resource_error.h" @@ -113,6 +115,10 @@ namespace flutter_inappwebview_plugin void onReceivedHttpAuthRequest(std::shared_ptr challenge, std::unique_ptr callback) const; void onReceivedClientCertRequest(std::shared_ptr challenge, std::unique_ptr callback) const; void onReceivedServerTrustAuthRequest(std::shared_ptr challenge, std::unique_ptr callback) const; + void onRenderProcessGone(const std::shared_ptr detail) const; + void onRenderProcessUnresponsive(const std::optional& url) const; + void onWebContentProcessDidTerminate() const; + void onProcessFailed(const std::shared_ptr detail) const; }; } diff --git a/flutter_inappwebview_windows/windows/types/frame_info.cpp b/flutter_inappwebview_windows/windows/types/frame_info.cpp new file mode 100644 index 000000000..f04d48c20 --- /dev/null +++ b/flutter_inappwebview_windows/windows/types/frame_info.cpp @@ -0,0 +1,76 @@ +#include "../utils/flutter.h" +#include "../utils/log.h" +#include "../utils/strconv.h" +#include "frame_info.h" + +#include + +namespace flutter_inappwebview_plugin +{ + FrameInfo::FrameInfo(const bool& isMainFrame, + const std::optional> request, + const std::optional> securityOrigin, + const std::optional& name, + const std::optional& frameId, + const std::optional& kind) + : isMainFrame(isMainFrame), request(request), securityOrigin(securityOrigin), name(name), frameId(frameId), kind(kind) + {} + + flutter::EncodableMap FrameInfo::toEncodableMap() const + { + return flutter::EncodableMap{ + {"isMainFrame", make_fl_value(isMainFrame)}, + {"request", request.has_value() ? request.value()->toEncodableMap() : make_fl_value()}, + {"securityOrigin", securityOrigin.has_value() ? securityOrigin.value()->toEncodableMap() : make_fl_value()}, + {"name", make_fl_value(name)}, + {"frameId", make_fl_value(frameId)}, + {"kind", make_fl_value(kind)} + }; + } + + std::unique_ptr FrameInfo::fromICoreWebView2FrameInfo(const wil::com_ptr webViewFrameInfo) + { + wil::unique_cotaskmem_string url; + auto request = std::optional>{}; + auto securityOrigin = std::optional>{}; + if (succeededOrLog(webViewFrameInfo->get_Source(&url))) { + request = std::make_shared( + wide_to_utf8(url.get()), + std::optional{}, + std::optional>{}, + std::optional>{} + ); + + try { + winrt::Windows::Foundation::Uri const uri{ url.get() }; + + securityOrigin = std::make_shared( + wide_to_utf8(uri.Host().c_str()), + uri.Port(), + wide_to_utf8(uri.SchemeName().c_str()) + ); + } + catch (winrt::hresult_error const& ex) { + debugLog(wide_to_utf8(ex.message().c_str())); + } + } + + auto webViewFrameInfo2 = webViewFrameInfo.try_query(); + + uint32_t frameId; + wil::unique_cotaskmem_string name; + COREWEBVIEW2_FRAME_KIND kind = COREWEBVIEW2_FRAME_KIND_UNKNOWN; + if (webViewFrameInfo2) { + failedLog(webViewFrameInfo2->get_FrameKind(&kind)); + } + + return std::make_unique( + webViewFrameInfo2 ? kind == COREWEBVIEW2_FRAME_KIND_MAIN_FRAME : false, + request, + securityOrigin, + succeededOrLog(webViewFrameInfo->get_Name(&name)) ? wide_to_utf8(name.get()) : std::optional{}, + webViewFrameInfo2 && succeededOrLog(webViewFrameInfo2->get_FrameId(&frameId)) ? frameId : std::optional{}, + webViewFrameInfo2 ? (int64_t)kind : std::optional{} + ); + } +} \ No newline at end of file diff --git a/flutter_inappwebview_windows/windows/types/frame_info.h b/flutter_inappwebview_windows/windows/types/frame_info.h new file mode 100644 index 000000000..103c30e1a --- /dev/null +++ b/flutter_inappwebview_windows/windows/types/frame_info.h @@ -0,0 +1,39 @@ +#ifndef FLUTTER_INAPPWEBVIEW_PLUGIN_FRAME_INFO_H_ +#define FLUTTER_INAPPWEBVIEW_PLUGIN_FRAME_INFO_H_ + +#include +#include +#include +#include +#include + +#include "security_origin.h" +#include "url_request.h" + +namespace flutter_inappwebview_plugin +{ + + class FrameInfo + { + public: + const bool isMainFrame; + const std::optional> request; + const std::optional> securityOrigin; + const std::optional name; + const std::optional frameId; + const std::optional kind; + + FrameInfo(const bool& isMainFrame, + const std::optional> request, + const std::optional> securityOrigin, + const std::optional& name, + const std::optional& frameId, + const std::optional& kind); + ~FrameInfo() = default; + + flutter::EncodableMap toEncodableMap() const; + static std::unique_ptr fromICoreWebView2FrameInfo(const wil::com_ptr webViewFrameInfo); + }; +} + +#endif //FLUTTER_INAPPWEBVIEW_PLUGIN_FRAME_INFO_H_ \ No newline at end of file diff --git a/flutter_inappwebview_windows/windows/types/process_failed_detail.cpp b/flutter_inappwebview_windows/windows/types/process_failed_detail.cpp new file mode 100644 index 000000000..be305a661 --- /dev/null +++ b/flutter_inappwebview_windows/windows/types/process_failed_detail.cpp @@ -0,0 +1,26 @@ +#include "../utils/flutter.h" +#include "process_failed_detail.h" + +namespace flutter_inappwebview_plugin +{ + ProcessFailedDetail::ProcessFailedDetail(const int64_t& kind, + const std::optional& exitCode, + const std::optional& processDescription, + const std::optional& reason, + const std::optional& failureSourceModulePath, + const std::optional>>& frameInfos) + : kind(kind), exitCode(exitCode), processDescription(processDescription), reason(reason), failureSourceModulePath(failureSourceModulePath), frameInfos(frameInfos) + {} + + flutter::EncodableMap ProcessFailedDetail::toEncodableMap() const + { + return flutter::EncodableMap{ + {"kind", make_fl_value(kind)}, + {"exitCode", make_fl_value(exitCode)}, + {"processDescription", make_fl_value(processDescription)}, + {"reason", make_fl_value(reason)}, + {"failureSourceModulePath", make_fl_value(failureSourceModulePath)}, + {"frameInfos", frameInfos.has_value() ? make_fl_value(functional_map(frameInfos.value(), [](const std::shared_ptr& item) { return item->toEncodableMap(); })) : make_fl_value()} + }; + } +} \ No newline at end of file diff --git a/flutter_inappwebview_windows/windows/types/process_failed_detail.h b/flutter_inappwebview_windows/windows/types/process_failed_detail.h new file mode 100644 index 000000000..555ae4f69 --- /dev/null +++ b/flutter_inappwebview_windows/windows/types/process_failed_detail.h @@ -0,0 +1,36 @@ +#ifndef FLUTTER_INAPPWEBVIEW_PLUGIN_PROCESS_FAILED_DETAIL_H_ +#define FLUTTER_INAPPWEBVIEW_PLUGIN_PROCESS_FAILED_DETAIL_H_ + +#include +#include +#include +#include + +#include "frame_info.h" + +namespace flutter_inappwebview_plugin +{ + + class ProcessFailedDetail + { + public: + const int64_t kind; + const std::optional exitCode; + const std::optional processDescription; + const std::optional reason; + const std::optional failureSourceModulePath; + const std::optional>> frameInfos; + + ProcessFailedDetail(const int64_t& kind, + const std::optional& exitCode, + const std::optional& processDescription, + const std::optional& reason, + const std::optional& failureSourceModulePath, + const std::optional>>& frameInfos); + ~ProcessFailedDetail() = default; + + flutter::EncodableMap toEncodableMap() const; + }; +} + +#endif //FLUTTER_INAPPWEBVIEW_PLUGIN_PROCESS_FAILED_DETAIL_H_ \ No newline at end of file diff --git a/flutter_inappwebview_windows/windows/types/render_process_gone_detail.cpp b/flutter_inappwebview_windows/windows/types/render_process_gone_detail.cpp new file mode 100644 index 000000000..8fbb1238a --- /dev/null +++ b/flutter_inappwebview_windows/windows/types/render_process_gone_detail.cpp @@ -0,0 +1,16 @@ +#include "../utils/flutter.h" +#include "render_process_gone_detail.h" + +namespace flutter_inappwebview_plugin +{ + RenderProcessGoneDetail::RenderProcessGoneDetail(const bool& didCrash) + : didCrash(didCrash) + {} + + flutter::EncodableMap RenderProcessGoneDetail::toEncodableMap() const + { + return flutter::EncodableMap{ + {"didCrash", make_fl_value(didCrash)} + }; + } +} \ No newline at end of file diff --git a/flutter_inappwebview_windows/windows/types/render_process_gone_detail.h b/flutter_inappwebview_windows/windows/types/render_process_gone_detail.h new file mode 100644 index 000000000..3e324c1ae --- /dev/null +++ b/flutter_inappwebview_windows/windows/types/render_process_gone_detail.h @@ -0,0 +1,21 @@ +#ifndef FLUTTER_INAPPWEBVIEW_PLUGIN_RENDER_PROCESS_GONE_DETAIL_H_ +#define FLUTTER_INAPPWEBVIEW_PLUGIN_RENDER_PROCESS_GONE_DETAIL_H_ + +#include + +namespace flutter_inappwebview_plugin +{ + + class RenderProcessGoneDetail + { + public: + const bool didCrash; + + RenderProcessGoneDetail(const bool& didCrash); + ~RenderProcessGoneDetail() = default; + + flutter::EncodableMap toEncodableMap() const; + }; +} + +#endif //FLUTTER_INAPPWEBVIEW_PLUGIN_RENDER_PROCESS_GONE_DETAIL_H_ \ No newline at end of file diff --git a/flutter_inappwebview_windows/windows/types/security_origin.cpp b/flutter_inappwebview_windows/windows/types/security_origin.cpp new file mode 100644 index 000000000..bfd43a329 --- /dev/null +++ b/flutter_inappwebview_windows/windows/types/security_origin.cpp @@ -0,0 +1,18 @@ +#include "../utils/flutter.h" +#include "security_origin.h" + +namespace flutter_inappwebview_plugin +{ + SecurityOrigin::SecurityOrigin(const std::string& host, const int64_t& port, const std::string& protocol) + : host(host), port(port), protocol(protocol) + {} + + flutter::EncodableMap SecurityOrigin::toEncodableMap() const + { + return flutter::EncodableMap{ + {"host", make_fl_value(host)}, + {"port", make_fl_value(port)}, + {"protocol", make_fl_value(protocol)} + }; + } +} \ No newline at end of file diff --git a/flutter_inappwebview_windows/windows/types/security_origin.h b/flutter_inappwebview_windows/windows/types/security_origin.h new file mode 100644 index 000000000..84c3fee28 --- /dev/null +++ b/flutter_inappwebview_windows/windows/types/security_origin.h @@ -0,0 +1,24 @@ +#ifndef FLUTTER_INAPPWEBVIEW_PLUGIN_SECURITY_ORIGIN_H_ +#define FLUTTER_INAPPWEBVIEW_PLUGIN_SECURITY_ORIGIN_H_ + +#include +#include + +namespace flutter_inappwebview_plugin +{ + + class SecurityOrigin + { + public: + const std::string host; + const int64_t port; + const std::string protocol; + + SecurityOrigin(const std::string& host, const int64_t& port, const std::string& protocol); + ~SecurityOrigin() = default; + + flutter::EncodableMap toEncodableMap() const; + }; +} + +#endif //FLUTTER_INAPPWEBVIEW_PLUGIN_SECURITY_ORIGIN_H_ \ No newline at end of file From df18df4419a5871a648c3c2800c2743919daa0bb Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 4 Nov 2024 02:14:52 +0100 Subject: [PATCH 046/181] Deprecated InAppWebViewSettings.forceDark and InAppWebViewSettings.forceDarkStrategy Android-only properties in favor of InAppWebViewSettings.algorithmicDarkeningAllowed --- .../src/exchangeable_object_generator.dart | 55 ++++++++++++++----- dev_packages/generators/pubspec.yaml | 1 + flutter_inappwebview/CHANGELOG.md | 1 + .../webview/in_app_webview/InAppWebView.java | 16 +++++- .../in_app_webview/InAppWebViewSettings.java | 9 ++- .../CHANGELOG.md | 1 + .../lib/src/context_menu/context_menu.dart | 4 +- .../lib/src/context_menu/context_menu.g.dart | 7 ++- .../context_menu/context_menu_settings.dart | 20 +------ .../context_menu/context_menu_settings.g.dart | 43 +++++++++++++++ .../platform_in_app_browser.dart | 4 ++ .../in_app_webview_settings.dart | 25 +++++++-- .../in_app_webview_settings.g.dart | 38 +++++++++---- .../src/in_app_webview/platform_webview.dart | 4 ++ 14 files changed, 170 insertions(+), 58 deletions(-) diff --git a/dev_packages/generators/lib/src/exchangeable_object_generator.dart b/dev_packages/generators/lib/src/exchangeable_object_generator.dart index ed5cb23e9..71ccd3198 100644 --- a/dev_packages/generators/lib/src/exchangeable_object_generator.dart +++ b/dev_packages/generators/lib/src/exchangeable_object_generator.dart @@ -1,9 +1,10 @@ -import 'package:build/src/builder/build_step.dart'; -import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/analysis/results.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:analyzer/dart/element/type.dart'; -import 'package:source_gen/source_gen.dart'; +import 'package:build/src/builder/build_step.dart'; +import 'package:collection/collection.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; +import 'package:source_gen/source_gen.dart'; import 'model_visitor.dart'; import 'util.dart'; @@ -229,24 +230,26 @@ class ExchangeableObjectGenerator .firstAnnotationOfExact(deprecatedField)! .getField("message")! .toStringValue()!; - final fieldName = message + final newFieldName = message .replaceFirst("Use ", "") .replaceFirst(" instead", "") .trim(); - final fieldElement = visitor.fields[fieldName]; - if (fieldElement != null) { - final fieldTypeElement = fieldElement.type.element; + + final newFieldElement = visitor.fields[newFieldName]; + final shouldUseNewFieldName = newFieldElement != null; + if (shouldUseNewFieldName) { + final fieldTypeElement = newFieldElement.type.element; final deprecatedFieldTypeElement = deprecatedField.type.element; - final isNullable = Util.typeIsNullable(fieldElement.type); - var hasDefaultValue = (fieldElement is ParameterElement) - ? (fieldElement as ParameterElement).hasDefaultValue + final isNullable = Util.typeIsNullable(newFieldElement.type); + var hasDefaultValue = (newFieldElement is ParameterElement) + ? (newFieldElement as ParameterElement).hasDefaultValue : false; if (!isNullable && hasDefaultValue) { continue; } - classBuffer.write('$fieldName = $fieldName ?? '); + classBuffer.write('$newFieldName = $newFieldName ?? '); if (fieldTypeElement != null && deprecatedFieldTypeElement != null) { final deprecatedIsNullable = Util.typeIsNullable(deprecatedField.type); @@ -274,7 +277,7 @@ class ExchangeableObjectGenerator } else if (deprecatedField.type .getDisplayString(withNullability: false) == "Uri" && - fieldElement.type.getDisplayString(withNullability: false) == + newFieldElement.type.getDisplayString(withNullability: false) == "WebUri") { if (deprecatedIsNullable) { classBuffer.write( @@ -333,7 +336,26 @@ class ExchangeableObjectGenerator .replaceFirst("Use ", "") .replaceFirst(" instead", "") .trim(); - value = "map['$newFieldName']"; + final newFieldElement = fieldElements + .firstWhereOrNull((element) => element.name == newFieldName); + final shouldUseNewFieldName = newFieldElement != null && + (newFieldElement.type == fieldElement.type || + (fieldElement.name.startsWith(RegExp(r'android|ios')) && + fieldElement.name.toLowerCase().replaceFirst( + RegExp(r'android|ioswk|ios'), "") == + newFieldName.toLowerCase()) || + (newFieldElement.type.element != null && + fieldElement.type.element != null && + ((hasFromNativeValueMethod( + newFieldElement.type.element!) && + hasFromNativeValueMethod( + fieldElement.type.element!) || + (hasFromMapMethod(newFieldElement.type.element!) && + hasFromMapMethod( + fieldElement.type.element!)))))); + if (shouldUseNewFieldName) { + value = "map['$newFieldName']"; + } } final mapValue = value; @@ -356,10 +378,13 @@ class ExchangeableObjectGenerator final constructorParameter = visitor.constructorParameters[fieldName]; final isRequiredParameter = constructorParameter != null && (constructorParameter.isRequiredNamed || - constructorParameter.isFinal || fieldElement.isFinal || + constructorParameter.isFinal || + fieldElement.isFinal || !Util.typeIsNullable(constructorParameter.type)) && !constructorParameter.hasDefaultValue; - if (isRequiredParameter || fieldElement.isFinal || annotation.read("fromMapForceAllInline").boolValue) { + if (isRequiredParameter || + fieldElement.isFinal || + annotation.read("fromMapForceAllInline").boolValue) { requiredFields.add('$fieldName: $value,'); } else { final isFieldNullable = Util.typeIsNullable(fieldElement.type); diff --git a/dev_packages/generators/pubspec.yaml b/dev_packages/generators/pubspec.yaml index ffa31b464..5a2622d9a 100755 --- a/dev_packages/generators/pubspec.yaml +++ b/dev_packages/generators/pubspec.yaml @@ -12,6 +12,7 @@ dependencies: sdk: flutter build: ^2.4.1 source_gen: ^1.5.0 + collection: any flutter_inappwebview_internal_annotations: ^1.1.1 dev_dependencies: diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index 1c6265bee..3f310b32a 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -19,6 +19,7 @@ Implemented security features to better manage access to the native javascript b - Added `onProcessFailed` WebView event - Added `JavaScriptHandlerFunctionData` type - Deprecated `JavaScriptHandlerCallback` type in favor of `JavaScriptHandlerFunction` type +- Deprecated `InAppWebViewSettings.forceDark` and `InAppWebViewSettings.forceDarkStrategy` Android-only properties in favor of `InAppWebViewSettings.algorithmicDarkeningAllowed` - Fixed X509Certificate PEM base64 decoding - Fixed specific URLAuthenticationChallenge type for `onReceivedHttpAuthRequest`, `onReceivedServerTrustAuthRequest`, `onReceivedClientCertRequest` events diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java index 2fe614887..d77686ec3 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebView.java @@ -373,7 +373,13 @@ else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) settings.setForceDark(customSettings.forceDark); } if (customSettings.forceDarkStrategy != null && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) { - WebSettingsCompat.setForceDarkStrategy(settings, customSettings.forceDarkStrategy); + try { + // for some reason the setForceDarkStrategy method could throw a ClassCastException + // from the Android WebView Chromium library. + WebSettingsCompat.setForceDarkStrategy(settings, customSettings.forceDarkStrategy); + } catch (Exception e) { + e.printStackTrace(); + } } settings.setGeolocationEnabled(customSettings.geolocationEnabled); if (customSettings.layoutAlgorithm != null) { @@ -995,7 +1001,13 @@ else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) if (newSettingsMap.get("forceDarkStrategy") != null && !customSettings.forceDarkStrategy.equals(newCustomSettings.forceDarkStrategy) && WebViewFeature.isFeatureSupported(WebViewFeature.FORCE_DARK_STRATEGY)) { - WebSettingsCompat.setForceDarkStrategy(settings, newCustomSettings.forceDarkStrategy); + try { + // for some reason the setForceDarkStrategy method could throw a ClassCastException + // from the Android WebView Chromium library. + WebSettingsCompat.setForceDarkStrategy(settings, newCustomSettings.forceDarkStrategy); + } catch (Exception e) { + e.printStackTrace(); + } } if (newSettingsMap.get("geolocationEnabled") != null && customSettings.geolocationEnabled != newCustomSettings.geolocationEnabled) diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java index 0a1a4b745..6f7744a62 100755 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/in_app_webview/InAppWebViewSettings.java @@ -87,8 +87,10 @@ public class InAppWebViewSettings implements ISettings { public Integer disabledActionModeMenuItems; public String fantasyFontFamily = "fantasy"; public String fixedFontFamily = "monospace"; - public Integer forceDark = 0; // WebSettingsCompat.FORCE_DARK_OFF - public Integer forceDarkStrategy = WebSettingsCompat.DARK_STRATEGY_PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING; + @Nullable @Deprecated + public Integer forceDark = null; + @Nullable @Deprecated + public Integer forceDarkStrategy = null; public Boolean geolocationEnabled = true; public WebSettings.LayoutAlgorithm layoutAlgorithm; public Boolean loadWithOverviewMode = true; @@ -106,11 +108,14 @@ public class InAppWebViewSettings implements ISettings { public Boolean supportMultipleWindows = false; public String regexToCancelSubFramesLoading; public Integer overScrollMode = View.OVER_SCROLL_IF_CONTENT_SCROLLS; + @Nullable public Boolean networkAvailable = null; public Integer scrollBarStyle = View.SCROLLBARS_INSIDE_OVERLAY; public Integer verticalScrollbarPosition = View.SCROLLBAR_POSITION_DEFAULT; + @Nullable public Integer scrollBarDefaultDelayBeforeFade = null; public Boolean scrollbarFadingEnabled = true; + @Nullable public Integer scrollBarFadeDuration = null; @Nullable public Map rendererPriorityPolicy = null; diff --git a/flutter_inappwebview_platform_interface/CHANGELOG.md b/flutter_inappwebview_platform_interface/CHANGELOG.md index 8bf316fed..ed56cf1ee 100644 --- a/flutter_inappwebview_platform_interface/CHANGELOG.md +++ b/flutter_inappwebview_platform_interface/CHANGELOG.md @@ -8,6 +8,7 @@ - Added `onProcessFailed` WebView event - Added `JavaScriptHandlerFunctionData` type - Deprecated `JavaScriptHandlerCallback` type in favor of `JavaScriptHandlerFunction` type +- Deprecated `InAppWebViewSettings.forceDark` and `InAppWebViewSettings.forceDarkStrategy` Android-only properties in favor of `InAppWebViewSettings.algorithmicDarkeningAllowed` - Fixed X509Certificate PEM base64 decoding - Fixed specific URLAuthenticationChallenge type for `onReceivedHttpAuthRequest`, `onReceivedServerTrustAuthRequest`, `onReceivedClientCertRequest` events diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart index 6e790c4d7..f791abaac 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart @@ -33,7 +33,7 @@ class ContextMenu_ { ///Use [settings] instead @Deprecated("Use settings instead") - final ContextMenuOptions? options; + final ContextMenuOptions_? options; ///Context menu settings. final ContextMenuSettings_? settings; @@ -55,7 +55,7 @@ class ContextMenu_ { Map _toMapMergeWith() { return { "settings": - (settings as ContextMenuSettings?)?.toMap() ?? options?.toMap() + (settings as ContextMenuSettings?)?.toMap() ?? (options as ContextMenuOptions?)?.toMap() }; } } diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart index 84e63405f..246632d29 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart @@ -59,7 +59,8 @@ class ContextMenu { final instance = ContextMenu( menuItems: List.from(map['menuItems'] .map((e) => ContextMenuItem.fromMap(e?.cast())!)), - options: map['settings'], + options: + ContextMenuOptions.fromMap(map['settings']?.cast()), settings: ContextMenuSettings.fromMap(map['settings']?.cast()), ); @@ -69,8 +70,8 @@ class ContextMenu { @ExchangeableObjectMethod(toMapMergeWith: true) Map _toMapMergeWith() { return { - "settings": - (settings as ContextMenuSettings?)?.toMap() ?? options?.toMap() + "settings": (settings as ContextMenuSettings?)?.toMap() ?? + (options as ContextMenuOptions?)?.toMap() }; } diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.dart index dd6c001a4..8f4565787 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.dart @@ -15,24 +15,10 @@ class ContextMenuSettings_ { ///Use [ContextMenuSettings] instead. @Deprecated("Use ContextMenuSettings instead") -class ContextMenuOptions { +@ExchangeableObject(copyMethod: true) +class ContextMenuOptions_ { ///Whether all the default system context menu items should be hidden or not. The default value is `false`. bool hideDefaultSystemContextMenuItems; - ContextMenuOptions({this.hideDefaultSystemContextMenuItems = false}); - - Map toMap() { - return { - "hideDefaultSystemContextMenuItems": hideDefaultSystemContextMenuItems - }; - } - - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return toMap().toString(); - } + ContextMenuOptions_({this.hideDefaultSystemContextMenuItems = false}); } diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.g.dart index 1c91e9eca..9f02f2bf2 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu_settings.g.dart @@ -47,3 +47,46 @@ class ContextMenuSettings { return 'ContextMenuSettings{hideDefaultSystemContextMenuItems: $hideDefaultSystemContextMenuItems}'; } } + +///Use [ContextMenuSettings] instead. +@Deprecated('Use ContextMenuSettings instead') +class ContextMenuOptions { + ///Whether all the default system context menu items should be hidden or not. The default value is `false`. + bool hideDefaultSystemContextMenuItems; + ContextMenuOptions({this.hideDefaultSystemContextMenuItems = false}); + + ///Gets a possible [ContextMenuOptions] instance from a [Map] value. + static ContextMenuOptions? fromMap(Map? map) { + if (map == null) { + return null; + } + final instance = ContextMenuOptions(); + if (map['hideDefaultSystemContextMenuItems'] != null) { + instance.hideDefaultSystemContextMenuItems = + map['hideDefaultSystemContextMenuItems']; + } + return instance; + } + + ///Converts instance to a map. + Map toMap() { + return { + "hideDefaultSystemContextMenuItems": hideDefaultSystemContextMenuItems, + }; + } + + ///Converts instance to a map. + Map toJson() { + return toMap(); + } + + ///Returns a copy of ContextMenuOptions. + ContextMenuOptions copy() { + return ContextMenuOptions.fromMap(toMap()) ?? ContextMenuOptions(); + } + + @override + String toString() { + return 'ContextMenuOptions{hideDefaultSystemContextMenuItems: $hideDefaultSystemContextMenuItems}'; + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart index 4a059886a..542ba56e2 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart @@ -827,6 +827,10 @@ abstract class PlatformInAppBrowserEvents { /// ///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge]. /// + ///**NOTE for iOS and macOS**: to override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. + ///See `NSAppTransportSecurity` in the [Information Property List Key Reference](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1) + ///for details. + /// ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onReceivedSslError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart index f85030c44..4e68f34c9 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart @@ -624,7 +624,16 @@ because there isn't any way to make the website data store non-persistent for th ]) String? fixedFontFamily; + ///Use [algorithmicDarkeningAllowed] instead. + /// ///Set the force dark mode for this WebView. The default value is [ForceDark.OFF]. + /// + ///Deprecated - The "force dark" model previously implemented by WebView was complex and didn't + ///interoperate well with current Web standards for `prefers-color-scheme` and `color-scheme`. + ///In apps with `targetSdkVersion` ≥ `android.os.Build.VERSION_CODES.TIRAMISU` this API is a no-op and + ///WebView will always use the dark style defined by web content authors if the app's theme is dark. + ///To customize the behavior, refer to [algorithmicDarkeningAllowed]. + @Deprecated("Use algorithmicDarkeningAllowed instead") @SupportedPlatforms(platforms: [ AndroidPlatform( available: "29", @@ -634,10 +643,17 @@ because there isn't any way to make the website data store non-persistent for th ]) ForceDark_? forceDark; - ///Sets whether Geolocation API is enabled. The default value is `true`. - + ///Use [algorithmicDarkeningAllowed] instead. + /// ///Set how WebView content should be darkened. ///The default value is [ForceDarkStrategy.PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING]. + /// + ///Deprecated - The "force dark" model previously implemented by WebView was complex and didn't + ///interoperate well with current Web standards for `prefers-color-scheme` and `color-scheme`. + ///In apps with `targetSdkVersion` ≥ `android.os.Build.VERSION_CODES.TIRAMISU` this API is a no-op and + ///WebView will always use the dark style defined by web content authors if the app's theme is dark. + ///To customize the behavior, refer to [algorithmicDarkeningAllowed]. + @Deprecated("Use algorithmicDarkeningAllowed instead") @SupportedPlatforms(platforms: [ AndroidPlatform( apiName: "WebSettingsCompat.setForceDarkStrategy", @@ -1862,9 +1878,8 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri this.disabledActionModeMenuItems, this.fantasyFontFamily = "fantasy", this.fixedFontFamily = "monospace", - this.forceDark = ForceDark_.OFF, - this.forceDarkStrategy = - ForceDarkStrategy_.PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING, + this.forceDark, + this.forceDarkStrategy, this.geolocationEnabled = true, this.layoutAlgorithm, this.loadWithOverviewMode = true, diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart index 11f6a9f21..7982ceb05 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart @@ -470,20 +470,37 @@ class InAppWebViewSettings { ///- Android native WebView ([Official API - WebSettings.setFixedFontFamily](https://developer.android.com/reference/android/webkit/WebSettings#setFixedFontFamily(java.lang.String))) String? fixedFontFamily; + ///Use [algorithmicDarkeningAllowed] instead. + /// ///Set the force dark mode for this WebView. The default value is [ForceDark.OFF]. /// + ///Deprecated - The "force dark" model previously implemented by WebView was complex and didn't + ///interoperate well with current Web standards for `prefers-color-scheme` and `color-scheme`. + ///In apps with `targetSdkVersion` ≥ `android.os.Build.VERSION_CODES.TIRAMISU` this API is a no-op and + ///WebView will always use the dark style defined by web content authors if the app's theme is dark. + ///To customize the behavior, refer to [algorithmicDarkeningAllowed]. + /// ///**Officially Supported Platforms/Implementations**: ///- Android native WebView 29+ ([Official API - WebSettings.setForceDark](https://developer.android.com/reference/android/webkit/WebSettings#setForceDark(int))) + @Deprecated('Use algorithmicDarkeningAllowed instead') ForceDark? forceDark; - ///Sets whether Geolocation API is enabled. The default value is `true`. + ///Use [algorithmicDarkeningAllowed] instead. + /// ///Set how WebView content should be darkened. ///The default value is [ForceDarkStrategy.PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING]. /// + ///Deprecated - The "force dark" model previously implemented by WebView was complex and didn't + ///interoperate well with current Web standards for `prefers-color-scheme` and `color-scheme`. + ///In apps with `targetSdkVersion` ≥ `android.os.Build.VERSION_CODES.TIRAMISU` this API is a no-op and + ///WebView will always use the dark style defined by web content authors if the app's theme is dark. + ///To customize the behavior, refer to [algorithmicDarkeningAllowed]. + /// ///**NOTE for Android native WebView**: it will take effect only if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.FORCE_DARK_STRATEGY]. /// ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebSettingsCompat.setForceDarkStrategy](https://developer.android.com/reference/androidx/webkit/WebSettingsCompat#setForceDarkStrategy(android.webkit.WebSettings,int))) + @Deprecated('Use algorithmicDarkeningAllowed instead') ForceDarkStrategy? forceDarkStrategy; ///Sets whether Geolocation is enabled. The default is `true`. @@ -1394,9 +1411,8 @@ class InAppWebViewSettings { this.disabledActionModeMenuItems, this.fantasyFontFamily = "fantasy", this.fixedFontFamily = "monospace", - this.forceDark = ForceDark.OFF, - this.forceDarkStrategy = - ForceDarkStrategy.PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING, + this.forceDark, + this.forceDarkStrategy, this.geolocationEnabled = true, this.layoutAlgorithm, this.loadWithOverviewMode = true, @@ -1531,6 +1547,9 @@ class InAppWebViewSettings { : null, disabledActionModeMenuItems: ActionModeMenuItem.fromNativeValue( map['disabledActionModeMenuItems']), + forceDark: ForceDark.fromNativeValue(map['forceDark']), + forceDarkStrategy: + ForceDarkStrategy.fromNativeValue(map['forceDarkStrategy']), horizontalScrollbarThumbColor: map['horizontalScrollbarThumbColor'] != null ? UtilColor.fromStringRepresentation( @@ -1640,8 +1659,8 @@ class InAppWebViewSettings { instance.builtInZoomControls = map['builtInZoomControls']; instance.cacheEnabled = map['cacheEnabled']; instance.cacheMode = CacheMode.fromNativeValue(map['cacheMode']); - instance.clearCache = map['InAppWebViewController.clearAllCache']; - instance.clearSessionCache = map['CookieManager.removeSessionCookies']; + instance.clearCache = map['clearCache']; + instance.clearSessionCache = map['clearSessionCache']; instance.contentBlockers = _deserializeContentBlockers(map['contentBlockers']); instance.contentInsetAdjustmentBehavior = @@ -1673,9 +1692,6 @@ class InAppWebViewSettings { map['enterpriseAuthenticationAppLinkPolicyEnabled']; instance.fantasyFontFamily = map['fantasyFontFamily']; instance.fixedFontFamily = map['fixedFontFamily']; - instance.forceDark = ForceDark.fromNativeValue(map['forceDark']); - instance.forceDarkStrategy = - ForceDarkStrategy.fromNativeValue(map['forceDarkStrategy']); instance.geolocationEnabled = map['geolocationEnabled']; instance.hardwareAcceleration = map['hardwareAcceleration']; instance.horizontalScrollBarEnabled = map['horizontalScrollBarEnabled']; @@ -1809,8 +1825,6 @@ class InAppWebViewSettings { enterpriseAuthenticationAppLinkPolicyEnabled, "fantasyFontFamily": fantasyFontFamily, "fixedFontFamily": fixedFontFamily, - "forceDark": forceDark?.toNativeValue(), - "forceDarkStrategy": forceDarkStrategy?.toNativeValue(), "geolocationEnabled": geolocationEnabled, "hardwareAcceleration": hardwareAcceleration, "horizontalScrollBarEnabled": horizontalScrollBarEnabled, @@ -1925,6 +1939,6 @@ class InAppWebViewSettings { @override String toString() { - return 'InAppWebViewSettings{accessibilityIgnoresInvertColors: $accessibilityIgnoresInvertColors, algorithmicDarkeningAllowed: $algorithmicDarkeningAllowed, allowBackgroundAudioPlaying: $allowBackgroundAudioPlaying, allowContentAccess: $allowContentAccess, allowFileAccess: $allowFileAccess, allowFileAccessFromFileURLs: $allowFileAccessFromFileURLs, allowUniversalAccessFromFileURLs: $allowUniversalAccessFromFileURLs, allowingReadAccessTo: $allowingReadAccessTo, allowsAirPlayForMediaPlayback: $allowsAirPlayForMediaPlayback, allowsBackForwardNavigationGestures: $allowsBackForwardNavigationGestures, allowsInlineMediaPlayback: $allowsInlineMediaPlayback, allowsLinkPreview: $allowsLinkPreview, allowsPictureInPictureMediaPlayback: $allowsPictureInPictureMediaPlayback, alwaysBounceHorizontal: $alwaysBounceHorizontal, alwaysBounceVertical: $alwaysBounceVertical, appCachePath: $appCachePath, applePayAPIEnabled: $applePayAPIEnabled, applicationNameForUserAgent: $applicationNameForUserAgent, automaticallyAdjustsScrollIndicatorInsets: $automaticallyAdjustsScrollIndicatorInsets, blockNetworkImage: $blockNetworkImage, blockNetworkLoads: $blockNetworkLoads, builtInZoomControls: $builtInZoomControls, cacheEnabled: $cacheEnabled, cacheMode: $cacheMode, contentBlockers: $contentBlockers, contentInsetAdjustmentBehavior: $contentInsetAdjustmentBehavior, cursiveFontFamily: $cursiveFontFamily, dataDetectorTypes: $dataDetectorTypes, databaseEnabled: $databaseEnabled, decelerationRate: $decelerationRate, defaultFixedFontSize: $defaultFixedFontSize, defaultFontSize: $defaultFontSize, defaultTextEncodingName: $defaultTextEncodingName, defaultVideoPoster: $defaultVideoPoster, disableContextMenu: $disableContextMenu, disableDefaultErrorPage: $disableDefaultErrorPage, disableHorizontalScroll: $disableHorizontalScroll, disableInputAccessoryView: $disableInputAccessoryView, disableLongPressContextMenuOnLinks: $disableLongPressContextMenuOnLinks, disableVerticalScroll: $disableVerticalScroll, disabledActionModeMenuItems: $disabledActionModeMenuItems, disallowOverScroll: $disallowOverScroll, displayZoomControls: $displayZoomControls, domStorageEnabled: $domStorageEnabled, enableViewportScale: $enableViewportScale, enterpriseAuthenticationAppLinkPolicyEnabled: $enterpriseAuthenticationAppLinkPolicyEnabled, fantasyFontFamily: $fantasyFontFamily, fixedFontFamily: $fixedFontFamily, forceDark: $forceDark, forceDarkStrategy: $forceDarkStrategy, geolocationEnabled: $geolocationEnabled, hardwareAcceleration: $hardwareAcceleration, horizontalScrollBarEnabled: $horizontalScrollBarEnabled, horizontalScrollbarThumbColor: $horizontalScrollbarThumbColor, horizontalScrollbarTrackColor: $horizontalScrollbarTrackColor, iframeAllow: $iframeAllow, iframeAllowFullscreen: $iframeAllowFullscreen, iframeAriaHidden: $iframeAriaHidden, iframeCsp: $iframeCsp, iframeName: $iframeName, iframeReferrerPolicy: $iframeReferrerPolicy, iframeRole: $iframeRole, iframeSandbox: $iframeSandbox, ignoresViewportScaleLimits: $ignoresViewportScaleLimits, incognito: $incognito, initialScale: $initialScale, interceptOnlyAsyncAjaxRequests: $interceptOnlyAsyncAjaxRequests, isDirectionalLockEnabled: $isDirectionalLockEnabled, isElementFullscreenEnabled: $isElementFullscreenEnabled, isFindInteractionEnabled: $isFindInteractionEnabled, isFraudulentWebsiteWarningEnabled: $isFraudulentWebsiteWarningEnabled, isInspectable: $isInspectable, isPagingEnabled: $isPagingEnabled, isSiteSpecificQuirksModeEnabled: $isSiteSpecificQuirksModeEnabled, isTextInteractionEnabled: $isTextInteractionEnabled, javaScriptBridgeEnabled: $javaScriptBridgeEnabled, javaScriptBridgeForMainFrameOnly: $javaScriptBridgeForMainFrameOnly, javaScriptBridgeOriginAllowList: $javaScriptBridgeOriginAllowList, javaScriptCanOpenWindowsAutomatically: $javaScriptCanOpenWindowsAutomatically, javaScriptEnabled: $javaScriptEnabled, javaScriptHandlersForMainFrameOnly: $javaScriptHandlersForMainFrameOnly, javaScriptHandlersOriginAllowList: $javaScriptHandlersOriginAllowList, layoutAlgorithm: $layoutAlgorithm, limitsNavigationsToAppBoundDomains: $limitsNavigationsToAppBoundDomains, loadWithOverviewMode: $loadWithOverviewMode, loadsImagesAutomatically: $loadsImagesAutomatically, maximumViewportInset: $maximumViewportInset, maximumZoomScale: $maximumZoomScale, mediaPlaybackRequiresUserGesture: $mediaPlaybackRequiresUserGesture, mediaType: $mediaType, minimumFontSize: $minimumFontSize, minimumLogicalFontSize: $minimumLogicalFontSize, minimumViewportInset: $minimumViewportInset, minimumZoomScale: $minimumZoomScale, mixedContentMode: $mixedContentMode, needInitialFocus: $needInitialFocus, networkAvailable: $networkAvailable, offscreenPreRaster: $offscreenPreRaster, overScrollMode: $overScrollMode, pageZoom: $pageZoom, pluginScriptsForMainFrameOnly: $pluginScriptsForMainFrameOnly, pluginScriptsOriginAllowList: $pluginScriptsOriginAllowList, preferredContentMode: $preferredContentMode, regexToCancelSubFramesLoading: $regexToCancelSubFramesLoading, rendererPriorityPolicy: $rendererPriorityPolicy, requestedWithHeaderOriginAllowList: $requestedWithHeaderOriginAllowList, resourceCustomSchemes: $resourceCustomSchemes, safeBrowsingEnabled: $safeBrowsingEnabled, sansSerifFontFamily: $sansSerifFontFamily, saveFormData: $saveFormData, scrollBarDefaultDelayBeforeFade: $scrollBarDefaultDelayBeforeFade, scrollBarFadeDuration: $scrollBarFadeDuration, scrollBarStyle: $scrollBarStyle, scrollMultiplier: $scrollMultiplier, scrollbarFadingEnabled: $scrollbarFadingEnabled, scrollsToTop: $scrollsToTop, selectionGranularity: $selectionGranularity, serifFontFamily: $serifFontFamily, sharedCookiesEnabled: $sharedCookiesEnabled, shouldPrintBackgrounds: $shouldPrintBackgrounds, standardFontFamily: $standardFontFamily, supportMultipleWindows: $supportMultipleWindows, supportZoom: $supportZoom, suppressesIncrementalRendering: $suppressesIncrementalRendering, textZoom: $textZoom, thirdPartyCookiesEnabled: $thirdPartyCookiesEnabled, transparentBackground: $transparentBackground, underPageBackgroundColor: $underPageBackgroundColor, upgradeKnownHostsToHTTPS: $upgradeKnownHostsToHTTPS, useHybridComposition: $useHybridComposition, useOnDownloadStart: $useOnDownloadStart, useOnLoadResource: $useOnLoadResource, useOnNavigationResponse: $useOnNavigationResponse, useOnRenderProcessGone: $useOnRenderProcessGone, useShouldInterceptAjaxRequest: $useShouldInterceptAjaxRequest, useShouldInterceptFetchRequest: $useShouldInterceptFetchRequest, useShouldInterceptRequest: $useShouldInterceptRequest, useShouldOverrideUrlLoading: $useShouldOverrideUrlLoading, useWideViewPort: $useWideViewPort, userAgent: $userAgent, verticalScrollBarEnabled: $verticalScrollBarEnabled, verticalScrollbarPosition: $verticalScrollbarPosition, verticalScrollbarThumbColor: $verticalScrollbarThumbColor, verticalScrollbarTrackColor: $verticalScrollbarTrackColor, webViewAssetLoader: $webViewAssetLoader}'; + return 'InAppWebViewSettings{accessibilityIgnoresInvertColors: $accessibilityIgnoresInvertColors, algorithmicDarkeningAllowed: $algorithmicDarkeningAllowed, allowBackgroundAudioPlaying: $allowBackgroundAudioPlaying, allowContentAccess: $allowContentAccess, allowFileAccess: $allowFileAccess, allowFileAccessFromFileURLs: $allowFileAccessFromFileURLs, allowUniversalAccessFromFileURLs: $allowUniversalAccessFromFileURLs, allowingReadAccessTo: $allowingReadAccessTo, allowsAirPlayForMediaPlayback: $allowsAirPlayForMediaPlayback, allowsBackForwardNavigationGestures: $allowsBackForwardNavigationGestures, allowsInlineMediaPlayback: $allowsInlineMediaPlayback, allowsLinkPreview: $allowsLinkPreview, allowsPictureInPictureMediaPlayback: $allowsPictureInPictureMediaPlayback, alwaysBounceHorizontal: $alwaysBounceHorizontal, alwaysBounceVertical: $alwaysBounceVertical, appCachePath: $appCachePath, applePayAPIEnabled: $applePayAPIEnabled, applicationNameForUserAgent: $applicationNameForUserAgent, automaticallyAdjustsScrollIndicatorInsets: $automaticallyAdjustsScrollIndicatorInsets, blockNetworkImage: $blockNetworkImage, blockNetworkLoads: $blockNetworkLoads, builtInZoomControls: $builtInZoomControls, cacheEnabled: $cacheEnabled, cacheMode: $cacheMode, contentBlockers: $contentBlockers, contentInsetAdjustmentBehavior: $contentInsetAdjustmentBehavior, cursiveFontFamily: $cursiveFontFamily, dataDetectorTypes: $dataDetectorTypes, databaseEnabled: $databaseEnabled, decelerationRate: $decelerationRate, defaultFixedFontSize: $defaultFixedFontSize, defaultFontSize: $defaultFontSize, defaultTextEncodingName: $defaultTextEncodingName, defaultVideoPoster: $defaultVideoPoster, disableContextMenu: $disableContextMenu, disableDefaultErrorPage: $disableDefaultErrorPage, disableHorizontalScroll: $disableHorizontalScroll, disableInputAccessoryView: $disableInputAccessoryView, disableLongPressContextMenuOnLinks: $disableLongPressContextMenuOnLinks, disableVerticalScroll: $disableVerticalScroll, disabledActionModeMenuItems: $disabledActionModeMenuItems, disallowOverScroll: $disallowOverScroll, displayZoomControls: $displayZoomControls, domStorageEnabled: $domStorageEnabled, enableViewportScale: $enableViewportScale, enterpriseAuthenticationAppLinkPolicyEnabled: $enterpriseAuthenticationAppLinkPolicyEnabled, fantasyFontFamily: $fantasyFontFamily, fixedFontFamily: $fixedFontFamily, geolocationEnabled: $geolocationEnabled, hardwareAcceleration: $hardwareAcceleration, horizontalScrollBarEnabled: $horizontalScrollBarEnabled, horizontalScrollbarThumbColor: $horizontalScrollbarThumbColor, horizontalScrollbarTrackColor: $horizontalScrollbarTrackColor, iframeAllow: $iframeAllow, iframeAllowFullscreen: $iframeAllowFullscreen, iframeAriaHidden: $iframeAriaHidden, iframeCsp: $iframeCsp, iframeName: $iframeName, iframeReferrerPolicy: $iframeReferrerPolicy, iframeRole: $iframeRole, iframeSandbox: $iframeSandbox, ignoresViewportScaleLimits: $ignoresViewportScaleLimits, incognito: $incognito, initialScale: $initialScale, interceptOnlyAsyncAjaxRequests: $interceptOnlyAsyncAjaxRequests, isDirectionalLockEnabled: $isDirectionalLockEnabled, isElementFullscreenEnabled: $isElementFullscreenEnabled, isFindInteractionEnabled: $isFindInteractionEnabled, isFraudulentWebsiteWarningEnabled: $isFraudulentWebsiteWarningEnabled, isInspectable: $isInspectable, isPagingEnabled: $isPagingEnabled, isSiteSpecificQuirksModeEnabled: $isSiteSpecificQuirksModeEnabled, isTextInteractionEnabled: $isTextInteractionEnabled, javaScriptBridgeEnabled: $javaScriptBridgeEnabled, javaScriptBridgeForMainFrameOnly: $javaScriptBridgeForMainFrameOnly, javaScriptBridgeOriginAllowList: $javaScriptBridgeOriginAllowList, javaScriptCanOpenWindowsAutomatically: $javaScriptCanOpenWindowsAutomatically, javaScriptEnabled: $javaScriptEnabled, javaScriptHandlersForMainFrameOnly: $javaScriptHandlersForMainFrameOnly, javaScriptHandlersOriginAllowList: $javaScriptHandlersOriginAllowList, layoutAlgorithm: $layoutAlgorithm, limitsNavigationsToAppBoundDomains: $limitsNavigationsToAppBoundDomains, loadWithOverviewMode: $loadWithOverviewMode, loadsImagesAutomatically: $loadsImagesAutomatically, maximumViewportInset: $maximumViewportInset, maximumZoomScale: $maximumZoomScale, mediaPlaybackRequiresUserGesture: $mediaPlaybackRequiresUserGesture, mediaType: $mediaType, minimumFontSize: $minimumFontSize, minimumLogicalFontSize: $minimumLogicalFontSize, minimumViewportInset: $minimumViewportInset, minimumZoomScale: $minimumZoomScale, mixedContentMode: $mixedContentMode, needInitialFocus: $needInitialFocus, networkAvailable: $networkAvailable, offscreenPreRaster: $offscreenPreRaster, overScrollMode: $overScrollMode, pageZoom: $pageZoom, pluginScriptsForMainFrameOnly: $pluginScriptsForMainFrameOnly, pluginScriptsOriginAllowList: $pluginScriptsOriginAllowList, preferredContentMode: $preferredContentMode, regexToCancelSubFramesLoading: $regexToCancelSubFramesLoading, rendererPriorityPolicy: $rendererPriorityPolicy, requestedWithHeaderOriginAllowList: $requestedWithHeaderOriginAllowList, resourceCustomSchemes: $resourceCustomSchemes, safeBrowsingEnabled: $safeBrowsingEnabled, sansSerifFontFamily: $sansSerifFontFamily, saveFormData: $saveFormData, scrollBarDefaultDelayBeforeFade: $scrollBarDefaultDelayBeforeFade, scrollBarFadeDuration: $scrollBarFadeDuration, scrollBarStyle: $scrollBarStyle, scrollMultiplier: $scrollMultiplier, scrollbarFadingEnabled: $scrollbarFadingEnabled, scrollsToTop: $scrollsToTop, selectionGranularity: $selectionGranularity, serifFontFamily: $serifFontFamily, sharedCookiesEnabled: $sharedCookiesEnabled, shouldPrintBackgrounds: $shouldPrintBackgrounds, standardFontFamily: $standardFontFamily, supportMultipleWindows: $supportMultipleWindows, supportZoom: $supportZoom, suppressesIncrementalRendering: $suppressesIncrementalRendering, textZoom: $textZoom, thirdPartyCookiesEnabled: $thirdPartyCookiesEnabled, transparentBackground: $transparentBackground, underPageBackgroundColor: $underPageBackgroundColor, upgradeKnownHostsToHTTPS: $upgradeKnownHostsToHTTPS, useHybridComposition: $useHybridComposition, useOnDownloadStart: $useOnDownloadStart, useOnLoadResource: $useOnLoadResource, useOnNavigationResponse: $useOnNavigationResponse, useOnRenderProcessGone: $useOnRenderProcessGone, useShouldInterceptAjaxRequest: $useShouldInterceptAjaxRequest, useShouldInterceptFetchRequest: $useShouldInterceptFetchRequest, useShouldInterceptRequest: $useShouldInterceptRequest, useShouldOverrideUrlLoading: $useShouldOverrideUrlLoading, useWideViewPort: $useWideViewPort, userAgent: $userAgent, verticalScrollBarEnabled: $verticalScrollBarEnabled, verticalScrollbarPosition: $verticalScrollbarPosition, verticalScrollbarThumbColor: $verticalScrollbarThumbColor, verticalScrollbarTrackColor: $verticalScrollbarTrackColor, webViewAssetLoader: $webViewAssetLoader}'; } } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart index 9b19ff767..7de987d63 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart @@ -380,6 +380,10 @@ class PlatformWebViewCreationParams { /// ///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge]. /// + ///**NOTE for iOS and macOS**: to override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. + ///See `NSAppTransportSecurity` in the [Information Property List Key Reference](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1) + ///for details. + /// ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - WebViewClient.onReceivedSslError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError))) ///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview)) From 99474490e73ba7e3c8fc95ff0046ed602411afbb Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 4 Nov 2024 02:23:40 +0100 Subject: [PATCH 047/181] updated plugin version to 6.2.0-beta.1 --- flutter_inappwebview/CHANGELOG.md | 14 +++++++------- flutter_inappwebview/pubspec.yaml | 14 +++++++------- flutter_inappwebview_android/CHANGELOG.md | 2 +- flutter_inappwebview_android/pubspec.yaml | 2 +- flutter_inappwebview_ios/CHANGELOG.md | 2 +- flutter_inappwebview_ios/pubspec.yaml | 2 +- flutter_inappwebview_macos/CHANGELOG.md | 2 +- flutter_inappwebview_macos/pubspec.yaml | 2 +- .../CHANGELOG.md | 2 +- .../pubspec.yaml | 2 +- flutter_inappwebview_web/CHANGELOG.md | 2 +- flutter_inappwebview_web/pubspec.yaml | 2 +- flutter_inappwebview_windows/CHANGELOG.md | 2 +- flutter_inappwebview_windows/pubspec.yaml | 2 +- 14 files changed, 26 insertions(+), 26 deletions(-) diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index 3f310b32a..b7970c3f0 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -1,12 +1,12 @@ -## 6.2.0 +## 6.2.0-beta.1 - Updated dependencies to the latest versions for all platform implementations: - - `flutter_inappwebview_platform_interface`: `^1.3.0` -> `^1.4.0` - - `flutter_inappwebview_android`: `^1.1.3` -> `^1.2.0` - - `flutter_inappwebview_ios`: `^1.1.2` -> `^1.2.0` - - `flutter_inappwebview_macos`: `^1.1.2` -> `^1.2.0` - - `flutter_inappwebview_web`: `^1.1.2` -> `^1.2.0` - - `flutter_inappwebview_windows`: `^0.6.0` -> `^0.7.0` + - `flutter_inappwebview_platform_interface`: `^1.3.0` -> `^1.4.0-beta.1` + - `flutter_inappwebview_android`: `^1.1.3` -> `^1.2.0-beta.1` + - `flutter_inappwebview_ios`: `^1.1.2` -> `^1.2.0-beta.1` + - `flutter_inappwebview_macos`: `^1.1.2` -> `^1.2.0-beta.1` + - `flutter_inappwebview_web`: `^1.1.2` -> `^1.2.0-beta.1` + - `flutter_inappwebview_windows`: `^0.6.0` -> `^0.7.0-beta.1` Implemented security features to better manage access to the native javascript bridge. diff --git a/flutter_inappwebview/pubspec.yaml b/flutter_inappwebview/pubspec.yaml index c58b7d424..779449baf 100755 --- a/flutter_inappwebview/pubspec.yaml +++ b/flutter_inappwebview/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview description: A Flutter plugin that allows you to add an inline webview, to use an headless webview, and to open an in-app browser window. -version: 6.2.0 +version: 6.2.0-beta.1 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues @@ -20,17 +20,17 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_platform_interface: #^1.4.0 + flutter_inappwebview_platform_interface: #^1.4.0-beta.1 path: ../flutter_inappwebview_platform_interface - flutter_inappwebview_android: #^1.2.0 + flutter_inappwebview_android: #^1.2.0-beta.1 path: ../flutter_inappwebview_android - flutter_inappwebview_ios: #^1.2.0 + flutter_inappwebview_ios: #^1.2.0-beta.1 path: ../flutter_inappwebview_ios - flutter_inappwebview_macos: #^1.2.0 + flutter_inappwebview_macos: #^1.2.0-beta.1 path: ../flutter_inappwebview_macos - flutter_inappwebview_web: #^1.2.0 + flutter_inappwebview_web: #^1.2.0-beta.1 path: ../flutter_inappwebview_web - flutter_inappwebview_windows: #^0.7.0 + flutter_inappwebview_windows: #^0.7.0-beta.1 path: ../flutter_inappwebview_windows dev_dependencies: diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md index 7de8e4034..d037d7d96 100644 --- a/flutter_inappwebview_android/CHANGELOG.md +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.2.0 +## 1.2.0-beta.1 - Updated flutter_inappwebview_platform_interface version to ^1.4.0 - Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method diff --git a/flutter_inappwebview_android/pubspec.yaml b/flutter_inappwebview_android/pubspec.yaml index 83dba2a37..dce9f49c6 100644 --- a/flutter_inappwebview_android/pubspec.yaml +++ b/flutter_inappwebview_android/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_android description: Android implementation of the flutter_inappwebview plugin. -version: 1.2.0 +version: 1.2.0-beta.1 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_android issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues diff --git a/flutter_inappwebview_ios/CHANGELOG.md b/flutter_inappwebview_ios/CHANGELOG.md index 19f2ef2eb..1041fe279 100644 --- a/flutter_inappwebview_ios/CHANGELOG.md +++ b/flutter_inappwebview_ios/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.2.0 +## 1.2.0-beta.1 - Updated flutter_inappwebview_platform_interface version to ^1.4.0 - Updated ConsoleLogJS internal PluginScript to main-frame only as using it on non-main frames could cause issues such as [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738) diff --git a/flutter_inappwebview_ios/pubspec.yaml b/flutter_inappwebview_ios/pubspec.yaml index cc3fafee9..a377bea3b 100644 --- a/flutter_inappwebview_ios/pubspec.yaml +++ b/flutter_inappwebview_ios/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_ios description: iOS implementation of the flutter_inappwebview plugin. -version: 1.2.0 +version: 1.2.0-beta.1 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_ios issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues diff --git a/flutter_inappwebview_macos/CHANGELOG.md b/flutter_inappwebview_macos/CHANGELOG.md index 40f1114ac..a07283b49 100644 --- a/flutter_inappwebview_macos/CHANGELOG.md +++ b/flutter_inappwebview_macos/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.2.0 +## 1.2.0-beta.1 - Updated flutter_inappwebview_platform_interface version to ^1.4.0 - Updated ConsoleLogJS internal PluginScript to main-frame only as using it on non-main frames could cause issues such as [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738) diff --git a/flutter_inappwebview_macos/pubspec.yaml b/flutter_inappwebview_macos/pubspec.yaml index 402274ead..b10ee0962 100644 --- a/flutter_inappwebview_macos/pubspec.yaml +++ b/flutter_inappwebview_macos/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_macos description: macOS implementation of the flutter_inappwebview plugin. -version: 1.2.0 +version: 1.2.0-beta.1 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_macos issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues diff --git a/flutter_inappwebview_platform_interface/CHANGELOG.md b/flutter_inappwebview_platform_interface/CHANGELOG.md index ed56cf1ee..4e13231ae 100644 --- a/flutter_inappwebview_platform_interface/CHANGELOG.md +++ b/flutter_inappwebview_platform_interface/CHANGELOG.md @@ -1,4 +1,4 @@ -#### 1.4.0 +#### 1.4.0-beta.1 - Updated static `fromMap` implementation for some classes - Updated `kJavaScriptHandlerForbiddenNames` list diff --git a/flutter_inappwebview_platform_interface/pubspec.yaml b/flutter_inappwebview_platform_interface/pubspec.yaml index 78131c8e7..b75eef581 100644 --- a/flutter_inappwebview_platform_interface/pubspec.yaml +++ b/flutter_inappwebview_platform_interface/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_platform_interface description: A common platform interface for the flutter_inappwebview plugin. -version: 1.4.0 +version: 1.4.0-beta.1 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_platform_interface issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues diff --git a/flutter_inappwebview_web/CHANGELOG.md b/flutter_inappwebview_web/CHANGELOG.md index 01f42810f..7c32ecf94 100644 --- a/flutter_inappwebview_web/CHANGELOG.md +++ b/flutter_inappwebview_web/CHANGELOG.md @@ -1,4 +1,4 @@ -## 1.2.0 +## 1.2.0-beta.1 - Updated flutter_inappwebview_platform_interface version to ^1.4.0 - Merged "[web] support iframe role and aria-hidden attributes" [2293](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2293) (thanks to [p-mazhnik](https://github.com/p-mazhnik)) diff --git a/flutter_inappwebview_web/pubspec.yaml b/flutter_inappwebview_web/pubspec.yaml index 193a6c152..70ab4dcf4 100644 --- a/flutter_inappwebview_web/pubspec.yaml +++ b/flutter_inappwebview_web/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_web description: Web implementation of the flutter_inappwebview plugin. -version: 1.2.0 +version: 1.2.0-beta.1 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_web issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues diff --git a/flutter_inappwebview_windows/CHANGELOG.md b/flutter_inappwebview_windows/CHANGELOG.md index 67fe54c6f..d4e1e2d18 100644 --- a/flutter_inappwebview_windows/CHANGELOG.md +++ b/flutter_inappwebview_windows/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.7.0 +## 0.7.0-beta.1 - Updated flutter_inappwebview_platform_interface version to ^1.4.0 - Updated `scrollMultiplier` default value from 6 to 1 diff --git a/flutter_inappwebview_windows/pubspec.yaml b/flutter_inappwebview_windows/pubspec.yaml index 5210d5bc4..51bed48fb 100644 --- a/flutter_inappwebview_windows/pubspec.yaml +++ b/flutter_inappwebview_windows/pubspec.yaml @@ -1,6 +1,6 @@ name: flutter_inappwebview_windows description: Windows implementation of the flutter_inappwebview plugin. -version: 0.7.0 +version: 0.7.0-beta.1 homepage: https://inappwebview.dev/ repository: https://github.com/pichillilorenzo/flutter_inappwebview/tree/master/flutter_inappwebview_windows issue_tracker: https://github.com/pichillilorenzo/flutter_inappwebview/issues From f8b94d8b5b964a71ab5c20e332e13c1758d9fc54 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:04:17 +0000 Subject: [PATCH 048/181] update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 5ddfc4b01..77e836e7c 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-88-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-89-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -196,6 +196,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Murmurl912
Murmurl912

💻 Benjamin Schulz
Benjamin Schulz

🤔 seal-app
seal-app

💻 + Takuya Tominaga
Takuya Tominaga

💻 From 593ebc6e2a1bb2145bd61cfeb41ac5822fc79b1b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:04:18 +0000 Subject: [PATCH 049/181] update .all-contributorsrc --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index b62b3eaa3..b461deb99 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -802,6 +802,15 @@ "contributions": [ "code" ] + }, + { + "login": "takuyaaaaaaahaaaaaa", + "name": "Takuya Tominaga", + "avatar_url": "https://avatars.githubusercontent.com/u/31458194?v=4", + "profile": "https://github.com/takuyaaaaaaahaaaaaa", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, From f0fcd6e821e74e95a74b6ab7b2c5d91e342ffb50 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 4 Nov 2024 10:14:13 +0100 Subject: [PATCH 050/181] ios, macos: updated _getCookieExpirationDate method format in case of falling back to use js --- flutter_inappwebview/CHANGELOG.md | 1 + flutter_inappwebview/README.md | 3 ++- flutter_inappwebview_android/CHANGELOG.md | 1 + flutter_inappwebview_ios/ios/Classes/PlatformUtil.swift | 1 + flutter_inappwebview_ios/lib/src/cookie_manager.dart | 8 +++----- flutter_inappwebview_macos/lib/src/cookie_manager.dart | 8 +++----- .../macos/Classes/PlatformUtil.swift | 1 + 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index b7970c3f0..0adc91e0a 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -32,6 +32,7 @@ Implemented security features to better manage access to the native javascript b - Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025) - Fixed crash when trying to open InAppBrowser with R.menu.menu_main on release mode - Merged "Prevent blank InAppBrowser Activity from being restored" [#1984](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1984) (thanks to [ShuheiSuzuki-07](https://github.com/ShuheiSuzuki-07)) +- Merged "Update Android Cookie Expiration date format to 24-hour format (HH)" [#2389](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2389) (thanks to [takuyaaaaaaahaaaaaa](https://github.com/takuyaaaaaaahaaaaaa)) #### macOS and iOS Platforms - Updated ConsoleLogJS internal PluginScript to main-frame only as using it on non-main frames could cause issues such as [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738) diff --git a/flutter_inappwebview/README.md b/flutter_inappwebview/README.md index 413b1099f..5ddfc4b01 100755 --- a/flutter_inappwebview/README.md +++ b/flutter_inappwebview/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-87-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-88-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -195,6 +195,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d nlog (solrin)
nlog (solrin)

💻 Murmurl912
Murmurl912

💻 Benjamin Schulz
Benjamin Schulz

🤔 + seal-app
seal-app

💻 diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md index d037d7d96..f5d4e25aa 100644 --- a/flutter_inappwebview_android/CHANGELOG.md +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -9,6 +9,7 @@ - Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025) - Fixed crash when trying to open InAppBrowser with R.menu.menu_main on release mode - Merged "Prevent blank InAppBrowser Activity from being restored" [#1984](https://github.com/pichillilorenzo/flutter_inappwebview/pull/1984) (thanks to [ShuheiSuzuki-07](https://github.com/ShuheiSuzuki-07)) +- Merged "Update Android Cookie Expiration date format to 24-hour format (HH)" [#2389](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2389) (thanks to [takuyaaaaaaahaaaaaa](https://github.com/takuyaaaaaaahaaaaaa)) ## 1.1.3 diff --git a/flutter_inappwebview_ios/ios/Classes/PlatformUtil.swift b/flutter_inappwebview_ios/ios/Classes/PlatformUtil.swift index a49d5316d..a44fabc0e 100644 --- a/flutter_inappwebview_ios/ios/Classes/PlatformUtil.swift +++ b/flutter_inappwebview_ios/ios/Classes/PlatformUtil.swift @@ -50,6 +50,7 @@ public class PlatformUtil: ChannelDelegate { static public func formatDate(date: Int64, format: String, locale: Locale, timezone: TimeZone) -> String { let formatter = DateFormatter() + formatter.locale = locale formatter.dateFormat = format formatter.timeZone = timezone return formatter.string(from: PlatformUtil.getDateFromMilliseconds(date: date)) diff --git a/flutter_inappwebview_ios/lib/src/cookie_manager.dart b/flutter_inappwebview_ios/lib/src/cookie_manager.dart index e640c9f02..b2272f38c 100755 --- a/flutter_inappwebview_ios/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_ios/lib/src/cookie_manager.dart @@ -407,13 +407,11 @@ class IOSCookieManager extends PlatformCookieManager with ChannelController { Future _getCookieExpirationDate(int expiresDate) async { var platformUtil = PlatformUtil.instance(); var dateTime = DateTime.fromMillisecondsSinceEpoch(expiresDate).toUtc(); - return !kIsWeb - ? await platformUtil.formatDate( + return await platformUtil.formatDate( date: dateTime, - format: 'EEE, dd MMM yyyy hh:mm:ss z', + format: 'EEE, dd MMM yyyy HH:mm:ss z', locale: 'en_US', - timezone: 'GMT') - : await platformUtil.getWebCookieExpirationDate(date: dateTime); + timezone: 'GMT'); } Future _shouldUseJavascript() async { diff --git a/flutter_inappwebview_macos/lib/src/cookie_manager.dart b/flutter_inappwebview_macos/lib/src/cookie_manager.dart index bf9d5a9bc..dba8e6088 100755 --- a/flutter_inappwebview_macos/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_macos/lib/src/cookie_manager.dart @@ -407,13 +407,11 @@ class MacOSCookieManager extends PlatformCookieManager with ChannelController { Future _getCookieExpirationDate(int expiresDate) async { var platformUtil = PlatformUtil.instance(); var dateTime = DateTime.fromMillisecondsSinceEpoch(expiresDate).toUtc(); - return !kIsWeb - ? await platformUtil.formatDate( + return await platformUtil.formatDate( date: dateTime, - format: 'EEE, dd MMM yyyy hh:mm:ss z', + format: 'EEE, dd MMM yyyy HH:mm:ss z', locale: 'en_US', - timezone: 'GMT') - : await platformUtil.getWebCookieExpirationDate(date: dateTime); + timezone: 'GMT'); } Future _shouldUseJavascript() async { diff --git a/flutter_inappwebview_macos/macos/Classes/PlatformUtil.swift b/flutter_inappwebview_macos/macos/Classes/PlatformUtil.swift index c9859d7d8..a349a908f 100644 --- a/flutter_inappwebview_macos/macos/Classes/PlatformUtil.swift +++ b/flutter_inappwebview_macos/macos/Classes/PlatformUtil.swift @@ -51,6 +51,7 @@ public class PlatformUtil: ChannelDelegate { static public func formatDate(date: Int64, format: String, locale: Locale, timezone: TimeZone) -> String { let formatter = DateFormatter() + formatter.locale = locale formatter.dateFormat = format formatter.timeZone = timezone return formatter.string(from: PlatformUtil.getDateFromMilliseconds(date: date)) From 91da20808b523a51c66ac3f1c04088875748547c Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 4 Nov 2024 10:16:30 +0100 Subject: [PATCH 051/181] updated readme --- flutter_inappwebview/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flutter_inappwebview/README.md b/flutter_inappwebview/README.md index 5ddfc4b01..77e836e7c 100755 --- a/flutter_inappwebview/README.md +++ b/flutter_inappwebview/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-88-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-89-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -196,6 +196,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Murmurl912
Murmurl912

💻 Benjamin Schulz
Benjamin Schulz

🤔 seal-app
seal-app

💻 + Takuya Tominaga
Takuya Tominaga

💻 From c4b4c23745aaa324bee3098339909837bc26e96b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:22:56 +0000 Subject: [PATCH 052/181] update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 77e836e7c..2c2325d28 100755 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-89-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-90-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -197,6 +197,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Benjamin Schulz
Benjamin Schulz

🤔 seal-app
seal-app

💻 Takuya Tominaga
Takuya Tominaga

💻 + Sergey
Sergey

💻 From d43e33977606086b3ec7582b14e2d45d4022cb12 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:22:57 +0000 Subject: [PATCH 053/181] update .all-contributorsrc --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index b461deb99..00748cac3 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -811,6 +811,15 @@ "contributions": [ "code" ] + }, + { + "login": "yamaha252", + "name": "Sergey", + "avatar_url": "https://avatars.githubusercontent.com/u/4444068?v=4", + "profile": "https://github.com/yamaha252", + "contributions": [ + "code" + ] } ], "contributorsPerLine": 7, From bd5960d515c2aad1b1401a1e646f7d1ff1bc8fe0 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 4 Nov 2024 10:23:47 +0100 Subject: [PATCH 054/181] updated readme --- flutter_inappwebview/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flutter_inappwebview/README.md b/flutter_inappwebview/README.md index 77e836e7c..2c2325d28 100755 --- a/flutter_inappwebview/README.md +++ b/flutter_inappwebview/README.md @@ -5,7 +5,7 @@ ![InAppWebView-logo](https://user-images.githubusercontent.com/5956938/195422744-bdcfed16-73f0-4bc9-94ab-ecf10771a1c4.png) -[![All Contributors](https://img.shields.io/badge/all_contributors-89-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-90-orange.svg?style=flat-square)](#contributors-) [![flutter_inappwebview version](https://img.shields.io/pub/v/flutter_inappwebview?include_prereleases)](https://pub.dartlang.org/packages/flutter_inappwebview) @@ -197,6 +197,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d Benjamin Schulz
Benjamin Schulz

🤔 seal-app
seal-app

💻 Takuya Tominaga
Takuya Tominaga

💻 + Sergey
Sergey

💻 From a2736353449fa67dba17c89223ae65810a681eee Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 4 Nov 2024 17:32:01 +0100 Subject: [PATCH 055/181] updated requestFocus implementation, macos: implemented requestFocus and clearFocus WebView methods, implemented workaround for macos #2380 --- flutter_inappwebview/CHANGELOG.md | 5 + .../lib/in_app_webiew_example.screen.dart | 3 +- .../in_app_webview_controller.dart | 12 +- flutter_inappwebview_android/CHANGELOG.md | 1 + .../types/InAppWebViewRect.java | 107 +++++++++++++++ .../webview/WebViewChannelDelegate.java | 17 ++- .../in_app_webview_controller.dart | 8 +- flutter_inappwebview_ios/CHANGELOG.md | 1 + .../Classes/InAppWebView/InAppWebView.swift | 8 +- .../InAppWebView/WebViewChannelDelegate.swift | 6 +- .../in_app_webview_controller.dart | 8 +- flutter_inappwebview_macos/CHANGELOG.md | 2 + .../src/in_app_webview/in_app_webview.dart | 2 +- .../in_app_webview_controller.dart | 24 ++++ .../Classes/InAppWebView/InAppWebView.swift | 44 ++++++ .../InAppWebView/WebViewChannelDelegate.swift | 16 +++ .../WebViewChannelDelegateMethods.swift | 2 + .../platform_inappwebview_controller.dart | 20 ++- .../lib/src/types/focus_direction.dart | 54 ++++++++ .../lib/src/types/focus_direction.g.dart | 125 ++++++++++++++++++ .../lib/src/types/main.dart | 1 + 21 files changed, 443 insertions(+), 23 deletions(-) create mode 100644 flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/InAppWebViewRect.java create mode 100644 flutter_inappwebview_platform_interface/lib/src/types/focus_direction.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/types/focus_direction.g.dart diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index 0adc91e0a..8eb2eff6c 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -16,6 +16,7 @@ Implemented security features to better manage access to the native javascript b - Added `PlatformInAppLocalhostServer.onData` parameter to set a custom on data server callback - Added `javaScriptBridgeEnabled`, `javaScriptBridgeOriginAllowList`, `javaScriptBridgeForMainFrameOnly`, `pluginScriptsOriginAllowList`, `pluginScriptsForMainFrameOnly`, `javaScriptHandlersOriginAllowList`, `javaScriptHandlersForMainFrameOnly`, `scrollMultiplier` InAppWebViewSettings parameters - Added `setJavaScriptBridgeName`, `getJavaScriptBridgeName` static WebView controller methods +- Added `requestFocus` WebView method - Added `onProcessFailed` WebView event - Added `JavaScriptHandlerFunctionData` type - Deprecated `JavaScriptHandlerCallback` type in favor of `JavaScriptHandlerFunction` type @@ -27,6 +28,7 @@ Implemented security features to better manage access to the native javascript b - Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method - Added `CookieManager.flush` method - Added support for `UserScript.forMainFrameOnly` parameter +- Implemented `requestFocus` WebView method - Updated UserScript at document end implementation - Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called - Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025) @@ -35,10 +37,13 @@ Implemented security features to better manage access to the native javascript b - Merged "Update Android Cookie Expiration date format to 24-hour format (HH)" [#2389](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2389) (thanks to [takuyaaaaaaahaaaaaa](https://github.com/takuyaaaaaaahaaaaaa)) #### macOS and iOS Platforms +- Implemented `requestFocus` WebView method - Updated ConsoleLogJS internal PluginScript to main-frame only as using it on non-main frames could cause issues such as [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738) - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error - Added support for `UserScript.allowedOriginRules` parameter - Merged "change priority of DispatchQueue" [#2322](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2322) (thanks to [nnnlog](https://github.com/nnnlog)) +- macOS: Implemented also `clearFocus` WebView method +- macOS: Implemented workaround for "[macOS] Copy Shortcut does not work if TextField outside of WebView has focus" [#2380](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2380) #### Windows Platform - Updated `scrollMultiplier` default value from 6 to 1 diff --git a/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart b/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart index 0a53f086c..82d17b658 100755 --- a/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart +++ b/flutter_inappwebview/example/lib/in_app_webiew_example.screen.dart @@ -1,4 +1,5 @@ import 'dart:collection'; + import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_inappwebview/flutter_inappwebview.dart'; @@ -116,7 +117,7 @@ class _InAppWebViewExampleScreenState extends State { key: webViewKey, webViewEnvironment: webViewEnvironment, initialUrlRequest: - URLRequest(url: WebUri('https://flutter.dev')), + URLRequest(url: WebUri('https://flutter.dev')), // initialUrlRequest: // URLRequest(url: WebUri(Uri.base.toString().replaceFirst("/#/", "/") + 'page.html')), // initialFile: "assets/index.html", diff --git a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart index 0920b9685..72e9dab13 100644 --- a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1,18 +1,14 @@ import 'dart:core'; -import 'dart:typed_data'; -import 'dart:ui'; -import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; +import '../print_job/main.dart'; import '../web_message/main.dart'; import '../web_storage/web_storage.dart'; import 'android/in_app_webview_controller.dart'; import 'apple/in_app_webview_controller.dart'; -import '../print_job/main.dart'; - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController} class InAppWebViewController { ///Use [InAppWebViewController] instead. @@ -289,7 +285,11 @@ class InAppWebViewController { platform.getHitTestResult(); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.requestFocus} - Future requestFocus() => platform.requestFocus(); + Future requestFocus( + {FocusDirection? direction, + InAppWebViewRect? previouslyFocusedRect}) => + platform.requestFocus( + direction: direction, previouslyFocusedRect: previouslyFocusedRect); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.clearFocus} Future clearFocus() => platform.clearFocus(); diff --git a/flutter_inappwebview_android/CHANGELOG.md b/flutter_inappwebview_android/CHANGELOG.md index f5d4e25aa..23e8baffd 100644 --- a/flutter_inappwebview_android/CHANGELOG.md +++ b/flutter_inappwebview_android/CHANGELOG.md @@ -4,6 +4,7 @@ - Added `InAppWebViewController.enableSlowWholeDocumentDraw` static method - Added `CookieManager.flush` method - Added support for `UserScript.forMainFrameOnly` parameter +- Implemented `requestFocus` WebView method - Updated UserScript at document end implementation - Updated `InAppWebViewController.takeScreenshot` implementation to support screenshot out of visible viewport when `InAppWebViewController.enableSlowWholeDocumentDraw` is called - Fixed "After dispose a InAppWebViewKeepAlive using InAppWebViewController.disposeKeepAlive. NullPointerException is thrown when main activity enter destroyed state." [#2025](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2025) diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/InAppWebViewRect.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/InAppWebViewRect.java new file mode 100644 index 000000000..b297899ff --- /dev/null +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/InAppWebViewRect.java @@ -0,0 +1,107 @@ +package com.pichillilorenzo.flutter_inappwebview_android.types; + +import android.graphics.Rect; + +import androidx.annotation.Nullable; + +import java.util.HashMap; +import java.util.Map; + +public class InAppWebViewRect { + private double height; + private double width; + private double x; + private double y; + + public InAppWebViewRect(double height, double width, double x, double y) { + this.height = height; + this.width = width; + this.x = x; + this.y = y; + } + + @Nullable + public static InAppWebViewRect fromMap(@Nullable Map map) { + if (map == null) { + return null; + } + double height = (double) map.get("height"); + double width = (double) map.get("width"); + double x = (double) map.get("x"); + double y = (double) map.get("y"); + return new InAppWebViewRect(height, width, x, y); + } + + public Map toMap() { + Map map = new HashMap<>(); + map.put("height", height); + map.put("width", width); + map.put("x", x); + map.put("y", y); + return map; + } + + public Rect toRect() { + return new Rect((int) x, (int) y, (int) (x + width), (int) (y + height)); + } + + public double getHeight() { + return height; + } + + public void setHeight(double height) { + this.height = height; + } + + public double getWidth() { + return width; + } + + public void setWidth(double width) { + this.width = width; + } + + public double getX() { + return x; + } + + public void setX(double x) { + this.x = x; + } + + public double getY() { + return y; + } + + public void setY(double y) { + this.y = y; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + InAppWebViewRect that = (InAppWebViewRect) o; + return Double.compare(height, that.height) == 0 && Double.compare(width, that.width) == 0 && Double.compare(x, that.x) == 0 && Double.compare(y, that.y) == 0; + } + + @Override + public int hashCode() { + int result = Double.hashCode(height); + result = 31 * result + Double.hashCode(width); + result = 31 * result + Double.hashCode(x); + result = 31 * result + Double.hashCode(y); + return result; + } + + @Override + public String toString() { + return "InAppWebViewRect{" + + "height=" + height + + ", width=" + width + + ", x=" + x + + ", y=" + y + + '}'; + } +} diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java index e4b12a976..e8e64a166 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/webview/WebViewChannelDelegate.java @@ -1,5 +1,6 @@ package com.pichillilorenzo.flutter_inappwebview_android.webview; +import android.graphics.Rect; import android.net.Uri; import android.os.Build; import android.webkit.ValueCallback; @@ -29,6 +30,7 @@ import com.pichillilorenzo.flutter_inappwebview_android.types.HitTestResult; import com.pichillilorenzo.flutter_inappwebview_android.types.HttpAuthResponse; import com.pichillilorenzo.flutter_inappwebview_android.types.HttpAuthenticationChallenge; +import com.pichillilorenzo.flutter_inappwebview_android.types.InAppWebViewRect; import com.pichillilorenzo.flutter_inappwebview_android.types.JavaScriptHandlerFunctionData; import com.pichillilorenzo.flutter_inappwebview_android.types.JsAlertResponse; import com.pichillilorenzo.flutter_inappwebview_android.types.JsBeforeUnloadResponse; @@ -477,9 +479,20 @@ public void onReceiveValue(String value) { break; case requestFocus: if (webView != null) { - webView.requestFocus(); + boolean resultValue = false; + Integer direction = (Integer) call.argument("direction"); + InAppWebViewRect previouslyFocusedRect = InAppWebViewRect.fromMap((Map) call.argument("previouslyFocusedRect")); + if (direction != null && previouslyFocusedRect != null) { + resultValue = webView.requestFocus(direction, previouslyFocusedRect.toRect()); + } else if (direction != null) { + resultValue = webView.requestFocus(direction); + } else { + resultValue = webView.requestFocus(); + } + result.success(resultValue); + } else { + result.success(false); } - result.success(true); break; case setContextMenu: if (webView != null) { diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart index c9cbc155c..4e3794b53 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2240,9 +2240,13 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController } @override - Future requestFocus() async { + Future requestFocus( + {FocusDirection? direction, + InAppWebViewRect? previouslyFocusedRect}) async { Map args = {}; - return await channel?.invokeMethod('requestFocus', args); + args.putIfAbsent("direction", () => direction?.toNativeValue()); + args.putIfAbsent("previouslyFocusedRect", () => previouslyFocusedRect?.toMap()); + return await channel?.invokeMethod('requestFocus', args); } @override diff --git a/flutter_inappwebview_ios/CHANGELOG.md b/flutter_inappwebview_ios/CHANGELOG.md index 1041fe279..2c52d0bf4 100644 --- a/flutter_inappwebview_ios/CHANGELOG.md +++ b/flutter_inappwebview_ios/CHANGELOG.md @@ -1,6 +1,7 @@ ## 1.2.0-beta.1 - Updated flutter_inappwebview_platform_interface version to ^1.4.0 +- Implemented `requestFocus` WebView method - Updated ConsoleLogJS internal PluginScript to main-frame only as using it on non-main frames could cause issues such as [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738) - Added support for `UserScript.allowedOriginRules` parameter - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error diff --git a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift index 98862b282..3a9d3ca8d 100755 --- a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift @@ -3259,12 +3259,12 @@ if(window.\(JavaScriptBridgeJS.get_JAVASCRIPT_BRIDGE_NAME())[\(_callHandlerID)] } } - public func clearFocus() { - self.scrollView.subviews.first?.resignFirstResponder() + public func clearFocus() -> Bool { + return self.scrollView.subviews.first?.resignFirstResponder() ?? false } - public func requestFocus() { - self.scrollView.subviews.first?.becomeFirstResponder() + public func requestFocus() -> Bool { + return self.scrollView.subviews.first?.becomeFirstResponder() ?? false } public func getCertificate() -> SslCertificate? { diff --git a/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift b/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift index 0e8c19670..b0d88ebcc 100644 --- a/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppWebView/WebViewChannelDelegate.swift @@ -345,12 +345,10 @@ public class WebViewChannelDelegate: ChannelDelegate { } break case .clearFocus: - webView?.clearFocus() - result(true) + result(webView?.clearFocus()) break case .requestFocus: - webView?.requestFocus() - result(true) + result(webView?.requestFocus()) break case .setContextMenu: if let webView = webView { diff --git a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart index d37e14602..7fe686162 100644 --- a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2233,9 +2233,13 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController } @override - Future requestFocus() async { + Future requestFocus( + {FocusDirection? direction, + InAppWebViewRect? previouslyFocusedRect}) async { Map args = {}; - return await channel?.invokeMethod('requestFocus', args); + args.putIfAbsent("direction", () => direction?.toNativeValue()); + args.putIfAbsent("previouslyFocusedRect", () => previouslyFocusedRect?.toMap()); + return await channel?.invokeMethod('requestFocus', args); } @override diff --git a/flutter_inappwebview_macos/CHANGELOG.md b/flutter_inappwebview_macos/CHANGELOG.md index a07283b49..b245ed568 100644 --- a/flutter_inappwebview_macos/CHANGELOG.md +++ b/flutter_inappwebview_macos/CHANGELOG.md @@ -1,10 +1,12 @@ ## 1.2.0-beta.1 - Updated flutter_inappwebview_platform_interface version to ^1.4.0 +- Implemented `requestFocus`, `clearFocus` WebView methods - Updated ConsoleLogJS internal PluginScript to main-frame only as using it on non-main frames could cause issues such as [#1738](https://github.com/pichillilorenzo/flutter_inappwebview/issues/1738) - Added support for `UserScript.allowedOriginRules` parameter - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error - Merged "change priority of DispatchQueue" [#2322](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2322) (thanks to [nnnlog](https://github.com/nnnlog)) +- Implemented workaround for "[macOS] Copy Shortcut does not work if TextField outside of WebView has focus" [#2380](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2380) ## 1.1.2 diff --git a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart index f2800a949..0d0499c69 100755 --- a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart @@ -2,9 +2,9 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; -import 'headless_in_app_webview.dart'; import '../find_interaction/find_interaction_controller.dart'; +import 'headless_in_app_webview.dart'; import 'in_app_webview_controller.dart'; /// Object specifying creation parameters for creating a [PlatformInAppWebViewWidget]. diff --git a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart index ec7cd242a..add535e8a 100644 --- a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart @@ -6,6 +6,7 @@ import 'dart:io'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; +import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; import '../in_app_browser/in_app_browser.dart'; @@ -188,6 +189,13 @@ class MacOSInAppWebViewController extends PlatformInAppWebViewController } Future _handleMethod(MethodCall call) async { + if (call.method == "_onMouseDown") { + // Workaround for https://github.com/pichillilorenzo/flutter_inappwebview/issues/2380 + // TODO: remove when Flutter fixes this + FocusManager.instance.primaryFocus?.unfocus(); + return; + } + if (PlatformInAppWebViewController.debugLoggingSettings.enabled && call.method != "onCallJsHandler") { _debugLog(call.method, call.arguments); @@ -2202,6 +2210,22 @@ class MacOSInAppWebViewController extends PlatformInAppWebViewController return await channel?.invokeMethod('getSelectedText', args); } + @override + Future requestFocus( + {FocusDirection? direction, + InAppWebViewRect? previouslyFocusedRect}) async { + Map args = {}; + args.putIfAbsent("direction", () => direction?.toNativeValue()); + args.putIfAbsent("previouslyFocusedRect", () => previouslyFocusedRect?.toMap()); + return await channel?.invokeMethod('requestFocus', args); + } + + @override + Future clearFocus() async { + Map args = {}; + return await channel?.invokeMethod('clearFocus', args); + } + @override Future> getMetaTags() async { List metaTags = []; diff --git a/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift b/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift index ce7f505f4..18c493cca 100755 --- a/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift @@ -53,6 +53,8 @@ public class InAppWebView: WKWebView, WKUIDelegate, private var exceptedBridgeSecret = NSUUID().uuidString private var javaScriptBridgeEnabled = true + public override var acceptsFirstResponder: Bool { return true } + init(id: Any?, plugin: InAppWebViewFlutterPlugin?, frame: CGRect, configuration: WKWebViewConfiguration, userScripts: [UserScript] = []) { super.init(frame: frame, configuration: configuration) @@ -2604,6 +2606,48 @@ if(window.\(JavaScriptBridgeJS.get_JAVASCRIPT_BRIDGE_NAME())[\(_callHandlerID)] } } + public func clearFocus() -> Bool { + return (self.superview?.window ?? self.window)?.makeFirstResponder(nil) ?? false + } + + public func requestFocus() -> Bool { + return (self.superview?.window ?? self.window)?.makeFirstResponder(self) ?? false + } + + // Workaround for https://github.com/pichillilorenzo/flutter_inappwebview/issues/2380 + // TODO: remove when Flutter fixes this + private var _isFirstResponder = true + override open func becomeFirstResponder() -> Bool { + _isFirstResponder = true + return super.becomeFirstResponder() + } + private func _fixFocus(callback: @escaping () -> Void) { + if _isFirstResponder, let channelDelegate = channelDelegate { + _isFirstResponder = false + channelDelegate._onMouseDown(callback: { [weak self] in + let _ = self?.requestFocus() + callback() + }) + } else { + callback() + } + } + override public func mouseDown(with event: NSEvent) { + _fixFocus { + super.mouseDown(with: event) + } + } + override public func rightMouseDown(with event: NSEvent) { + _fixFocus { + super.rightMouseDown(with: event) + } + } + override public func otherMouseDown(with event: NSEvent) { + _fixFocus { + super.otherMouseDown(with: event) + } + } + public func getCertificate() -> SslCertificate? { guard let scheme = url?.scheme, scheme == "https", diff --git a/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegate.swift b/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegate.swift index 671083388..cd8a5358a 100644 --- a/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegate.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegate.swift @@ -370,6 +370,12 @@ public class WebViewChannelDelegate: ChannelDelegate { result(nil) } break + case .clearFocus: + result(webView?.clearFocus()) + break + case .requestFocus: + result(webView?.requestFocus()) + break case .getCertificate: result(webView?.getCertificate()?.toMap()) break @@ -1166,6 +1172,16 @@ public class WebViewChannelDelegate: ChannelDelegate { channel?.invokeMethod("onPrintRequest", arguments: arguments, callback: callback) } + internal func _onMouseDown(callback: @escaping () -> Void) { + if channel == nil { + return + } + let arguments: [String:Any] = [:]; + channel?.invokeMethod("_onMouseDown", arguments: arguments) {(result) -> Void in + callback() + } + } + public override func dispose() { super.dispose() webView = nil diff --git a/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegateMethods.swift b/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegateMethods.swift index 4810bae3b..8dac64e48 100644 --- a/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegateMethods.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppWebView/WebViewChannelDelegateMethods.swift @@ -58,6 +58,8 @@ public enum WebViewChannelDelegateMethods: String { case getSelectedText = "getSelectedText" case getScrollX = "getScrollX" case getScrollY = "getScrollY" + case clearFocus = "clearFocus" + case requestFocus = "requestFocus" case getCertificate = "getCertificate" case addUserScript = "addUserScript" case removeUserScript = "removeUserScript" diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart index 43aa98baf..6a7502052 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart @@ -1071,7 +1071,24 @@ abstract class PlatformInAppWebViewController extends PlatformInterface 'getHitTestResult is not implemented on the current platform'); } - Future requestFocus() { + ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.requestFocus} + ///Call this method when you want to try the WebView to be the first responder. + /// + ///On Android, call this to try to give focus to the WebView and + ///give it hints about the [direction] and a specific [previouslyFocusedRect] that the focus is coming from. + ///The [previouslyFocusedRect] can help give larger views a finer grained hint about where focus is coming from, + ///and therefore, where to show selection, or forward focus change internally. + /// + ///Returns `true` whether this WebView actually took focus; otherwise, `false`. + /// + ///**NOTE**: [direction] and [previouslyFocusedRect] are available only on Android. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - WebView.requestFocus](https://developer.android.com/reference/android/webkit/WebView#requestFocus(int,%20android.graphics.Rect))) + ///- iOS ([Official API - UIResponder.becomeFirstResponder](https://developer.apple.com/documentation/uikit/uiresponder/1621113-becomefirstresponder)) + ///- MacOS ([Official API - NSWindow.makeFirstResponder](https://developer.apple.com/documentation/appkit/nswindow/1419366-makefirstresponder)) + ///{@endtemplate} + Future requestFocus({FocusDirection? direction, InAppWebViewRect? previouslyFocusedRect}) { throw UnimplementedError( 'requestFocus is not implemented on the current platform'); } @@ -1082,6 +1099,7 @@ abstract class PlatformInAppWebViewController extends PlatformInterface ///**Officially Supported Platforms/Implementations**: ///- Android native WebView ([Official API - ViewGroup.clearFocus](https://developer.android.com/reference/android/view/ViewGroup#clearFocus())) ///- iOS ([Official API - UIResponder.resignFirstResponder](https://developer.apple.com/documentation/uikit/uiresponder/1621097-resignfirstresponder)) + ///- MacOS ([Official API - NSWindow.makeFirstResponder](https://developer.apple.com/documentation/appkit/nswindow/1419366-makefirstresponder)) ///{@endtemplate} Future clearFocus() { throw UnimplementedError( diff --git a/flutter_inappwebview_platform_interface/lib/src/types/focus_direction.dart b/flutter_inappwebview_platform_interface/lib/src/types/focus_direction.dart new file mode 100644 index 000000000..c3f593b8b --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/focus_direction.dart @@ -0,0 +1,54 @@ +import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; + +part 'focus_direction.g.dart'; + +///Class used to indicate the force dark mode. +@ExchangeableEnum() +class FocusDirection_ { + // ignore: unused_field + final String _value; + // ignore: unused_field + final dynamic _nativeValue = null; + const FocusDirection_._internal(this._value); + + ///Move focus up. + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'FOCUS_UP', + apiUrl: 'https://developer.android.com/reference/android/view/View#FOCUS_UP', + value: 33 + ), + ]) + static const UP = const FocusDirection_._internal('UP'); + + ///Move focus down. + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'FOCUS_DOWN', + apiUrl: 'https://developer.android.com/reference/android/view/View#FOCUS_DOWN', + value: 130 + ), + ]) + static const DOWN = const FocusDirection_._internal('DOWN'); + + ///Move focus to the left. + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'FOCUS_LEFT', + apiUrl: 'https://developer.android.com/reference/android/view/View#FOCUS_LEFT', + value: 130 + ), + ]) + static const LEFT = const FocusDirection_._internal('LEFT'); + + ///Move focus to the right. + @EnumSupportedPlatforms(platforms: [ + EnumAndroidPlatform( + apiName: 'FOCUS_RIGHT', + apiUrl: 'https://developer.android.com/reference/android/view/View#FOCUS_RIGHT', + value: 130 + ), + ]) + static const RIGHT = const FocusDirection_._internal('RIGHT'); +} \ No newline at end of file diff --git a/flutter_inappwebview_platform_interface/lib/src/types/focus_direction.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/focus_direction.g.dart new file mode 100644 index 000000000..76684e551 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/types/focus_direction.g.dart @@ -0,0 +1,125 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'focus_direction.dart'; + +// ************************************************************************** +// ExchangeableEnumGenerator +// ************************************************************************** + +///Class used to indicate the force dark mode. +class FocusDirection { + final String _value; + final dynamic _nativeValue; + const FocusDirection._internal(this._value, this._nativeValue); +// ignore: unused_element + factory FocusDirection._internalMultiPlatform( + String value, Function nativeValue) => + FocusDirection._internal(value, nativeValue()); + + ///Move focus down. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - FOCUS_DOWN](https://developer.android.com/reference/android/view/View#FOCUS_DOWN)) + static final DOWN = FocusDirection._internalMultiPlatform('DOWN', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 130; + default: + break; + } + return null; + }); + + ///Move focus to the left. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - FOCUS_LEFT](https://developer.android.com/reference/android/view/View#FOCUS_LEFT)) + static final LEFT = FocusDirection._internalMultiPlatform('LEFT', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 130; + default: + break; + } + return null; + }); + + ///Move focus to the right. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - FOCUS_RIGHT](https://developer.android.com/reference/android/view/View#FOCUS_RIGHT)) + static final RIGHT = FocusDirection._internalMultiPlatform('RIGHT', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 130; + default: + break; + } + return null; + }); + + ///Move focus up. + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android native WebView ([Official API - FOCUS_UP](https://developer.android.com/reference/android/view/View#FOCUS_UP)) + static final UP = FocusDirection._internalMultiPlatform('UP', () { + switch (defaultTargetPlatform) { + case TargetPlatform.android: + return 33; + default: + break; + } + return null; + }); + + ///Set of all values of [FocusDirection]. + static final Set values = [ + FocusDirection.DOWN, + FocusDirection.LEFT, + FocusDirection.RIGHT, + FocusDirection.UP, + ].toSet(); + + ///Gets a possible [FocusDirection] instance from [String] value. + static FocusDirection? fromValue(String? value) { + if (value != null) { + try { + return FocusDirection.values + .firstWhere((element) => element.toValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets a possible [FocusDirection] instance from a native value. + static FocusDirection? fromNativeValue(dynamic value) { + if (value != null) { + try { + return FocusDirection.values + .firstWhere((element) => element.toNativeValue() == value); + } catch (e) { + return null; + } + } + return null; + } + + ///Gets [String] value. + String toValue() => _value; + + ///Gets [dynamic] native value. + dynamic toNativeValue() => _nativeValue; + + @override + int get hashCode => _value.hashCode; + + @override + bool operator ==(value) => value == _value; + + @override + String toString() { + return _value; + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/main.dart b/flutter_inappwebview_platform_interface/lib/src/types/main.dart index 738df7950..d6d4c78cb 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/main.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/main.dart @@ -235,3 +235,4 @@ export 'frame_kind.dart' show FrameKind; export 'process_failed_kind.dart' show ProcessFailedKind; export 'process_failed_reason.dart' show ProcessFailedReason; export 'process_failed_detail.dart' show ProcessFailedDetail; +export 'focus_direction.dart' show FocusDirection; From f16fe0622e6458446b1fe3f4132eb51cfe1e0a16 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Tue, 5 Nov 2024 01:50:26 +0100 Subject: [PATCH 056/181] updated tests, android: fixed js bridge logic, ios: Fixed show, hide methods and hidden setting for InAppBrowser --- flutter_inappwebview/CHANGELOG.md | 1 + .../chrome_safari_browser/open_and_close.dart | 2 +- .../in_app_webview/user_scripts.dart | 2 + .../in_app_webview/web_archive.dart | 4 +- .../plugin_scripts_js/JavaScriptBridgeJS.java | 4 +- .../types/UserContentController.java | 8 +-- flutter_inappwebview_ios/CHANGELOG.md | 1 + .../InAppBrowser/InAppBrowserManager.swift | 31 ++++----- .../InAppBrowserNavigationController.swift | 4 -- .../InAppBrowserWebViewController.swift | 64 ++++++++++--------- .../PluginScriptsJS/JavaScriptBridgeJS.swift | 2 +- .../PluginScriptsJS/JavaScriptBridgeJS.swift | 2 +- .../lib/src/types/user_script.dart | 4 ++ .../lib/src/types/user_script.g.dart | 4 ++ 14 files changed, 73 insertions(+), 60 deletions(-) diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index 8eb2eff6c..4cbf82219 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -42,6 +42,7 @@ Implemented security features to better manage access to the native javascript b - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error - Added support for `UserScript.allowedOriginRules` parameter - Merged "change priority of DispatchQueue" [#2322](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2322) (thanks to [nnnlog](https://github.com/nnnlog)) +- ios: Fixed `show`, `hide` methods and `hidden` setting for `InAppBrowser` - macOS: Implemented also `clearFocus` WebView method - macOS: Implemented workaround for "[macOS] Copy Shortcut does not work if TextField outside of WebView has focus" [#2380](https://github.com/pichillilorenzo/flutter_inappwebview/issues/2380) diff --git a/flutter_inappwebview/example/integration_test/chrome_safari_browser/open_and_close.dart b/flutter_inappwebview/example/integration_test/chrome_safari_browser/open_and_close.dart index 4615f4573..78eb9c4dc 100644 --- a/flutter_inappwebview/example/integration_test/chrome_safari_browser/open_and_close.dart +++ b/flutter_inappwebview/example/integration_test/chrome_safari_browser/open_and_close.dart @@ -40,7 +40,7 @@ void openAndClose() { activityButton: ActivityButton( templateImage: UIImage(systemName: "sun.max"), extensionIdentifier: - "com.pichillilorenzo.flutterinappwebview-ios-example.test"))); + "com.pichillilorenzo.flutterinappwebview-ios-example3.test"))); await chromeSafariBrowser.opened.future; expect(chromeSafariBrowser.isOpened(), true); expect(() async { diff --git a/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart b/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart index 078218caf..339fd53dd 100644 --- a/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart +++ b/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart @@ -32,10 +32,12 @@ void userScripts() { UserScript( source: "var bar = 2;", injectionTime: UserScriptInjectionTime.AT_DOCUMENT_END, + forMainFrameOnly: defaultTargetPlatform != TargetPlatform.android, contentWorld: ContentWorld.DEFAULT_CLIENT), UserScript( source: "var bar2 = 12;", injectionTime: UserScriptInjectionTime.AT_DOCUMENT_END, + forMainFrameOnly: defaultTargetPlatform != TargetPlatform.android, contentWorld: ContentWorld.world(name: "test")), ]), onWebViewCreated: (controller) { diff --git a/flutter_inappwebview/example/integration_test/in_app_webview/web_archive.dart b/flutter_inappwebview/example/integration_test/in_app_webview/web_archive.dart index 914011ec4..36a25f410 100644 --- a/flutter_inappwebview/example/integration_test/in_app_webview/web_archive.dart +++ b/flutter_inappwebview/example/integration_test/in_app_webview/web_archive.dart @@ -60,7 +60,9 @@ void webArchive() { controllerCompleter.complete(controller); }, onLoadStop: (controller, url) { - pageLoaded.complete(); + if (!pageLoaded.isCompleted) { + pageLoaded.complete(); + } }, ), ), diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/JavaScriptBridgeJS.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/JavaScriptBridgeJS.java index 66fc8bf21..a48d08a1e 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/JavaScriptBridgeJS.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/plugin_scripts_js/JavaScriptBridgeJS.java @@ -322,7 +322,7 @@ public static String JAVASCRIPT_BRIDGE_JS_SOURCE() { " _Array_slice.call = window.Function.prototype.call;" + " _setTimeout = window.setTimeout;" + " _Promise = window.Promise;" + - " _javaInjectedObject = window." + get_JAVASCRIPT_BRIDGE_NAME() + ";" + + " _javaInjectedObject = window.top." + get_JAVASCRIPT_BRIDGE_NAME() + ";" + " } catch (_) { return; }" + " window." + get_JAVASCRIPT_BRIDGE_NAME() + ".callHandler = function() {" + " var _callHandlerID = _setTimeout(function(){});" + @@ -337,7 +337,7 @@ public static String JAVASCRIPT_BRIDGE_JS_SOURCE() { " 'args': _JSON_stringify(_Array_slice.call(arguments, 1))" + " }));" + " return new _Promise(function(resolve, reject) {" + - " window.top." + get_JAVASCRIPT_BRIDGE_NAME() + "[_callHandlerID] = {resolve: resolve, reject: reject};" + + " _javaInjectedObject[_callHandlerID] = {resolve: resolve, reject: reject};" + " });" + " } catch (error) {" + " return new _Promise(function(resolve, reject) { resolve(); });" + diff --git a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserContentController.java b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserContentController.java index 21b596d27..0e59a581d 100644 --- a/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserContentController.java +++ b/flutter_inappwebview_android/android/src/main/java/com/pichillilorenzo/flutter_inappwebview_android/types/UserContentController.java @@ -460,15 +460,15 @@ static private String wrapSourceCodeAddChecks(String source, UserScript userScri } private static String USER_SCRIPTS_AT_DOCUMENT_START_WRAPPER_JS_SOURCE() { - return "if (window._userScriptsAtDocumentStartLoaded == null || !window._userScriptsAtDocumentStartLoaded) {" + - " window._userScriptsAtDocumentStartLoaded = true;" + + return "if (window._" + JavaScriptBridgeJS.get_JAVASCRIPT_BRIDGE_NAME() + "_userScriptsAtDocumentStartLoaded == null || !window._" + JavaScriptBridgeJS.get_JAVASCRIPT_BRIDGE_NAME() + "_userScriptsAtDocumentStartLoaded) {" + + " window._" + JavaScriptBridgeJS.get_JAVASCRIPT_BRIDGE_NAME() + "_userScriptsAtDocumentStartLoaded = true;" + " " + PluginScriptsUtil.VAR_PLACEHOLDER_VALUE + "}"; } private static String USER_SCRIPTS_AT_DOCUMENT_END_WRAPPER_JS_SOURCE() { - return "if (window._userScriptsAtDocumentEndLoaded == null || !window._userScriptsAtDocumentEndLoaded) {" + - " window._userScriptsAtDocumentEndLoaded = true;" + + return "if (window._" + JavaScriptBridgeJS.get_JAVASCRIPT_BRIDGE_NAME() + "_userScriptsAtDocumentEndLoaded == null || !window._" + JavaScriptBridgeJS.get_JAVASCRIPT_BRIDGE_NAME() + "_userScriptsAtDocumentEndLoaded) {" + + " window._" + JavaScriptBridgeJS.get_JAVASCRIPT_BRIDGE_NAME() + "_userScriptsAtDocumentEndLoaded = true;" + " " + PluginScriptsUtil.VAR_PLACEHOLDER_VALUE + "}"; } diff --git a/flutter_inappwebview_ios/CHANGELOG.md b/flutter_inappwebview_ios/CHANGELOG.md index 2c52d0bf4..51c5596b8 100644 --- a/flutter_inappwebview_ios/CHANGELOG.md +++ b/flutter_inappwebview_ios/CHANGELOG.md @@ -6,6 +6,7 @@ - Added support for `UserScript.allowedOriginRules` parameter - Moved `WKUserContentController` initialization on `preWKWebViewConfiguration` to fix possible `undefined is not an object (evaluating 'window.webkit.messageHandlers')` javascript error - Merged "change priority of DispatchQueue" [#2322](https://github.com/pichillilorenzo/flutter_inappwebview/pull/2322) (thanks to [nnnlog](https://github.com/nnnlog)) +- Fixed `show`, `hide` methods and `hidden` setting for `InAppBrowser` ## 1.1.2 diff --git a/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserManager.swift b/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserManager.swift index 06219762e..c7c3b8e77 100755 --- a/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserManager.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserManager.swift @@ -17,8 +17,8 @@ public class InAppBrowserManager: ChannelDelegate { static let WEBVIEW_STORYBOARD_CONTROLLER_ID = "viewController" static let NAV_STORYBOARD_CONTROLLER_ID = "navController" var plugin: SwiftFlutterPlugin? - - private var previousStatusBarStyle = -1 + + var navControllers: [String: InAppBrowserNavigationController?] = [:] init(plugin: SwiftFlutterPlugin) { super.init(channel: FlutterMethodChannel(name: InAppBrowserManager.METHOD_CHANNEL_NAME, binaryMessenger: plugin.registrar!.messenger())) @@ -44,10 +44,6 @@ public class InAppBrowserManager: ChannelDelegate { } public func prepareInAppBrowserWebViewController(settings: [String: Any?]) -> InAppBrowserWebViewController { - if previousStatusBarStyle == -1 { - previousStatusBarStyle = UIApplication.shared.statusBarStyle.rawValue - } - let browserSettings = InAppBrowserSettings() let _ = browserSettings.parse(settings: settings) @@ -59,7 +55,6 @@ public class InAppBrowserManager: ChannelDelegate { webViewController.browserSettings = browserSettings webViewController.isHidden = browserSettings.hidden webViewController.webViewSettings = webViewSettings - webViewController.previousStatusBarStyle = previousStatusBarStyle return webViewController } @@ -105,17 +100,12 @@ public class InAppBrowserManager: ChannelDelegate { navController.pushViewController(webViewController, animated: false) webViewController.prepareNavigationControllerBeforeViewWillAppear() - var animated = true - if let browserSettings = webViewController.browserSettings, browserSettings.hidden { - animated = false - } - guard let visibleViewController = UIApplication.shared.visibleViewController else { assertionFailure("Failure init the visibleViewController!") return } - - if let popover = navController.popoverPresentationController { + + if let popover = webViewController.popoverPresentationController { let sourceView = visibleViewController.view ?? UIView() popover.sourceRect = CGRect(x: sourceView.bounds.midX, y: sourceView.bounds.midY, width: 0, height: 0) @@ -123,7 +113,13 @@ public class InAppBrowserManager: ChannelDelegate { popover.sourceView = sourceView } - visibleViewController.present(navController, animated: animated) + if let browserSettings = webViewController.browserSettings, browserSettings.hidden { + webViewController.loadViewIfNeeded() + } else { + visibleViewController.present(navController, animated: true) + } + + navControllers[webViewController.id] = navController } public func openWithSystemBrowser(url: String, result: @escaping FlutterResult) { @@ -144,6 +140,11 @@ public class InAppBrowserManager: ChannelDelegate { public override func dispose() { super.dispose() + let navControllersValues = navControllers.values + navControllersValues.forEach { (navController: InAppBrowserNavigationController?) in + navController?.dismiss(animated: false) + } + navControllers.removeAll() plugin = nil } diff --git a/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserNavigationController.swift b/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserNavigationController.swift index 2d7b8c590..1ab8a3642 100644 --- a/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserNavigationController.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserNavigationController.swift @@ -8,12 +8,8 @@ import Foundation public class InAppBrowserNavigationController: UINavigationController { - var tmpWindow: UIWindow? - deinit { debugPrint("InAppBrowserNavigationController - dealloc") - tmpWindow?.windowLevel = UIWindow.Level(rawValue: 0.0) - tmpWindow = nil UIApplication.shared.delegate?.window??.makeKeyAndVisible() } } diff --git a/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift b/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift index c75434782..befa12ab0 100755 --- a/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppBrowser/InAppBrowserWebViewController.swift @@ -47,7 +47,6 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega var initialMimeType: String? var initialEncoding: String? var initialBaseUrl: String? - var previousStatusBarStyle = -1 var initialUserScripts: [[String: Any]] = [] var pullToRefreshInitialSettings: [String: Any?] = [:] var isHidden = false @@ -214,7 +213,9 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega } public override func viewDidDisappear(_ animated: Bool) { - dispose() + if !isHidden { + dispose() + } super.viewDidDisappear(animated) } @@ -411,31 +412,27 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega } public func show(completion: (() -> Void)? = nil) { - if let navController = navigationController as? InAppBrowserNavigationController, let window = navController.tmpWindow { + if let visibleViewController = UIApplication.shared.visibleViewController, + let navigationController = navigationController { isHidden = false - window.alpha = 0.0 - window.isHidden = false - window.makeKeyAndVisible() - UIView.animate(withDuration: 0.2) { - window.alpha = 1.0 + visibleViewController.present(navigationController, animated: true) { completion?() } + } else { + completion?() } } public func hide(completion: (() -> Void)? = nil) { - if let navController = navigationController as? InAppBrowserNavigationController, let window = navController.tmpWindow { + if let navigationController = navigationController { isHidden = true - window.alpha = 1.0 - UIView.animate(withDuration: 0.2) { - window.alpha = 0.0 - } completion: { (finished) in - if finished { - window.isHidden = true - UIApplication.shared.delegate?.window??.makeKeyAndVisible() - completion?() - } + navigationController.dismiss(animated: true) { + completion?() + UIApplication.shared.delegate?.window??.makeKeyAndVisible() } + } else { + completion?() + UIApplication.shared.delegate?.window??.makeKeyAndVisible() } } @@ -451,24 +448,31 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega public func close(completion: (() -> Void)? = nil) { if (navigationController?.responds(to: #selector(getter: navigationController?.presentingViewController)))! { - navigationController?.presentingViewController?.dismiss(animated: true, completion: {() -> Void in + if let presentingViewController = navigationController?.presentingViewController { + presentingViewController.dismiss(animated: true, completion: {() -> Void in + completion?() + self.dispose() + }) + } else { completion?() - }) + dispose() + } } else { - navigationController?.parent?.dismiss(animated: true, completion: {() -> Void in + if let parent = navigationController?.parent { + parent.dismiss(animated: true, completion: {() -> Void in + completion?() + self.dispose() + }) + } else { completion?() - }) + dispose() + } } } @objc public func close() { - if (navigationController?.responds(to: #selector(getter: navigationController?.presentingViewController)))! { - navigationController?.presentingViewController?.dismiss(animated: true, completion: nil) - } - else { - navigationController?.parent?.dismiss(animated: true, completion: nil) - } + close(completion: nil) } @objc public func goBack() { @@ -633,9 +637,6 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega webView?.removeFromSuperview() webView = nil view = nil - if previousStatusBarStyle != -1, let statusBarStyle = UIStatusBarStyle(rawValue: previousStatusBarStyle) { - UIApplication.shared.statusBarStyle = statusBarStyle - } transitioningDelegate = nil searchBar?.delegate = nil closeButton?.target = nil @@ -644,6 +645,7 @@ public class InAppBrowserWebViewController: UIViewController, InAppBrowserDelega reloadButton?.target = nil shareButton?.target = nil menuButton?.target = nil + plugin?.inAppBrowserManager?.navControllers[id] = nil plugin = nil } diff --git a/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift b/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift index b4df2ee73..0e42a3734 100644 --- a/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift +++ b/flutter_inappwebview_ios/ios/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift @@ -66,7 +66,7 @@ public class JavaScriptBridgeJS { }); return new _Promise(function(resolve, reject) { try { - (window.top != window ? window.top : window).\(get_JAVASCRIPT_BRIDGE_NAME())[_callHandlerID] = {resolve: resolve, reject: reject}; + (window.top === window ? window : window.top).\(get_JAVASCRIPT_BRIDGE_NAME())[_callHandlerID] = {resolve: resolve, reject: reject}; } catch (e) { resolve(); } diff --git a/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift b/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift index b4df2ee73..0e42a3734 100644 --- a/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift +++ b/flutter_inappwebview_macos/macos/Classes/PluginScriptsJS/JavaScriptBridgeJS.swift @@ -66,7 +66,7 @@ public class JavaScriptBridgeJS { }); return new _Promise(function(resolve, reject) { try { - (window.top != window ? window.top : window).\(get_JAVASCRIPT_BRIDGE_NAME())[_callHandlerID] = {resolve: resolve, reject: reject}; + (window.top === window ? window : window.top).\(get_JAVASCRIPT_BRIDGE_NAME())[_callHandlerID] = {resolve: resolve, reject: reject}; } catch (e) { resolve(); } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/user_script.dart b/flutter_inappwebview_platform_interface/lib/src/types/user_script.dart index c3614b490..fb655cd55 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/user_script.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/user_script.dart @@ -47,6 +47,10 @@ class UserScript_ { ///A scope of execution in which to evaluate the script to prevent conflicts between different scripts. ///For more information about content worlds, see [ContentWorld]. + /// + ///**NOTE for Android**: because of how a Content World is implemented on Android, if [forMainFrameOnly] is `true`, + ///the [source] inside a specific Content World that is not [ContentWorld.PAGE] will not be executed. + ///See [ContentWorld] for more details. late ContentWorld contentWorld; @ExchangeableObjectConstructor() diff --git a/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart index 53a92ff19..e2f5fc415 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart @@ -23,6 +23,10 @@ class UserScript { ///A scope of execution in which to evaluate the script to prevent conflicts between different scripts. ///For more information about content worlds, see [ContentWorld]. + /// + ///**NOTE for Android**: because of how a Content World is implemented on Android, if [forMainFrameOnly] is `true`, + ///the [source] inside a specific Content World that is not [ContentWorld.PAGE] will not be executed. + ///See [ContentWorld] for more details. late ContentWorld contentWorld; ///A Boolean value that indicates whether to inject the script into the main frame. From 1c90aef65f4cb138a43dbec9d8cde75252961eb1 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Tue, 5 Nov 2024 01:52:16 +0100 Subject: [PATCH 057/181] code format --- .../in_app_webview/user_scripts.dart | 6 +- .../src/in_app_webview/in_app_webview.dart | 18 ++-- .../in_app_webview_controller.dart | 3 +- .../lib/src/cookie_manager.dart | 8 +- .../in_app_webview_controller.dart | 5 +- .../lib/src/cookie_manager.dart | 8 +- .../in_app_webview_controller.dart | 5 +- .../lib/src/context_menu/context_menu.dart | 4 +- .../platform_inappwebview_controller.dart | 3 +- .../src/in_app_webview/platform_webview.dart | 3 +- .../lib/src/types/client_cert_challenge.dart | 32 +++---- .../lib/src/types/client_cert_response.dart | 2 +- .../lib/src/types/focus_direction.dart | 26 ++--- .../lib/src/types/frame_info.dart | 8 +- .../lib/src/types/frame_kind.dart | 34 +++---- .../lib/src/types/process_failed_detail.dart | 18 ++-- .../lib/src/types/process_failed_kind.dart | 95 +++++++++++-------- .../lib/src/types/process_failed_reason.dart | 47 ++++----- .../lib/src/types/ssl_error_type.dart | 19 ++-- .../in_app_webview_controller.dart | 48 ++++++---- 20 files changed, 212 insertions(+), 180 deletions(-) diff --git a/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart b/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart index 339fd53dd..933bfc428 100644 --- a/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart +++ b/flutter_inappwebview/example/integration_test/in_app_webview/user_scripts.dart @@ -32,12 +32,14 @@ void userScripts() { UserScript( source: "var bar = 2;", injectionTime: UserScriptInjectionTime.AT_DOCUMENT_END, - forMainFrameOnly: defaultTargetPlatform != TargetPlatform.android, + forMainFrameOnly: + defaultTargetPlatform != TargetPlatform.android, contentWorld: ContentWorld.DEFAULT_CLIENT), UserScript( source: "var bar2 = 12;", injectionTime: UserScriptInjectionTime.AT_DOCUMENT_END, - forMainFrameOnly: defaultTargetPlatform != TargetPlatform.android, + forMainFrameOnly: + defaultTargetPlatform != TargetPlatform.android, contentWorld: ContentWorld.world(name: "test")), ]), onWebViewCreated: (controller) { diff --git a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart index 249cbd645..5a42a3959 100755 --- a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart @@ -166,14 +166,14 @@ class InAppWebView extends StatefulWidget { onPrintRequest, void Function(InAppWebViewController controller, int progress)? onProgressChanged, - Future Function(InAppWebViewController controller, - ClientCertChallenge challenge)? + Future Function( + InAppWebViewController controller, ClientCertChallenge challenge)? onReceivedClientCertRequest, Future Function(InAppWebViewController controller, - HttpAuthenticationChallenge challenge)? + HttpAuthenticationChallenge challenge)? onReceivedHttpAuthRequest, - Future Function(InAppWebViewController controller, - ServerTrustChallenge challenge)? + Future Function( + InAppWebViewController controller, ServerTrustChallenge challenge)? onReceivedServerTrustAuthRequest, void Function(InAppWebViewController controller, int x, int y)? onScrollChanged, @@ -294,8 +294,9 @@ class InAppWebView extends StatefulWidget { void Function(InAppWebViewController controller, Size oldContentSize, Size newContentSize)? onContentSizeChanged, - void Function(InAppWebViewController controller, ProcessFailedDetail detail)? - onProcessFailed, + void Function( + InAppWebViewController controller, ProcessFailedDetail detail)? + onProcessFailed, }) : this.fromPlatformCreationParams( key: key, params: PlatformInAppWebViewWidgetCreationParams( @@ -660,8 +661,7 @@ class InAppWebView extends StatefulWidget { : null, onProcessFailed: onProcessFailed != null ? (controller, detail) => - onProcessFailed.call( - controller, detail) + onProcessFailed.call(controller, detail) : null, gestureRecognizers: gestureRecognizers, headlessWebView: headlessWebView?.platform, diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart index 4e3794b53..5ce328db3 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2245,7 +2245,8 @@ class AndroidInAppWebViewController extends PlatformInAppWebViewController InAppWebViewRect? previouslyFocusedRect}) async { Map args = {}; args.putIfAbsent("direction", () => direction?.toNativeValue()); - args.putIfAbsent("previouslyFocusedRect", () => previouslyFocusedRect?.toMap()); + args.putIfAbsent( + "previouslyFocusedRect", () => previouslyFocusedRect?.toMap()); return await channel?.invokeMethod('requestFocus', args); } diff --git a/flutter_inappwebview_ios/lib/src/cookie_manager.dart b/flutter_inappwebview_ios/lib/src/cookie_manager.dart index b2272f38c..2c0eea9cd 100755 --- a/flutter_inappwebview_ios/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_ios/lib/src/cookie_manager.dart @@ -408,10 +408,10 @@ class IOSCookieManager extends PlatformCookieManager with ChannelController { var platformUtil = PlatformUtil.instance(); var dateTime = DateTime.fromMillisecondsSinceEpoch(expiresDate).toUtc(); return await platformUtil.formatDate( - date: dateTime, - format: 'EEE, dd MMM yyyy HH:mm:ss z', - locale: 'en_US', - timezone: 'GMT'); + date: dateTime, + format: 'EEE, dd MMM yyyy HH:mm:ss z', + locale: 'en_US', + timezone: 'GMT'); } Future _shouldUseJavascript() async { diff --git a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart index 7fe686162..ee76ad6f4 100644 --- a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2235,10 +2235,11 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController @override Future requestFocus( {FocusDirection? direction, - InAppWebViewRect? previouslyFocusedRect}) async { + InAppWebViewRect? previouslyFocusedRect}) async { Map args = {}; args.putIfAbsent("direction", () => direction?.toNativeValue()); - args.putIfAbsent("previouslyFocusedRect", () => previouslyFocusedRect?.toMap()); + args.putIfAbsent( + "previouslyFocusedRect", () => previouslyFocusedRect?.toMap()); return await channel?.invokeMethod('requestFocus', args); } diff --git a/flutter_inappwebview_macos/lib/src/cookie_manager.dart b/flutter_inappwebview_macos/lib/src/cookie_manager.dart index dba8e6088..6078cb526 100755 --- a/flutter_inappwebview_macos/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_macos/lib/src/cookie_manager.dart @@ -408,10 +408,10 @@ class MacOSCookieManager extends PlatformCookieManager with ChannelController { var platformUtil = PlatformUtil.instance(); var dateTime = DateTime.fromMillisecondsSinceEpoch(expiresDate).toUtc(); return await platformUtil.formatDate( - date: dateTime, - format: 'EEE, dd MMM yyyy HH:mm:ss z', - locale: 'en_US', - timezone: 'GMT'); + date: dateTime, + format: 'EEE, dd MMM yyyy HH:mm:ss z', + locale: 'en_US', + timezone: 'GMT'); } Future _shouldUseJavascript() async { diff --git a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart index add535e8a..4a6ebd52a 100644 --- a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart @@ -2213,10 +2213,11 @@ class MacOSInAppWebViewController extends PlatformInAppWebViewController @override Future requestFocus( {FocusDirection? direction, - InAppWebViewRect? previouslyFocusedRect}) async { + InAppWebViewRect? previouslyFocusedRect}) async { Map args = {}; args.putIfAbsent("direction", () => direction?.toNativeValue()); - args.putIfAbsent("previouslyFocusedRect", () => previouslyFocusedRect?.toMap()); + args.putIfAbsent( + "previouslyFocusedRect", () => previouslyFocusedRect?.toMap()); return await channel?.invokeMethod('requestFocus', args); } diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart index f791abaac..cf9c81592 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.dart @@ -54,8 +54,8 @@ class ContextMenu_ { // ignore: unused_element Map _toMapMergeWith() { return { - "settings": - (settings as ContextMenuSettings?)?.toMap() ?? (options as ContextMenuOptions?)?.toMap() + "settings": (settings as ContextMenuSettings?)?.toMap() ?? + (options as ContextMenuOptions?)?.toMap() }; } } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart index 6a7502052..968b2c8f8 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart @@ -1088,7 +1088,8 @@ abstract class PlatformInAppWebViewController extends PlatformInterface ///- iOS ([Official API - UIResponder.becomeFirstResponder](https://developer.apple.com/documentation/uikit/uiresponder/1621113-becomefirstresponder)) ///- MacOS ([Official API - NSWindow.makeFirstResponder](https://developer.apple.com/documentation/appkit/nswindow/1419366-makefirstresponder)) ///{@endtemplate} - Future requestFocus({FocusDirection? direction, InAppWebViewRect? previouslyFocusedRect}) { + Future requestFocus( + {FocusDirection? direction, InAppWebViewRect? previouslyFocusedRect}) { throw UnimplementedError( 'requestFocus is not implemented on the current platform'); } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart index 7de987d63..b53bba279 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart @@ -1080,7 +1080,8 @@ class PlatformWebViewCreationParams { ///**Officially Supported Platforms/Implementations**: ///- Windows ([Official API - ICoreWebView2.add_ProcessFailed](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed)) ///{@endtemplate} - final void Function(T controller, ProcessFailedDetail detail)? onProcessFailed; + final void Function(T controller, ProcessFailedDetail detail)? + onProcessFailed; ///{@template flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.initialUrlRequest} ///Initial url request that will be loaded. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/client_cert_challenge.dart b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_challenge.dart index fd8cc5a62..5c094362a 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/client_cert_challenge.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_challenge.dart @@ -41,31 +41,25 @@ class ClientCertChallenge_ extends URLAuthenticationChallenge_ { ///The collection contains Base64 encoding of DER encoded distinguished names ///of certificate authorities allowed by the server. - @SupportedPlatforms(platforms: [ - WindowsPlatform() - ]) + @SupportedPlatforms(platforms: [WindowsPlatform()]) List? allowedCertificateAuthorities; ///If the server that issued this request is an http proxy. - @SupportedPlatforms(platforms: [ - WindowsPlatform() - ]) + @SupportedPlatforms(platforms: [WindowsPlatform()]) bool? isProxy; ///The collection contains mutually trusted CA certificates. - @SupportedPlatforms(platforms: [ - WindowsPlatform() - ]) + @SupportedPlatforms(platforms: [WindowsPlatform()]) List? mutuallyTrustedCertificates; - ClientCertChallenge_( - {required URLProtectionSpace_ protectionSpace, - @Deprecated('Use principals instead') this.androidPrincipals, - this.principals, - @Deprecated('Use keyTypes instead') this.androidKeyTypes, - this.keyTypes, - this.allowedCertificateAuthorities, - this.isProxy, - this.mutuallyTrustedCertificates,}) - : super(protectionSpace: protectionSpace); + ClientCertChallenge_({ + required URLProtectionSpace_ protectionSpace, + @Deprecated('Use principals instead') this.androidPrincipals, + this.principals, + @Deprecated('Use keyTypes instead') this.androidKeyTypes, + this.keyTypes, + this.allowedCertificateAuthorities, + this.isProxy, + this.mutuallyTrustedCertificates, + }) : super(protectionSpace: protectionSpace); } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/client_cert_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_response.dart index ee9f91d0f..ed3194e93 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/client_cert_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/client_cert_response.dart @@ -51,7 +51,7 @@ class ClientCertResponse_ { @Deprecated('Use keyStoreType instead') this.androidKeyStoreType = "PKCS12", this.keyStoreType = "PKCS12", - this.selectedCertificate = -1, + this.selectedCertificate = -1, this.action = ClientCertResponseAction_.CANCEL}) { if (this.action == ClientCertResponseAction_.PROCEED && !Util.isWindows) assert(certificatePath.isNotEmpty); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/focus_direction.dart b/flutter_inappwebview_platform_interface/lib/src/types/focus_direction.dart index c3f593b8b..aead758e8 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/focus_direction.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/focus_direction.dart @@ -16,9 +16,9 @@ class FocusDirection_ { @EnumSupportedPlatforms(platforms: [ EnumAndroidPlatform( apiName: 'FOCUS_UP', - apiUrl: 'https://developer.android.com/reference/android/view/View#FOCUS_UP', - value: 33 - ), + apiUrl: + 'https://developer.android.com/reference/android/view/View#FOCUS_UP', + value: 33), ]) static const UP = const FocusDirection_._internal('UP'); @@ -26,9 +26,9 @@ class FocusDirection_ { @EnumSupportedPlatforms(platforms: [ EnumAndroidPlatform( apiName: 'FOCUS_DOWN', - apiUrl: 'https://developer.android.com/reference/android/view/View#FOCUS_DOWN', - value: 130 - ), + apiUrl: + 'https://developer.android.com/reference/android/view/View#FOCUS_DOWN', + value: 130), ]) static const DOWN = const FocusDirection_._internal('DOWN'); @@ -36,9 +36,9 @@ class FocusDirection_ { @EnumSupportedPlatforms(platforms: [ EnumAndroidPlatform( apiName: 'FOCUS_LEFT', - apiUrl: 'https://developer.android.com/reference/android/view/View#FOCUS_LEFT', - value: 130 - ), + apiUrl: + 'https://developer.android.com/reference/android/view/View#FOCUS_LEFT', + value: 130), ]) static const LEFT = const FocusDirection_._internal('LEFT'); @@ -46,9 +46,9 @@ class FocusDirection_ { @EnumSupportedPlatforms(platforms: [ EnumAndroidPlatform( apiName: 'FOCUS_RIGHT', - apiUrl: 'https://developer.android.com/reference/android/view/View#FOCUS_RIGHT', - value: 130 - ), + apiUrl: + 'https://developer.android.com/reference/android/view/View#FOCUS_RIGHT', + value: 130), ]) static const RIGHT = const FocusDirection_._internal('RIGHT'); -} \ No newline at end of file +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/frame_info.dart b/flutter_inappwebview_platform_interface/lib/src/types/frame_info.dart index 6283a3100..ad8906c8c 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/frame_info.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/frame_info.dart @@ -52,8 +52,12 @@ class FrameInfo_ { FrameKind_? kind; FrameInfo_( - {required this.isMainFrame, required this.request, this.securityOrigin, - this.name, this.frameId, this.kind}); + {required this.isMainFrame, + required this.request, + this.securityOrigin, + this.name, + this.frameId, + this.kind}); } ///An object that contains information about a frame on a webpage. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart b/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart index 8b3a19cda..c3a6c6965 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart @@ -15,10 +15,10 @@ class FrameKind_ { ///Indicates that the frame is an unknown type frame. We may extend this enum type to identify more frame kinds in the future. @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( - apiName: 'COREWEBVIEW2_FRAME_KIND_UNKNOWN', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', - value: 0 - ), + apiName: 'COREWEBVIEW2_FRAME_KIND_UNKNOWN', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', + value: 0), ]) static const UNKNOWN = const FrameKind_._internal('UNKNOWN'); @@ -26,9 +26,9 @@ class FrameKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_FRAME_KIND_MAIN_FRAME', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', - value: 1 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', + value: 1), ]) static const MAIN_FRAME = const FrameKind_._internal('MAIN_FRAME'); @@ -36,9 +36,9 @@ class FrameKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_FRAME_KIND_IFRAME', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', - value: 2 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', + value: 2), ]) static const IFRAME = const FrameKind_._internal('IFRAME'); @@ -46,9 +46,9 @@ class FrameKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_FRAME_KIND_EMBED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', - value: 3 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', + value: 3), ]) static const EMBED = const FrameKind_._internal('EMBED'); @@ -56,9 +56,9 @@ class FrameKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_FRAME_KIND_OBJECT', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', - value: 4 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind', + value: 4), ]) static const OBJECT = const FrameKind_._internal('OBJECT'); -} \ No newline at end of file +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.dart index 7f865fd28..c9704c296 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.dart @@ -65,12 +65,12 @@ class ProcessFailedDetail_ { ]) List? frameInfos; - ProcessFailedDetail_( - {required this.kind, - this.exitCode, - this.processDescription, - this.reason, - this.failureSourceModulePath, - this.frameInfos, - }); -} \ No newline at end of file + ProcessFailedDetail_({ + required this.kind, + this.exitCode, + this.processDescription, + this.reason, + this.failureSourceModulePath, + this.frameInfos, + }); +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart index 2e3d1db73..cee266e32 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart @@ -17,11 +17,12 @@ class ProcessFailedKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', - value: 0 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 0), ]) - static const BROWSER_PROCESS_EXITED = const ProcessFailedKind_._internal('BROWSER_PROCESS_EXITED'); + static const BROWSER_PROCESS_EXITED = + const ProcessFailedKind_._internal('BROWSER_PROCESS_EXITED'); ///Indicates that the main frame's render process ended unexpectedly. Any subframes in the WebView will be gone too. ///A new render process is created automatically and navigated to an error page. @@ -29,11 +30,12 @@ class ProcessFailedKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', - value: 1 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 1), ]) - static const RENDER_PROCESS_EXITED = const ProcessFailedKind_._internal('RENDER_PROCESS_EXITED'); + static const RENDER_PROCESS_EXITED = + const ProcessFailedKind_._internal('RENDER_PROCESS_EXITED'); ///Indicates that the main frame's render process is unresponsive. ///Renderer process unresponsiveness can happen for the following reasons: @@ -51,11 +53,12 @@ class ProcessFailedKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', - value: 2 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 2), ]) - static const RENDER_PROCESS_UNRESPONSIVE = const ProcessFailedKind_._internal('RENDER_PROCESS_UNRESPONSIVE'); + static const RENDER_PROCESS_UNRESPONSIVE = + const ProcessFailedKind_._internal('RENDER_PROCESS_UNRESPONSIVE'); ///Indicates that a frame-only render process ended unexpectedly. ///The process exit does not affect the top-level document, only a subset of the subframes within it. @@ -63,11 +66,12 @@ class ProcessFailedKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_FRAME_RENDER_PROCESS_EXITED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', - value: 3 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 3), ]) - static const FRAME_RENDER_PROCESS_EXITED = const ProcessFailedKind_._internal('FRAME_RENDER_PROCESS_EXITED'); + static const FRAME_RENDER_PROCESS_EXITED = + const ProcessFailedKind_._internal('FRAME_RENDER_PROCESS_EXITED'); ///Indicates that a utility process ended unexpectedly. ///The failed process is recreated automatically. @@ -75,23 +79,26 @@ class ProcessFailedKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_UTILITY_PROCESS_EXITED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', - value: 4 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 4), ]) - static const UTILITY_PROCESS_EXITED = const ProcessFailedKind_._internal('UTILITY_PROCESS_EXITED'); + static const UTILITY_PROCESS_EXITED = + const ProcessFailedKind_._internal('UTILITY_PROCESS_EXITED'); ///Indicates that a sandbox helper process ended unexpectedly. ///This failure is not fatal. ///Your application does not need to handle recovery for this event. @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( - apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_SANDBOX_HELPER_PROCESS_EXITED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', - value: 5 - ), + apiName: + 'COREWEBVIEW2_PROCESS_FAILED_KIND_SANDBOX_HELPER_PROCESS_EXITED', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 5), ]) - static const SANDBOX_HELPER_PROCESS_EXITED = const ProcessFailedKind_._internal('SANDBOX_HELPER_PROCESS_EXITED'); + static const SANDBOX_HELPER_PROCESS_EXITED = + const ProcessFailedKind_._internal('SANDBOX_HELPER_PROCESS_EXITED'); ///Indicates that the GPU process ended unexpectedly. ///The failed process is recreated automatically. @@ -99,11 +106,12 @@ class ProcessFailedKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_GPU_PROCESS_EXITED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', - value: 6 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 6), ]) - static const GPU_PROCESS_EXITED = const ProcessFailedKind_._internal('GPU_PROCESS_EXITED'); + static const GPU_PROCESS_EXITED = + const ProcessFailedKind_._internal('GPU_PROCESS_EXITED'); ///Indicates that a PPAPI plugin process ended unexpectedly. ///This failure is not fatal. @@ -111,11 +119,12 @@ class ProcessFailedKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_PLUGIN_PROCESS_EXITED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', - value: 7 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 7), ]) - static const PPAPI_PLUGIN_PROCESS_EXITED = const ProcessFailedKind_._internal('PPAPI_PLUGIN_PROCESS_EXITED'); + static const PPAPI_PLUGIN_PROCESS_EXITED = + const ProcessFailedKind_._internal('PPAPI_PLUGIN_PROCESS_EXITED'); ///Indicates that a PPAPI plugin broker process ended unexpectedly. ///This failure is not fatal. @@ -123,19 +132,21 @@ class ProcessFailedKind_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_BROKER_PROCESS_EXITED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', - value: 8 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 8), ]) - static const PPAPI_BROKER_PROCESS_EXITED = const ProcessFailedKind_._internal('PPAPI_BROKER_PROCESS_EXITED'); + static const PPAPI_BROKER_PROCESS_EXITED = + const ProcessFailedKind_._internal('PPAPI_BROKER_PROCESS_EXITED'); ///Indicates that a process of unspecified kind ended unexpectedly. @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_KIND_UNKNOWN_PROCESS_EXITED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', - value: 9 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind', + value: 9), ]) - static const UNKNOWN_PROCESS_EXITED = const ProcessFailedKind_._internal('UNKNOWN_PROCESS_EXITED'); -} \ No newline at end of file + static const UNKNOWN_PROCESS_EXITED = + const ProcessFailedKind_._internal('UNKNOWN_PROCESS_EXITED'); +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart index b21afbc4b..647e6e887 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart @@ -16,9 +16,9 @@ class ProcessFailedReason_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_UNEXPECTED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', - value: 0 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 0), ]) static const UNEXPECTED = const ProcessFailedReason_._internal('UNEXPECTED'); @@ -26,19 +26,20 @@ class ProcessFailedReason_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_UNRESPONSIVE', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', - value: 1 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 1), ]) - static const UNRESPONSIVE = const ProcessFailedReason_._internal('UNRESPONSIVE'); + static const UNRESPONSIVE = + const ProcessFailedReason_._internal('UNRESPONSIVE'); ///The process was terminated. For example, from Task Manager. @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_TERMINATED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', - value: 2 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 2), ]) static const TERMINATED = const ProcessFailedReason_._internal('TERMINATED'); @@ -46,9 +47,9 @@ class ProcessFailedReason_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_CRASHED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', - value: 3 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 3), ]) static const CRASHED = const ProcessFailedReason_._internal('CRASHED'); @@ -56,19 +57,21 @@ class ProcessFailedReason_ { @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_LAUNCH_FAILED', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', - value: 4 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 4), ]) - static const LAUNCH_FAILED = const ProcessFailedReason_._internal('LAUNCH_FAILED'); + static const LAUNCH_FAILED = + const ProcessFailedReason_._internal('LAUNCH_FAILED'); ///The process terminated due to running out of memory. @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_PROCESS_FAILED_REASON_OUT_OF_MEMORY', - apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', - value: 5 - ), + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason', + value: 5), ]) - static const OUT_OF_MEMORY = const ProcessFailedReason_._internal('OUT_OF_MEMORY'); -} \ No newline at end of file + static const OUT_OF_MEMORY = + const ProcessFailedReason_._internal('OUT_OF_MEMORY'); +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/ssl_error_type.dart b/flutter_inappwebview_platform_interface/lib/src/types/ssl_error_type.dart index 0b114bce1..a8348cdb3 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/ssl_error_type.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/ssl_error_type.dart @@ -36,7 +36,7 @@ class SslErrorType_ { EnumWindowsPlatform( apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_EXPIRED', apiUrl: - 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status', + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status', value: 2) ]) static const EXPIRED = SslErrorType_._internal('EXPIRED'); @@ -91,7 +91,7 @@ class SslErrorType_ { EnumWindowsPlatform( apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_IS_INVALID', apiUrl: - 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status', + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status', value: 5) ]) static const INVALID = SslErrorType_._internal('INVALID'); @@ -201,9 +201,10 @@ class SslErrorType_ { 'https://developer.apple.com/documentation/security/sectrustresulttype/othererror', value: 7), EnumWindowsPlatform( - apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_CLIENT_CERTIFICATE_CONTAINS_ERRORS', + apiName: + 'COREWEBVIEW2_WEB_ERROR_STATUS_CLIENT_CERTIFICATE_CONTAINS_ERRORS', apiUrl: - 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status', + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status', value: 3) ]) static const OTHER_ERROR = SslErrorType_._internal('OTHER_ERROR'); @@ -211,19 +212,21 @@ class SslErrorType_ { ///Indicates that the SSL certificate common name does not match the web address. @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( - apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_COMMON_NAME_IS_INCORRECT', + apiName: + 'COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_COMMON_NAME_IS_INCORRECT', apiUrl: - 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status', + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status', value: 1) ]) - static const COMMON_NAME_IS_INCORRECT = SslErrorType_._internal('COMMON_NAME_IS_INCORRECT'); + static const COMMON_NAME_IS_INCORRECT = + SslErrorType_._internal('COMMON_NAME_IS_INCORRECT'); ///Indicates that the SSL certificate has been revoked. @EnumSupportedPlatforms(platforms: [ EnumWindowsPlatform( apiName: 'COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_REVOKED', apiUrl: - 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status', + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status', value: 4) ]) static const REVOKED = SslErrorType_._internal('REVOKED'); diff --git a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart index 084d6e3b7..b8cc2e12f 100644 --- a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart @@ -890,9 +890,13 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController Map arguments = call.arguments.cast(); - if (arguments['protectionSpace'] is Map && arguments['protectionSpace']['sslCertificate'] is Map && - arguments['protectionSpace']['sslCertificate']['x509Certificate'] is String) { - arguments['protectionSpace']['sslCertificate']['x509Certificate'] = utf8.encode(arguments['protectionSpace']['sslCertificate']['x509Certificate']); + if (arguments['protectionSpace'] is Map && + arguments['protectionSpace']['sslCertificate'] is Map && + arguments['protectionSpace']['sslCertificate']['x509Certificate'] + is String) { + arguments['protectionSpace']['sslCertificate']['x509Certificate'] = + utf8.encode(arguments['protectionSpace']['sslCertificate'] + ['x509Certificate']); } HttpAuthenticationChallenge challenge = @@ -916,9 +920,13 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController Map arguments = call.arguments.cast(); - if (arguments['protectionSpace'] is Map && arguments['protectionSpace']['sslCertificate'] is Map && - arguments['protectionSpace']['sslCertificate']['x509Certificate'] is String) { - arguments['protectionSpace']['sslCertificate']['x509Certificate'] = utf8.encode(arguments['protectionSpace']['sslCertificate']['x509Certificate']); + if (arguments['protectionSpace'] is Map && + arguments['protectionSpace']['sslCertificate'] is Map && + arguments['protectionSpace']['sslCertificate']['x509Certificate'] + is String) { + arguments['protectionSpace']['sslCertificate']['x509Certificate'] = + utf8.encode(arguments['protectionSpace']['sslCertificate'] + ['x509Certificate']); } ServerTrustChallenge challenge = @@ -942,18 +950,22 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController Map arguments = call.arguments.cast(); - if (arguments['protectionSpace'] is Map && arguments['protectionSpace']['sslCertificate'] is Map && - arguments['protectionSpace']['sslCertificate']['x509Certificate'] is String) { - arguments['protectionSpace']['sslCertificate']['x509Certificate'] = utf8.encode(arguments['protectionSpace']['sslCertificate']['x509Certificate']); + if (arguments['protectionSpace'] is Map && + arguments['protectionSpace']['sslCertificate'] is Map && + arguments['protectionSpace']['sslCertificate']['x509Certificate'] + is String) { + arguments['protectionSpace']['sslCertificate']['x509Certificate'] = + utf8.encode(arguments['protectionSpace']['sslCertificate'] + ['x509Certificate']); } arguments['mutuallyTrustedCertificates'] = (arguments['mutuallyTrustedCertificates'] as List) .cast>() .map((c) { - c['x509Certificate'] = utf8.encode(c['x509Certificate']); - return c; - }).toList(); + c['x509Certificate'] = utf8.encode(c['x509Certificate']); + return c; + }).toList(); ClientCertChallenge challenge = ClientCertChallenge.fromMap(arguments)!; @@ -1428,18 +1440,16 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController } break; case "onProcessFailed": - if ((webviewParams != null && - webviewParams!.onProcessFailed != null) || + if ((webviewParams != null && webviewParams!.onProcessFailed != null) || _inAppBrowserEventHandler != null) { - Map arguments = call.arguments.cast(); + Map arguments = + call.arguments.cast(); final detail = ProcessFailedDetail.fromMap(arguments)!; - if (webviewParams != null && - webviewParams!.onProcessFailed != null) + if (webviewParams != null && webviewParams!.onProcessFailed != null) webviewParams!.onProcessFailed!(_controllerFromPlatform, detail); else - _inAppBrowserEventHandler! - .onProcessFailed(detail); + _inAppBrowserEventHandler!.onProcessFailed(detail); } break; case "onCallJsHandler": From 9a03fecd8ab32ff62f984b689331898ac0025cc6 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Tue, 5 Nov 2024 10:12:10 +0100 Subject: [PATCH 058/181] Update in_app_webview_settings.dart --- .../in_app_webview_settings.dart | 269 ++++++++++++++++-- 1 file changed, 242 insertions(+), 27 deletions(-) diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart index 2b0f896f0..1d33b0a1f 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart @@ -1,23 +1,16 @@ -import 'dart:typed_data'; - import 'package:flutter/foundation.dart'; import 'package:flutter/widgets.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; +import 'dart:typed_data'; -import '../content_blocker.dart'; -import '../context_menu/context_menu.dart'; -import '../in_app_browser/in_app_browser_settings.dart'; -import '../in_app_browser/platform_in_app_browser.dart'; -import '../in_app_webview/platform_inappwebview_controller.dart'; import '../platform_webview_asset_loader.dart'; -import '../platform_webview_feature.dart'; import '../types/action_mode_menu_item.dart'; import '../types/cache_mode.dart'; import '../types/data_detector_types.dart'; import '../types/force_dark.dart'; import '../types/force_dark_strategy.dart'; import '../types/layout_algorithm.dart'; -import '../types/main.dart'; import '../types/mixed_content_mode.dart'; import '../types/over_scroll_mode.dart'; import '../types/referrer_policy.dart'; @@ -29,10 +22,18 @@ import '../types/scrollview_deceleration_rate.dart'; import '../types/selection_granularity.dart'; import '../types/user_preferred_content_mode.dart'; import '../types/vertical_scrollbar_position.dart'; -import '../util.dart'; +import '../types/user_script.dart'; import '../web_uri.dart'; import 'android/in_app_webview_options.dart'; import 'apple/in_app_webview_options.dart'; +import '../content_blocker.dart'; +import '../types/main.dart'; +import '../util.dart'; +import '../in_app_browser/in_app_browser_settings.dart'; +import '../platform_webview_feature.dart'; +import '../in_app_webview/platform_inappwebview_controller.dart'; +import '../context_menu/context_menu.dart'; +import '../in_app_browser/platform_in_app_browser.dart'; import 'platform_webview.dart'; part 'in_app_webview_settings.g.dart'; @@ -58,8 +59,12 @@ class InAppWebViewSettings_ { ///If the [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event is implemented and this value is `null`, ///it will be automatically inferred as `true`, otherwise, the default value is `false`. ///This logic will not be applied for [PlatformInAppBrowser], where you must set the value manually. - @SupportedPlatforms( - platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform() + ]) bool? useShouldOverrideUrlLoading; ///Set to `true` to be able to listen at the [PlatformWebViewCreationParams.onLoadResource] event. @@ -99,7 +104,11 @@ class InAppWebViewSettings_ { MacOSPlatform( apiName: "WKWebView.customUserAgent", apiUrl: - "https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent") + "https://developer.apple.com/documentation/webkit/wkwebview/1414950-customuseragent"), + WindowsPlatform( + apiName: 'ICoreWebView2Settings2.put_UserAgent', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings2?view=webview2-1.0.2210.55#put_useragent') ]) String? userAgent; @@ -131,7 +140,11 @@ class InAppWebViewSettings_ { apiName: "WKWebpagePreferences.allowsContentJavaScript", apiUrl: "https://developer.apple.com/documentation/webkit/wkwebpagepreferences/3552422-allowscontentjavascript/"), - WebPlatform(requiresSameOrigin: false) + WebPlatform(requiresSameOrigin: false), + WindowsPlatform( + apiName: "ICoreWebView2Settings.put_IsScriptEnabled", + apiUrl: + "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_isscriptenabled") ]) bool? javaScriptEnabled; @@ -295,7 +308,11 @@ class InAppWebViewSettings_ { """setting this to `true`, it will clear all the cookies of all WebView instances, because there isn't any way to make the website data store non-persistent for the specific WebView instance such as on iOS."""), IOSPlatform(), - MacOSPlatform() + MacOSPlatform(), + WindowsPlatform( + apiName: "ICoreWebView2ControllerOptions.put_IsInPrivateModeEnabled", + apiUrl: + "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controlleroptions?view=webview2-1.0.2792.45#put_isinprivatemodeenabled") ]) bool? incognito; @@ -308,7 +325,12 @@ because there isn't any way to make the website data store non-persistent for th @SupportedPlatforms(platforms: [ AndroidPlatform(), IOSPlatform(), - MacOSPlatform(available: "12.0") + MacOSPlatform(available: "12.0"), + WindowsPlatform( + available: '1.0.774.44', + apiName: 'ICoreWebView2Controller2.put_DefaultBackgroundColor', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller2?view=webview2-1.0.2210.55#put_defaultbackgroundcolor') ]) bool? transparentBackground; @@ -323,8 +345,15 @@ because there isn't any way to make the website data store non-persistent for th bool? disableHorizontalScroll; ///Set to `true` to disable context menu. The default value is `false`. - @SupportedPlatforms( - platforms: [AndroidPlatform(), IOSPlatform(), WebPlatform()]) + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + WebPlatform(), + WindowsPlatform( + apiName: "ICoreWebView2Settings.put_AreDefaultContextMenusEnabled", + apiUrl: + "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredefaultcontextmenusenabled") + ]) bool? disableContextMenu; ///Set to `false` if the WebView should not support zooming using its on-screen zoom controls and gestures. The default value is `true`. @@ -334,7 +363,11 @@ because there isn't any way to make the website data store non-persistent for th apiUrl: "https://developer.android.com/reference/android/webkit/WebSettings?hl=en#setSupportZoom(boolean)"), IOSPlatform(), - MacOSPlatform() + MacOSPlatform(), + WindowsPlatform( + apiName: "ICoreWebView2Settings.put_IsZoomControlEnabled", + apiUrl: + "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_iszoomcontrolenabled") ]) bool? supportZoom; @@ -591,7 +624,16 @@ because there isn't any way to make the website data store non-persistent for th ]) String? fixedFontFamily; + ///Use [algorithmicDarkeningAllowed] instead. + /// ///Set the force dark mode for this WebView. The default value is [ForceDark.OFF]. + /// + ///Deprecated - The "force dark" model previously implemented by WebView was complex and didn't + ///interoperate well with current Web standards for `prefers-color-scheme` and `color-scheme`. + ///In apps with `targetSdkVersion` ≥ `android.os.Build.VERSION_CODES.TIRAMISU` this API is a no-op and + ///WebView will always use the dark style defined by web content authors if the app's theme is dark. + ///To customize the behavior, refer to [algorithmicDarkeningAllowed]. + @Deprecated("Use algorithmicDarkeningAllowed instead") @SupportedPlatforms(platforms: [ AndroidPlatform( available: "29", @@ -601,10 +643,17 @@ because there isn't any way to make the website data store non-persistent for th ]) ForceDark_? forceDark; - ///Sets whether Geolocation API is enabled. The default value is `true`. - + ///Use [algorithmicDarkeningAllowed] instead. + /// ///Set how WebView content should be darkened. ///The default value is [ForceDarkStrategy.PREFER_WEB_THEME_OVER_USER_AGENT_DARKENING]. + /// + ///Deprecated - The "force dark" model previously implemented by WebView was complex and didn't + ///interoperate well with current Web standards for `prefers-color-scheme` and `color-scheme`. + ///In apps with `targetSdkVersion` ≥ `android.os.Build.VERSION_CODES.TIRAMISU` this API is a no-op and + ///WebView will always use the dark style defined by web content authors if the app's theme is dark. + ///To customize the behavior, refer to [algorithmicDarkeningAllowed]. + @Deprecated("Use algorithmicDarkeningAllowed instead") @SupportedPlatforms(platforms: [ AndroidPlatform( apiName: "WebSettingsCompat.setForceDarkStrategy", @@ -778,8 +827,8 @@ because there isn't any way to make the website data store non-persistent for th @SupportedPlatforms(platforms: [AndroidPlatform()]) String? regexToCancelSubFramesLoading; - ///Regular expression used by [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event to cancel navigation requests - ///If the url request not matches the regular expression, then the shouldOverrideUrlLoading is return false. + ///Regular expression used by [PlatformWebViewCreationParams.shouldOverrideUrlLoading] event to cancel navigation requests. + ///If the url request doesn't match the regular expression, then the request is canceled. @SupportedPlatforms(platforms: [AndroidPlatform()]) String? regexToCancelOverrideUrlLoading; @@ -1543,7 +1592,11 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri available: "13.3", apiName: "WKWebView.isInspectable", apiUrl: - "https://developer.apple.com/documentation/webkit/wkwebview/4111163-isinspectable") + "https://developer.apple.com/documentation/webkit/wkwebview/4111163-isinspectable"), + WindowsPlatform( + apiName: "ICoreWebView2Settings.put_AreDevToolsEnabled", + apiUrl: + "https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2settings?view=webview2-1.0.2210.55#put_aredevtoolsenabled") ]) bool? isInspectable; @@ -1564,6 +1617,139 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri ]) bool? shouldPrintBackgrounds; + ///A [Set] of Regular Expression Patterns that will be used on native side to match the allowed origins + ///that are able to execute the JavaScript Handlers defined for the current WebView. + ///This will affect also the internal JavaScript Handlers used by the plugin itself. + /// + ///An empty [Set] will block every origin. + /// + ///The default value is `null` and will allow every origin. + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform(), + ]) + Set? javaScriptHandlersOriginAllowList; + + ///Set to `true` to allow to execute the JavaScript Handlers only on the main frame. + ///This will affect also the internal JavaScript Handlers used by the plugin itself. + ///The default value is `false`. + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform(), + ]) + bool? javaScriptHandlersForMainFrameOnly; + + ///Set to `false` to disable the JavaScript Bridge completely. + ///This will affect also all the internal plugin [UserScript]s + ///that are using the JavaScript Bridge to work. + /// + ///**NOTE**: setting or changing this value after the WebView has been created won't have any effect. + ///It should be set when initializing the WebView through [PlatformWebViewCreationParams.initialSettings] parameter. + /// + ///The default value is `true`. + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform(), + ]) + bool? javaScriptBridgeEnabled; + + ///A [Set] of patterns that will be used to match the allowed origins where + ///the JavaScript Bridge could be used. + ///If [pluginScriptsOriginAllowList] is present, then this value will override + ///it only for the JavaScript Bridge internal plugin. + ///Adding `'*'` as an allowed origin or setting this to `null`, it means it will allow every origin. + ///Instead, an empty [Set] will block every origin and, in this case, + ///it will force the behaviour of the [javaScriptBridgeEnabled] parameter, + ///as it was set to `false`. + /// + ///**NOTE**: setting or changing this value after the WebView has been created won't have any effect. + ///It should be set when initializing the WebView through [PlatformWebViewCreationParams.initialSettings] parameter. + /// + ///**NOTE for Android**: each origin pattern MUST follow the table rule of [PlatformInAppWebViewController.addWebMessageListener]. + /// + ///**NOTE for iOS, macOS, Windows**: each origin pattern will be used as a + ///Regular Expression Pattern that will be used on JavaScript side using [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp). + /// + ///The default value is `null` and will allow every origin. + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform(), + ]) + Set? javaScriptBridgeOriginAllowList; + + ///Set to `true` to allow the JavaScript Bridge only on the main frame. + ///If [pluginScriptsForMainFrameOnly] is present, then this value will override + ///it only for the JavaScript Bridge internal plugin. + /// + ///**NOTE**: setting or changing this value after the WebView has been created won't have any effect. + ///It should be set when initializing the WebView through [PlatformWebViewCreationParams.initialSettings] parameter. + /// + ///The default value is `false`. + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform(), + ]) + bool? javaScriptBridgeForMainFrameOnly; + + ///A [Set] of patterns that will be used to match the allowed origins + ///that are able to load all the internal plugin [UserScript]s used by the plugin itself. + ///Adding `'*'` as an allowed origin or setting this to `null`, it means it will allow every origin. + ///Instead, an empty [Set] will block every origin. + /// + ///**NOTE**: If [javaScriptBridgeOriginAllowList] is not present, this value will affect also the JavaScript Bridge internal plugin. + ///Also, setting or changing this value after the WebView has been created won't have any effect. + ///It should be set when initializing the WebView through [PlatformWebViewCreationParams.initialSettings] parameter. + /// + ///**NOTE for Android**: each origin pattern MUST follow the table rule of [PlatformInAppWebViewController.addWebMessageListener]. + /// + ///**NOTE for iOS, macOS, Windows**: each origin pattern will be used as a + ///Regular Expression Pattern that will be used on JavaScript side using [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp). + /// + ///The default value is `null` and will allow every origin. + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform(), + ]) + Set? pluginScriptsOriginAllowList; + + ///Set to `true` to allow internal plugin [UserScript]s only on the main frame. + /// + ///**NOTE**: If [javaScriptBridgeForMainFrameOnly] is not present, this value will affect also the JavaScript Bridge internal plugin. + ///Also, setting or changing this value after the WebView has been created won't have any effect. + ///It should be set when initializing the WebView through [PlatformWebViewCreationParams.initialSettings] parameter. + /// + ///The default value is `false`. + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WindowsPlatform(), + ]) + bool? pluginScriptsForMainFrameOnly; + + ///The multiplier applied to the scroll amount for the WebView. + /// + ///This value determines how much the content will scroll in response to user input. + ///A higher value means faster scrolling, while a lower value means slower scrolling. + /// + ///The default value is `1`. + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + int? scrollMultiplier; + ///Specifies a feature policy for the `. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///- Windows WebView2 String? name; ///The frame’s current request. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS - ///- Windows + ///- iOS WKWebView + ///- macOS WKWebView + ///- Windows WebView2 URLRequest? request; ///The frame’s security origin. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS - ///- Windows + ///- iOS WKWebView + ///- macOS WKWebView + ///- Windows WebView2 SecurityOrigin? securityOrigin; FrameInfo( {this.frameId, diff --git a/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart b/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart index c3a6c6965..a4afe1575 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.dart @@ -9,7 +9,7 @@ class FrameKind_ { // ignore: unused_field final String _value; // ignore: unused_field - final dynamic _nativeValue = null; + final int? _nativeValue = null; const FrameKind_._internal(this._value); ///Indicates that the frame is an unknown type frame. We may extend this enum type to identify more frame kinds in the future. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.g.dart index a4162c3e0..0c47a6451 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/frame_kind.g.dart @@ -9,7 +9,7 @@ part of 'frame_kind.dart'; ///Class used to indicate the the frame kind. class FrameKind { final String _value; - final dynamic _nativeValue; + final int? _nativeValue; const FrameKind._internal(this._value, this._nativeValue); // ignore: unused_element factory FrameKind._internalMultiPlatform( @@ -19,7 +19,7 @@ class FrameKind { ///Indicates that the frame is an embed element. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_FRAME_KIND_EMBED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_FRAME_KIND_EMBED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) static final EMBED = FrameKind._internalMultiPlatform('EMBED', () { switch (defaultTargetPlatform) { case TargetPlatform.windows: @@ -33,7 +33,7 @@ class FrameKind { ///Indicates that the frame is an iframe. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_FRAME_KIND_IFRAME](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_FRAME_KIND_IFRAME](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) static final IFRAME = FrameKind._internalMultiPlatform('IFRAME', () { switch (defaultTargetPlatform) { case TargetPlatform.windows: @@ -47,7 +47,7 @@ class FrameKind { ///Indicates that the frame is a primary main frame(webview). /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_FRAME_KIND_MAIN_FRAME](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_FRAME_KIND_MAIN_FRAME](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) static final MAIN_FRAME = FrameKind._internalMultiPlatform('MAIN_FRAME', () { switch (defaultTargetPlatform) { case TargetPlatform.windows: @@ -61,7 +61,7 @@ class FrameKind { ///Indicates that the frame is an object element. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_FRAME_KIND_OBJECT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_FRAME_KIND_OBJECT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) static final OBJECT = FrameKind._internalMultiPlatform('OBJECT', () { switch (defaultTargetPlatform) { case TargetPlatform.windows: @@ -75,7 +75,7 @@ class FrameKind { ///Indicates that the frame is an unknown type frame. We may extend this enum type to identify more frame kinds in the future. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_FRAME_KIND_UNKNOWN](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_FRAME_KIND_UNKNOWN](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_frame_kind)) static final UNKNOWN = FrameKind._internalMultiPlatform('UNKNOWN', () { switch (defaultTargetPlatform) { case TargetPlatform.windows: @@ -109,7 +109,7 @@ class FrameKind { } ///Gets a possible [FrameKind] instance from a native value. - static FrameKind? fromNativeValue(dynamic value) { + static FrameKind? fromNativeValue(int? value) { if (value != null) { try { return FrameKind.values @@ -152,8 +152,8 @@ class FrameKind { ///Gets [String] value. String toValue() => _value; - ///Gets [dynamic] native value. - dynamic toNativeValue() => _nativeValue; + ///Gets [int] native value if supported by the current platform, otherwise `null`. + int? toNativeValue() => _nativeValue; ///Gets the name of the value. String name() { @@ -178,6 +178,11 @@ class FrameKind { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response_action.g.dart index 664ce22d8..192ff0dda 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/http_auth_response_action.g.dart @@ -19,27 +19,27 @@ class HttpAuthResponseAction { ///Instructs the WebView to cancel the authentication request. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Windows + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Windows WebView2 static const CANCEL = HttpAuthResponseAction._internal(0, 0); ///Instructs the WebView to proceed with the authentication with the given credentials. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Windows + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Windows WebView2 static const PROCEED = HttpAuthResponseAction._internal(1, 1); ///Uses the credentials stored for the current host. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView static const USE_SAVED_HTTP_AUTH_CREDENTIALS = HttpAuthResponseAction._internal(2, 2); @@ -131,6 +131,11 @@ class HttpAuthResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/http_cookie_same_site_policy.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/http_cookie_same_site_policy.g.dart index 7da454fc6..980fde6b0 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/http_cookie_same_site_policy.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/http_cookie_same_site_policy.g.dart @@ -121,6 +121,11 @@ class HTTPCookieSameSitePolicy { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result_type.g.dart index c395c99f3..abfe2fa96 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_hit_test_result_type.g.dart @@ -145,6 +145,11 @@ class InAppWebViewHitTestResultType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart index bfe52cee7..b7b5ee91d 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/in_app_webview_initial_data.g.dart @@ -24,7 +24,7 @@ class InAppWebViewInitialData { ///The URL to use as the history entry. If `null` defaults to `about:blank`. If non-null, this must be a valid URL. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView WebUri? historyUrl; ///The MIME type of the data, e.g. "text/html". The default value is `"text/html"`. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_alert_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_request.g.dart index 1e8951577..d907fc39e 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_alert_request.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_request.g.dart @@ -15,8 +15,8 @@ class JsAlertRequest { ///Indicates whether the request was made for the main frame. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView bool? isMainFrame; ///Message to be displayed in the window. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response_action.g.dart index cef0b42bc..8327945a3 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_alert_response_action.g.dart @@ -101,6 +101,11 @@ class JsAlertResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response_action.g.dart index eda8d59ce..984769d13 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_before_unload_response_action.g.dart @@ -108,6 +108,11 @@ class JsBeforeUnloadResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_request.g.dart index 6d3497c3a..7d398c110 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_request.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_request.g.dart @@ -15,8 +15,8 @@ class JsConfirmRequest { ///Indicates whether the request was made for the main frame. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView bool? isMainFrame; ///Message to be displayed in the window. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response_action.g.dart index fff5abf6b..be17478a7 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_confirm_response_action.g.dart @@ -107,6 +107,11 @@ class JsConfirmResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_request.g.dart index 7ec6fad89..097b29844 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_request.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_request.g.dart @@ -18,8 +18,8 @@ class JsPromptRequest { ///Indicates whether the request was made for the main frame. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView bool? isMainFrame; ///Message to be displayed in the window. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response_action.g.dart index ff4257fb4..ddd317b9f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/js_prompt_response_action.g.dart @@ -107,6 +107,11 @@ class JsPromptResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/layout_algorithm.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/layout_algorithm.g.dart index 0f47008ee..2f7a6857e 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/layout_algorithm.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/layout_algorithm.g.dart @@ -117,6 +117,11 @@ class LayoutAlgorithm { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; @@ -237,6 +242,11 @@ class AndroidLayoutAlgorithm { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/layout_in_display_cutout_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/layout_in_display_cutout_mode.g.dart index db21271b9..c941ab7f6 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/layout_in_display_cutout_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/layout_in_display_cutout_mode.g.dart @@ -128,6 +128,11 @@ class LayoutInDisplayCutoutMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -262,6 +267,11 @@ class AndroidLayoutInDisplayCutoutMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/media_capture_state.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/media_capture_state.g.dart index 73cdcad5e..0db6b3a76 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/media_capture_state.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/media_capture_state.g.dart @@ -113,6 +113,11 @@ class MediaCaptureState { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/media_playback_state.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/media_playback_state.g.dart index 62b8d7642..69f6c9267 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/media_playback_state.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/media_playback_state.g.dart @@ -119,6 +119,11 @@ class MediaPlaybackState { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/mixed_content_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/mixed_content_mode.g.dart index 5d75fd1b2..ba7f4dbe2 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/mixed_content_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/mixed_content_mode.g.dart @@ -120,6 +120,11 @@ class MixedContentMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -247,6 +252,11 @@ class AndroidMixedContentMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/modal_presentation_style.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/modal_presentation_style.g.dart index c784d481d..3786dbdf9 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/modal_presentation_style.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/modal_presentation_style.g.dart @@ -157,6 +157,11 @@ class ModalPresentationStyle { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -318,6 +323,11 @@ class IOSUIModalPresentationStyle { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/modal_transition_style.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/modal_transition_style.g.dart index 56222c794..9816e993e 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/modal_transition_style.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/modal_transition_style.g.dart @@ -125,6 +125,11 @@ class ModalTransitionStyle { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -253,6 +258,11 @@ class IOSUIModalTransitionStyle { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.g.dart index b69730c60..ddbb26920 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.g.dart @@ -21,13 +21,11 @@ class NavigationAction { ///the sequence of events which caused the request to be created was initiated by a user ///gesture. /// - ///**NOTE for Android native WebView**: On Android < 21, this is always `false` - /// - ///**NOTE for Windows**: Available only if the request is associated to the [PlatformWebViewCreationParams.onCreateWindow] event - /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView 21+ ([Official API - WebResourceRequest.hasGesture](https://developer.android.com/reference/android/webkit/WebResourceRequest#hasGesture())) - ///- Windows + ///- Android WebView 21+ ([Official API - WebResourceRequest.hasGesture](https://developer.android.com/reference/android/webkit/WebResourceRequest#hasGesture())): + /// - On Android < 21, this is always `false` + ///- Windows WebView2 : + /// - Available only if the request is associated to the [PlatformWebViewCreationParams.onCreateWindow] event bool? hasGesture; ///Use [sourceFrame] instead. @@ -54,16 +52,16 @@ class NavigationAction { ///Also, on Android < 21, this is always `false`. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView 21+ ([Official API - WebResourceRequest.isRedirect](https://developer.android.com/reference/android/webkit/WebResourceRequest#isRedirect())) - ///- Windows + ///- Android WebView 21+ ([Official API - WebResourceRequest.isRedirect](https://developer.android.com/reference/android/webkit/WebResourceRequest#isRedirect())) + ///- Windows WebView2 bool? isRedirect; ///The type of action triggering the navigation. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKNavigationAction.navigationType](https://developer.apple.com/documentation/webkit/wknavigationaction/1401914-navigationtype)) - ///- MacOS ([Official API - WKNavigationAction.navigationType](https://developer.apple.com/documentation/webkit/wknavigationaction/1401914-navigationtype)) - ///- Windows + ///- iOS WKWebView ([Official API - WKNavigationAction.navigationType](https://developer.apple.com/documentation/webkit/wknavigationaction/1401914-navigationtype)) + ///- macOS WKWebView ([Official API - WKNavigationAction.navigationType](https://developer.apple.com/documentation/webkit/wknavigationaction/1401914-navigationtype)) + ///- Windows WebView2 NavigationType? navigationType; ///The URL request object associated with the navigation action. @@ -77,22 +75,22 @@ class NavigationAction { ///A value indicating whether the web content used a download attribute to indicate that this should be downloaded. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS 14.5+ ([Official API - WKNavigationAction.shouldPerformDownload](https://developer.apple.com/documentation/webkit/wknavigationaction/3727357-shouldperformdownload)) - ///- MacOS 11.3+ ([Official API - WKNavigationAction.shouldPerformDownload](https://developer.apple.com/documentation/webkit/wknavigationaction/3727357-shouldperformdownload)) + ///- iOS WKWebView 14.5+ ([Official API - WKNavigationAction.shouldPerformDownload](https://developer.apple.com/documentation/webkit/wknavigationaction/3727357-shouldperformdownload)) + ///- macOS WKWebView 11.3+ ([Official API - WKNavigationAction.shouldPerformDownload](https://developer.apple.com/documentation/webkit/wknavigationaction/3727357-shouldperformdownload)) bool? shouldPerformDownload; ///The frame that requested the navigation. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKNavigationAction.sourceFrame](https://developer.apple.com/documentation/webkit/wknavigationaction/1401926-sourceframe)) - ///- MacOS ([Official API - WKNavigationAction.sourceFrame](https://developer.apple.com/documentation/webkit/wknavigationaction/1401926-sourceframe)) + ///- iOS WKWebView ([Official API - WKNavigationAction.sourceFrame](https://developer.apple.com/documentation/webkit/wknavigationaction/1401926-sourceframe)) + ///- macOS WKWebView ([Official API - WKNavigationAction.sourceFrame](https://developer.apple.com/documentation/webkit/wknavigationaction/1401926-sourceframe)) FrameInfo? sourceFrame; ///The frame in which to display the new content. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKNavigationAction.targetFrame](https://developer.apple.com/documentation/webkit/wknavigationaction/1401918-targetframe)) - ///- MacOS ([Official API - WKNavigationAction.targetFrame](https://developer.apple.com/documentation/webkit/wknavigationaction/1401918-targetframe)) + ///- iOS WKWebView ([Official API - WKNavigationAction.targetFrame](https://developer.apple.com/documentation/webkit/wknavigationaction/1401918-targetframe)) + ///- macOS WKWebView ([Official API - WKNavigationAction.targetFrame](https://developer.apple.com/documentation/webkit/wknavigationaction/1401918-targetframe)) FrameInfo? targetFrame; NavigationAction( {@Deprecated('Use hasGesture instead') this.androidHasGesture, diff --git a/flutter_inappwebview_platform_interface/lib/src/types/navigation_action_policy.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action_policy.g.dart index 90636aa90..464d56e40 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/navigation_action_policy.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action_policy.g.dart @@ -116,6 +116,11 @@ class NavigationActionPolicy { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/navigation_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_response_action.g.dart index 6f1e4183e..088811d79 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/navigation_response_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/navigation_response_action.g.dart @@ -116,6 +116,11 @@ class NavigationResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -227,6 +232,11 @@ class IOSNavigationResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/navigation_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_type.g.dart index 4954e7c7b..665d9a5c5 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/navigation_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/navigation_type.g.dart @@ -19,9 +19,9 @@ class NavigationType { ///An item from the back-forward list was requested. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted)) - ///- MacOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted)) - ///- Windows ([Official API - COREWEBVIEW2_NAVIGATION_KIND_BACK_OR_FORWARD](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind)) + ///- iOS WKWebView ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted)) + ///- macOS WKWebView ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_NAVIGATION_KIND_BACK_OR_FORWARD](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind)) static final BACK_FORWARD = NavigationType._internalMultiPlatform('BACK_FORWARD', () { switch (defaultTargetPlatform) { @@ -40,8 +40,8 @@ class NavigationType { ///A form was resubmitted (for example by going back, going forward, or reloading). /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted)) - ///- MacOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted)) + ///- iOS WKWebView ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted)) + ///- macOS WKWebView ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formresubmitted)) static final FORM_RESUBMITTED = NavigationType._internalMultiPlatform('FORM_RESUBMITTED', () { switch (defaultTargetPlatform) { @@ -58,8 +58,8 @@ class NavigationType { ///A form was submitted. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted)) - ///- MacOS ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted)) + ///- iOS WKWebView ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted)) + ///- macOS WKWebView ([Official API - WKNavigationType.formSubmitted](https://developer.apple.com/documentation/webkit/wknavigationtype/formsubmitted)) static final FORM_SUBMITTED = NavigationType._internalMultiPlatform('FORM_SUBMITTED', () { switch (defaultTargetPlatform) { @@ -76,9 +76,9 @@ class NavigationType { ///A link with an href attribute was activated by the user. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKNavigationType.linkActivated](https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated)) - ///- MacOS ([Official API - WKNavigationType.linkActivated](https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated)) - ///- Windows + ///- iOS WKWebView ([Official API - WKNavigationType.linkActivated](https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated)) + ///- macOS WKWebView ([Official API - WKNavigationType.linkActivated](https://developer.apple.com/documentation/webkit/wknavigationtype/linkactivated)) + ///- Windows WebView2 static final LINK_ACTIVATED = NavigationType._internalMultiPlatform('LINK_ACTIVATED', () { switch (defaultTargetPlatform) { @@ -97,9 +97,9 @@ class NavigationType { ///Navigation is taking place for some other reason. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKNavigationType.other](https://developer.apple.com/documentation/webkit/wknavigationtype/other)) - ///- MacOS ([Official API - WKNavigationType.other](https://developer.apple.com/documentation/webkit/wknavigationtype/other)) - ///- Windows + ///- iOS WKWebView ([Official API - WKNavigationType.other](https://developer.apple.com/documentation/webkit/wknavigationtype/other)) + ///- macOS WKWebView ([Official API - WKNavigationType.other](https://developer.apple.com/documentation/webkit/wknavigationtype/other)) + ///- Windows WebView2 static final OTHER = NavigationType._internalMultiPlatform('OTHER', () { switch (defaultTargetPlatform) { case TargetPlatform.iOS: @@ -117,9 +117,9 @@ class NavigationType { ///The webpage was reloaded. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKNavigationType.reload](https://developer.apple.com/documentation/webkit/wknavigationtype/reload)) - ///- MacOS ([Official API - WKNavigationType.reload](https://developer.apple.com/documentation/webkit/wknavigationtype/reload)) - ///- Windows ([Official API - COREWEBVIEW2_NAVIGATION_KIND_RELOAD](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind)) + ///- iOS WKWebView ([Official API - WKNavigationType.reload](https://developer.apple.com/documentation/webkit/wknavigationtype/reload)) + ///- macOS WKWebView ([Official API - WKNavigationType.reload](https://developer.apple.com/documentation/webkit/wknavigationtype/reload)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_NAVIGATION_KIND_RELOAD](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_navigation_kind)) static final RELOAD = NavigationType._internalMultiPlatform('RELOAD', () { switch (defaultTargetPlatform) { case TargetPlatform.iOS: @@ -202,7 +202,7 @@ class NavigationType { ///Gets [String] value. String toValue() => _value; - ///Gets [int?] native value. + ///Gets [int] native value if supported by the current platform, otherwise `null`. int? toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -230,6 +230,11 @@ class NavigationType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; @@ -363,6 +368,11 @@ class IOSWKNavigationType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/over_scroll_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/over_scroll_mode.g.dart index 228e28b4f..ca887ad7a 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/over_scroll_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/over_scroll_mode.g.dart @@ -113,6 +113,11 @@ class OverScrollMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -230,6 +235,11 @@ class AndroidOverScrollMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/pdf_toolbar_items.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/pdf_toolbar_items.g.dart index 5a9fdc1e5..a40929eb0 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/pdf_toolbar_items.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/pdf_toolbar_items.g.dart @@ -181,6 +181,12 @@ class PdfToolbarItems { PdfToolbarItems operator |(PdfToolbarItems value) => PdfToolbarItems._internal( value.toValue() | _value, value.toNativeValue() | _nativeValue); + + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/permission_resource_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_resource_type.g.dart index 3ab4ae8a1..94f9d6405 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/permission_resource_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/permission_resource_type.g.dart @@ -23,7 +23,7 @@ class PermissionResourceType { ///for details. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_AUTOPLAY](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_AUTOPLAY](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final AUTOPLAY = PermissionResourceType._internalMultiPlatform('AUTOPLAY', () { switch (defaultTargetPlatform) { @@ -38,10 +38,10 @@ class PermissionResourceType { ///Resource belongs to video capture device, like camera. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_VIDEO_CAPTURE](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_VIDEO_CAPTURE)) - ///- iOS 15.0+ ([Official API - WKMediaCaptureType.camera](https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera)) - ///- MacOS 12.0+ ([Official API - WKMediaCaptureType.camera](https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera)) - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_CAMERA](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Android WebView ([Official API - PermissionRequest.RESOURCE_VIDEO_CAPTURE](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_VIDEO_CAPTURE)) + ///- iOS WKWebView 15.0+ ([Official API - WKMediaCaptureType.camera](https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera)) + ///- macOS WKWebView 12.0+ ([Official API - WKMediaCaptureType.camera](https://developer.apple.com/documentation/webkit/wkmediacapturetype/camera)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_CAMERA](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final CAMERA = PermissionResourceType._internalMultiPlatform('CAMERA', () { switch (defaultTargetPlatform) { @@ -62,8 +62,8 @@ class PermissionResourceType { ///A media device or devices that can capture audio and video. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS 15.0+ ([Official API - WKMediaCaptureType.cameraAndMicrophone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone)) - ///- MacOS 12.0+ ([Official API - WKMediaCaptureType.cameraAndMicrophone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone)) + ///- iOS WKWebView 15.0+ ([Official API - WKMediaCaptureType.cameraAndMicrophone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone)) + ///- macOS WKWebView 12.0+ ([Official API - WKMediaCaptureType.cameraAndMicrophone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/cameraandmicrophone)) static final CAMERA_AND_MICROPHONE = PermissionResourceType._internalMultiPlatform('CAMERA_AND_MICROPHONE', () { @@ -81,7 +81,7 @@ class PermissionResourceType { ///Indicates permission to read the system clipboard without a user gesture. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_CLIPBOARD_READ](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_CLIPBOARD_READ](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final CLIPBOARD_READ = PermissionResourceType._internalMultiPlatform('CLIPBOARD_READ', () { switch (defaultTargetPlatform) { @@ -96,8 +96,8 @@ class PermissionResourceType { ///Resource belongs to the device’s orientation and motion. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS 15.0+ - ///- MacOS 12.0+ + ///- iOS WKWebView 15.0+ + ///- macOS WKWebView 12.0+ static final DEVICE_ORIENTATION_AND_MOTION = PermissionResourceType._internalMultiPlatform( 'DEVICE_ORIENTATION_AND_MOTION', () { @@ -118,7 +118,7 @@ class PermissionResourceType { ///"readwrite" permission for the user's selection. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_FILE_READ_WRITE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_FILE_READ_WRITE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final FILE_READ_WRITE = PermissionResourceType._internalMultiPlatform('FILE_READ_WRITE', () { switch (defaultTargetPlatform) { @@ -133,7 +133,7 @@ class PermissionResourceType { ///Indicates permission to access geolocation. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_GEOLOCATION](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_GEOLOCATION](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final GEOLOCATION = PermissionResourceType._internalMultiPlatform('GEOLOCATION', () { switch (defaultTargetPlatform) { @@ -150,7 +150,7 @@ class PermissionResourceType { ///to query the system fonts available for styling web content. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_LOCAL_FONTS](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_LOCAL_FONTS](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final LOCAL_FONTS = PermissionResourceType._internalMultiPlatform('LOCAL_FONTS', () { switch (defaultTargetPlatform) { @@ -165,10 +165,10 @@ class PermissionResourceType { ///Resource belongs to audio capture device, like microphone. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_AUDIO_CAPTURE](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_AUDIO_CAPTURE)) - ///- iOS 15.0+ ([Official API - WKMediaCaptureType.microphone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone)) - ///- MacOS 12.0+ ([Official API - WKMediaCaptureType.microphone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone)) - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_MICROPHONE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Android WebView ([Official API - PermissionRequest.RESOURCE_AUDIO_CAPTURE](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_AUDIO_CAPTURE)) + ///- iOS WKWebView 15.0+ ([Official API - WKMediaCaptureType.microphone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone)) + ///- macOS WKWebView 12.0+ ([Official API - WKMediaCaptureType.microphone](https://developer.apple.com/documentation/webkit/wkmediacapturetype/microphone)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_MICROPHONE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final MICROPHONE = PermissionResourceType._internalMultiPlatform('MICROPHONE', () { switch (defaultTargetPlatform) { @@ -191,8 +191,8 @@ class PermissionResourceType { ///Permission may be requested for this resource in API levels 21 and above, if the Android device has been updated to WebView 45 or above. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_MIDI_SYSEX](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_MIDI_SYSEX)) - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_MIDI_SYSTEM_EXCLUSIVE_MESSAGES](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Android WebView ([Official API - PermissionRequest.RESOURCE_MIDI_SYSEX](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_MIDI_SYSEX)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_MIDI_SYSTEM_EXCLUSIVE_MESSAGES](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final MIDI_SYSEX = PermissionResourceType._internalMultiPlatform('MIDI_SYSEX', () { switch (defaultTargetPlatform) { @@ -210,7 +210,7 @@ class PermissionResourceType { ///Permission is requested when multiple downloads are triggered in quick succession. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_MULTIPLE_AUTOMATIC_DOWNLOADS](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_MULTIPLE_AUTOMATIC_DOWNLOADS](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final MULTIPLE_AUTOMATIC_DOWNLOADS = PermissionResourceType._internalMultiPlatform( 'MULTIPLE_AUTOMATIC_DOWNLOADS', () { @@ -226,7 +226,7 @@ class PermissionResourceType { ///Indicates permission to send web notifications. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_NOTIFICATIONS](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_NOTIFICATIONS](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final NOTIFICATIONS = PermissionResourceType._internalMultiPlatform('NOTIFICATIONS', () { switch (defaultTargetPlatform) { @@ -241,7 +241,7 @@ class PermissionResourceType { ///Indicates permission to access generic sensor. Generic Sensor covers ambient-light-sensor, accelerometer, gyroscope, and magnetometer. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_OTHER_SENSORS](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_OTHER_SENSORS](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final OTHER_SENSORS = PermissionResourceType._internalMultiPlatform('OTHER_SENSORS', () { switch (defaultTargetPlatform) { @@ -256,7 +256,7 @@ class PermissionResourceType { ///Resource belongs to protected media identifier. After the user grants this resource, the origin can use EME APIs to generate the license requests. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_PROTECTED_MEDIA_ID)) + ///- Android WebView ([Official API - PermissionRequest.RESOURCE_PROTECTED_MEDIA_ID](https://developer.android.com/reference/android/webkit/PermissionRequest#RESOURCE_PROTECTED_MEDIA_ID)) static final PROTECTED_MEDIA_ID = PermissionResourceType._internalMultiPlatform('PROTECTED_MEDIA_ID', () { switch (defaultTargetPlatform) { @@ -271,7 +271,7 @@ class PermissionResourceType { ///Indicates an unknown permission. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_UNKNOWN_PERMISSION](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_UNKNOWN_PERMISSION](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final UNKNOWN = PermissionResourceType._internalMultiPlatform('UNKNOWN', () { switch (defaultTargetPlatform) { @@ -288,7 +288,7 @@ class PermissionResourceType { ///to get screen details. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PERMISSION_KIND_WINDOW_MANAGEMENT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PERMISSION_KIND_WINDOW_MANAGEMENT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2792.45#corewebview2_permission_kind)) static final WINDOW_MANAGEMENT = PermissionResourceType._internalMultiPlatform('WINDOW_MANAGEMENT', () { switch (defaultTargetPlatform) { @@ -379,7 +379,7 @@ class PermissionResourceType { ///Gets [String] value. String toValue() => _value; - ///Gets [dynamic] native value. + ///Gets [dynamic] native value if supported by the current platform, otherwise `null`. dynamic toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -427,6 +427,11 @@ class PermissionResourceType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/permission_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/permission_response_action.g.dart index 2dbce8e18..1e4e85295 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/permission_response_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/permission_response_action.g.dart @@ -113,6 +113,11 @@ class PermissionResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -224,6 +229,11 @@ class PermissionRequestResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/print_job_attributes.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_attributes.g.dart index 90385bd45..118128585 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/print_job_attributes.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_attributes.g.dart @@ -12,28 +12,28 @@ class PrintJobAttributes { ///The color mode. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- MacOS + ///- Android WebView + ///- macOS WKWebView PrintJobColorMode? colorMode; ///If `true`, produce detailed reports when an error occurs. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView bool? detailedErrorReporting; ///The duplex mode to use for the print job. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView 23+ - ///- iOS - ///- MacOS + ///- Android WebView 23+ + ///- iOS WKWebView + ///- macOS WKWebView PrintJobDuplexMode? duplex; ///A fax number. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView String? faxNumber; ///The height of the page footer. @@ -42,13 +42,13 @@ class PrintJobAttributes { ///The default footer height is `0.0`. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS WKWebView double? footerHeight; ///If `true`, a standard header and footer are added outside the margins of each page. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView bool? headerAndFooter; ///The height of the page header. @@ -57,49 +57,49 @@ class PrintJobAttributes { ///The default header height is `0.0`. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS WKWebView double? headerHeight; ///The horizontal pagination mode. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView PrintJobPaginationMode? horizontalPagination; ///Indicates whether the image is centered horizontally. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView bool? isHorizontallyCentered; ///Indicates whether only the currently selected contents should be printed. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView bool? isSelectionOnly; ///Indicates whether the image is centered vertically. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView bool? isVerticallyCentered; ///The action specified for the job. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView PrintJobDisposition? jobDisposition; ///An URL containing the location to which the job file will be saved when the [jobDisposition] is [PrintJobDisposition.SAVE]. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView WebUri? jobSavingURL; ///The human-readable name of the currently selected paper size, suitable for presentation in user interfaces. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView String? localizedPaperName; ///The margins for each printed page. @@ -107,8 +107,8 @@ class PrintJobAttributes { ///the amount of white space on the left of the content and so on. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView EdgeInsets? margins; ///The maximum height of the content area. @@ -119,7 +119,7 @@ class PrintJobAttributes { ///The default value of this property is the maximum float value. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS WKWebView double? maximumContentHeight; ///The maximum width of the content area. @@ -129,45 +129,45 @@ class PrintJobAttributes { ///The default value of this property is the maximum float value. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS WKWebView double? maximumContentWidth; ///The media size. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView PrintJobMediaSize? mediaSize; ///If `true`, collates output. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView bool? mustCollate; ///The orientation of the printed content, portrait or landscape. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView PrintJobOrientation? orientation; ///The number of logical pages to be tiled horizontally on a physical sheet of paper. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView int? pagesAcross; ///The number of logical pages to be tiled vertically on a physical sheet of paper. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView int? pagesDown; ///The name of the currently selected paper size. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView String? paperName; ///The size of the paper used for printing. @@ -176,8 +176,8 @@ class PrintJobAttributes { ///The origin is always (0,0). /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView InAppWebViewRect? paperRect; ///The area in which printing can occur. @@ -186,32 +186,32 @@ class PrintJobAttributes { ///Sometimes this is referred to as the imageable area of the paper. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView InAppWebViewRect? printableRect; ///The supported resolution in DPI (dots per inch). /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView PrintJobResolution? resolution; ///The current scaling factor. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView double? scalingFactor; ///A timestamp that specifies the time at which printing should begin. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView int? time; ///The vertical pagination to the specified mode. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView PrintJobPaginationMode? verticalPagination; PrintJobAttributes( {this.colorMode, diff --git a/flutter_inappwebview_platform_interface/lib/src/types/print_job_color_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_color_mode.g.dart index 471ec4619..708a26af2 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/print_job_color_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_color_mode.g.dart @@ -19,8 +19,8 @@ class PrintJobColorMode { ///Color color scheme, for example many colors are used. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- MacOS + ///- Android WebView + ///- macOS WKWebView static final COLOR = PrintJobColorMode._internalMultiPlatform(2, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -36,8 +36,8 @@ class PrintJobColorMode { ///Monochrome color scheme, for example one color is used. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- MacOS + ///- Android WebView + ///- macOS WKWebView static final MONOCHROME = PrintJobColorMode._internalMultiPlatform(1, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -115,7 +115,7 @@ class PrintJobColorMode { ///Gets [int] value. int toValue() => _value; - ///Gets [dynamic] native value. + ///Gets [dynamic] native value if supported by the current platform, otherwise `null`. dynamic toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -135,6 +135,11 @@ class PrintJobColorMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/print_job_disposition.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_disposition.g.dart index 14c5a01e4..67c0a91b1 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/print_job_disposition.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_disposition.g.dart @@ -19,7 +19,7 @@ class PrintJobDisposition { ///Cancel print job. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final CANCEL = PrintJobDisposition._internalMultiPlatform('CANCEL', () { switch (defaultTargetPlatform) { @@ -34,7 +34,7 @@ class PrintJobDisposition { ///Send to Preview application. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final PREVIEW = PrintJobDisposition._internalMultiPlatform('PREVIEW', () { switch (defaultTargetPlatform) { @@ -49,7 +49,7 @@ class PrintJobDisposition { ///Save to a file. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final SAVE = PrintJobDisposition._internalMultiPlatform('SAVE', () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -63,7 +63,7 @@ class PrintJobDisposition { ///Normal print job. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final SPOOL = PrintJobDisposition._internalMultiPlatform('SPOOL', () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -165,6 +165,11 @@ class PrintJobDisposition { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/print_job_duplex_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_duplex_mode.g.dart index 0ee6d2811..2af3f61e0 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/print_job_duplex_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_duplex_mode.g.dart @@ -20,9 +20,9 @@ class PrintJobDuplexMode { ///Pages are turned sideways along the long edge - like a book. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView static final LONG_EDGE = PrintJobDuplexMode._internalMultiPlatform('LONG_EDGE', () { switch (defaultTargetPlatform) { @@ -41,9 +41,9 @@ class PrintJobDuplexMode { ///No double-sided (duplex) printing; single-sided printing only. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView static final NONE = PrintJobDuplexMode._internalMultiPlatform('NONE', () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -62,9 +62,9 @@ class PrintJobDuplexMode { ///Pages are turned upwards along the short edge - like a notepad. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView static final SHORT_EDGE = PrintJobDuplexMode._internalMultiPlatform('SHORT_EDGE', () { switch (defaultTargetPlatform) { @@ -146,7 +146,7 @@ class PrintJobDuplexMode { ///Gets [String] value. String toValue() => _value; - ///Gets [int?] native value. + ///Gets [int] native value if supported by the current platform, otherwise `null`. int? toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -168,6 +168,11 @@ class PrintJobDuplexMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/print_job_orientation.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_orientation.g.dart index 15cda90d4..74a124195 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/print_job_orientation.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_orientation.g.dart @@ -19,9 +19,9 @@ class PrintJobOrientation { ///Pages are printed in landscape orientation. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView static final LANDSCAPE = PrintJobOrientation._internalMultiPlatform(1, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -39,9 +39,9 @@ class PrintJobOrientation { ///Pages are printed in portrait orientation. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView static final PORTRAIT = PrintJobOrientation._internalMultiPlatform(0, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -141,6 +141,11 @@ class PrintJobOrientation { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/print_job_output_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_output_type.g.dart index a4d7a9945..a6e67a665 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/print_job_output_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_output_type.g.dart @@ -129,6 +129,11 @@ class PrintJobOutputType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/print_job_page_order.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_page_order.g.dart index 2274d4155..5f8cf77c8 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/print_job_page_order.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_page_order.g.dart @@ -19,7 +19,7 @@ class PrintJobPageOrder { ///Ascending (back to front) page order. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final ASCENDING = PrintJobPageOrder._internalMultiPlatform(1, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -33,7 +33,7 @@ class PrintJobPageOrder { ///Descending (front to back) page order. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final DESCENDING = PrintJobPageOrder._internalMultiPlatform(-1, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -47,7 +47,7 @@ class PrintJobPageOrder { ///The spooler does not rearrange pages—they are printed in the order received by the spooler. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final SPECIAL = PrintJobPageOrder._internalMultiPlatform(0, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -61,7 +61,7 @@ class PrintJobPageOrder { ///No page order specified. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final UNKNOWN = PrintJobPageOrder._internalMultiPlatform(2, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -163,6 +163,11 @@ class PrintJobPageOrder { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/print_job_pagination_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_pagination_mode.g.dart index ac7bf9986..07613cb56 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/print_job_pagination_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_pagination_mode.g.dart @@ -19,7 +19,7 @@ class PrintJobPaginationMode { /// /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final AUTOMATIC = PrintJobPaginationMode._internalMultiPlatform('AUTOMATIC', () { switch (defaultTargetPlatform) { @@ -34,7 +34,7 @@ class PrintJobPaginationMode { /// /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final CLIP = PrintJobPaginationMode._internalMultiPlatform('CLIP', () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -48,7 +48,7 @@ class PrintJobPaginationMode { /// /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final FIT = PrintJobPaginationMode._internalMultiPlatform('FIT', () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -125,7 +125,7 @@ class PrintJobPaginationMode { ///Gets [String] value. String toValue() => _value; - ///Gets [int?] native value. + ///Gets [int] native value if supported by the current platform, otherwise `null`. int? toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -147,6 +147,11 @@ class PrintJobPaginationMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/print_job_rendering_quality.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_rendering_quality.g.dart index 0a4783cd8..4da1a4454 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/print_job_rendering_quality.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_rendering_quality.g.dart @@ -19,8 +19,8 @@ class PrintJobRenderingQuality { ///Renders the printing at the best possible quality, regardless of speed. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView static final BEST = PrintJobRenderingQuality._internalMultiPlatform(0, () { switch (defaultTargetPlatform) { case TargetPlatform.iOS: @@ -37,8 +37,8 @@ class PrintJobRenderingQuality { ///This option should be used only after establishing that best quality rendering does indeed make the user interface unresponsive. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView static final RESPONSIVE = PrintJobRenderingQuality._internalMultiPlatform(1, () { switch (defaultTargetPlatform) { @@ -137,6 +137,11 @@ class PrintJobRenderingQuality { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/print_job_state.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/print_job_state.g.dart index 082b1cea8..9e2d3464e 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/print_job_state.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/print_job_state.g.dart @@ -21,7 +21,7 @@ class PrintJobState { ///Next valid states: [FAILED], [CANCELED], [STARTED]. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_BLOCKED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_BLOCKED)) + ///- Android WebView ([Official API - PrintJobInfo.STATE_BLOCKED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_BLOCKED)) static final BLOCKED = PrintJobState._internalMultiPlatform(4, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -37,9 +37,9 @@ class PrintJobState { ///Next valid states: None. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_CANCELED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CANCELED)) - ///- iOS - ///- MacOS + ///- Android WebView ([Official API - PrintJobInfo.STATE_CANCELED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CANCELED)) + ///- iOS WKWebView + ///- macOS WKWebView static final CANCELED = PrintJobState._internalMultiPlatform(7, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -59,9 +59,9 @@ class PrintJobState { ///Next valid states: None. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_COMPLETED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_COMPLETED)) - ///- iOS - ///- MacOS + ///- Android WebView ([Official API - PrintJobInfo.STATE_COMPLETED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_COMPLETED)) + ///- iOS WKWebView + ///- macOS WKWebView static final COMPLETED = PrintJobState._internalMultiPlatform(5, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -81,9 +81,9 @@ class PrintJobState { ///Next valid states: [QUEUED]. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_CREATED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CREATED)) - ///- iOS - ///- MacOS + ///- Android WebView ([Official API - PrintJobInfo.STATE_CREATED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_CREATED)) + ///- iOS WKWebView + ///- macOS WKWebView static final CREATED = PrintJobState._internalMultiPlatform(1, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -103,8 +103,8 @@ class PrintJobState { ///Next valid states: None. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_FAILED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_FAILED)) - ///- iOS + ///- Android WebView ([Official API - PrintJobInfo.STATE_FAILED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_FAILED)) + ///- iOS WKWebView static final FAILED = PrintJobState._internalMultiPlatform(6, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -122,7 +122,7 @@ class PrintJobState { ///Next valid states: [STARTED], [FAILED], [CANCELED]. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_QUEUED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_QUEUED)) + ///- Android WebView ([Official API - PrintJobInfo.STATE_QUEUED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_QUEUED)) static final QUEUED = PrintJobState._internalMultiPlatform(2, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -138,9 +138,9 @@ class PrintJobState { ///Next valid states: [COMPLETED], [FAILED], [CANCELED], [BLOCKED]. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJobInfo.STATE_STARTED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_STARTED)) - ///- iOS - ///- MacOS + ///- Android WebView ([Official API - PrintJobInfo.STATE_STARTED](https://developer.android.com/reference/android/print/PrintJobInfo#STATE_STARTED)) + ///- iOS WKWebView + ///- macOS WKWebView static final STARTED = PrintJobState._internalMultiPlatform(3, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -224,7 +224,7 @@ class PrintJobState { ///Gets [int] value. int toValue() => _value; - ///Gets [int?] native value. + ///Gets [int] native value if supported by the current platform, otherwise `null`. int? toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -254,6 +254,11 @@ class PrintJobState { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/printer.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/printer.g.dart index 6c95e6a25..0d422c4b8 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/printer.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/printer.g.dart @@ -11,26 +11,26 @@ class Printer { ///The unique id of the printer. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + ///- Android WebView + ///- iOS WKWebView String? id; ///The PostScript language level recognized by the printer. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView int? languageLevel; ///The printer’s name. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView String? name; ///A description of the printer’s make and model. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView String? type; Printer({this.id, this.languageLevel, this.name, this.type}); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.g.dart index 6b0aa7f32..ffda82c1d 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_detail.g.dart @@ -13,7 +13,7 @@ class ProcessFailedDetail { ///The exit code is always STILL_ACTIVE (259) when [ProcessFailedKind.RENDER_PROCESS_UNRESPONSIVE]. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///- Windows WebView2 int? exitCode; ///This property is the full path of the module that caused the crash in cases of Windows Code Integrity failures. @@ -28,7 +28,7 @@ class ProcessFailedDetail { ///- It has been blocked by an administrator or a security policy. This property always will be the empty string if failure is not caused by STATUS_INVALID_IMAGE_HASH. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///- Windows WebView2 String? failureSourceModulePath; ///The collection of [FrameInfo]s for frames in the WebView that were being rendered by the failed process. @@ -39,13 +39,13 @@ class ProcessFailedDetail { ///for the main frame and subframes within it, for which the failure kind is [ProcessFailedKind.RENDER_PROCESS_EXITED]. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///- Windows WebView2 List? frameInfos; ///The kind of process failure that has occurred. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///- Windows WebView2 ProcessFailedKind kind; ///Description of the process assigned by the WebView2 Runtime. @@ -55,13 +55,13 @@ class ProcessFailedDetail { ///The returned [processDescription] is empty if the WebView2 Runtime did not assign a description to the process. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///- Windows WebView2 String? processDescription; ///The reason for the process failure. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///- Windows WebView2 ProcessFailedReason? reason; ProcessFailedDetail( {this.exitCode, diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart index cee266e32..ebe30da23 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.dart @@ -9,7 +9,7 @@ class ProcessFailedKind_ { // ignore: unused_field final String _value; // ignore: unused_field - final dynamic _nativeValue = null; + final int? _nativeValue = null; const ProcessFailedKind_._internal(this._value); ///Indicates that the browser process ended unexpectedly. The WebView automatically moves to the Closed state. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.g.dart index 729477570..693ee5eb1 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_kind.g.dart @@ -9,7 +9,7 @@ part of 'process_failed_kind.dart'; ///Class used to indicate the kind of process failure that has occurred. class ProcessFailedKind { final String _value; - final dynamic _nativeValue; + final int? _nativeValue; const ProcessFailedKind._internal(this._value, this._nativeValue); // ignore: unused_element factory ProcessFailedKind._internalMultiPlatform( @@ -20,7 +20,7 @@ class ProcessFailedKind { ///The app has to recreate a new WebView to recover from this failure. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_BROWSER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) static final BROWSER_PROCESS_EXITED = ProcessFailedKind._internalMultiPlatform('BROWSER_PROCESS_EXITED', () { switch (defaultTargetPlatform) { @@ -37,7 +37,7 @@ class ProcessFailedKind { ///The content in these frames is replaced with an error page in the frame. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_FRAME_RENDER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_FRAME_RENDER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) static final FRAME_RENDER_PROCESS_EXITED = ProcessFailedKind._internalMultiPlatform('FRAME_RENDER_PROCESS_EXITED', () { @@ -55,7 +55,7 @@ class ProcessFailedKind { ///Your application does not need to handle recovery for this event. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_GPU_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_GPU_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) static final GPU_PROCESS_EXITED = ProcessFailedKind._internalMultiPlatform('GPU_PROCESS_EXITED', () { switch (defaultTargetPlatform) { @@ -72,7 +72,7 @@ class ProcessFailedKind { ///Your application does not need to handle recovery for this event. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_BROKER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_BROKER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) static final PPAPI_BROKER_PROCESS_EXITED = ProcessFailedKind._internalMultiPlatform('PPAPI_BROKER_PROCESS_EXITED', () { @@ -90,7 +90,7 @@ class ProcessFailedKind { ///Your application does not need to handle recovery for this event. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_PLUGIN_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_PPAPI_PLUGIN_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) static final PPAPI_PLUGIN_PROCESS_EXITED = ProcessFailedKind._internalMultiPlatform('PPAPI_PLUGIN_PROCESS_EXITED', () { @@ -108,7 +108,7 @@ class ProcessFailedKind { ///You can use the reload method to try to recover from this failure. Alternatively, you can close and recreate the WebView. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) static final RENDER_PROCESS_EXITED = ProcessFailedKind._internalMultiPlatform('RENDER_PROCESS_EXITED', () { switch (defaultTargetPlatform) { @@ -135,7 +135,7 @@ class ProcessFailedKind { ///reload the page, or navigate away. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_RENDER_PROCESS_UNRESPONSIVE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) static final RENDER_PROCESS_UNRESPONSIVE = ProcessFailedKind._internalMultiPlatform('RENDER_PROCESS_UNRESPONSIVE', () { @@ -153,7 +153,7 @@ class ProcessFailedKind { ///Your application does not need to handle recovery for this event. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_SANDBOX_HELPER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_SANDBOX_HELPER_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) static final SANDBOX_HELPER_PROCESS_EXITED = ProcessFailedKind._internalMultiPlatform('SANDBOX_HELPER_PROCESS_EXITED', () { @@ -169,7 +169,7 @@ class ProcessFailedKind { ///Indicates that a process of unspecified kind ended unexpectedly. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_UNKNOWN_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_UNKNOWN_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) static final UNKNOWN_PROCESS_EXITED = ProcessFailedKind._internalMultiPlatform('UNKNOWN_PROCESS_EXITED', () { switch (defaultTargetPlatform) { @@ -186,7 +186,7 @@ class ProcessFailedKind { ///Your application does not need to handle recovery for this event. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_UTILITY_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_KIND_UTILITY_PROCESS_EXITED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_kind)) static final UTILITY_PROCESS_EXITED = ProcessFailedKind._internalMultiPlatform('UTILITY_PROCESS_EXITED', () { switch (defaultTargetPlatform) { @@ -226,7 +226,7 @@ class ProcessFailedKind { } ///Gets a possible [ProcessFailedKind] instance from a native value. - static ProcessFailedKind? fromNativeValue(dynamic value) { + static ProcessFailedKind? fromNativeValue(int? value) { if (value != null) { try { return ProcessFailedKind.values @@ -271,8 +271,8 @@ class ProcessFailedKind { ///Gets [String] value. String toValue() => _value; - ///Gets [dynamic] native value. - dynamic toNativeValue() => _nativeValue; + ///Gets [int] native value if supported by the current platform, otherwise `null`. + int? toNativeValue() => _nativeValue; ///Gets the name of the value. String name() { @@ -307,6 +307,11 @@ class ProcessFailedKind { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart index 647e6e887..53ea7cf58 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.dart @@ -9,7 +9,7 @@ class ProcessFailedReason_ { // ignore: unused_field final String _value; // ignore: unused_field - final dynamic _nativeValue = null; + final int? _nativeValue = null; const ProcessFailedReason_._internal(this._value); ///An unexpected process failure occurred. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.g.dart index 648cc1447..1516332c0 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/process_failed_reason.g.dart @@ -9,7 +9,7 @@ part of 'process_failed_reason.dart'; ///Class used to indicate the kind of process failure that has occurred. class ProcessFailedReason { final String _value; - final dynamic _nativeValue; + final int? _nativeValue; const ProcessFailedReason._internal(this._value, this._nativeValue); // ignore: unused_element factory ProcessFailedReason._internalMultiPlatform( @@ -19,7 +19,7 @@ class ProcessFailedReason { ///The process crashed. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_CRASHED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_CRASHED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) static final CRASHED = ProcessFailedReason._internalMultiPlatform('CRASHED', () { switch (defaultTargetPlatform) { @@ -34,7 +34,7 @@ class ProcessFailedReason { ///The process failed to launch. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_LAUNCH_FAILED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_LAUNCH_FAILED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) static final LAUNCH_FAILED = ProcessFailedReason._internalMultiPlatform('LAUNCH_FAILED', () { switch (defaultTargetPlatform) { @@ -49,7 +49,7 @@ class ProcessFailedReason { ///The process terminated due to running out of memory. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_OUT_OF_MEMORY](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_OUT_OF_MEMORY](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) static final OUT_OF_MEMORY = ProcessFailedReason._internalMultiPlatform('OUT_OF_MEMORY', () { switch (defaultTargetPlatform) { @@ -64,7 +64,7 @@ class ProcessFailedReason { ///The process was terminated. For example, from Task Manager. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_TERMINATED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_TERMINATED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) static final TERMINATED = ProcessFailedReason._internalMultiPlatform('TERMINATED', () { switch (defaultTargetPlatform) { @@ -79,7 +79,7 @@ class ProcessFailedReason { ///An unexpected process failure occurred. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_UNEXPECTED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_UNEXPECTED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) static final UNEXPECTED = ProcessFailedReason._internalMultiPlatform('UNEXPECTED', () { switch (defaultTargetPlatform) { @@ -94,7 +94,7 @@ class ProcessFailedReason { ///The process became unresponsive. This only applies to the main frame's render process. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_UNRESPONSIVE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_PROCESS_FAILED_REASON_UNRESPONSIVE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_process_failed_reason)) static final UNRESPONSIVE = ProcessFailedReason._internalMultiPlatform('UNRESPONSIVE', () { switch (defaultTargetPlatform) { @@ -130,7 +130,7 @@ class ProcessFailedReason { } ///Gets a possible [ProcessFailedReason] instance from a native value. - static ProcessFailedReason? fromNativeValue(dynamic value) { + static ProcessFailedReason? fromNativeValue(int? value) { if (value != null) { try { return ProcessFailedReason.values @@ -175,8 +175,8 @@ class ProcessFailedReason { ///Gets [String] value. String toValue() => _value; - ///Gets [dynamic] native value. - dynamic toNativeValue() => _nativeValue; + ///Gets [int] native value if supported by the current platform, otherwise `null`. + int? toNativeValue() => _nativeValue; ///Gets the name of the value. String name() { @@ -203,6 +203,11 @@ class ProcessFailedReason { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/proxy_relay_hop.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/proxy_relay_hop.g.dart index f7ffce3b2..c5079e2e2 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/proxy_relay_hop.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/proxy_relay_hop.g.dart @@ -17,22 +17,22 @@ class ProxyRelayHop { ///A dictionary of additional HTTP headers to send as part of CONNECT requests to the relay. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView Map? additionalHTTPHeaders; ///A URL or host endpoint identifying the relay server accessible using HTTP/2. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView String? http2RelayEndpoint; ///A URL or host endpoint identifying the relay server accessible using HTTP/3. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView String? http3RelayEndpoint; ProxyRelayHop( {this.http3RelayEndpoint, diff --git a/flutter_inappwebview_platform_interface/lib/src/types/proxy_rule.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/proxy_rule.g.dart index 02115af81..2ac833531 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/proxy_rule.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/proxy_rule.g.dart @@ -12,52 +12,52 @@ class ProxyRule { ///Failover isn’t allowed by default. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView bool? allowFailover; ///Define an array of domains to determine which hosts should not use the proxy. ///If the array is empty, no domains are excluded. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView List? excludedDomains; ///Define an array of domains to determine which hosts should use the proxy. If the array is empty, ///all domains are allowed to use the proxy other than domains listed in [excludedDomains]. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView List? matchDomains; ///Sets a password to use as authentication for a proxy configuration. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView String? password; ///Represents the scheme filter. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView ProxySchemeFilter? schemeFilter; ///Represents the proxy URL. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView String url; ///Sets a username to use as authentication for a proxy configuration. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView String? username; ProxyRule( {this.allowFailover, diff --git a/flutter_inappwebview_platform_interface/lib/src/types/proxy_scheme_filter.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/proxy_scheme_filter.g.dart index 56b9414e3..22b9d5dc8 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/proxy_scheme_filter.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/proxy_scheme_filter.g.dart @@ -113,6 +113,11 @@ class ProxySchemeFilter { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/pull_to_refresh_size.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/pull_to_refresh_size.g.dart index 4a518d8df..521de3753 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/pull_to_refresh_size.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/pull_to_refresh_size.g.dart @@ -107,6 +107,11 @@ class PullToRefreshSize { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -216,6 +221,11 @@ class AndroidPullToRefreshSize { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/referrer_policy.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/referrer_policy.g.dart index 6ea14e309..855f98f47 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/referrer_policy.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/referrer_policy.g.dart @@ -155,6 +155,11 @@ class ReferrerPolicy { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/renderer_priority.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/renderer_priority.g.dart index e8116339a..513f7f467 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/renderer_priority.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/renderer_priority.g.dart @@ -114,6 +114,11 @@ class RendererPriority { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response_action.g.dart index 5a1645263..683bf22ec 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_response_action.g.dart @@ -114,6 +114,11 @@ class SafeBrowsingResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_threat.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_threat.g.dart index f91cc5957..f5413b450 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_threat.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/safe_browsing_threat.g.dart @@ -133,6 +133,11 @@ class SafeBrowsingThreat { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/sandbox.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/sandbox.g.dart index e946bc67d..706ffe4ac 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/sandbox.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/sandbox.g.dart @@ -154,7 +154,7 @@ class Sandbox { return _value ?? ''; } - ///Gets [String?] native value. + ///Gets [String] native value if supported by the current platform, otherwise `null`. String? toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -197,4 +197,9 @@ class Sandbox { @override bool operator ==(value) => value == _value; + + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart index b25b22637..e417d405b 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/screenshot_configuration.g.dart @@ -13,18 +13,18 @@ class ScreenshotConfiguration { ///If you change the value to `false`, the `WebView` takes the snapshot immediately, and before incorporating any new changes. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS 13.0+ - ///- MacOS 10.15+ + ///- iOS WKWebView 13.0+ + ///- macOS WKWebView 10.15+ bool afterScreenUpdates; ///The compression format of the captured image. ///The default value is [CompressFormat.PNG]. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Windows + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Windows WebView2 CompressFormat compressFormat; ///Use [afterScreenUpdates] instead. @@ -35,10 +35,10 @@ class ScreenshotConfiguration { ///[CompressFormat.PNG] is lossless, so this value is ignored. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Windows + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Windows WebView2 int quality; ///The portion of your web view to capture, specified as a rectangle in the view’s coordinate system. @@ -46,10 +46,10 @@ class ScreenshotConfiguration { ///If you specify a custom rectangle, it must lie within the bounds rectangle of the `WebView` object. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Windows + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Windows WebView2 InAppWebViewRect? rect; ///The width of the captured image, in points. @@ -59,9 +59,9 @@ class ScreenshotConfiguration { ///The default value of this property is `null`, which returns an image whose size matches the original size of the captured rectangle. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView double? snapshotWidth; ScreenshotConfiguration( {this.rect, diff --git a/flutter_inappwebview_platform_interface/lib/src/types/scrollbar_style.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/scrollbar_style.g.dart index 7acdeb53d..21c24621d 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/scrollbar_style.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/scrollbar_style.g.dart @@ -131,6 +131,11 @@ class ScrollBarStyle { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -267,6 +272,11 @@ class AndroidScrollBarStyle { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/scrollview_content_inset_adjustment_behavior.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/scrollview_content_inset_adjustment_behavior.g.dart index 7b2335906..353682c87 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/scrollview_content_inset_adjustment_behavior.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/scrollview_content_inset_adjustment_behavior.g.dart @@ -124,6 +124,11 @@ class ScrollViewContentInsetAdjustmentBehavior { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -257,6 +262,11 @@ class IOSUIScrollViewContentInsetAdjustmentBehavior { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/scrollview_deceleration_rate.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/scrollview_deceleration_rate.g.dart index 291579327..ffad421db 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/scrollview_deceleration_rate.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/scrollview_deceleration_rate.g.dart @@ -109,6 +109,11 @@ class ScrollViewDecelerationRate { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; @@ -221,6 +226,11 @@ class IOSUIScrollViewDecelerationRate { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/search_result_display_style.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/search_result_display_style.g.dart index 292de50ab..cc190e922 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/search_result_display_style.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/search_result_display_style.g.dart @@ -113,6 +113,11 @@ class SearchResultDisplayStyle { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/selection_granularity.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/selection_granularity.g.dart index 4944cbe71..af5c5c9fa 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/selection_granularity.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/selection_granularity.g.dart @@ -107,6 +107,11 @@ class SelectionGranularity { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -217,6 +222,11 @@ class IOSWKSelectionGranularity { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/server_trust_auth_response_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/server_trust_auth_response_action.g.dart index ebfdccf65..a372d8d55 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/server_trust_auth_response_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/server_trust_auth_response_action.g.dart @@ -108,6 +108,11 @@ class ServerTrustAuthResponseAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/should_allow_deprecated_tls_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/should_allow_deprecated_tls_action.g.dart index c41616a30..228b86a32 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/should_allow_deprecated_tls_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/should_allow_deprecated_tls_action.g.dart @@ -110,6 +110,11 @@ class ShouldAllowDeprecatedTLSAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -222,6 +227,11 @@ class IOSShouldAllowDeprecatedTLSAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request_mode.g.dart index 2785b69b7..6a48ef42a 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request_mode.g.dart @@ -19,7 +19,7 @@ class ShowFileChooserRequestMode { ///Open single file. Requires that the file exists before allowing the user to pick it. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView static final OPEN = ShowFileChooserRequestMode._internalMultiPlatform(0, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -35,7 +35,7 @@ class ShowFileChooserRequestMode { ///This feature is not supported at the moment. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView static final OPEN_FOLDER = ShowFileChooserRequestMode._internalMultiPlatform(2, () { switch (defaultTargetPlatform) { @@ -50,7 +50,7 @@ class ShowFileChooserRequestMode { ///Like Open but allows multiple files to be selected. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView static final OPEN_MULTIPLE = ShowFileChooserRequestMode._internalMultiPlatform(1, () { switch (defaultTargetPlatform) { @@ -65,7 +65,7 @@ class ShowFileChooserRequestMode { ///Allows picking a nonexistent file and saving it. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView static final SAVE = ShowFileChooserRequestMode._internalMultiPlatform(3, () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -144,7 +144,7 @@ class ShowFileChooserRequestMode { ///Gets [int] value. int toValue() => _value; - ///Gets [int?] native value. + ///Gets [int] native value if supported by the current platform, otherwise `null`. int? toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -168,6 +168,11 @@ class ShowFileChooserRequestMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/ssl_error_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/ssl_error_type.g.dart index ba0d2204f..de0aade1f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/ssl_error_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/ssl_error_type.g.dart @@ -20,7 +20,7 @@ class SslErrorType { ///Indicates that the SSL certificate common name does not match the web address. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_COMMON_NAME_IS_INCORRECT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_COMMON_NAME_IS_INCORRECT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status)) static final COMMON_NAME_IS_INCORRECT = SslErrorType._internalMultiPlatform('COMMON_NAME_IS_INCORRECT', () { switch (defaultTargetPlatform) { @@ -35,7 +35,7 @@ class SslErrorType { ///The date of the certificate is invalid. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SslError.DATE_INVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_DATE_INVALID)) + ///- Android WebView ([Official API - SslError.DATE_INVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_DATE_INVALID)) static final DATE_INVALID = SslErrorType._internalMultiPlatform('DATE_INVALID', () { switch (defaultTargetPlatform) { @@ -55,8 +55,8 @@ class SslErrorType { ///The Keychain Access utility refers to this value as "Never Trust." /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - SecTrustResultType.deny](https://developer.apple.com/documentation/security/sectrustresulttype/deny)) - ///- MacOS ([Official API - SecTrustResultType.deny](https://developer.apple.com/documentation/security/sectrustresulttype/deny)) + ///- iOS WKWebView ([Official API - SecTrustResultType.deny](https://developer.apple.com/documentation/security/sectrustresulttype/deny)) + ///- macOS WKWebView ([Official API - SecTrustResultType.deny](https://developer.apple.com/documentation/security/sectrustresulttype/deny)) static final DENY = SslErrorType._internalMultiPlatform('DENY', () { switch (defaultTargetPlatform) { case TargetPlatform.iOS: @@ -72,8 +72,8 @@ class SslErrorType { ///The certificate has expired. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SslError.SSL_EXPIRED](https://developer.android.com/reference/android/net/http/SslError#SSL_EXPIRED)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_EXPIRED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status)) + ///- Android WebView ([Official API - SslError.SSL_EXPIRED](https://developer.android.com/reference/android/net/http/SslError#SSL_EXPIRED)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_EXPIRED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status)) static final EXPIRED = SslErrorType._internalMultiPlatform('EXPIRED', () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -94,8 +94,8 @@ class SslErrorType { ///Changing parameter values and reevaluating is unlikely to succeed unless you provide different certificates. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - SecTrustResultType.fatalTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/fataltrustfailure)) - ///- MacOS ([Official API - SecTrustResultType.fatalTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/fataltrustfailure)) + ///- iOS WKWebView ([Official API - SecTrustResultType.fatalTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/fataltrustfailure)) + ///- macOS WKWebView ([Official API - SecTrustResultType.fatalTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/fataltrustfailure)) static final FATAL_TRUST_FAILURE = SslErrorType._internalMultiPlatform('FATAL_TRUST_FAILURE', () { switch (defaultTargetPlatform) { @@ -112,7 +112,7 @@ class SslErrorType { ///Hostname mismatch. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SslError.SSL_IDMISMATCH](https://developer.android.com/reference/android/net/http/SslError#SSL_IDMISMATCH)) + ///- Android WebView ([Official API - SslError.SSL_IDMISMATCH](https://developer.android.com/reference/android/net/http/SslError#SSL_IDMISMATCH)) static final IDMISMATCH = SslErrorType._internalMultiPlatform('IDMISMATCH', () { switch (defaultTargetPlatform) { @@ -127,10 +127,10 @@ class SslErrorType { ///Indicates an invalid setting or result. A generic error occurred. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SslError.SSL_INVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_INVALID)) - ///- iOS ([Official API - SecTrustResultType.invalid](https://developer.apple.com/documentation/security/sectrustresulttype/invalid)) - ///- MacOS ([Official API - SecTrustResultType.invalid](https://developer.apple.com/documentation/security/sectrustresulttype/invalid)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_IS_INVALID](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status)) + ///- Android WebView ([Official API - SslError.SSL_INVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_INVALID)) + ///- iOS WKWebView ([Official API - SecTrustResultType.invalid](https://developer.apple.com/documentation/security/sectrustresulttype/invalid)) + ///- macOS WKWebView ([Official API - SecTrustResultType.invalid](https://developer.apple.com/documentation/security/sectrustresulttype/invalid)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_IS_INVALID](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status)) static final INVALID = SslErrorType._internalMultiPlatform('INVALID', () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -150,7 +150,7 @@ class SslErrorType { ///The certificate is not yet valid. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SslError.SSL_NOTYETVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_NOTYETVALID)) + ///- Android WebView ([Official API - SslError.SSL_NOTYETVALID](https://developer.android.com/reference/android/net/http/SslError#SSL_NOTYETVALID)) static final NOT_YET_VALID = SslErrorType._internalMultiPlatform('NOT_YET_VALID', () { switch (defaultTargetPlatform) { @@ -170,9 +170,9 @@ class SslErrorType { ///by OS-level errors that are unrelated to the certificates themselves. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - SecTrustResultType.otherError](https://developer.apple.com/documentation/security/sectrustresulttype/othererror)) - ///- MacOS ([Official API - SecTrustResultType.otherError](https://developer.apple.com/documentation/security/sectrustresulttype/othererror)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CLIENT_CERTIFICATE_CONTAINS_ERRORS](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status)) + ///- iOS WKWebView ([Official API - SecTrustResultType.otherError](https://developer.apple.com/documentation/security/sectrustresulttype/othererror)) + ///- macOS WKWebView ([Official API - SecTrustResultType.otherError](https://developer.apple.com/documentation/security/sectrustresulttype/othererror)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CLIENT_CERTIFICATE_CONTAINS_ERRORS](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status)) static final OTHER_ERROR = SslErrorType._internalMultiPlatform('OTHER_ERROR', () { switch (defaultTargetPlatform) { @@ -199,8 +199,8 @@ class SslErrorType { ///you should check again using that date to see if the message was valid when you originally received it. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - SecTrustResultType.recoverableTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/recoverabletrustfailure)) - ///- MacOS ([Official API - SecTrustResultType.recoverableTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/recoverabletrustfailure)) + ///- iOS WKWebView ([Official API - SecTrustResultType.recoverableTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/recoverabletrustfailure)) + ///- macOS WKWebView ([Official API - SecTrustResultType.recoverableTrustFailure](https://developer.apple.com/documentation/security/sectrustresulttype/recoverabletrustfailure)) static final RECOVERABLE_TRUST_FAILURE = SslErrorType._internalMultiPlatform('RECOVERABLE_TRUST_FAILURE', () { switch (defaultTargetPlatform) { @@ -217,7 +217,7 @@ class SslErrorType { ///Indicates that the SSL certificate has been revoked. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_REVOKED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CERTIFICATE_REVOKED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#corewebview2_web_error_status)) static final REVOKED = SslErrorType._internalMultiPlatform('REVOKED', () { switch (defaultTargetPlatform) { case TargetPlatform.windows: @@ -238,8 +238,8 @@ class SslErrorType { ///When receiving this value, most apps should trust the chain. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - SecTrustResultType.unspecified](https://developer.apple.com/documentation/security/sectrustresulttype/unspecified)) - ///- MacOS ([Official API - SecTrustResultType.unspecified](https://developer.apple.com/documentation/security/sectrustresulttype/unspecified)) + ///- iOS WKWebView ([Official API - SecTrustResultType.unspecified](https://developer.apple.com/documentation/security/sectrustresulttype/unspecified)) + ///- macOS WKWebView ([Official API - SecTrustResultType.unspecified](https://developer.apple.com/documentation/security/sectrustresulttype/unspecified)) static final UNSPECIFIED = SslErrorType._internalMultiPlatform('UNSPECIFIED', () { switch (defaultTargetPlatform) { @@ -256,7 +256,7 @@ class SslErrorType { ///The certificate authority is not trusted. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SslError.SSL_UNTRUSTED](https://developer.android.com/reference/android/net/http/SslError#SSL_UNTRUSTED)) + ///- Android WebView ([Official API - SslError.SSL_UNTRUSTED](https://developer.android.com/reference/android/net/http/SslError#SSL_UNTRUSTED)) static final UNTRUSTED = SslErrorType._internalMultiPlatform('UNTRUSTED', () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -342,7 +342,7 @@ class SslErrorType { ///Gets [String] value. String toValue() => _value; - ///Gets [int?] native value. + ///Gets [int] native value if supported by the current platform, otherwise `null`. int? toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -384,6 +384,11 @@ class SslErrorType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; @@ -517,6 +522,11 @@ class AndroidSslError { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -649,6 +659,11 @@ class IOSSslError { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/tracing_category.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/tracing_category.g.dart index 5943c03f6..5d91e3476 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/tracing_category.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/tracing_category.g.dart @@ -151,6 +151,11 @@ class TracingCategory { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/tracing_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/tracing_mode.g.dart index 1dab01ed6..303d7c2ec 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/tracing_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/tracing_mode.g.dart @@ -111,6 +111,11 @@ class TracingMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/trusted_web_activity_screen_orientation.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/trusted_web_activity_screen_orientation.g.dart index f17fdc4b8..93976eac5 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/trusted_web_activity_screen_orientation.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/trusted_web_activity_screen_orientation.g.dart @@ -172,6 +172,11 @@ class TrustedWebActivityScreenOrientation { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/ui_image.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/ui_image.g.dart index 9f17ed58b..dff760b06 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/ui_image.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/ui_image.g.dart @@ -24,8 +24,8 @@ class UIImage { ///The name of the system symbol image. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS 13.0+ - ///- MacOS 11.0+ + ///- iOS WKWebView 13.0+ + ///- macOS WKWebView 11.0+ String? systemName; UIImage({this.name, this.systemName, this.data}) { assert(this.name != null || this.systemName != null || this.data != null); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/underline_style.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/underline_style.g.dart index fd6277469..8b4a5d06b 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/underline_style.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/underline_style.g.dart @@ -148,6 +148,11 @@ class UnderlineStyle { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -299,6 +304,11 @@ class IOSNSUnderlineStyle { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/url_credential.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/url_credential.g.dart index 90b481db4..94fc317c7 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/url_credential.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/url_credential.g.dart @@ -12,8 +12,8 @@ class URLCredential { ///The intermediate certificates of the credential, if it is a client certificate credential. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView List? certificates; ///Use [certificates] instead. @@ -30,8 +30,8 @@ class URLCredential { ///The credential’s persistence setting. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView + ///- macOS WKWebView URLCredentialPersistence? persistence; ///The credential’s user name. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/url_credential_persistence.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/url_credential_persistence.g.dart index dd5a05f6a..14c60abdf 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/url_credential_persistence.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/url_credential_persistence.g.dart @@ -120,6 +120,11 @@ class URLCredentialPersistence { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -243,6 +248,11 @@ class IOSURLCredentialPersistence { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space.g.dart index 55ad5df09..22d45cdae 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space.g.dart @@ -11,8 +11,8 @@ class URLProtectionSpace { ///The authentication method used by the receiver. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLProtectionSpace.authenticationMethod](https://developer.apple.com/documentation/foundation/urlprotectionspace/1415028-authenticationmethod)) - ///- MacOS ([Official API - URLProtectionSpace.authenticationMethod](https://developer.apple.com/documentation/foundation/urlprotectionspace/1415028-authenticationmethod)) + ///- iOS WKWebView ([Official API - URLProtectionSpace.authenticationMethod](https://developer.apple.com/documentation/foundation/urlprotectionspace/1415028-authenticationmethod)) + ///- macOS WKWebView ([Official API - URLProtectionSpace.authenticationMethod](https://developer.apple.com/documentation/foundation/urlprotectionspace/1415028-authenticationmethod)) URLProtectionSpaceAuthenticationMethod? authenticationMethod; ///The acceptable certificate-issuing authorities for client certificate authentication. @@ -20,8 +20,8 @@ class URLProtectionSpace { ///The returned issuing authorities are encoded with Distinguished Encoding Rules (DER). /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLProtectionSpace.distinguishedNames](https://developer.apple.com/documentation/foundation/urlprotectionspace/1417061-distinguishednames)) - ///- MacOS ([Official API - URLProtectionSpace.distinguishedNames](https://developer.apple.com/documentation/foundation/urlprotectionspace/1417061-distinguishednames)) + ///- iOS WKWebView ([Official API - URLProtectionSpace.distinguishedNames](https://developer.apple.com/documentation/foundation/urlprotectionspace/1417061-distinguishednames)) + ///- macOS WKWebView ([Official API - URLProtectionSpace.distinguishedNames](https://developer.apple.com/documentation/foundation/urlprotectionspace/1417061-distinguishednames)) List? distinguishedNames; ///The hostname of the server. @@ -54,8 +54,8 @@ class URLProtectionSpace { ///The supported proxy types are listed in [URLProtectionSpaceProxyType.values]. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLProtectionSpace.proxyType](https://developer.apple.com/documentation/foundation/urlprotectionspace/1411924-proxytype)) - ///- MacOS ([Official API - URLProtectionSpace.proxyType](https://developer.apple.com/documentation/foundation/urlprotectionspace/1411924-proxytype)) + ///- iOS WKWebView ([Official API - URLProtectionSpace.proxyType](https://developer.apple.com/documentation/foundation/urlprotectionspace/1411924-proxytype)) + ///- macOS WKWebView ([Official API - URLProtectionSpace.proxyType](https://developer.apple.com/documentation/foundation/urlprotectionspace/1411924-proxytype)) URLProtectionSpaceProxyType? proxyType; ///A string indicating a protocol-specific subdivision of a single host. @@ -67,8 +67,8 @@ class URLProtectionSpace { ///This value is `true` if the credentials for the protection space represented by the receiver can be sent securely, `false` otherwise. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLProtectionSpace.receivesCredentialSecurely](https://developer.apple.com/documentation/foundation/urlprotectionspace/1415176-receivescredentialsecurely)) - ///- MacOS ([Official API - URLProtectionSpace.receivesCredentialSecurely](https://developer.apple.com/documentation/foundation/urlprotectionspace/1415176-receivescredentialsecurely)) + ///- iOS WKWebView ([Official API - URLProtectionSpace.receivesCredentialSecurely](https://developer.apple.com/documentation/foundation/urlprotectionspace/1415176-receivescredentialsecurely)) + ///- macOS WKWebView ([Official API - URLProtectionSpace.receivesCredentialSecurely](https://developer.apple.com/documentation/foundation/urlprotectionspace/1415176-receivescredentialsecurely)) bool? receivesCredentialSecurely; ///The SSL certificate used. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space_authentication_method.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space_authentication_method.g.dart index 16e75e5ee..17e96fb4c 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space_authentication_method.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space_authentication_method.g.dart @@ -136,6 +136,11 @@ class URLProtectionSpaceAuthenticationMethod { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; @@ -276,6 +281,11 @@ class IOSNSURLProtectionSpaceAuthenticationMethod { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space_proxy_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space_proxy_type.g.dart index b234553c7..740c8f6e0 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space_proxy_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/url_protection_space_proxy_type.g.dart @@ -128,6 +128,11 @@ class URLProtectionSpaceProxyType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; @@ -259,6 +264,11 @@ class IOSNSURLProtectionSpaceProxyType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/url_request.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/url_request.g.dart index 9c99ea0c6..271fd46b1 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/url_request.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/url_request.g.dart @@ -11,22 +11,22 @@ class URLRequest { ///A Boolean value indicating whether the request is allowed to use the built-in cellular radios to satisfy the request. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLRequest.allowsCellularAccess](https://developer.apple.com/documentation/foundation/urlrequest/2011607-allowscellularaccess/)) - ///- MacOS ([Official API - URLRequest.allowsCellularAccess](https://developer.apple.com/documentation/foundation/urlrequest/2011607-allowscellularaccess/)) + ///- iOS WKWebView ([Official API - URLRequest.allowsCellularAccess](https://developer.apple.com/documentation/foundation/urlrequest/2011607-allowscellularaccess/)) + ///- macOS WKWebView ([Official API - URLRequest.allowsCellularAccess](https://developer.apple.com/documentation/foundation/urlrequest/2011607-allowscellularaccess/)) bool? allowsCellularAccess; ///A Boolean value that indicates whether the request may use the network when the user has specified Low Data Mode. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS 13.0+ ([Official API - URLRequest.allowsConstrainedNetworkAccess](https://developer.apple.com/documentation/foundation/urlrequest/3358304-allowsconstrainednetworkaccess)) - ///- MacOS 10.15+ ([Official API - URLRequest.allowsConstrainedNetworkAccess](https://developer.apple.com/documentation/foundation/urlrequest/3358304-allowsconstrainednetworkaccess)) + ///- iOS WKWebView 13.0+ ([Official API - URLRequest.allowsConstrainedNetworkAccess](https://developer.apple.com/documentation/foundation/urlrequest/3358304-allowsconstrainednetworkaccess)) + ///- macOS WKWebView 10.15+ ([Official API - URLRequest.allowsConstrainedNetworkAccess](https://developer.apple.com/documentation/foundation/urlrequest/3358304-allowsconstrainednetworkaccess)) bool? allowsConstrainedNetworkAccess; ///A Boolean value that indicates whether connections may use a network interface that the system considers expensive. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS 13.0+ ([Official API - URLRequest.allowsExpensiveNetworkAccess](https://developer.apple.com/documentation/foundation/urlrequest/3358305-allowsexpensivenetworkaccess)) - ///- MacOS 10.15+ ([Official API - URLRequest.allowsExpensiveNetworkAccess](https://developer.apple.com/documentation/foundation/urlrequest/3358305-allowsexpensivenetworkaccess)) + ///- iOS WKWebView 13.0+ ([Official API - URLRequest.allowsExpensiveNetworkAccess](https://developer.apple.com/documentation/foundation/urlrequest/3358305-allowsexpensivenetworkaccess)) + ///- macOS WKWebView 10.15+ ([Official API - URLRequest.allowsExpensiveNetworkAccess](https://developer.apple.com/documentation/foundation/urlrequest/3358305-allowsexpensivenetworkaccess)) bool? allowsExpensiveNetworkAccess; ///`true` if server endpoint is known to support HTTP/3. Enables QUIC racing @@ -34,8 +34,8 @@ class URLRequest { ///The default may be `true` in a future OS update. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS 14.5+ ([Official API - URLRequest.assumesHTTP3Capable](https://developer.apple.com/documentation/foundation/urlrequest/3738175-assumeshttp3capable)) - ///- MacOS 11.3+ ([Official API - URLRequest.assumesHTTP3Capable](https://developer.apple.com/documentation/foundation/urlrequest/3738175-assumeshttp3capable)) + ///- iOS WKWebView 14.5+ ([Official API - URLRequest.assumesHTTP3Capable](https://developer.apple.com/documentation/foundation/urlrequest/3738175-assumeshttp3capable)) + ///- macOS WKWebView 11.3+ ([Official API - URLRequest.assumesHTTP3Capable](https://developer.apple.com/documentation/foundation/urlrequest/3738175-assumeshttp3capable)) bool? assumesHTTP3Capable; ///The entities that can make a network request. @@ -43,8 +43,8 @@ class URLRequest { ///If you don’t set a value, the system assumes [URLRequestAttribution.DEVELOPER]. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS 15.0+ ([Official API - URLRequest.attribution](https://developer.apple.com/documentation/foundation/urlrequest/3767318-attribution)) - ///- MacOS 12.0+ ([Official API - URLRequest.attribution](https://developer.apple.com/documentation/foundation/urlrequest/3767318-attribution)) + ///- iOS WKWebView 15.0+ ([Official API - URLRequest.attribution](https://developer.apple.com/documentation/foundation/urlrequest/3767318-attribution)) + ///- macOS WKWebView 12.0+ ([Official API - URLRequest.attribution](https://developer.apple.com/documentation/foundation/urlrequest/3767318-attribution)) URLRequestAttribution? attribution; ///The data sent as the message body of a request, such as for an HTTP POST request. @@ -53,8 +53,8 @@ class URLRequest { ///The request’s cache policy. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLRequest.cachePolicy](https://developer.apple.com/documentation/foundation/urlrequest/2011593-cachepolicy)) - ///- MacOS ([Official API - URLRequest.cachePolicy](https://developer.apple.com/documentation/foundation/urlrequest/2011593-cachepolicy)) + ///- iOS WKWebView ([Official API - URLRequest.cachePolicy](https://developer.apple.com/documentation/foundation/urlrequest/2011593-cachepolicy)) + ///- macOS WKWebView ([Official API - URLRequest.cachePolicy](https://developer.apple.com/documentation/foundation/urlrequest/2011593-cachepolicy)) URLRequestCachePolicy? cachePolicy; ///A dictionary containing all of the HTTP header fields for a request. @@ -63,15 +63,15 @@ class URLRequest { ///A Boolean value indicating whether cookies will be sent with and set for this request. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLRequest.httpShouldHandleCookies](https://developer.apple.com/documentation/foundation/urlrequest/2011548-httpshouldhandlecookies)) - ///- MacOS ([Official API - URLRequest.httpShouldHandleCookies](https://developer.apple.com/documentation/foundation/urlrequest/2011548-httpshouldhandlecookies)) + ///- iOS WKWebView ([Official API - URLRequest.httpShouldHandleCookies](https://developer.apple.com/documentation/foundation/urlrequest/2011548-httpshouldhandlecookies)) + ///- macOS WKWebView ([Official API - URLRequest.httpShouldHandleCookies](https://developer.apple.com/documentation/foundation/urlrequest/2011548-httpshouldhandlecookies)) bool? httpShouldHandleCookies; ///A Boolean value indicating whether the request should transmit before the previous response is received. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLRequest.httpShouldUsePipelining](https://developer.apple.com/documentation/foundation/urlrequest/2011508-httpshouldusepipelining)) - ///- MacOS ([Official API - URLRequest.httpShouldUsePipelining](https://developer.apple.com/documentation/foundation/urlrequest/2011508-httpshouldusepipelining)) + ///- iOS WKWebView ([Official API - URLRequest.httpShouldUsePipelining](https://developer.apple.com/documentation/foundation/urlrequest/2011508-httpshouldusepipelining)) + ///- macOS WKWebView ([Official API - URLRequest.httpShouldUsePipelining](https://developer.apple.com/documentation/foundation/urlrequest/2011508-httpshouldusepipelining)) bool? httpShouldUsePipelining; ///Use [allowsCellularAccess] instead. @@ -114,8 +114,8 @@ class URLRequest { ///This URL is used for the cookie “same domain as main document” policy. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLRequest.mainDocumentURL](https://developer.apple.com/documentation/foundation/urlrequest/2011552-maindocumenturl)) - ///- MacOS ([Official API - URLRequest.mainDocumentURL](https://developer.apple.com/documentation/foundation/urlrequest/2011552-maindocumenturl)) + ///- iOS WKWebView ([Official API - URLRequest.mainDocumentURL](https://developer.apple.com/documentation/foundation/urlrequest/2011552-maindocumenturl)) + ///- macOS WKWebView ([Official API - URLRequest.mainDocumentURL](https://developer.apple.com/documentation/foundation/urlrequest/2011552-maindocumenturl)) WebUri? mainDocumentURL; ///The HTTP request method. @@ -126,15 +126,15 @@ class URLRequest { ///The service type associated with this request. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLRequest.networkServiceType](https://developer.apple.com/documentation/foundation/urlrequest/2011409-networkservicetype)) - ///- MacOS ([Official API - URLRequest.networkServiceType](https://developer.apple.com/documentation/foundation/urlrequest/2011409-networkservicetype)) + ///- iOS WKWebView ([Official API - URLRequest.networkServiceType](https://developer.apple.com/documentation/foundation/urlrequest/2011409-networkservicetype)) + ///- macOS WKWebView ([Official API - URLRequest.networkServiceType](https://developer.apple.com/documentation/foundation/urlrequest/2011409-networkservicetype)) URLRequestNetworkServiceType? networkServiceType; ///The timeout interval of the request. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLRequest.timeoutInterval](https://developer.apple.com/documentation/foundation/urlrequest/2011509-timeoutinterval)) - ///- MacOS ([Official API - URLRequest.timeoutInterval](https://developer.apple.com/documentation/foundation/urlrequest/2011509-timeoutinterval)) + ///- iOS WKWebView ([Official API - URLRequest.timeoutInterval](https://developer.apple.com/documentation/foundation/urlrequest/2011509-timeoutinterval)) + ///- macOS WKWebView ([Official API - URLRequest.timeoutInterval](https://developer.apple.com/documentation/foundation/urlrequest/2011509-timeoutinterval)) double? timeoutInterval; ///The URL of the request. Setting this to `null` will load `about:blank`. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/url_request_attribution.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/url_request_attribution.g.dart index 82480202f..6fab9a089 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/url_request_attribution.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/url_request_attribution.g.dart @@ -113,6 +113,11 @@ class URLRequestAttribution { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/url_request_cache_policy.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/url_request_cache_policy.g.dart index 5bfeeba2a..c9bf1de3d 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/url_request_cache_policy.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/url_request_cache_policy.g.dart @@ -149,6 +149,11 @@ class URLRequestCachePolicy { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -300,6 +305,11 @@ class IOSURLRequestCachePolicy { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/url_request_network_service_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/url_request_network_service_type.g.dart index 2c0ee1e49..4f3e0db03 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/url_request_network_service_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/url_request_network_service_type.g.dart @@ -151,6 +151,11 @@ class URLRequestNetworkServiceType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -307,6 +312,11 @@ class IOSURLRequestNetworkServiceType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/user_preferred_content_mode.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/user_preferred_content_mode.g.dart index eadb1d2f4..941ae6876 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/user_preferred_content_mode.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/user_preferred_content_mode.g.dart @@ -113,6 +113,11 @@ class UserPreferredContentMode { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart index 9eb75b082..099370534 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/user_script.g.dart @@ -18,10 +18,10 @@ class UserScript { ///Regular Expression Pattern that will be used on JavaScript side using [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp). /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Windows + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Windows WebView2 late Set allowedOriginRules; ///A scope of execution in which to evaluate the script to prevent conflicts between different scripts. @@ -37,10 +37,10 @@ class UserScript { ///The default value is `true`. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Windows + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Windows WebView2 bool forMainFrameOnly; ///The script’s group name. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/user_script_injection_time.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/user_script_injection_time.g.dart index d7b270043..26c717bc6 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/user_script_injection_time.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/user_script_injection_time.g.dart @@ -111,6 +111,11 @@ class UserScriptInjectionTime { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/vertical_scrollbar_position.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/vertical_scrollbar_position.g.dart index 655090c24..e54226fc3 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/vertical_scrollbar_position.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/vertical_scrollbar_position.g.dart @@ -117,6 +117,11 @@ class VerticalScrollbarPosition { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); @@ -237,6 +242,11 @@ class AndroidVerticalScrollbarPosition { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/web_archive_format.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/web_archive_format.g.dart index 28d47d072..9c4adbc74 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/web_archive_format.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/web_archive_format.g.dart @@ -108,6 +108,11 @@ class WebArchiveFormat { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/web_authentication_session_error.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/web_authentication_session_error.g.dart index 268c9f0a0..410b9c7f6 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/web_authentication_session_error.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/web_authentication_session_error.g.dart @@ -116,6 +116,11 @@ class WebAuthenticationSessionError { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/web_history_item.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/web_history_item.g.dart index 698c0503f..c52f90d56 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/web_history_item.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/web_history_item.g.dart @@ -12,7 +12,7 @@ class WebHistoryItem { ///Unique id of the navigation history entry. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///- Windows WebView2 int? entryId; ///0-based position index in the back-forward [WebHistory.list]. diff --git a/flutter_inappwebview_platform_interface/lib/src/types/web_resource_error_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/web_resource_error_type.g.dart index f21682027..1932ca64a 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/web_resource_error_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/web_resource_error_type.g.dart @@ -19,8 +19,8 @@ class WebResourceErrorType { ///App Transport Security disallowed a connection because there is no secure network connection. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.appTransportSecurityRequiresSecureConnection](https://developer.apple.com/documentation/foundation/urlerror/code/2882980-apptransportsecurityrequiressecu)) - ///- MacOS ([Official API - URLError.appTransportSecurityRequiresSecureConnection](https://developer.apple.com/documentation/foundation/urlerror/code/2882980-apptransportsecurityrequiressecu)) + ///- iOS WKWebView ([Official API - URLError.appTransportSecurityRequiresSecureConnection](https://developer.apple.com/documentation/foundation/urlerror/code/2882980-apptransportsecurityrequiressecu)) + ///- macOS WKWebView ([Official API - URLError.appTransportSecurityRequiresSecureConnection](https://developer.apple.com/documentation/foundation/urlerror/code/2882980-apptransportsecurityrequiressecu)) static final APP_TRANSPORT_SECURITY_REQUIRES_SECURE_CONNECTION = WebResourceErrorType._internalMultiPlatform( 'APP_TRANSPORT_SECURITY_REQUIRES_SECURE_CONNECTION', () { @@ -38,8 +38,8 @@ class WebResourceErrorType { ///An app or app extension attempted to connect to a background session that is already connected to a process. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.backgroundSessionInUseByAnotherProcess](https://developer.apple.com/documentation/foundation/urlerror/code/2882923-backgroundsessioninusebyanotherp)) - ///- MacOS ([Official API - URLError.backgroundSessionInUseByAnotherProcess](https://developer.apple.com/documentation/foundation/urlerror/code/2882923-backgroundsessioninusebyanotherp)) + ///- iOS WKWebView ([Official API - URLError.backgroundSessionInUseByAnotherProcess](https://developer.apple.com/documentation/foundation/urlerror/code/2882923-backgroundsessioninusebyanotherp)) + ///- macOS WKWebView ([Official API - URLError.backgroundSessionInUseByAnotherProcess](https://developer.apple.com/documentation/foundation/urlerror/code/2882923-backgroundsessioninusebyanotherp)) static final BACKGROUND_SESSION_IN_USE_BY_ANOTHER_PROCESS = WebResourceErrorType._internalMultiPlatform( 'BACKGROUND_SESSION_IN_USE_BY_ANOTHER_PROCESS', () { @@ -57,8 +57,8 @@ class WebResourceErrorType { ///The shared container identifier of the URL session configuration is needed but has not been set. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.backgroundSessionRequiresSharedContainer](https://developer.apple.com/documentation/foundation/urlerror/code/2883169-backgroundsessionrequiressharedc)) - ///- MacOS ([Official API - URLError.backgroundSessionRequiresSharedContainer](https://developer.apple.com/documentation/foundation/urlerror/code/2883169-backgroundsessionrequiressharedc)) + ///- iOS WKWebView ([Official API - URLError.backgroundSessionRequiresSharedContainer](https://developer.apple.com/documentation/foundation/urlerror/code/2883169-backgroundsessionrequiressharedc)) + ///- macOS WKWebView ([Official API - URLError.backgroundSessionRequiresSharedContainer](https://developer.apple.com/documentation/foundation/urlerror/code/2883169-backgroundsessionrequiressharedc)) static final BACKGROUND_SESSION_REQUIRES_SHARED_CONTAINER = WebResourceErrorType._internalMultiPlatform( 'BACKGROUND_SESSION_REQUIRES_SHARED_CONTAINER', () { @@ -76,8 +76,8 @@ class WebResourceErrorType { ///The app is suspended or exits while a background data task is processing. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.backgroundSessionWasDisconnected](https://developer.apple.com/documentation/foundation/urlerror/code/2883075-backgroundsessionwasdisconnected)) - ///- MacOS ([Official API - URLError.backgroundSessionWasDisconnected](https://developer.apple.com/documentation/foundation/urlerror/code/2883075-backgroundsessionwasdisconnected)) + ///- iOS WKWebView ([Official API - URLError.backgroundSessionWasDisconnected](https://developer.apple.com/documentation/foundation/urlerror/code/2883075-backgroundsessionwasdisconnected)) + ///- macOS WKWebView ([Official API - URLError.backgroundSessionWasDisconnected](https://developer.apple.com/documentation/foundation/urlerror/code/2883075-backgroundsessionwasdisconnected)) static final BACKGROUND_SESSION_WAS_DISCONNECTED = WebResourceErrorType._internalMultiPlatform( 'BACKGROUND_SESSION_WAS_DISCONNECTED', () { @@ -95,9 +95,9 @@ class WebResourceErrorType { ///The URL Loading System received bad data from the server. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.badServerResponse](https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse)) - ///- MacOS ([Official API - URLError.badServerResponse](https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_ERROR_HTTP_INVALID_SERVER_RESPONSE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- iOS WKWebView ([Official API - URLError.badServerResponse](https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse)) + ///- macOS WKWebView ([Official API - URLError.badServerResponse](https://developer.apple.com/documentation/foundation/urlerror/2293606-badserverresponse)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_ERROR_HTTP_INVALID_SERVER_RESPONSE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final BAD_SERVER_RESPONSE = WebResourceErrorType._internalMultiPlatform('BAD_SERVER_RESPONSE', () { switch (defaultTargetPlatform) { @@ -116,9 +116,9 @@ class WebResourceErrorType { ///A malformed URL prevented a URL request from being initiated. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_BAD_URL](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_BAD_URL)) - ///- iOS ([Official API - URLError.badURL](https://developer.apple.com/documentation/foundation/urlerror/2293516-badurl)) - ///- MacOS ([Official API - URLError.badURL](https://developer.apple.com/documentation/foundation/urlerror/2293516-badurl)) + ///- Android WebView ([Official API - WebViewClient.ERROR_BAD_URL](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_BAD_URL)) + ///- iOS WKWebView ([Official API - URLError.badURL](https://developer.apple.com/documentation/foundation/urlerror/2293516-badurl)) + ///- macOS WKWebView ([Official API - URLError.badURL](https://developer.apple.com/documentation/foundation/urlerror/2293516-badurl)) static final BAD_URL = WebResourceErrorType._internalMultiPlatform('BAD_URL', () { switch (defaultTargetPlatform) { @@ -137,8 +137,8 @@ class WebResourceErrorType { ///A connection was attempted while a phone call is active on a network that does not support simultaneous phone and data communication (EDGE or GPRS). /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.callIsActive](https://developer.apple.com/documentation/foundation/urlerror/code/2883170-callisactive)) - ///- MacOS ([Official API - URLError.callIsActive](https://developer.apple.com/documentation/foundation/urlerror/code/2883170-callisactive)) + ///- iOS WKWebView ([Official API - URLError.callIsActive](https://developer.apple.com/documentation/foundation/urlerror/code/2883170-callisactive)) + ///- macOS WKWebView ([Official API - URLError.callIsActive](https://developer.apple.com/documentation/foundation/urlerror/code/2883170-callisactive)) static final CALL_IS_ACTIVE = WebResourceErrorType._internalMultiPlatform('CALL_IS_ACTIVE', () { switch (defaultTargetPlatform) { @@ -155,9 +155,9 @@ class WebResourceErrorType { ///An asynchronous load has been canceled. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cancelled](https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled)) - ///- MacOS ([Official API - URLError.cancelled](https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- iOS WKWebView ([Official API - URLError.cancelled](https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled)) + ///- macOS WKWebView ([Official API - URLError.cancelled](https://developer.apple.com/documentation/foundation/urlerror/code/2883178-cancelled)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_OPERATION_CANCELED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final CANCELLED = WebResourceErrorType._internalMultiPlatform('CANCELLED', () { switch (defaultTargetPlatform) { @@ -176,8 +176,8 @@ class WebResourceErrorType { ///A download task couldn’t close the downloaded file on disk. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cannotCloseFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883215-cannotclosefile)) - ///- MacOS ([Official API - URLError.cannotCloseFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883215-cannotclosefile)) + ///- iOS WKWebView ([Official API - URLError.cannotCloseFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883215-cannotclosefile)) + ///- macOS WKWebView ([Official API - URLError.cannotCloseFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883215-cannotclosefile)) static final CANNOT_CLOSE_FILE = WebResourceErrorType._internalMultiPlatform('CANNOT_CLOSE_FILE', () { switch (defaultTargetPlatform) { @@ -194,10 +194,10 @@ class WebResourceErrorType { ///Failed to connect to the server. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_CONNECT](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_CONNECT)) - ///- iOS ([Official API - URLError.cannotConnectToHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost)) - ///- MacOS ([Official API - URLError.cannotConnectToHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CANNOT_CONNECT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- Android WebView ([Official API - WebViewClient.ERROR_CONNECT](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_CONNECT)) + ///- iOS WKWebView ([Official API - URLError.cannotConnectToHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost)) + ///- macOS WKWebView ([Official API - URLError.cannotConnectToHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883001-cannotconnecttohost)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CANNOT_CONNECT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final CANNOT_CONNECT_TO_HOST = WebResourceErrorType._internalMultiPlatform('CANNOT_CONNECT_TO_HOST', () { switch (defaultTargetPlatform) { @@ -218,8 +218,8 @@ class WebResourceErrorType { ///A download task couldn’t create the downloaded file on disk because of an I/O failure. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cannotCreateFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883204-cannotcreatefile)) - ///- MacOS ([Official API - URLError.cannotCreateFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883204-cannotcreatefile)) + ///- iOS WKWebView ([Official API - URLError.cannotCreateFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883204-cannotcreatefile)) + ///- macOS WKWebView ([Official API - URLError.cannotCreateFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883204-cannotcreatefile)) static final CANNOT_CREATE_FILE = WebResourceErrorType._internalMultiPlatform('CANNOT_CREATE_FILE', () { switch (defaultTargetPlatform) { @@ -236,8 +236,8 @@ class WebResourceErrorType { ///Content data received during a connection request couldn’t be decoded for a known content encoding. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cannotDecodeContentData](https://developer.apple.com/documentation/foundation/urlerror/2292983-cannotdecodecontentdata)) - ///- MacOS ([Official API - URLError.cannotDecodeContentData](https://developer.apple.com/documentation/foundation/urlerror/2292983-cannotdecodecontentdata)) + ///- iOS WKWebView ([Official API - URLError.cannotDecodeContentData](https://developer.apple.com/documentation/foundation/urlerror/2292983-cannotdecodecontentdata)) + ///- macOS WKWebView ([Official API - URLError.cannotDecodeContentData](https://developer.apple.com/documentation/foundation/urlerror/2292983-cannotdecodecontentdata)) static final CANNOT_DECODE_CONTENT_DATA = WebResourceErrorType._internalMultiPlatform('CANNOT_DECODE_CONTENT_DATA', () { @@ -255,8 +255,8 @@ class WebResourceErrorType { ///Content data received during a connection request couldn’t be decoded for a known content encoding. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cannotDecodeRawData](https://developer.apple.com/documentation/foundation/urlerror/2293573-cannotdecoderawdata)) - ///- MacOS ([Official API - URLError.cannotDecodeRawData](https://developer.apple.com/documentation/foundation/urlerror/2293573-cannotdecoderawdata)) + ///- iOS WKWebView ([Official API - URLError.cannotDecodeRawData](https://developer.apple.com/documentation/foundation/urlerror/2293573-cannotdecoderawdata)) + ///- macOS WKWebView ([Official API - URLError.cannotDecodeRawData](https://developer.apple.com/documentation/foundation/urlerror/2293573-cannotdecoderawdata)) static final CANNOT_DECODE_RAW_DATA = WebResourceErrorType._internalMultiPlatform('CANNOT_DECODE_RAW_DATA', () { switch (defaultTargetPlatform) { @@ -273,8 +273,8 @@ class WebResourceErrorType { ///A request to load an item only from the cache could not be satisfied. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cannotLoadFromNetwork](https://developer.apple.com/documentation/foundation/urlerror/code/2882968-cannotloadfromnetwork)) - ///- MacOS ([Official API - URLError.cannotLoadFromNetwork](https://developer.apple.com/documentation/foundation/urlerror/code/2882968-cannotloadfromnetwork)) + ///- iOS WKWebView ([Official API - URLError.cannotLoadFromNetwork](https://developer.apple.com/documentation/foundation/urlerror/code/2882968-cannotloadfromnetwork)) + ///- macOS WKWebView ([Official API - URLError.cannotLoadFromNetwork](https://developer.apple.com/documentation/foundation/urlerror/code/2882968-cannotloadfromnetwork)) static final CANNOT_LOAD_FROM_NETWORK = WebResourceErrorType._internalMultiPlatform('CANNOT_LOAD_FROM_NETWORK', () { @@ -292,8 +292,8 @@ class WebResourceErrorType { ///A download task was unable to move a downloaded file on disk. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cannotMoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883180-cannotmovefile)) - ///- MacOS ([Official API - URLError.cannotMoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883180-cannotmovefile)) + ///- iOS WKWebView ([Official API - URLError.cannotMoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883180-cannotmovefile)) + ///- macOS WKWebView ([Official API - URLError.cannotMoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883180-cannotmovefile)) static final CANNOT_MOVE_FILE = WebResourceErrorType._internalMultiPlatform('CANNOT_MOVE_FILE', () { switch (defaultTargetPlatform) { @@ -310,8 +310,8 @@ class WebResourceErrorType { ///A download task was unable to open the downloaded file on disk. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cannotOpenFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883034-cannotopenfile)) - ///- MacOS ([Official API - URLError.cannotOpenFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883034-cannotopenfile)) + ///- iOS WKWebView ([Official API - URLError.cannotOpenFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883034-cannotopenfile)) + ///- macOS WKWebView ([Official API - URLError.cannotOpenFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883034-cannotopenfile)) static final CANNOT_OPEN_FILE = WebResourceErrorType._internalMultiPlatform('CANNOT_OPEN_FILE', () { switch (defaultTargetPlatform) { @@ -328,8 +328,8 @@ class WebResourceErrorType { ///A task could not parse a response. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cannotParseResponse](https://developer.apple.com/documentation/foundation/urlerror/code/2882919-cannotparseresponse)) - ///- MacOS ([Official API - URLError.cannotParseResponse](https://developer.apple.com/documentation/foundation/urlerror/code/2882919-cannotparseresponse)) + ///- iOS WKWebView ([Official API - URLError.cannotParseResponse](https://developer.apple.com/documentation/foundation/urlerror/code/2882919-cannotparseresponse)) + ///- macOS WKWebView ([Official API - URLError.cannotParseResponse](https://developer.apple.com/documentation/foundation/urlerror/code/2882919-cannotparseresponse)) static final CANNOT_PARSE_RESPONSE = WebResourceErrorType._internalMultiPlatform('CANNOT_PARSE_RESPONSE', () { switch (defaultTargetPlatform) { @@ -346,8 +346,8 @@ class WebResourceErrorType { ///A download task was unable to remove a downloaded file from disk. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cannotRemoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883202-cannotremovefile)) - ///- MacOS ([Official API - URLError.cannotRemoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883202-cannotremovefile)) + ///- iOS WKWebView ([Official API - URLError.cannotRemoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883202-cannotremovefile)) + ///- macOS WKWebView ([Official API - URLError.cannotRemoveFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883202-cannotremovefile)) static final CANNOT_REMOVE_FILE = WebResourceErrorType._internalMultiPlatform('CANNOT_REMOVE_FILE', () { switch (defaultTargetPlatform) { @@ -364,8 +364,8 @@ class WebResourceErrorType { ///A download task was unable to write to the downloaded file on disk. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.cannotWriteToFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883098-cannotwritetofile)) - ///- MacOS ([Official API - URLError.cannotWriteToFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883098-cannotwritetofile)) + ///- iOS WKWebView ([Official API - URLError.cannotWriteToFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883098-cannotwritetofile)) + ///- macOS WKWebView ([Official API - URLError.cannotWriteToFile](https://developer.apple.com/documentation/foundation/urlerror/code/2883098-cannotwritetofile)) static final CANNOT_WRITE_TO_FILE = WebResourceErrorType._internalMultiPlatform('CANNOT_WRITE_TO_FILE', () { switch (defaultTargetPlatform) { @@ -382,8 +382,8 @@ class WebResourceErrorType { ///A server certificate was rejected. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.clientCertificateRejected](https://developer.apple.com/documentation/foundation/urlerror/code/2883091-clientcertificaterejected)) - ///- MacOS ([Official API - URLError.clientCertificateRejected](https://developer.apple.com/documentation/foundation/urlerror/code/2883091-clientcertificaterejected)) + ///- iOS WKWebView ([Official API - URLError.clientCertificateRejected](https://developer.apple.com/documentation/foundation/urlerror/code/2883091-clientcertificaterejected)) + ///- macOS WKWebView ([Official API - URLError.clientCertificateRejected](https://developer.apple.com/documentation/foundation/urlerror/code/2883091-clientcertificaterejected)) static final CLIENT_CERTIFICATE_REJECTED = WebResourceErrorType._internalMultiPlatform('CLIENT_CERTIFICATE_REJECTED', () { @@ -401,8 +401,8 @@ class WebResourceErrorType { ///A client certificate was required to authenticate an SSL connection during a request. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.clientCertificateRequired](https://developer.apple.com/documentation/foundation/urlerror/code/2883199-clientcertificaterequired)) - ///- MacOS ([Official API - URLError.clientCertificateRequired](https://developer.apple.com/documentation/foundation/urlerror/code/2883199-clientcertificaterequired)) + ///- iOS WKWebView ([Official API - URLError.clientCertificateRequired](https://developer.apple.com/documentation/foundation/urlerror/code/2883199-clientcertificaterequired)) + ///- macOS WKWebView ([Official API - URLError.clientCertificateRequired](https://developer.apple.com/documentation/foundation/urlerror/code/2883199-clientcertificaterequired)) static final CLIENT_CERTIFICATE_REQUIRED = WebResourceErrorType._internalMultiPlatform('CLIENT_CERTIFICATE_REQUIRED', () { @@ -420,7 +420,7 @@ class WebResourceErrorType { ///Indicates that the connection was stopped. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_ABORTED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_ABORTED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final CONNECTION_ABORTED = WebResourceErrorType._internalMultiPlatform('CONNECTION_ABORTED', () { switch (defaultTargetPlatform) { @@ -435,8 +435,8 @@ class WebResourceErrorType { ///The length of the resource data exceeds the maximum allowed. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.dataLengthExceedsMaximum](https://developer.apple.com/documentation/foundation/urlerror/code/2882930-datalengthexceedsmaximum)) - ///- MacOS ([Official API - URLError.dataLengthExceedsMaximum](https://developer.apple.com/documentation/foundation/urlerror/code/2882930-datalengthexceedsmaximum)) + ///- iOS WKWebView ([Official API - URLError.dataLengthExceedsMaximum](https://developer.apple.com/documentation/foundation/urlerror/code/2882930-datalengthexceedsmaximum)) + ///- macOS WKWebView ([Official API - URLError.dataLengthExceedsMaximum](https://developer.apple.com/documentation/foundation/urlerror/code/2882930-datalengthexceedsmaximum)) static final DATA_LENGTH_EXCEEDS_MAXIMUM = WebResourceErrorType._internalMultiPlatform('DATA_LENGTH_EXCEEDS_MAXIMUM', () { @@ -454,8 +454,8 @@ class WebResourceErrorType { ///The cellular network disallowed a connection. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.dataNotAllowed](https://developer.apple.com/documentation/foundation/urlerror/code/2883217-datanotallowed)) - ///- MacOS ([Official API - URLError.dataNotAllowed](https://developer.apple.com/documentation/foundation/urlerror/code/2883217-datanotallowed)) + ///- iOS WKWebView ([Official API - URLError.dataNotAllowed](https://developer.apple.com/documentation/foundation/urlerror/code/2883217-datanotallowed)) + ///- macOS WKWebView ([Official API - URLError.dataNotAllowed](https://developer.apple.com/documentation/foundation/urlerror/code/2883217-datanotallowed)) static final DATA_NOT_ALLOWED = WebResourceErrorType._internalMultiPlatform('DATA_NOT_ALLOWED', () { switch (defaultTargetPlatform) { @@ -472,8 +472,8 @@ class WebResourceErrorType { ///A download task failed to decode an encoded file during the download. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.downloadDecodingFailedMidStream](https://developer.apple.com/documentation/foundation/urlerror/code/2883224-downloaddecodingfailedmidstream)) - ///- MacOS ([Official API - URLError.downloadDecodingFailedMidStream](https://developer.apple.com/documentation/foundation/urlerror/code/2883224-downloaddecodingfailedmidstream)) + ///- iOS WKWebView ([Official API - URLError.downloadDecodingFailedMidStream](https://developer.apple.com/documentation/foundation/urlerror/code/2883224-downloaddecodingfailedmidstream)) + ///- macOS WKWebView ([Official API - URLError.downloadDecodingFailedMidStream](https://developer.apple.com/documentation/foundation/urlerror/code/2883224-downloaddecodingfailedmidstream)) static final DOWNLOAD_DECODING_FAILED_MID_STREAM = WebResourceErrorType._internalMultiPlatform( 'DOWNLOAD_DECODING_FAILED_MID_STREAM', () { @@ -491,8 +491,8 @@ class WebResourceErrorType { ///A download task failed to decode an encoded file after downloading. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.downloadDecodingFailedToComplete](https://developer.apple.com/documentation/foundation/urlerror/code/2882936-downloaddecodingfailedtocomplete)) - ///- MacOS ([Official API - URLError.downloadDecodingFailedToComplete](https://developer.apple.com/documentation/foundation/urlerror/code/2882936-downloaddecodingfailedtocomplete)) + ///- iOS WKWebView ([Official API - URLError.downloadDecodingFailedToComplete](https://developer.apple.com/documentation/foundation/urlerror/code/2882936-downloaddecodingfailedtocomplete)) + ///- macOS WKWebView ([Official API - URLError.downloadDecodingFailedToComplete](https://developer.apple.com/documentation/foundation/urlerror/code/2882936-downloaddecodingfailedtocomplete)) static final DOWNLOAD_DECODING_FAILED_TO_COMPLETE = WebResourceErrorType._internalMultiPlatform( 'DOWNLOAD_DECODING_FAILED_TO_COMPLETE', () { @@ -510,7 +510,7 @@ class WebResourceErrorType { ///Failed to perform SSL handshake. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_FAILED_SSL_HANDSHAKE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FAILED_SSL_HANDSHAKE)) + ///- Android WebView ([Official API - WebViewClient.ERROR_FAILED_SSL_HANDSHAKE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FAILED_SSL_HANDSHAKE)) static final FAILED_SSL_HANDSHAKE = WebResourceErrorType._internalMultiPlatform('FAILED_SSL_HANDSHAKE', () { switch (defaultTargetPlatform) { @@ -525,8 +525,8 @@ class WebResourceErrorType { ///A request for an FTP file resulted in the server responding that the file is not a plain file, but a directory. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.fileIsDirectory](https://developer.apple.com/documentation/foundation/urlerror/code/2883220-fileisdirectory)) - ///- MacOS ([Official API - URLError.fileIsDirectory](https://developer.apple.com/documentation/foundation/urlerror/code/2883220-fileisdirectory)) + ///- iOS WKWebView ([Official API - URLError.fileIsDirectory](https://developer.apple.com/documentation/foundation/urlerror/code/2883220-fileisdirectory)) + ///- macOS WKWebView ([Official API - URLError.fileIsDirectory](https://developer.apple.com/documentation/foundation/urlerror/code/2883220-fileisdirectory)) static final FILE_IS_DIRECTORY = WebResourceErrorType._internalMultiPlatform('FILE_IS_DIRECTORY', () { switch (defaultTargetPlatform) { @@ -543,9 +543,9 @@ class WebResourceErrorType { ///File not found. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_FILE_NOT_FOUND](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FILE_NOT_FOUND)) - ///- iOS ([Official API - URLError.fileDoesNotExist](https://developer.apple.com/documentation/foundation/urlerror/code/2883074-filedoesnotexist)) - ///- MacOS ([Official API - URLError.fileDoesNotExist](https://developer.apple.com/documentation/foundation/urlerror/code/2883074-filedoesnotexist)) + ///- Android WebView ([Official API - WebViewClient.ERROR_FILE_NOT_FOUND](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FILE_NOT_FOUND)) + ///- iOS WKWebView ([Official API - URLError.fileDoesNotExist](https://developer.apple.com/documentation/foundation/urlerror/code/2883074-filedoesnotexist)) + ///- macOS WKWebView ([Official API - URLError.fileDoesNotExist](https://developer.apple.com/documentation/foundation/urlerror/code/2883074-filedoesnotexist)) static final FILE_NOT_FOUND = WebResourceErrorType._internalMultiPlatform('FILE_NOT_FOUND', () { switch (defaultTargetPlatform) { @@ -564,7 +564,7 @@ class WebResourceErrorType { ///Generic file error. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_FILE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FILE)) + ///- Android WebView ([Official API - WebViewClient.ERROR_FILE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_FILE)) static final GENERIC_FILE_ERROR = WebResourceErrorType._internalMultiPlatform('GENERIC_FILE_ERROR', () { switch (defaultTargetPlatform) { @@ -579,10 +579,10 @@ class WebResourceErrorType { ///Server or proxy hostname lookup failed. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_HOST_LOOKUP](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_HOST_LOOKUP)) - ///- iOS ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost)) - ///- MacOS ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_HOST_NAME_NOT_RESOLVED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- Android WebView ([Official API - WebViewClient.ERROR_HOST_LOOKUP](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_HOST_LOOKUP)) + ///- iOS WKWebView ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost)) + ///- macOS WKWebView ([Official API - URLError.cannotFindHost](https://developer.apple.com/documentation/foundation/urlerror/code/2883157-cannotfindhost)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_HOST_NAME_NOT_RESOLVED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final HOST_LOOKUP = WebResourceErrorType._internalMultiPlatform('HOST_LOOKUP', () { switch (defaultTargetPlatform) { @@ -603,8 +603,8 @@ class WebResourceErrorType { ///The attempted connection required activating a data context while roaming, but international roaming is disabled. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.internationalRoamingOff](https://developer.apple.com/documentation/foundation/urlerror/code/2883134-internationalroamingoff)) - ///- MacOS ([Official API - URLError.internationalRoamingOff](https://developer.apple.com/documentation/foundation/urlerror/code/2883134-internationalroamingoff)) + ///- iOS WKWebView ([Official API - URLError.internationalRoamingOff](https://developer.apple.com/documentation/foundation/urlerror/code/2883134-internationalroamingoff)) + ///- macOS WKWebView ([Official API - URLError.internationalRoamingOff](https://developer.apple.com/documentation/foundation/urlerror/code/2883134-internationalroamingoff)) static final INTERNATIONAL_ROAMING_OFF = WebResourceErrorType._internalMultiPlatform('INTERNATIONAL_ROAMING_OFF', () { @@ -622,7 +622,7 @@ class WebResourceErrorType { ///Failed to read or write to the server. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_IO](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_IO)) + ///- Android WebView ([Official API - WebViewClient.ERROR_IO](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_IO)) static final IO = WebResourceErrorType._internalMultiPlatform('IO', () { switch (defaultTargetPlatform) { case TargetPlatform.android: @@ -636,9 +636,9 @@ class WebResourceErrorType { ///A client or server connection was severed in the middle of an in-progress load. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.networkConnectionLost](https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost)) - ///- MacOS ([Official API - URLError.networkConnectionLost](https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_DISCONNECTED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- iOS WKWebView ([Official API - URLError.networkConnectionLost](https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost)) + ///- macOS WKWebView ([Official API - URLError.networkConnectionLost](https://developer.apple.com/documentation/foundation/urlerror/2293759-networkconnectionlost)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_DISCONNECTED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final NETWORK_CONNECTION_LOST = WebResourceErrorType._internalMultiPlatform('NETWORK_CONNECTION_LOST', () { @@ -658,8 +658,8 @@ class WebResourceErrorType { ///A network resource was requested, but an internet connection hasn’t been established and can’t be established automatically. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.notConnectedToInternet](https://developer.apple.com/documentation/foundation/urlerror/2293104-notconnectedtointernet)) - ///- MacOS ([Official API - URLError.notConnectedToInternet](https://developer.apple.com/documentation/foundation/urlerror/2293104-notconnectedtointernet)) + ///- iOS WKWebView ([Official API - URLError.notConnectedToInternet](https://developer.apple.com/documentation/foundation/urlerror/2293104-notconnectedtointernet)) + ///- macOS WKWebView ([Official API - URLError.notConnectedToInternet](https://developer.apple.com/documentation/foundation/urlerror/2293104-notconnectedtointernet)) static final NOT_CONNECTED_TO_INTERNET = WebResourceErrorType._internalMultiPlatform('NOT_CONNECTED_TO_INTERNET', () { @@ -677,8 +677,8 @@ class WebResourceErrorType { ///A resource couldn’t be read because of insufficient permissions. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.noPermissionsToReadFile](https://developer.apple.com/documentation/foundation/urlerror/code/2882941-nopermissionstoreadfile)) - ///- MacOS ([Official API - URLError.noPermissionsToReadFile](https://developer.apple.com/documentation/foundation/urlerror/code/2882941-nopermissionstoreadfile)) + ///- iOS WKWebView ([Official API - URLError.noPermissionsToReadFile](https://developer.apple.com/documentation/foundation/urlerror/code/2882941-nopermissionstoreadfile)) + ///- macOS WKWebView ([Official API - URLError.noPermissionsToReadFile](https://developer.apple.com/documentation/foundation/urlerror/code/2882941-nopermissionstoreadfile)) static final NO_PERMISSIONS_TO_READ_FILE = WebResourceErrorType._internalMultiPlatform('NO_PERMISSIONS_TO_READ_FILE', () { @@ -696,7 +696,7 @@ class WebResourceErrorType { ///User authentication failed on proxy. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_PROXY_AUTHENTICATION](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_PROXY_AUTHENTICATION)) + ///- Android WebView ([Official API - WebViewClient.ERROR_PROXY_AUTHENTICATION](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_PROXY_AUTHENTICATION)) static final PROXY_AUTHENTICATION = WebResourceErrorType._internalMultiPlatform('PROXY_AUTHENTICATION', () { switch (defaultTargetPlatform) { @@ -711,7 +711,7 @@ class WebResourceErrorType { ///Indicates that the request redirect failed. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_REDIRECT_FAILED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_REDIRECT_FAILED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final REDIRECT_FAILED = WebResourceErrorType._internalMultiPlatform('REDIRECT_FAILED', () { switch (defaultTargetPlatform) { @@ -726,8 +726,8 @@ class WebResourceErrorType { ///A redirect was specified by way of server response code, but the server didn’t accompany this code with a redirect URL. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.redirectToNonExistentLocation](https://developer.apple.com/documentation/foundation/urlerror/2293066-redirecttononexistentlocation)) - ///- MacOS ([Official API - URLError.redirectToNonExistentLocation](https://developer.apple.com/documentation/foundation/urlerror/2293066-redirecttononexistentlocation)) + ///- iOS WKWebView ([Official API - URLError.redirectToNonExistentLocation](https://developer.apple.com/documentation/foundation/urlerror/2293066-redirecttononexistentlocation)) + ///- macOS WKWebView ([Official API - URLError.redirectToNonExistentLocation](https://developer.apple.com/documentation/foundation/urlerror/2293066-redirecttononexistentlocation)) static final REDIRECT_TO_NON_EXISTENT_LOCATION = WebResourceErrorType._internalMultiPlatform( 'REDIRECT_TO_NON_EXISTENT_LOCATION', () { @@ -745,8 +745,8 @@ class WebResourceErrorType { ///A body stream is needed but the client did not provide one. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.requestBodyStreamExhausted](https://developer.apple.com/documentation/foundation/urlerror/code/2883176-requestbodystreamexhausted)) - ///- MacOS ([Official API - URLError.requestBodyStreamExhausted](https://developer.apple.com/documentation/foundation/urlerror/code/2883176-requestbodystreamexhausted)) + ///- iOS WKWebView ([Official API - URLError.requestBodyStreamExhausted](https://developer.apple.com/documentation/foundation/urlerror/code/2883176-requestbodystreamexhausted)) + ///- macOS WKWebView ([Official API - URLError.requestBodyStreamExhausted](https://developer.apple.com/documentation/foundation/urlerror/code/2883176-requestbodystreamexhausted)) static final REQUEST_BODY_STREAM_EXHAUSTED = WebResourceErrorType._internalMultiPlatform( 'REQUEST_BODY_STREAM_EXHAUSTED', () { @@ -764,7 +764,7 @@ class WebResourceErrorType { ///Indicates that the connection was reset. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_RESET](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_CONNECTION_RESET](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final RESET = WebResourceErrorType._internalMultiPlatform('RESET', () { switch (defaultTargetPlatform) { case TargetPlatform.windows: @@ -779,8 +779,8 @@ class WebResourceErrorType { ///This error can indicate a file-not-found situation, or decoding problems that prevent data from being processed correctly. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.resourceUnavailable](https://developer.apple.com/documentation/foundation/urlerror/2293555-resourceunavailable)) - ///- MacOS ([Official API - URLError.resourceUnavailable](https://developer.apple.com/documentation/foundation/urlerror/2293555-resourceunavailable)) + ///- iOS WKWebView ([Official API - URLError.resourceUnavailable](https://developer.apple.com/documentation/foundation/urlerror/2293555-resourceunavailable)) + ///- macOS WKWebView ([Official API - URLError.resourceUnavailable](https://developer.apple.com/documentation/foundation/urlerror/2293555-resourceunavailable)) static final RESOURCE_UNAVAILABLE = WebResourceErrorType._internalMultiPlatform('RESOURCE_UNAVAILABLE', () { switch (defaultTargetPlatform) { @@ -797,8 +797,8 @@ class WebResourceErrorType { ///An attempt to establish a secure connection failed for reasons that can’t be expressed more specifically. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.secureConnectionFailed](https://developer.apple.com/documentation/foundation/urlerror/code/2883122-secureconnectionfailed)) - ///- MacOS ([Official API - URLError.secureConnectionFailed](https://developer.apple.com/documentation/foundation/urlerror/code/2883122-secureconnectionfailed)) + ///- iOS WKWebView ([Official API - URLError.secureConnectionFailed](https://developer.apple.com/documentation/foundation/urlerror/code/2883122-secureconnectionfailed)) + ///- macOS WKWebView ([Official API - URLError.secureConnectionFailed](https://developer.apple.com/documentation/foundation/urlerror/code/2883122-secureconnectionfailed)) static final SECURE_CONNECTION_FAILED = WebResourceErrorType._internalMultiPlatform('SECURE_CONNECTION_FAILED', () { @@ -816,8 +816,8 @@ class WebResourceErrorType { ///A server certificate had a date which indicates it has expired, or is not yet valid. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.serverCertificateHasBadDate](https://developer.apple.com/documentation/foundation/urlerror/code/2883088-servercertificatehasbaddate)) - ///- MacOS ([Official API - URLError.serverCertificateHasBadDate](https://developer.apple.com/documentation/foundation/urlerror/code/2883088-servercertificatehasbaddate)) + ///- iOS WKWebView ([Official API - URLError.serverCertificateHasBadDate](https://developer.apple.com/documentation/foundation/urlerror/code/2883088-servercertificatehasbaddate)) + ///- macOS WKWebView ([Official API - URLError.serverCertificateHasBadDate](https://developer.apple.com/documentation/foundation/urlerror/code/2883088-servercertificatehasbaddate)) static final SERVER_CERTIFICATE_HAS_BAD_DATE = WebResourceErrorType._internalMultiPlatform( 'SERVER_CERTIFICATE_HAS_BAD_DATE', () { @@ -835,8 +835,8 @@ class WebResourceErrorType { ///A server certificate was not signed by any root server. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.serverCertificateHasUnknownRoot](https://developer.apple.com/documentation/foundation/urlerror/code/2883085-servercertificatehasunknownroot)) - ///- MacOS ([Official API - URLError.serverCertificateHasUnknownRoot](https://developer.apple.com/documentation/foundation/urlerror/code/2883085-servercertificatehasunknownroot)) + ///- iOS WKWebView ([Official API - URLError.serverCertificateHasUnknownRoot](https://developer.apple.com/documentation/foundation/urlerror/code/2883085-servercertificatehasunknownroot)) + ///- macOS WKWebView ([Official API - URLError.serverCertificateHasUnknownRoot](https://developer.apple.com/documentation/foundation/urlerror/code/2883085-servercertificatehasunknownroot)) static final SERVER_CERTIFICATE_HAS_UNKNOWN_ROOT = WebResourceErrorType._internalMultiPlatform( 'SERVER_CERTIFICATE_HAS_UNKNOWN_ROOT', () { @@ -854,8 +854,8 @@ class WebResourceErrorType { ///A server certificate is not yet valid. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.serverCertificateNotYetValid](https://developer.apple.com/documentation/foundation/urlerror/code/2882991-servercertificatenotyetvalid)) - ///- MacOS ([Official API - URLError.serverCertificateNotYetValid](https://developer.apple.com/documentation/foundation/urlerror/code/2882991-servercertificatenotyetvalid)) + ///- iOS WKWebView ([Official API - URLError.serverCertificateNotYetValid](https://developer.apple.com/documentation/foundation/urlerror/code/2882991-servercertificatenotyetvalid)) + ///- macOS WKWebView ([Official API - URLError.serverCertificateNotYetValid](https://developer.apple.com/documentation/foundation/urlerror/code/2882991-servercertificatenotyetvalid)) static final SERVER_CERTIFICATE_NOT_YET_VALID = WebResourceErrorType._internalMultiPlatform( 'SERVER_CERTIFICATE_NOT_YET_VALID', () { @@ -873,8 +873,8 @@ class WebResourceErrorType { ///A server certificate was signed by a root server that isn’t trusted. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.serverCertificateUntrusted](https://developer.apple.com/documentation/foundation/urlerror/code/2882976-servercertificateuntrusted)) - ///- MacOS ([Official API - URLError.serverCertificateUntrusted](https://developer.apple.com/documentation/foundation/urlerror/code/2882976-servercertificateuntrusted)) + ///- iOS WKWebView ([Official API - URLError.serverCertificateUntrusted](https://developer.apple.com/documentation/foundation/urlerror/code/2882976-servercertificateuntrusted)) + ///- macOS WKWebView ([Official API - URLError.serverCertificateUntrusted](https://developer.apple.com/documentation/foundation/urlerror/code/2882976-servercertificateuntrusted)) static final SERVER_CERTIFICATE_UNTRUSTED = WebResourceErrorType._internalMultiPlatform( 'SERVER_CERTIFICATE_UNTRUSTED', () { @@ -892,7 +892,7 @@ class WebResourceErrorType { ///Indicates that the host is unreachable. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_SERVER_UNREACHABLE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_SERVER_UNREACHABLE](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final SERVER_UNREACHABLE = WebResourceErrorType._internalMultiPlatform('SERVER_UNREACHABLE', () { switch (defaultTargetPlatform) { @@ -907,10 +907,10 @@ class WebResourceErrorType { ///Connection timed out. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_TIMEOUT](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TIMEOUT)) - ///- iOS ([Official API - URLError.timedOut](https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout)) - ///- MacOS ([Official API - URLError.timedOut](https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_TIMEOUT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- Android WebView ([Official API - WebViewClient.ERROR_TIMEOUT](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TIMEOUT)) + ///- iOS WKWebView ([Official API - URLError.timedOut](https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout)) + ///- macOS WKWebView ([Official API - URLError.timedOut](https://developer.apple.com/documentation/foundation/urlerror/code/2883027-timedout)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_TIMEOUT](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final TIMEOUT = WebResourceErrorType._internalMultiPlatform('TIMEOUT', () { switch (defaultTargetPlatform) { @@ -931,9 +931,9 @@ class WebResourceErrorType { ///A redirect loop has been detected or the threshold for number of allowable redirects has been exceeded (currently `16` on iOS). /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_REDIRECT_LOOP](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_REDIRECT_LOOP)) - ///- iOS ([Official API - URLError.httpTooManyRedirects](https://developer.apple.com/documentation/foundation/urlerror/code/2883099-httptoomanyredirects)) - ///- MacOS ([Official API - URLError.httpTooManyRedirects](https://developer.apple.com/documentation/foundation/urlerror/code/2883099-httptoomanyredirects)) + ///- Android WebView ([Official API - WebViewClient.ERROR_REDIRECT_LOOP](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_REDIRECT_LOOP)) + ///- iOS WKWebView ([Official API - URLError.httpTooManyRedirects](https://developer.apple.com/documentation/foundation/urlerror/code/2883099-httptoomanyredirects)) + ///- macOS WKWebView ([Official API - URLError.httpTooManyRedirects](https://developer.apple.com/documentation/foundation/urlerror/code/2883099-httptoomanyredirects)) static final TOO_MANY_REDIRECTS = WebResourceErrorType._internalMultiPlatform('TOO_MANY_REDIRECTS', () { switch (defaultTargetPlatform) { @@ -952,7 +952,7 @@ class WebResourceErrorType { ///Too many requests during this load. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_TOO_MANY_REQUESTS](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TOO_MANY_REQUESTS)) + ///- Android WebView ([Official API - WebViewClient.ERROR_TOO_MANY_REQUESTS](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_TOO_MANY_REQUESTS)) static final TOO_MANY_REQUESTS = WebResourceErrorType._internalMultiPlatform('TOO_MANY_REQUESTS', () { switch (defaultTargetPlatform) { @@ -967,7 +967,7 @@ class WebResourceErrorType { ///Indicates that an unexpected error occurred. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_UNEXPECTED_ERROR](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_UNEXPECTED_ERROR](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final UNEXPECTED_ERROR = WebResourceErrorType._internalMultiPlatform('UNEXPECTED_ERROR', () { switch (defaultTargetPlatform) { @@ -982,10 +982,10 @@ class WebResourceErrorType { ///The URL Loading System encountered an error that it can’t interpret. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_UNKNOWN](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNKNOWN)) - ///- iOS ([Official API - URLError.unknown](https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown)) - ///- MacOS ([Official API - URLError.unknown](https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_UNKNOWN](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- Android WebView ([Official API - WebViewClient.ERROR_UNKNOWN](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNKNOWN)) + ///- iOS WKWebView ([Official API - URLError.unknown](https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown)) + ///- macOS WKWebView ([Official API - URLError.unknown](https://developer.apple.com/documentation/foundation/urlerror/2293357-unknown)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_UNKNOWN](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final UNKNOWN = WebResourceErrorType._internalMultiPlatform('UNKNOWN', () { switch (defaultTargetPlatform) { @@ -1006,7 +1006,7 @@ class WebResourceErrorType { ///Resource load was canceled by Safe Browsing. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_UNSAFE_RESOURCE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSAFE_RESOURCE)) + ///- Android WebView ([Official API - WebViewClient.ERROR_UNSAFE_RESOURCE](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSAFE_RESOURCE)) static final UNSAFE_RESOURCE = WebResourceErrorType._internalMultiPlatform('UNSAFE_RESOURCE', () { switch (defaultTargetPlatform) { @@ -1021,7 +1021,7 @@ class WebResourceErrorType { ///Unsupported authentication scheme (not basic or digest). /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_UNSUPPORTED_AUTH_SCHEME](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSUPPORTED_AUTH_SCHEME)) + ///- Android WebView ([Official API - WebViewClient.ERROR_UNSUPPORTED_AUTH_SCHEME](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSUPPORTED_AUTH_SCHEME)) static final UNSUPPORTED_AUTH_SCHEME = WebResourceErrorType._internalMultiPlatform('UNSUPPORTED_AUTH_SCHEME', () { @@ -1038,9 +1038,9 @@ class WebResourceErrorType { ///Typically this occurs when there is no available protocol handler for the URL. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_UNSUPPORTED_SCHEME](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSUPPORTED_SCHEME)) - ///- iOS ([Official API - URLError.unsupportedURL](https://developer.apple.com/documentation/foundation/urlerror/code/2883043-unsupportedurl)) - ///- MacOS ([Official API - URLError.unsupportedURL](https://developer.apple.com/documentation/foundation/urlerror/code/2883043-unsupportedurl)) + ///- Android WebView ([Official API - WebViewClient.ERROR_UNSUPPORTED_SCHEME](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_UNSUPPORTED_SCHEME)) + ///- iOS WKWebView ([Official API - URLError.unsupportedURL](https://developer.apple.com/documentation/foundation/urlerror/code/2883043-unsupportedurl)) + ///- macOS WKWebView ([Official API - URLError.unsupportedURL](https://developer.apple.com/documentation/foundation/urlerror/code/2883043-unsupportedurl)) static final UNSUPPORTED_SCHEME = WebResourceErrorType._internalMultiPlatform('UNSUPPORTED_SCHEME', () { switch (defaultTargetPlatform) { @@ -1059,7 +1059,7 @@ class WebResourceErrorType { ///User authentication failed on server. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebViewClient.ERROR_AUTHENTICATION](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_AUTHENTICATION)) + ///- Android WebView ([Official API - WebViewClient.ERROR_AUTHENTICATION](https://developer.android.com/reference/android/webkit/WebViewClient#ERROR_AUTHENTICATION)) static final USER_AUTHENTICATION_FAILED = WebResourceErrorType._internalMultiPlatform('USER_AUTHENTICATION_FAILED', () { @@ -1075,9 +1075,9 @@ class WebResourceErrorType { ///Authentication is required to access a resource. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.userAuthenticationRequired](https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired)) - ///- MacOS ([Official API - URLError.userAuthenticationRequired](https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired)) - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- iOS WKWebView ([Official API - URLError.userAuthenticationRequired](https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired)) + ///- macOS WKWebView ([Official API - URLError.userAuthenticationRequired](https://developer.apple.com/documentation/foundation/urlerror/2293560-userauthenticationrequired)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_VALID_AUTHENTICATION_CREDENTIALS_REQUIRED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final USER_AUTHENTICATION_REQUIRED = WebResourceErrorType._internalMultiPlatform( 'USER_AUTHENTICATION_REQUIRED', () { @@ -1098,8 +1098,8 @@ class WebResourceErrorType { ///This error typically occurs when a user clicks a "Cancel" button in a username/password dialog, rather than attempting to authenticate. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.userCancelledAuthentication](https://developer.apple.com/documentation/foundation/urlerror/2293330-usercancelledauthentication)) - ///- MacOS ([Official API - URLError.userCancelledAuthentication](https://developer.apple.com/documentation/foundation/urlerror/2293330-usercancelledauthentication)) + ///- iOS WKWebView ([Official API - URLError.userCancelledAuthentication](https://developer.apple.com/documentation/foundation/urlerror/2293330-usercancelledauthentication)) + ///- macOS WKWebView ([Official API - URLError.userCancelledAuthentication](https://developer.apple.com/documentation/foundation/urlerror/2293330-usercancelledauthentication)) static final USER_CANCELLED_AUTHENTICATION = WebResourceErrorType._internalMultiPlatform( 'USER_CANCELLED_AUTHENTICATION', () { @@ -1117,7 +1117,7 @@ class WebResourceErrorType { ///Indicates that user lacks proper authentication credentials for a proxy server. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) + ///- Windows WebView2 ([Official API - COREWEBVIEW2_WEB_ERROR_STATUS_VALID_PROXY_AUTHENTICATION_REQUIRED](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#corewebview2_web_error_status)) static final VALID_PROXY_AUTHENTICATION_REQUIRED = WebResourceErrorType._internalMultiPlatform( 'VALID_PROXY_AUTHENTICATION_REQUIRED', () { @@ -1133,8 +1133,8 @@ class WebResourceErrorType { ///A server reported that a URL has a non-zero content length, but terminated the network connection gracefully without sending any data. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - URLError.zeroByteResource](https://developer.apple.com/documentation/foundation/urlerror/2293773-zerobyteresource)) - ///- MacOS ([Official API - URLError.zeroByteResource](https://developer.apple.com/documentation/foundation/urlerror/2293773-zerobyteresource)) + ///- iOS WKWebView ([Official API - URLError.zeroByteResource](https://developer.apple.com/documentation/foundation/urlerror/2293773-zerobyteresource)) + ///- macOS WKWebView ([Official API - URLError.zeroByteResource](https://developer.apple.com/documentation/foundation/urlerror/2293773-zerobyteresource)) static final ZERO_BYTE_RESOURCE = WebResourceErrorType._internalMultiPlatform('ZERO_BYTE_RESOURCE', () { switch (defaultTargetPlatform) { @@ -1272,7 +1272,7 @@ class WebResourceErrorType { ///Gets [String] value. String toValue() => _value; - ///Gets [int?] native value. + ///Gets [int] native value if supported by the current platform, otherwise `null`. int? toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -1410,6 +1410,11 @@ class WebResourceErrorType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/web_storage_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/web_storage_type.g.dart index 69546d999..78278f313 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/web_storage_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/web_storage_type.g.dart @@ -110,6 +110,11 @@ class WebStorageType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/website_data_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/website_data_type.g.dart index f19bab6af..ca0692d28 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/website_data_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/website_data_type.g.dart @@ -187,6 +187,11 @@ class WebsiteDataType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; @@ -383,6 +388,11 @@ class IOSWKWebsiteDataType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/webview_interface.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/webview_interface.g.dart index a3cdfd661..25888210f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/webview_interface.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/webview_interface.g.dart @@ -384,6 +384,11 @@ class WebViewInterface { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.g.dart index 73494b545..d2ae3753b 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/webview_render_process_action.g.dart @@ -20,7 +20,7 @@ class WebViewRenderProcessAction { ///Cause this renderer to terminate. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView static const TERMINATE = WebViewRenderProcessAction._internal(0, 0); ///Set of all values of [WebViewRenderProcessAction]. @@ -106,6 +106,11 @@ class WebViewRenderProcessAction { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/window_style_mask.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/window_style_mask.g.dart index 159f07f26..c9ad9ccd3 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/window_style_mask.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/window_style_mask.g.dart @@ -19,7 +19,7 @@ class WindowStyleMask { ///The window displays none of the usual peripheral elements. Useful only for display or caching purposes. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.borderless](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644698-borderless)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.borderless](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644698-borderless)) static final BORDERLESS = WindowStyleMask._internalMultiPlatform(0, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -33,7 +33,7 @@ class WindowStyleMask { ///The window displays a close button. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.closable](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644610-closable)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.closable](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644610-closable)) static final CLOSABLE = WindowStyleMask._internalMultiPlatform(2, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -47,7 +47,7 @@ class WindowStyleMask { ///The window is a document-modal panel. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.docModalWindow](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644253-docmodalwindow)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.docModalWindow](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644253-docmodalwindow)) static final DOC_MODAL_WINDOW = WindowStyleMask._internalMultiPlatform(64, () { switch (defaultTargetPlatform) { @@ -62,7 +62,7 @@ class WindowStyleMask { ///The window can appear full screen. A fullscreen window does not draw its title bar, and may have special handling for its toolbar. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.fullScreen](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644530-fullscreen)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.fullScreen](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644530-fullscreen)) static final FULLSCREEN = WindowStyleMask._internalMultiPlatform(16384, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -78,7 +78,7 @@ class WindowStyleMask { ///Note that using this mask opts in to layer-backing. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.fullSizeContentView](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644646-fullsizecontentview)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.fullSizeContentView](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644646-fullsizecontentview)) static final FULL_SIZE_CONTENT_VIEW = WindowStyleMask._internalMultiPlatform(32768, () { switch (defaultTargetPlatform) { @@ -93,7 +93,7 @@ class WindowStyleMask { ///The window is a HUD panel. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.hudWindow](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644653-hudwindow)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.hudWindow](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644653-hudwindow)) static final HUD_WINDOW = WindowStyleMask._internalMultiPlatform(8192, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -107,7 +107,7 @@ class WindowStyleMask { ///The window displays a minimize button. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.miniaturizable](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644650-miniaturizable)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.miniaturizable](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644650-miniaturizable)) static final MINIATURIZABLE = WindowStyleMask._internalMultiPlatform(4, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -121,7 +121,7 @@ class WindowStyleMask { ///The window is a panel that does not activate the owning app. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.nonactivatingPanel](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644696-nonactivatingpanel)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.nonactivatingPanel](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644696-nonactivatingpanel)) static final NONACTIVATING_PANEL = WindowStyleMask._internalMultiPlatform(128, () { switch (defaultTargetPlatform) { @@ -136,7 +136,7 @@ class WindowStyleMask { ///The window can be resized by the user. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.miniaturizable](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644717-resizable)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.miniaturizable](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644717-resizable)) static final RESIZABLE = WindowStyleMask._internalMultiPlatform(8, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -150,7 +150,7 @@ class WindowStyleMask { ///The window displays a title bar. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.titled](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644724-titled)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.titled](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644724-titled)) static final TITLED = WindowStyleMask._internalMultiPlatform(1, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -164,7 +164,7 @@ class WindowStyleMask { ///The window is a panel. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS ([Official API - NSWindow.StyleMask.utilityWindow](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644672-utilitywindow)) + ///- macOS WKWebView ([Official API - NSWindow.StyleMask.utilityWindow](https://developer.apple.com/documentation/appkit/nswindow/stylemask/1644672-utilitywindow)) static final UTILITY_WINDOW = WindowStyleMask._internalMultiPlatform(16, () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -248,7 +248,7 @@ class WindowStyleMask { ///Gets [int] value. int toValue() => _value; - ///Gets [int?] native value. + ///Gets [int] native value if supported by the current platform, otherwise `null`. int? toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -292,6 +292,12 @@ class WindowStyleMask { value.toNativeValue() != null && _nativeValue != null ? value.toNativeValue()! | _nativeValue! : _nativeValue); + + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/window_titlebar_separator_style.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/window_titlebar_separator_style.g.dart index c2e41fa62..aceeb0712 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/window_titlebar_separator_style.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/window_titlebar_separator_style.g.dart @@ -19,7 +19,7 @@ class WindowTitlebarSeparatorStyle { ///A style indicating that the system determines the type of separator. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final AUTOMATIC = WindowTitlebarSeparatorStyle._internalMultiPlatform(0, () { switch (defaultTargetPlatform) { @@ -34,7 +34,7 @@ class WindowTitlebarSeparatorStyle { ///A style indicating that there’s no title bar separator. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final LINE = WindowTitlebarSeparatorStyle._internalMultiPlatform(2, () { switch (defaultTargetPlatform) { @@ -49,7 +49,7 @@ class WindowTitlebarSeparatorStyle { ///A style indicating that the title bar separator is a line. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final NONE = WindowTitlebarSeparatorStyle._internalMultiPlatform(1, () { switch (defaultTargetPlatform) { @@ -64,7 +64,7 @@ class WindowTitlebarSeparatorStyle { ///A style indicating that the title bar separator is a shadow. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS + ///- macOS WKWebView static final SHADOW = WindowTitlebarSeparatorStyle._internalMultiPlatform(3, () { switch (defaultTargetPlatform) { @@ -144,7 +144,7 @@ class WindowTitlebarSeparatorStyle { ///Gets [int] value. int toValue() => _value; - ///Gets [int?] native value. + ///Gets [int] native value if supported by the current platform, otherwise `null`. int? toNativeValue() => _nativeValue; ///Gets the name of the value. @@ -168,6 +168,11 @@ class WindowTitlebarSeparatorStyle { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/types/window_type.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/window_type.g.dart index e1628c9fe..ea532135b 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/window_type.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/window_type.g.dart @@ -19,8 +19,8 @@ class WindowType { ///Adds the new browser window as a child window of the main window. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS - ///- Windows + ///- macOS WKWebView + ///- Windows WebView2 static final CHILD = WindowType._internalMultiPlatform('CHILD', () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -36,7 +36,7 @@ class WindowType { ///Adds the new browser window as a new tab in a tabbed window of the main window. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS 10.12++ + ///- macOS WKWebView 10.12++ static final TABBED = WindowType._internalMultiPlatform('TABBED', () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -50,8 +50,8 @@ class WindowType { ///Adds the new browser window as a separate new window from the main window. /// ///**Officially Supported Platforms/Implementations**: - ///- MacOS - ///- Windows + ///- macOS WKWebView + ///- Windows WebView2 static final WINDOW = WindowType._internalMultiPlatform('WINDOW', () { switch (defaultTargetPlatform) { case TargetPlatform.macOS: @@ -151,6 +151,11 @@ class WindowType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return toNativeValue() != null; + } + @override String toString() { return _value; diff --git a/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.g.dart b/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.g.dart index f3bf55b2a..affc1cda3 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_message/web_message.g.dart @@ -108,6 +108,11 @@ class WebMessageType { @override bool operator ==(value) => value == _value; + ///Checks if the value is supported by the [defaultTargetPlatform]. + bool isSupported() { + return true; + } + @override String toString() { return name(); diff --git a/flutter_inappwebview_platform_interface/lib/src/webview_environment/webview_environment_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/webview_environment/webview_environment_settings.g.dart index 8b192f994..0f84d0c5f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/webview_environment/webview_environment_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/webview_environment/webview_environment_settings.g.dart @@ -12,7 +12,7 @@ part of 'webview_environment_settings.dart'; ///may be overridden by values either specified in environment variables or in the registry. /// ///**Officially Supported Platforms/Implementations**: -///- Windows +///- Windows WebView2 class WebViewEnvironmentSettings { ///If there are multiple switches, there should be a space in between them. ///The one exception is if multiple features are being enabled/disabled for a single switch, @@ -20,14 +20,14 @@ class WebViewEnvironmentSettings { ///Example: `"--disable-features=feature1,feature2 --some-other-switch --do-something"` /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - ICoreWebView2EnvironmentOptions.put_AdditionalBrowserArguments](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_additionalbrowserarguments)) + ///- Windows WebView2 ([Official API - ICoreWebView2EnvironmentOptions.put_AdditionalBrowserArguments](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_additionalbrowserarguments)) final String? additionalBrowserArguments; ///This property is used to enable single sign on with Azure Active Directory (AAD) ///and personal Microsoft Account (MSA) resources inside WebView. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - ICoreWebView2EnvironmentOptions.put_AllowSingleSignOnUsingOSPrimaryAccount](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_allowsinglesignonusingosprimaryaccount)) + ///- Windows WebView2 ([Official API - ICoreWebView2EnvironmentOptions.put_AllowSingleSignOnUsingOSPrimaryAccount](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_allowsinglesignonusingosprimaryaccount)) final bool? allowSingleSignOnUsingOSPrimaryAccount; ///When this property is set to `true` new extensions can be added to user profile and used. @@ -38,7 +38,7 @@ class WebViewEnvironmentSettings { ///[areBrowserExtensionsEnabled] property, it will fail with `HRESULT_FROM_WIN32(ERROR_INVALID_STATE)`. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.2210.55+ ([Official API - ICoreWebView2EnvironmentOptions6.put_AreBrowserExtensionsEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions6?view=webview2-1.0.2849.39#put_arebrowserextensionsenabled)) + ///- Windows WebView2 1.0.2210.55+ ([Official API - ICoreWebView2EnvironmentOptions6.put_AreBrowserExtensionsEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions6?view=webview2-1.0.2849.39#put_arebrowserextensionsenabled)) final bool? areBrowserExtensionsEnabled; ///Use [browserExecutableFolder] to specify whether WebView2 controls use a fixed @@ -58,7 +58,7 @@ class WebViewEnvironmentSettings { ///applicable `releaseChannelPreference` registry value is set to `1`, the channel search order is reversed. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - CreateCoreWebView2EnvironmentWithOptions.browserExecutableFolder](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions)) + ///- Windows WebView2 ([Official API - CreateCoreWebView2EnvironmentWithOptions.browserExecutableFolder](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions)) final String? browserExecutableFolder; ///This property is [EnvironmentChannelSearchKind.MOST_STABLE] by default; @@ -76,13 +76,13 @@ class WebViewEnvironmentSettings { ///Set the value to `1` to set the search kind to [EnvironmentChannelSearchKind.LEAST_STABLE]. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.2478.35+ ([Official API - ICoreWebView2EnvironmentOptions7.put_ChannelSearchKind](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions7?view=webview2-1.0.2849.39#put_channelsearchkind)) + ///- Windows WebView2 1.0.2478.35+ ([Official API - ICoreWebView2EnvironmentOptions7.put_ChannelSearchKind](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions7?view=webview2-1.0.2849.39#put_channelsearchkind)) final EnvironmentChannelSearchKind? channelSearchKind; ///Set the array of custom scheme registrations to be used. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.1587.40+ ([Official API - ICoreWebView2EnvironmentOptions4.SetCustomSchemeRegistrations](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions4?view=webview2-1.0.2739.15#setcustomschemeregistrations)) + ///- Windows WebView2 1.0.1587.40+ ([Official API - ICoreWebView2EnvironmentOptions4.SetCustomSchemeRegistrations](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions4?view=webview2-1.0.2739.15#setcustomschemeregistrations)) final List? customSchemeRegistrations; ///This property is used to enable/disable tracking prevention feature in WebView2. @@ -102,7 +102,7 @@ class WebViewEnvironmentSettings { ///See [Tracking prevention](https://learn.microsoft.com/en-us/microsoft-edge/web-platform/tracking-prevention). /// ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.1661.34+ ([Official API - ICoreWebView2EnvironmentOptions5.put_EnableTrackingPrevention](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions5?view=webview2-1.0.2849.39#put_enabletrackingprevention)) + ///- Windows WebView2 1.0.1661.34+ ([Official API - ICoreWebView2EnvironmentOptions5.put_EnableTrackingPrevention](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions5?view=webview2-1.0.2849.39#put_enabletrackingprevention)) final bool? enableTrackingPrevention; ///Whether other processes can create WebView2 from WebView2Environment created @@ -111,7 +111,7 @@ class WebViewEnvironmentSettings { ///The default value is `false`. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.1185.39+ ([Official API - ICoreWebView2EnvironmentOptions2.put_ExclusiveUserDataFolderAccess](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions2?view=webview2-1.0.2849.39#put_exclusiveuserdatafolderaccess)) + ///- Windows WebView2 1.0.1185.39+ ([Official API - ICoreWebView2EnvironmentOptions2.put_ExclusiveUserDataFolderAccess](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions2?view=webview2-1.0.2849.39#put_exclusiveuserdatafolderaccess)) final bool? exclusiveUserDataFolderAccess; ///When IsCustomCrashReportingEnabled is set to `true`, @@ -121,13 +121,13 @@ class WebViewEnvironmentSettings { ///In this case, WebView will respect OS consent. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.1518.46+ ([Official API - ICoreWebView2EnvironmentOptions3.put_IsCustomCrashReportingEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions3?view=webview2-1.0.2849.39#put_iscustomcrashreportingenabled)) + ///- Windows WebView2 1.0.1518.46+ ([Official API - ICoreWebView2EnvironmentOptions3.put_IsCustomCrashReportingEnabled](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions3?view=webview2-1.0.2849.39#put_iscustomcrashreportingenabled)) final bool? isCustomCrashReportingEnabled; ///The default display language for WebView. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - ICoreWebView2EnvironmentOptions.put_Language](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_language)) + ///- Windows WebView2 ([Official API - ICoreWebView2EnvironmentOptions.put_Language](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_language)) final String? language; ///Sets the [releaseChannels], which is a mask of one or more [EnvironmentReleaseChannels] @@ -166,7 +166,7 @@ class WebViewEnvironmentSettings { ///[PlatformWebViewEnvironment] creation attempts to interpret each integer and treats any invalid entry as Stable channel. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.2478.35+ ([Official API - ICoreWebView2EnvironmentOptions7.put_ReleaseChannels](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions7?view=webview2-1.0.2849.39#put_releasechannels)) + ///- Windows WebView2 1.0.2478.35+ ([Official API - ICoreWebView2EnvironmentOptions7.put_ReleaseChannels](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions7?view=webview2-1.0.2849.39#put_releasechannels)) final EnvironmentReleaseChannels? releaseChannels; ///The ScrollBar style being set on the WebView2 Environment. @@ -178,13 +178,13 @@ class WebViewEnvironmentSettings { ///CSS styles that modify the ScrollBar applied on top of native ScrollBar styling that is selected with [scrollbarStyle]. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.2535.41+ ([Official API - ICoreWebView2EnvironmentOptions8.put_ScrollBarStyle](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions8?view=webview2-1.0.2849.39#put_scrollbarstyle)) + ///- Windows WebView2 1.0.2535.41+ ([Official API - ICoreWebView2EnvironmentOptions8.put_ScrollBarStyle](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions8?view=webview2-1.0.2849.39#put_scrollbarstyle)) final EnvironmentScrollbarStyle? scrollbarStyle; ///Specifies the version of the WebView2 Runtime binaries required to be compatible with your app. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - ICoreWebView2EnvironmentOptions.put_TargetCompatibleBrowserVersion](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_targetcompatiblebrowserversion)) + ///- Windows WebView2 ([Official API - ICoreWebView2EnvironmentOptions.put_TargetCompatibleBrowserVersion](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environmentoptions?view=webview2-1.0.2210.55#put_targetcompatiblebrowserversion)) final String? targetCompatibleBrowserVersion; ///You may specify the [userDataFolder] to change the default user data folder location for WebView2. @@ -203,12 +203,12 @@ class WebViewEnvironmentSettings { ///running in the shared browser process. /// ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - CreateCoreWebView2EnvironmentWithOptions.userDataFolder](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions)) + ///- Windows WebView2 ([Official API - CreateCoreWebView2EnvironmentWithOptions.userDataFolder](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions)) final String? userDataFolder; /// ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///- Windows WebView2 WebViewEnvironmentSettings( {this.additionalBrowserArguments, this.allowSingleSignOnUsingOSPrimaryAccount, diff --git a/flutter_inappwebview_platform_interface/pubspec.yaml b/flutter_inappwebview_platform_interface/pubspec.yaml index 451ca6807..f6dfa65db 100644 --- a/flutter_inappwebview_platform_interface/pubspec.yaml +++ b/flutter_inappwebview_platform_interface/pubspec.yaml @@ -20,8 +20,8 @@ environment: dependencies: flutter: sdk: flutter - flutter_inappwebview_internal_annotations: ^1.2.0 - # path: ../dev_packages/flutter_inappwebview_internal_annotations + flutter_inappwebview_internal_annotations: #^1.3.0 + path: ../dev_packages/flutter_inappwebview_internal_annotations plugin_platform_interface: ^2.1.8 dev_dependencies: diff --git a/flutter_inappwebview_web/lib/src/in_app_browser/in_app_browser.dart b/flutter_inappwebview_web/lib/src/in_app_browser/in_app_browser.dart new file mode 100755 index 000000000..f14ff81fe --- /dev/null +++ b/flutter_inappwebview_web/lib/src/in_app_browser/in_app_browser.dart @@ -0,0 +1,17 @@ +import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; + +///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser} +class WebPlatformInAppBrowser extends PlatformInAppBrowser with ChannelController { + /// Constructs a [WebPlatformInAppBrowser]. + WebPlatformInAppBrowser(PlatformInAppBrowserCreationParams params) + : super.implementation(params) { + } + + static final WebPlatformInAppBrowser _staticValue = + WebPlatformInAppBrowser(PlatformInAppBrowserCreationParams()); + + /// Provide static access. + factory WebPlatformInAppBrowser.static() { + return _staticValue; + } +} \ No newline at end of file diff --git a/flutter_inappwebview_web/lib/src/in_app_browser/main.dart b/flutter_inappwebview_web/lib/src/in_app_browser/main.dart new file mode 100644 index 000000000..e11eb8b18 --- /dev/null +++ b/flutter_inappwebview_web/lib/src/in_app_browser/main.dart @@ -0,0 +1 @@ +export 'in_app_browser.dart' hide InternalInAppBrowser; diff --git a/flutter_inappwebview_web/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview_web/lib/src/in_app_webview/headless_in_app_webview.dart index 8fb657ff8..c323adb6e 100644 --- a/flutter_inappwebview_web/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/flutter_inappwebview_web/lib/src/in_app_webview/headless_in_app_webview.dart @@ -268,6 +268,14 @@ class WebPlatformHeadlessInAppWebView extends PlatformHeadlessInAppWebView id = IdGenerator.generate(); } + static final WebPlatformHeadlessInAppWebView _staticValue = + WebPlatformHeadlessInAppWebView( + WebPlatformHeadlessInAppWebViewCreationParams()); + + factory WebPlatformHeadlessInAppWebView.static() { + return _staticValue; + } + @override WebPlatformInAppWebViewController? get webViewController => _webViewController; diff --git a/flutter_inappwebview_web/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_web/lib/src/in_app_webview/in_app_webview.dart index 61981c2ff..653185b13 100755 --- a/flutter_inappwebview_web/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_web/lib/src/in_app_webview/in_app_webview.dart @@ -272,6 +272,14 @@ class WebPlatformInAppWebViewWidget extends PlatformInAppWebViewWidget { WebPlatformHeadlessInAppWebView? get _macosHeadlessInAppWebView => _webPlatformParams.headlessWebView as WebPlatformHeadlessInAppWebView?; + static final WebPlatformInAppWebViewWidget _staticValue = + WebPlatformInAppWebViewWidget( + WebPlatformInAppWebViewWidgetCreationParams()); + + factory WebPlatformInAppWebViewWidget.static() { + return _staticValue; + } + @override Widget build(BuildContext context) { final initialSettings = diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index 55d428203..6dd6ac73d 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -2,6 +2,7 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla import 'cookie_manager.dart'; import 'in_app_webview/main.dart'; +import 'in_app_browser/main.dart'; /// Implementation of [InAppWebViewPlatform] using the Web API. class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { @@ -53,6 +54,16 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { return WebPlatformInAppWebViewWidget(params); } + /// Creates a new empty [WebPlatformInAppWebViewWidget] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppWebView] in `flutter_inappwebview` instead. + @override + WebPlatformInAppWebViewWidget createPlatformInAppWebViewWidgetStatic() { + return WebPlatformInAppWebViewWidget.static(); + } + + /// Creates a new [WebPlatformHeadlessInAppWebView]. /// /// This function should only be called by the app-facing package. @@ -63,4 +74,22 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { ) { return WebPlatformHeadlessInAppWebView(params); } + + /// Creates a new empty [WebPlatformHeadlessInAppWebView] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HeadlessInAppWebView] in `flutter_inappwebview` instead. + @override + WebPlatformHeadlessInAppWebView createPlatformHeadlessInAppWebViewStatic() { + return WebPlatformHeadlessInAppWebView.static(); + } + + /// Creates a new empty [WebPlatformInAppBrowser] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppBrowser] in `flutter_inappwebview` instead. + @override + WebPlatformInAppBrowser createPlatformInAppBrowserStatic() { + return WebPlatformInAppBrowser.static(); + } } diff --git a/flutter_inappwebview_windows/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview_windows/lib/src/in_app_webview/headless_in_app_webview.dart index 5c3034b76..4dd946476 100644 --- a/flutter_inappwebview_windows/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/flutter_inappwebview_windows/lib/src/in_app_webview/headless_in_app_webview.dart @@ -279,6 +279,14 @@ class WindowsHeadlessInAppWebView extends PlatformHeadlessInAppWebView id = IdGenerator.generate(); } + static final WindowsHeadlessInAppWebView _staticValue = + WindowsHeadlessInAppWebView( + WindowsHeadlessInAppWebViewCreationParams()); + + factory WindowsHeadlessInAppWebView.static() { + return _staticValue; + } + @override WindowsInAppWebViewController? get webViewController => _webViewController; diff --git a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview.dart index d916e4a86..d0998b74f 100644 --- a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview.dart @@ -285,6 +285,14 @@ class WindowsInAppWebViewWidget extends PlatformInAppWebViewWidget { WindowsHeadlessInAppWebView? get _windowsHeadlessInAppWebView => params.headlessWebView as WindowsHeadlessInAppWebView?; + static final WindowsInAppWebViewWidget _staticValue = + WindowsInAppWebViewWidget( + WindowsInAppWebViewWidgetCreationParams()); + + factory WindowsInAppWebViewWidget.static() { + return _staticValue; + } + @override Widget build(BuildContext context) { final initialSettings = params.initialSettings ?? InAppWebViewSettings(); diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index b3ac05646..a20d71a1a 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -57,6 +57,15 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { return WindowsInAppWebViewWidget(params); } + /// Creates a new empty [WindowsInAppWebViewWidget] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [InAppWebView] in `flutter_inappwebview` instead. + @override + WindowsInAppWebViewWidget createPlatformInAppWebViewWidgetStatic() { + return WindowsInAppWebViewWidget.static(); + } + /// Creates a new [WindowsInAppBrowser]. /// /// This function should only be called by the app-facing package. @@ -88,6 +97,15 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { return WindowsHeadlessInAppWebView(params); } + /// Creates a new empty [WindowsHeadlessInAppWebView] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HeadlessInAppWebView] in `flutter_inappwebview` instead. + @override + WindowsHeadlessInAppWebView createPlatformHeadlessInAppWebViewStatic() { + return WindowsHeadlessInAppWebView.static(); + } + /// Creates a new [WindowsWebViewEnvironment]. /// /// This function should only be called by the app-facing package. diff --git a/package.json b/package.json index c41fa8b95..2487f6396 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "publish:dry": ".fvm/flutter_sdk/bin/flutter pub publish --dry-run", "format": ".fvm/flutter_sdk/bin/dart format flutter_inappwebview/lib flutter_inappwebview/example/integration_test flutter_inappwebview_platform_interface/lib flutter_inappwebview_android/lib flutter_inappwebview_ios/lib flutter_inappwebview_macos/lib flutter_inappwebview_web/lib flutter_inappwebview_windows/lib", - "docs:gen": "cd flutter_inappwebview && ../.fvm/flutter_sdk/bin/dart doc ../", + "docs:gen": "cd flutter_inappwebview && ../.fvm/flutter_sdk/bin/dart doc --output=../doc/api .", "docs:serve": ".fvm/flutter_sdk/bin/flutter pub global activate dhttpd && .fvm/flutter_sdk/bin/flutter pub global run dhttpd:dhttpd --path doc/api", "publish:platform_interface": "cd flutter_inappwebview_platform_interface && ../.fvm/flutter_sdk/bin/flutter pub publish && cd ..", From b854e2f11cc6affc15b9e6bf282fa1702c1f6338 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 6 Dec 2024 21:21:12 +0100 Subject: [PATCH 141/181] added support methods for PlatformChromeSafariBrowser and ChromeSafariBrowserSettings classes --- ...ter_inappwebview_internal_annotations.dart | 3 +- .../lib/src/constants.dart | 16 + .../lib/src/enum_supported_platforms.dart | 115 ++- .../lib/src/supported_platforms.dart | 116 ++- dev_packages/generators/lib/builder.dart | 2 +- ...art => supported_platforms_generator.dart} | 0 dev_packages/generators/lib/src/util.dart | 82 ++- .../chrome_safari_browser.dart | 71 +- .../src/in_app_browser/in_app_browser.dart | 120 +++- .../lib/src/inappwebview_platform.dart | 29 +- .../chrome_safari_action_button.g.dart | 4 +- .../chrome_safari_browser_menu_item.g.dart | 4 +- ...me_safari_browser_secondary_toolbar.g.dart | 8 +- .../chrome_safari_browser_settings.dart | 209 +++--- .../chrome_safari_browser_settings.g.dart | 541 ++++++++++++-- .../platform_chrome_safari_browser.dart | 544 +++++++++----- .../platform_chrome_safari_browser.g.dart | 675 ++++++++++++++++++ .../lib/src/context_menu/context_menu.g.dart | 4 +- .../platform_in_app_browser.dart | 28 +- .../platform_in_app_browser.g.dart | 30 +- .../in_app_webview_settings.g.dart | 12 +- .../platform_headless_in_app_webview.g.dart | 6 +- .../platform_inappwebview_controller.g.dart | 90 +-- .../in_app_webview/platform_webview.g.dart | 32 +- .../lib/src/types/cookie.g.dart | 12 +- .../lib/src/types/navigation_action.g.dart | 2 +- .../src/in_app_browser/in_app_browser.dart | 17 - .../lib/src/in_app_browser/main.dart | 1 - .../lib/src/inappwebview_platform.dart | 41 +- .../lib/src/inappwebview_platform.dart | 28 +- 30 files changed, 2248 insertions(+), 594 deletions(-) rename dev_packages/generators/lib/src/{method_supported_platforms_generator.dart => supported_platforms_generator.dart} (100%) create mode 100644 flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.g.dart delete mode 100755 flutter_inappwebview_web/lib/src/in_app_browser/in_app_browser.dart delete mode 100644 flutter_inappwebview_web/lib/src/in_app_browser/main.dart diff --git a/dev_packages/flutter_inappwebview_internal_annotations/lib/flutter_inappwebview_internal_annotations.dart b/dev_packages/flutter_inappwebview_internal_annotations/lib/flutter_inappwebview_internal_annotations.dart index 841cf81c6..1ff80f76a 100644 --- a/dev_packages/flutter_inappwebview_internal_annotations/lib/flutter_inappwebview_internal_annotations.dart +++ b/dev_packages/flutter_inappwebview_internal_annotations/lib/flutter_inappwebview_internal_annotations.dart @@ -7,4 +7,5 @@ export 'src/exchangeable_object_method.dart'; export 'src/exchangeable_enum.dart'; export 'src/exchangeable_enum_custom_value.dart'; export 'src/supported_platforms.dart'; -export 'src/enum_supported_platforms.dart'; \ No newline at end of file +export 'src/enum_supported_platforms.dart'; +export 'src/constants.dart'; \ No newline at end of file diff --git a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/constants.dart b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/constants.dart index b17ecdf7e..38eca5fa2 100644 --- a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/constants.dart +++ b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/constants.dart @@ -4,6 +4,14 @@ const kPlatformNameMacOS = "macOS WKWebView"; const kPlatformNameWindows = "Windows WebView2"; const kPlatformNameLinux = "Linux WebKitGTK"; const kPlatformNameWeb = "Web \\"; +const kPlatformNameValues = [ + kPlatformNameAndroid, + kPlatformNameIOS, + kPlatformNameMacOS, + kPlatformNameWindows, + kPlatformNameLinux, + kPlatformNameWeb, +]; const kTargetPlatformNameAndroid = "android"; const kTargetPlatformNameIOS = "iOS"; @@ -11,3 +19,11 @@ const kTargetPlatformNameMacOS = "macOS"; const kTargetPlatformNameWindows = "windows"; const kTargetPlatformNameLinux = "linux"; const kTargetPlatformNameWeb = "web"; +const kTargetPlatformNameValues = [ + kTargetPlatformNameAndroid, + kTargetPlatformNameIOS, + kTargetPlatformNameMacOS, + kTargetPlatformNameWindows, + kTargetPlatformNameLinux, + kTargetPlatformNameWeb, +]; diff --git a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/enum_supported_platforms.dart b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/enum_supported_platforms.dart index d78166099..2115a644a 100644 --- a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/enum_supported_platforms.dart +++ b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/enum_supported_platforms.dart @@ -6,13 +6,19 @@ abstract class EnumPlatform implements Platform { final String? apiName; final String? apiUrl; final String? note; + final String name; + final String targetPlatformName; final dynamic value; - const EnumPlatform( - {this.available, this.apiName, this.apiUrl, this.note, this.value}); - - final name = ""; - final targetPlatformName = ""; + const EnumPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = '', + this.targetPlatformName = '', + this.value, + }); } class EnumAndroidPlatform implements EnumPlatform, AndroidPlatform { @@ -20,13 +26,19 @@ class EnumAndroidPlatform implements EnumPlatform, AndroidPlatform { final String? apiName; final String? apiUrl; final String? note; + final String name; + final String targetPlatformName; final dynamic value; - const EnumAndroidPlatform( - {this.available, this.apiName, this.apiUrl, this.note, this.value}); - - final name = kPlatformNameAndroid; - final targetPlatformName = kTargetPlatformNameAndroid; + const EnumAndroidPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = kPlatformNameAndroid, + this.targetPlatformName = kTargetPlatformNameAndroid, + this.value, + }); } class EnumIOSPlatform implements EnumPlatform, IOSPlatform { @@ -34,13 +46,19 @@ class EnumIOSPlatform implements EnumPlatform, IOSPlatform { final String? apiName; final String? apiUrl; final String? note; + final String name; + final String targetPlatformName; final dynamic value; - const EnumIOSPlatform( - {this.available, this.apiName, this.apiUrl, this.note, this.value}); - - final name = kPlatformNameIOS; - final targetPlatformName = kTargetPlatformNameIOS; + const EnumIOSPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = kPlatformNameIOS, + this.targetPlatformName = kTargetPlatformNameIOS, + this.value, + }); } class EnumMacOSPlatform implements EnumPlatform, MacOSPlatform { @@ -48,13 +66,19 @@ class EnumMacOSPlatform implements EnumPlatform, MacOSPlatform { final String? apiName; final String? apiUrl; final String? note; + final String name; + final String targetPlatformName; final dynamic value; - const EnumMacOSPlatform( - {this.available, this.apiName, this.apiUrl, this.note, this.value}); - - final name = kPlatformNameMacOS; - final targetPlatformName = kTargetPlatformNameMacOS; + const EnumMacOSPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = kPlatformNameMacOS, + this.targetPlatformName = kTargetPlatformNameMacOS, + this.value, + }); } class EnumWindowsPlatform implements EnumPlatform, WindowsPlatform { @@ -62,13 +86,19 @@ class EnumWindowsPlatform implements EnumPlatform, WindowsPlatform { final String? apiName; final String? apiUrl; final String? note; + final String name; + final String targetPlatformName; final dynamic value; - const EnumWindowsPlatform( - {this.available, this.apiName, this.apiUrl, this.note, this.value}); - - final name = kPlatformNameWindows; - final targetPlatformName = kTargetPlatformNameWindows; + const EnumWindowsPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = kPlatformNameWindows, + this.targetPlatformName = kTargetPlatformNameWindows, + this.value, + }); } class EnumLinuxPlatform implements EnumPlatform, LinuxPlatform { @@ -76,13 +106,19 @@ class EnumLinuxPlatform implements EnumPlatform, LinuxPlatform { final String? apiName; final String? apiUrl; final String? note; + final String name; + final String targetPlatformName; final dynamic value; - const EnumLinuxPlatform( - {this.available, this.apiName, this.apiUrl, this.note, this.value}); - - final name = kPlatformNameLinux; - final targetPlatformName = kTargetPlatformNameLinux; + const EnumLinuxPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = kPlatformNameLinux, + this.targetPlatformName = kTargetPlatformNameLinux, + this.value, + }); } class EnumWebPlatform implements EnumPlatform, WebPlatform { @@ -90,19 +126,20 @@ class EnumWebPlatform implements EnumPlatform, WebPlatform { final String? apiName; final String? apiUrl; final String? note; + final String name; + final String targetPlatformName; final dynamic value; final bool requiresSameOrigin; const EnumWebPlatform( {this.available, - this.apiName, - this.apiUrl, - this.note, - this.value, - this.requiresSameOrigin = true}); - - final name = kPlatformNameWeb; - final targetPlatformName = kTargetPlatformNameWeb; + this.apiName, + this.apiUrl, + this.note, + this.value, + this.name = kPlatformNameWeb, + this.targetPlatformName = kTargetPlatformNameWeb, + this.requiresSameOrigin = true}); } class EnumSupportedPlatforms { @@ -113,4 +150,4 @@ class EnumSupportedPlatforms { required this.platforms, this.defaultValue, }); -} \ No newline at end of file +} diff --git a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/supported_platforms.dart b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/supported_platforms.dart index 88435d979..9bb54c50c 100644 --- a/dev_packages/flutter_inappwebview_internal_annotations/lib/src/supported_platforms.dart +++ b/dev_packages/flutter_inappwebview_internal_annotations/lib/src/supported_platforms.dart @@ -5,11 +5,17 @@ abstract class Platform { final String? apiName; final String? apiUrl; final String? note; - - const Platform({this.available, this.apiName, this.apiUrl, this.note}); - - final name = ""; - final targetPlatformName = ""; + final String name; + final String targetPlatformName; + + const Platform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = '', + this.targetPlatformName = '', + }); } class AndroidPlatform implements Platform { @@ -17,11 +23,17 @@ class AndroidPlatform implements Platform { final String? apiName; final String? apiUrl; final String? note; - - const AndroidPlatform({this.available, this.apiName, this.apiUrl, this.note}); - - final name = kPlatformNameAndroid; - final targetPlatformName = kTargetPlatformNameAndroid; + final String name; + final String targetPlatformName; + + const AndroidPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = kPlatformNameAndroid, + this.targetPlatformName = kTargetPlatformNameAndroid, + }); } class IOSPlatform implements Platform { @@ -29,11 +41,17 @@ class IOSPlatform implements Platform { final String? apiName; final String? apiUrl; final String? note; - - const IOSPlatform({this.available, this.apiName, this.apiUrl, this.note}); - - final name = kPlatformNameIOS; - final targetPlatformName = kTargetPlatformNameIOS; + final String name; + final String targetPlatformName; + + const IOSPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = kPlatformNameIOS, + this.targetPlatformName = kTargetPlatformNameIOS, + }); } class MacOSPlatform implements Platform { @@ -41,11 +59,17 @@ class MacOSPlatform implements Platform { final String? apiName; final String? apiUrl; final String? note; - - const MacOSPlatform({this.available, this.apiName, this.apiUrl, this.note}); - - final name = kPlatformNameMacOS; - final targetPlatformName = kTargetPlatformNameMacOS; + final String name; + final String targetPlatformName; + + const MacOSPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = kPlatformNameMacOS, + this.targetPlatformName = kTargetPlatformNameMacOS, + }); } class WindowsPlatform implements Platform { @@ -53,11 +77,17 @@ class WindowsPlatform implements Platform { final String? apiName; final String? apiUrl; final String? note; - - const WindowsPlatform({this.available, this.apiName, this.apiUrl, this.note}); - - final name = kPlatformNameWindows; - final targetPlatformName = kTargetPlatformNameWindows; + final String name; + final String targetPlatformName; + + const WindowsPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = kPlatformNameWindows, + this.targetPlatformName = kTargetPlatformNameWindows, + }); } class LinuxPlatform implements Platform { @@ -65,11 +95,17 @@ class LinuxPlatform implements Platform { final String? apiName; final String? apiUrl; final String? note; - - const LinuxPlatform({this.available, this.apiName, this.apiUrl, this.note}); - - final name = kPlatformNameLinux; - final targetPlatformName = kTargetPlatformNameLinux; + final String name; + final String targetPlatformName; + + const LinuxPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.name = kPlatformNameLinux, + this.targetPlatformName = kTargetPlatformNameLinux, + }); } class WebPlatform implements Platform { @@ -77,17 +113,19 @@ class WebPlatform implements Platform { final String? apiName; final String? apiUrl; final String? note; + final String name; + final String targetPlatformName; final bool requiresSameOrigin; - const WebPlatform( - {this.available, - this.apiName, - this.apiUrl, - this.note, - this.requiresSameOrigin = true}); - - final name = kPlatformNameWeb; - final targetPlatformName = kTargetPlatformNameWeb; + const WebPlatform({ + this.available, + this.apiName, + this.apiUrl, + this.note, + this.requiresSameOrigin = true, + this.name = kPlatformNameWeb, + this.targetPlatformName = kTargetPlatformNameWeb, + }); } class SupportedPlatforms { diff --git a/dev_packages/generators/lib/builder.dart b/dev_packages/generators/lib/builder.dart index 42bee8d46..c0d7cc08e 100644 --- a/dev_packages/generators/lib/builder.dart +++ b/dev_packages/generators/lib/builder.dart @@ -2,7 +2,7 @@ import 'package:build/build.dart'; import 'package:source_gen/source_gen.dart'; import 'src/exchangeable_object_generator.dart'; import 'src/exchangeable_enum_generator.dart'; -import 'src/method_supported_platforms_generator.dart'; +import 'src/supported_platforms_generator.dart'; Builder generateExchangeableObject(BuilderOptions options) => SharedPartBuilder([ExchangeableObjectGenerator()], 'exchangeable_object'); diff --git a/dev_packages/generators/lib/src/method_supported_platforms_generator.dart b/dev_packages/generators/lib/src/supported_platforms_generator.dart similarity index 100% rename from dev_packages/generators/lib/src/method_supported_platforms_generator.dart rename to dev_packages/generators/lib/src/supported_platforms_generator.dart diff --git a/dev_packages/generators/lib/src/util.dart b/dev_packages/generators/lib/src/util.dart index a8fdfc8b1..56365bceb 100644 --- a/dev_packages/generators/lib/src/util.dart +++ b/dev_packages/generators/lib/src/util.dart @@ -1,9 +1,10 @@ +import 'package:analyzer/dart/constant/value.dart'; import 'package:analyzer/dart/element/element.dart'; -import 'package:source_gen/source_gen.dart'; -import 'package:analyzer/dart/element/type.dart'; import 'package:analyzer/dart/element/nullability_suffix.dart'; -import 'package:analyzer/dart/constant/value.dart'; +import 'package:analyzer/dart/element/type.dart'; +import 'package:collection/collection.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; +import 'package:source_gen/source_gen.dart'; final _coreCheckerObjectMethod = const TypeChecker.fromRuntime(ExchangeableObjectMethod); @@ -22,6 +23,16 @@ abstract class Util { true; } + static ClassElement? getClassElement(Element element) { + if (element is ClassElement) { + return element; + } + if (element.enclosingElement != null) { + return getClassElement(element.enclosingElement!); + } + return null; + } + static String? getSupportedDocs(TypeChecker checker, Element element) { final platformSupportedList = []; final platforms = checker @@ -29,8 +40,27 @@ abstract class Util { ?.getField('platforms') ?.toListValue() ?? []; + + final classElement = getClassElement(element); + List classElementPlatforms = []; + if (classElement != null) { + classElementPlatforms = checker + .firstAnnotationOfExact(classElement) + ?.getField('platforms') + ?.toListValue() ?? + []; + } for (var platform in platforms) { - final platformName = platform.getField("name")!.toStringValue(); + final classElementPlatform = classElementPlatforms + .firstWhereOrNull((p) => p.type == platform.type); + final classElementPlatformName = + classElementPlatform?.getField("name")!.toStringValue()!; + var platformName = platform.getField("name")!.toStringValue()!; + if (classElementPlatformName != null && + kPlatformNameValues.contains(platformName) && + !kPlatformNameValues.contains(classElementPlatformName)) { + platformName = classElementPlatformName; + } final apiName = platform.getField("apiName")?.toStringValue(); final apiUrl = platform.getField("apiUrl")?.toStringValue(); final available = platform.getField("available")?.toStringValue(); @@ -61,7 +91,8 @@ abstract class Util { } } - platformSupportedList.add("///- $platformName $api${platformNote.isNotEmpty ? ":\n/// - " + platformNote : ""}"); + platformSupportedList.add( + "///- ${(platformName + ' ' + api).trim()}${platformNote.isNotEmpty ? ":\n/// - " + platformNote : ""}"); } if (platformSupportedList.isNotEmpty) { return """/// @@ -71,26 +102,51 @@ abstract class Util { return null; } - static String? getParameterSupportedDocs(TypeChecker checker, List parameters, [Map>? workaroundPlatforms]) { - final nonDeprecatedParameters = parameters.where((p) => !p.hasDeprecated).toList(); + static String? getParameterSupportedDocs( + TypeChecker checker, List parameters, + [Map>? workaroundPlatforms]) { + final nonDeprecatedParameters = + parameters.where((p) => !p.hasDeprecated).toList(); if (nonDeprecatedParameters.isEmpty) { return null; } - var docs = "///**Parameters - Officially Supported Platforms/Implementations**:"; + final classElement = getClassElement(nonDeprecatedParameters.first); + List classElementPlatforms = []; + if (classElement != null) { + classElementPlatforms = checker + .firstAnnotationOfExact(classElement) + ?.getField('platforms') + ?.toListValue() ?? + []; + } + + var docs = + "///**Parameters - Officially Supported Platforms/Implementations**:"; for (final parameter in nonDeprecatedParameters) { var platforms = checker - .firstAnnotationOfExact(parameter) - ?.getField('platforms') - ?.toListValue() ?? - (workaroundPlatforms?[parameter.name] != null ? workaroundPlatforms![parameter.name]! : []); + .firstAnnotationOfExact(parameter) + ?.getField('platforms') + ?.toListValue() ?? + (workaroundPlatforms?[parameter.name] != null + ? workaroundPlatforms![parameter.name]! + : []); if (platforms.isEmpty) { docs += "\n///- [${parameter.name}]: all platforms"; } else { docs += "\n///- [${parameter.name}]: "; for (var platform in platforms) { - final platformName = platform.getField("name")!.toStringValue(); + final classElementPlatform = classElementPlatforms + .firstWhereOrNull((p) => p.type == platform.type); + final classElementPlatformName = + classElementPlatform?.getField("name")!.toStringValue()!; + var platformName = platform.getField("name")!.toStringValue(); + if (classElementPlatformName != null && + kPlatformNameValues.contains(platformName) && + !kPlatformNameValues.contains(classElementPlatformName)) { + platformName = classElementPlatformName; + } final apiName = platform.getField("apiName")?.toStringValue(); final apiUrl = platform.getField("apiUrl")?.toStringValue(); final available = platform.getField("available")?.toStringValue(); diff --git a/flutter_inappwebview/lib/src/chrome_safari_browser/chrome_safari_browser.dart b/flutter_inappwebview/lib/src/chrome_safari_browser/chrome_safari_browser.dart index e0ab275f0..81122ec76 100755 --- a/flutter_inappwebview/lib/src/chrome_safari_browser/chrome_safari_browser.dart +++ b/flutter_inappwebview/lib/src/chrome_safari_browser/chrome_safari_browser.dart @@ -6,10 +6,14 @@ import 'package:flutter/services.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.supported_platforms} class ChromeSafariBrowser implements PlatformChromeSafariBrowserEvents { - /// Constructs a [ChromeSafariBrowser]. + ///Constructs a [ChromeSafariBrowser]. /// - /// {@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser} + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.supported_platforms} ChromeSafariBrowser() : this.fromPlatformCreationParams( PlatformChromeSafariBrowserCreationParams(), @@ -34,6 +38,8 @@ class ChromeSafariBrowser implements PlatformChromeSafariBrowserEvents { String get id => platform.id; ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.open} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.open.supported_platforms} Future open( {WebUri? url, Map? headers, @@ -53,6 +59,8 @@ class ChromeSafariBrowser implements PlatformChromeSafariBrowserEvents { } ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.launchUrl} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.launchUrl.supported_platforms} Future launchUrl({ required WebUri url, Map? headers, @@ -66,90 +74,130 @@ class ChromeSafariBrowser implements PlatformChromeSafariBrowserEvents { referrer: referrer); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.mayLaunchUrl} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.mayLaunchUrl.supported_platforms} Future mayLaunchUrl({WebUri? url, List? otherLikelyURLs}) => platform.mayLaunchUrl(url: url, otherLikelyURLs: otherLikelyURLs); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.validateRelationship} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.validateRelationship.supported_platforms} Future validateRelationship( {required CustomTabsRelationType relation, required WebUri origin}) => platform.validateRelationship(relation: relation, origin: origin); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.close} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.close.supported_platforms} Future close() => platform.close(); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isOpened} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isOpened.supported_platforms} bool isOpened() => platform.isOpened(); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setActionButton} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setActionButton.supported_platforms} void setActionButton(ChromeSafariBrowserActionButton actionButton) => platform.setActionButton(actionButton); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateActionButton} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateActionButton.supported_platforms} Future updateActionButton( {required Uint8List icon, required String description}) => platform.updateActionButton(icon: icon, description: description); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setSecondaryToolbar} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setSecondaryToolbar.supported_platforms} void setSecondaryToolbar( ChromeSafariBrowserSecondaryToolbar secondaryToolbar) => platform.setSecondaryToolbar(secondaryToolbar); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateSecondaryToolbar} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateSecondaryToolbar.supported_platforms} Future updateSecondaryToolbar( ChromeSafariBrowserSecondaryToolbar secondaryToolbar) => platform.updateSecondaryToolbar(secondaryToolbar); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItem} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItem.supported_platforms} void addMenuItem(ChromeSafariBrowserMenuItem menuItem) => platform.addMenuItem(menuItem); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItems} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItems.supported_platforms} void addMenuItems(List menuItems) => platform.addMenuItems(menuItems); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.requestPostMessageChannel} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.requestPostMessageChannel.supported_platforms} Future requestPostMessageChannel( {required WebUri sourceOrigin, WebUri? targetOrigin}) => platform.requestPostMessageChannel( sourceOrigin: sourceOrigin, targetOrigin: targetOrigin); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.postMessage} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.postMessage.supported_platforms} Future postMessage(String message) => platform.postMessage(message); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable.supported_platforms} Future isEngagementSignalsApiAvailable() => platform.isEngagementSignalsApiAvailable(); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isAvailable} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isAvailable.supported_platforms} static Future isAvailable() => PlatformChromeSafariBrowser.static().isAvailable(); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getMaxToolbarItems} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getMaxToolbarItems.supported_platforms} static Future getMaxToolbarItems() => PlatformChromeSafariBrowser.static().getMaxToolbarItems(); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getPackageName} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getPackageName.supported_platforms} static Future getPackageName( {List? packages, bool ignoreDefault = false}) => PlatformChromeSafariBrowser.static() .getPackageName(packages: packages, ignoreDefault: ignoreDefault); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.clearWebsiteData} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.clearWebsiteData.supported_platforms} static Future clearWebsiteData() => PlatformChromeSafariBrowser.static().clearWebsiteData(); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.prewarmConnections} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.prewarmConnections.supported_platforms} static Future prewarmConnections(List URLs) => PlatformChromeSafariBrowser.static().prewarmConnections(URLs); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.invalidatePrewarmingToken} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.invalidatePrewarmingToken.supported_platforms} static Future invalidatePrewarmingToken( PrewarmingToken prewarmingToken) => PlatformChromeSafariBrowser.static() .invalidatePrewarmingToken(prewarmingToken); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.dispose} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.dispose.supported_platforms} @mustCallSuper void dispose() => platform.dispose(); @@ -192,4 +240,23 @@ class ChromeSafariBrowser implements PlatformChromeSafariBrowserEvents { @override void onWillOpenInBrowser() {} + + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformChromeSafariBrowser.static().isClassSupported( + platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isMethodSupported} + static bool isMethodSupported(PlatformChromeSafariBrowserMethod property, + {TargetPlatform? platform}) => + PlatformChromeSafariBrowser.static().isMethodSupported( + property, + platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.isMethodSupported} + static bool isEventMethodSupported(PlatformChromeSafariBrowserEventsMethod method, + {TargetPlatform? platform}) => + PlatformChromeSafariBrowserEvents.isMethodSupported( + method, + platform: platform); } diff --git a/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart b/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart index a3bfa53a9..2d0ac5e23 100755 --- a/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart +++ b/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart @@ -14,10 +14,14 @@ import '../in_app_webview/in_app_webview_controller.dart'; import '../webview_environment/webview_environment.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.supported_platforms} class InAppBrowser implements PlatformInAppBrowserEvents { - /// Constructs a [InAppBrowser]. + ///Constructs a [InAppBrowser]. /// - /// {@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser} + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.supported_platforms} InAppBrowser({ ContextMenu? contextMenu, PullToRefreshController? pullToRefreshController, @@ -54,10 +58,14 @@ class InAppBrowser implements PlatformInAppBrowserEvents { ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.id} String get id => platform.id; - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.contextMenu} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.contextMenu} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.contextMenu.supported_platforms} ContextMenu? get contextMenu => platform.contextMenu; - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.pullToRefreshController} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.pullToRefreshController} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.pullToRefreshController.supported_platforms} PullToRefreshController? get pullToRefreshController { final pullToRefreshControllerPlatform = platform.pullToRefreshController; if (pullToRefreshControllerPlatform == null) { @@ -67,7 +75,9 @@ class InAppBrowser implements PlatformInAppBrowserEvents { platform: pullToRefreshControllerPlatform); } - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.findInteractionController} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.findInteractionController} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.findInteractionController.supported_platforms} FindInteractionController? get findInteractionController { final findInteractionControllerPlatform = platform.findInteractionController; @@ -78,11 +88,15 @@ class InAppBrowser implements PlatformInAppBrowserEvents { platform: findInteractionControllerPlatform); } - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.initialUserScripts} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.initialUserScripts} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.initialUserScripts.supported_platforms} UnmodifiableListView? get initialUserScripts => platform.initialUserScripts; - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.windowId} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.windowId} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.windowId.supported_platforms} int? get windowId => platform.windowId; ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.webViewController} @@ -96,6 +110,8 @@ class InAppBrowser implements PlatformInAppBrowserEvents { } ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.openUrlRequest} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.openUrlRequest.supported_platforms} Future openUrlRequest( {required URLRequest urlRequest, @Deprecated('Use settings instead') InAppBrowserClassOptions? options, @@ -106,6 +122,8 @@ class InAppBrowser implements PlatformInAppBrowserEvents { } ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.openFile} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.openFile.supported_platforms} Future openFile( {required String assetFilePath, @Deprecated('Use settings instead') InAppBrowserClassOptions? options, @@ -116,6 +134,8 @@ class InAppBrowser implements PlatformInAppBrowserEvents { } ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.openData} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.openData.supported_platforms} Future openData( {required String data, String mimeType = "text/html", @@ -138,90 +158,98 @@ class InAppBrowser implements PlatformInAppBrowserEvents { } ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.openWithSystemBrowser} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.openWithSystemBrowser.supported_platforms} static Future openWithSystemBrowser({required WebUri url}) => PlatformInAppBrowser.static().openWithSystemBrowser(url: url); - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isClassSupported} - static bool isClassSupported({TargetPlatform? platform}) => - PlatformInAppBrowser.static().isClassSupported( - platform: platform); - - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isPropertySupported} - static bool isPropertySupported(PlatformInAppBrowserProperty property, - {TargetPlatform? platform}) => - PlatformInAppBrowser.static().isPropertySupported( - property, - platform: platform); - - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isMethodSupported} - static bool isMethodSupported(PlatformInAppBrowserMethod property, - {TargetPlatform? platform}) => - PlatformInAppBrowser.static().isMethodSupported( - property, - platform: platform); - - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.isMethodSupported} - static bool isEventMethodSupported(PlatformInAppBrowserEventsMethod method, - {TargetPlatform? platform}) => - PlatformInAppBrowserEvents.isMethodSupported( - method, - platform: platform); - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.addMenuItem} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.addMenuItem.supported_platforms} void addMenuItem(InAppBrowserMenuItem menuItem) => platform.addMenuItem(menuItem); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.addMenuItems} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.addMenuItems.supported_platforms} void addMenuItems(List menuItems) => platform.addMenuItems(menuItems); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeMenuItem} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeMenuItem.supported_platforms} bool removeMenuItem(InAppBrowserMenuItem menuItem) => platform.removeMenuItem(menuItem); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeMenuItems} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeMenuItems.supported_platforms} void removeMenuItems(List menuItems) => platform.removeMenuItems(menuItems); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeAllMenuItem} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeAllMenuItem.supported_platforms} void removeAllMenuItem() => platform.removeAllMenuItem(); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.hasMenuItem} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.hasMenuItem.supported_platforms} bool hasMenuItem(InAppBrowserMenuItem menuItem) => platform.hasMenuItem(menuItem); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.show} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.show.supported_platforms} Future show() => platform.show(); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.hide} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.hide.supported_platforms} Future hide() => platform.hide(); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.close} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.close.supported_platforms} Future close() => platform.close(); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isHidden} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isHidden.supported_platforms} Future isHidden() => platform.isHidden(); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.setOptions} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.setOptions.supported_platforms} @Deprecated('Use setSettings instead') Future setOptions({required InAppBrowserClassOptions options}) => platform.setOptions(options: options); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.getOptions} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.getOptions.supported_platforms} @Deprecated('Use getSettings instead') Future getOptions() => platform.getOptions(); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.setSettings} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.setSettings.supported_platforms} Future setSettings({required InAppBrowserClassSettings settings}) => platform.setSettings(settings: settings); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.getSettings} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.getSettings.supported_platforms} Future getSettings() => platform.getSettings(); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isOpened} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isOpened.supported_platforms} bool isOpened() => platform.isOpened(); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.dispose} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.dispose.supported_platforms} @mustCallSuper void dispose() => platform.dispose(); @@ -640,4 +668,30 @@ class InAppBrowser implements PlatformInAppBrowserEvents { FutureOr onShowFileChooser(ShowFileChooserRequest request) { return null; } + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformInAppBrowser.static().isClassSupported( + platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isPropertySupported} + static bool isPropertySupported(PlatformInAppBrowserProperty property, + {TargetPlatform? platform}) => + PlatformInAppBrowser.static().isPropertySupported( + property, + platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isMethodSupported} + static bool isMethodSupported(PlatformInAppBrowserMethod property, + {TargetPlatform? platform}) => + PlatformInAppBrowser.static().isMethodSupported( + property, + platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.isMethodSupported} + static bool isEventMethodSupported(PlatformInAppBrowserEventsMethod method, + {TargetPlatform? platform}) => + PlatformInAppBrowserEvents.isMethodSupported( + method, + platform: platform); } diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index 978bedf96..a611599ed 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -1,15 +1,15 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; import 'cookie_manager.dart'; -import 'http_auth_credentials_database.dart'; import 'find_interaction/main.dart'; +import 'http_auth_credentials_database.dart'; import 'in_app_browser/in_app_browser.dart'; import 'in_app_webview/main.dart'; import 'print_job/main.dart'; +import 'proxy_controller.dart'; +import 'web_authentication_session/main.dart'; import 'web_message/main.dart'; import 'web_storage/main.dart'; -import 'web_authentication_session/main.dart'; -import 'proxy_controller.dart'; /// Implementation of [InAppWebViewPlatform] using the WebKit API. class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { @@ -262,7 +262,28 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [ProxyController] in `flutter_inappwebview` instead. @override - PlatformProxyController createPlatformProxyController(PlatformProxyControllerCreationParams params) { + PlatformProxyController createPlatformProxyController( + PlatformProxyControllerCreationParams params) { return MacOSProxyController(params); } + + // ************************************************************************ // + // Create static instances of unsupported classes to be able to call // + // isClassSupported, isMethodSupported, isPropertySupported, etc. // + // static methods without throwing a missing platform implementation // + // exception. // + // ************************************************************************ // + + PlatformChromeSafariBrowser createPlatformChromeSafariBrowserStatic() { + return _PlatformChromeSafariBrowser.static(); + } +} + +class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { + _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams params) + : super.implementation(params); + static final _PlatformChromeSafariBrowser _staticValue = + _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams()); + + factory _PlatformChromeSafariBrowser.static() => _staticValue; } diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart index 030583b65..1b2197de3 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_action_button.g.dart @@ -9,7 +9,7 @@ part of 'chrome_safari_action_button.dart'; ///Class that represents a custom action button for a [PlatformChromeSafariBrowser] instance. /// ///**Officially Supported Platforms/Implementations**: -///- Android WebView : +///- Android WebView: /// - Not available in an Android Trusted Web Activity. class ChromeSafariBrowserActionButton { ///Use onClick instead. @@ -33,7 +33,7 @@ class ChromeSafariBrowserActionButton { /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - Not available in an Android Trusted Web Activity. ChromeSafariBrowserActionButton( {required this.id, diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart index cb3605cce..53fc91201 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_menu_item.g.dart @@ -9,7 +9,7 @@ part of 'chrome_safari_browser_menu_item.dart'; ///Class that represents a custom menu item for a [PlatformChromeSafariBrowser] instance. /// ///**Officially Supported Platforms/Implementations**: -///- Android WebView : +///- Android WebView: /// - Not available in an Android Trusted Web Activity. ///- iOS WKWebView class ChromeSafariBrowserMenuItem { @@ -31,7 +31,7 @@ class ChromeSafariBrowserMenuItem { /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - Not available in an Android Trusted Web Activity. ///- iOS WKWebView ChromeSafariBrowserMenuItem( diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart index 90bd1c281..9899dc75c 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_secondary_toolbar.g.dart @@ -16,7 +16,7 @@ part of 'chrome_safari_browser_secondary_toolbar.dart'; ///Check the [RemoteViews Official API](https://developer.android.com/reference/android/widget/RemoteViews.html) for more details. /// ///**Officially Supported Platforms/Implementations**: -///- Android WebView : +///- Android WebView: /// - Not available in an Android Trusted Web Activity. class ChromeSafariBrowserSecondaryToolbar { ///The IDs of clickable views. The `onClick` event of these views will be handled by custom tabs. @@ -27,7 +27,7 @@ class ChromeSafariBrowserSecondaryToolbar { /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - Not available in an Android Trusted Web Activity. ChromeSafariBrowserSecondaryToolbar( {this.clickableIDs = const [], required this.layout}); @@ -76,7 +76,7 @@ class ChromeSafariBrowserSecondaryToolbar { ///Class that represents a clickable ID item of the secondary toolbar for a [PlatformChromeSafariBrowser] instance. /// ///**Officially Supported Platforms/Implementations**: -///- Android WebView : +///- Android WebView: /// - Not available in an Android Trusted Web Activity. class ChromeSafariBrowserSecondaryToolbarClickableID { ///The android id resource @@ -87,7 +87,7 @@ class ChromeSafariBrowserSecondaryToolbarClickableID { /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - Not available in an Android Trusted Web Activity. ChromeSafariBrowserSecondaryToolbarClickableID( {required this.id, this.onClick}); diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart index 7d854d45b..b95b582a4 100755 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart @@ -1,5 +1,6 @@ import 'dart:ui'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import '../types/activity_button.dart'; @@ -15,7 +16,6 @@ import '../types/ui_event_attribution.dart'; import '../util.dart'; import 'android/chrome_custom_tabs_options.dart'; import 'apple/safari_options.dart'; -import '../types/enum_method.dart'; part 'chrome_safari_browser_settings.g.dart'; @@ -58,63 +58,65 @@ class ChromeSafariBrowserOptions { } } +///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings} ///Class that represents the settings that can be used for an [ChromeSafariBrowser] window. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform( + name: 'Android Chrome Custom Tabs', + ), + IOSPlatform(name: 'iOS SFSafariViewController'), +]) @ExchangeableObject(copyMethod: true) class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { ///The share state that should be applied to the custom tab. The default value is [CustomTabsShareState.SHARE_STATE_DEFAULT]. - /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(note: 'Not available in a Trusted Web Activity.',), + ]) CustomTabsShareState_? shareState; ///Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`. - /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(note: 'Not available in a Trusted Web Activity.',), + ]) bool? showTitle; ///Set the custom background color of the toolbar. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) Color_? toolbarBackgroundColor; ///Sets the navigation bar color. Has no effect on Android API versions below L. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) Color_? navigationBarColor; ///Sets the navigation bar divider color. Has no effect on Android API versions below P. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) Color_? navigationBarDividerColor; ///Sets the color of the secondary toolbar. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) Color_? secondaryToolbarColor; ///Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`. - /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform( note: 'Not available in a Trusted Web Activity.',), + ]) bool? enableUrlBarHiding; ///Set to `true` to enable Instant Apps. The default value is `false`. - /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform( note: 'Not available in a Trusted Web Activity.',), + ]) bool? instantAppsEnabled; ///Set an explicit application package name that limits @@ -122,149 +124,133 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { ///value of null, all components in all applications will considered. ///If non-null, the Intent can only match the components in the given ///application package. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) String? packageName; ///Set to `true` to enable Keep Alive. The default value is `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) bool? keepAliveEnabled; ///Set to `true` to launch the Android activity in `singleInstance` mode. The default value is `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) bool? isSingleInstance; ///Set to `true` to launch the Android intent with the flag `FLAG_ACTIVITY_NO_HISTORY`. The default value is `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) bool? noHistory; ///Set to `true` to launch the Custom Tab as a Trusted Web Activity. The default value is `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) bool? isTrustedWebActivity; ///Sets a list of additional trusted origins that the user may navigate or be redirected to from the starting uri. - /// - ///**NOTE**: Available only in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(note: 'Not available in a Trusted Web Activity.',), + ]) List? additionalTrustedOrigins; ///Sets a display mode of a Trusted Web Activity. - /// - ///**NOTE**: Available only in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(note: 'Not available in a Trusted Web Activity.',), + ]) @ExchangeableObjectProperty(deserializer: _deserializeDisplayMode) TrustedWebActivityDisplayMode_? displayMode; ///Sets a screen orientation. This can be used e.g. to enable the locking of an orientation lock type. - /// - ///**NOTE**: Available only in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(note: 'Not available in a Trusted Web Activity.',), + ]) TrustedWebActivityScreenOrientation_? screenOrientation; ///Sets the start animations. ///It must contain 2 [AndroidResource], where the first one represents the "enter" animation for the browser ///and the second one represents the "exit" animation for the application. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) List? startAnimations; ///Sets the exit animations. ///It must contain 2 [AndroidResource], where the first one represents the "enter" animation for the application ///and the second one represents the "exit" animation for the browser. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) List? exitAnimations; ///Adds the necessary flags and extras to signal any browser supporting custom tabs to use the browser UI ///at all times and avoid showing custom tab like UI. ///Calling this with an intent will override any custom tabs related customizations. ///The default value is `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) bool? alwaysUseBrowserUI; ///Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS + @SupportedPlatforms(platforms: [ + IOSPlatform(), + ]) bool? entersReaderIfAvailable; ///Set to `true` to enable bar collapsing. The default value is `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS + @SupportedPlatforms(platforms: [ + IOSPlatform(), + ]) bool? barCollapsingEnabled; ///Set the custom style for the dismiss button. The default value is [DismissButtonStyle.DONE]. - /// - ///**NOTE**: available on iOS 11.0+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS + @SupportedPlatforms(platforms: [ + IOSPlatform(available: '11.0'), + ]) DismissButtonStyle_? dismissButtonStyle; ///Set the custom background color of the navigation bar and the toolbar. - /// - ///**NOTE**: available on iOS 10.0+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS + @SupportedPlatforms(platforms: [ + IOSPlatform(available: '10.0'), + ]) Color_? preferredBarTintColor; ///Set the custom color of the control buttons on the navigation bar and the toolbar. - /// - ///**NOTE**: available on iOS 10.0+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS + @SupportedPlatforms(platforms: [ + IOSPlatform(available: '10.0'), + ]) Color_? preferredControlTintColor; ///Set the custom modal presentation style when presenting the WebView. The default value is [ModalPresentationStyle.FULL_SCREEN]. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS + @SupportedPlatforms(platforms: [ + IOSPlatform(), + ]) ModalPresentationStyle_? presentationStyle; ///Set to the custom transition style when presenting the WebView. The default value is [ModalTransitionStyle.COVER_VERTICAL]. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS + @SupportedPlatforms(platforms: [ + IOSPlatform(), + ]) ModalTransitionStyle_? transitionStyle; ///An additional button to be shown in `SFSafariViewController`'s toolbar. ///This allows the user to access powerful functionality from your extension without needing to first show the `UIActivityViewController`. - /// - ///**NOTE**: available on iOS 15.0+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS + @SupportedPlatforms(platforms: [ + IOSPlatform(available: '15.0'), + ]) ActivityButton_? activityButton; ///An event attribution associated with a click that caused this `SFSafariViewController` to be opened. ///This attribute is ignored if the `SFSafariViewController` url has a scheme of 'http'. - /// - ///**NOTE**: available on iOS 15.2+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS + @SupportedPlatforms(platforms: [ + IOSPlatform(available: '15.2'), + ]) UIEventAttribution_? eventAttribution; @ExchangeableObjectConstructor() @@ -324,6 +310,11 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { Map toMap() { throw UnimplementedError(); } + + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported(ChromeSafariBrowserSettingsProperty property, + {TargetPlatform? platform}) => + _ChromeSafariBrowserSettingsPropertySupported.isPropertySupported(property, platform: platform); } ///Class that represents the options that can be used for an [ChromeSafariBrowser] window. diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart index 577c4fac2..0af9272a3 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart @@ -6,23 +6,28 @@ part of 'chrome_safari_browser_settings.dart'; // ExchangeableObjectGenerator // ************************************************************************** +///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings} ///Class that represents the settings that can be used for an [ChromeSafariBrowser] window. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.supported_platforms} +/// +///**Officially Supported Platforms/Implementations**: +///- Android Chrome Custom Tabs +///- iOS SFSafariViewController class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///An additional button to be shown in `SFSafariViewController`'s toolbar. ///This allows the user to access powerful functionality from your extension without needing to first show the `UIActivityViewController`. /// - ///**NOTE**: available on iOS 15.0+. - /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS SFSafariViewController 15.0+ ActivityButton? activityButton; ///Sets a list of additional trusted origins that the user may navigate or be redirected to from the starting uri. /// - ///**NOTE**: Available only in a Trusted Web Activity. - /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. List? additionalTrustedOrigins; ///Adds the necessary flags and extras to signal any browser supporting custom tabs to use the browser UI @@ -31,52 +36,46 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///The default value is `false`. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs bool? alwaysUseBrowserUI; ///Set to `true` to enable bar collapsing. The default value is `false`. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS SFSafariViewController bool? barCollapsingEnabled; ///Set the custom style for the dismiss button. The default value is [DismissButtonStyle.DONE]. /// - ///**NOTE**: available on iOS 11.0+. - /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS SFSafariViewController 11.0+ DismissButtonStyle? dismissButtonStyle; ///Sets a display mode of a Trusted Web Activity. /// - ///**NOTE**: Available only in a Trusted Web Activity. - /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. TrustedWebActivityDisplayMode? displayMode; ///Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`. /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. bool? enableUrlBarHiding; ///Set to `true` if Reader mode should be entered automatically when it is available for the webpage. The default value is `false`. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS SFSafariViewController bool? entersReaderIfAvailable; ///An event attribution associated with a click that caused this `SFSafariViewController` to be opened. ///This attribute is ignored if the `SFSafariViewController` url has a scheme of 'http'. /// - ///**NOTE**: available on iOS 15.2+. - /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS SFSafariViewController 15.2+ UIEventAttribution? eventAttribution; ///Sets the exit animations. @@ -84,51 +83,50 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///and the second one represents the "exit" animation for the browser. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs List? exitAnimations; ///Set to `true` to enable Instant Apps. The default value is `false`. /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. bool? instantAppsEnabled; ///Set to `true` to launch the Android activity in `singleInstance` mode. The default value is `false`. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs bool? isSingleInstance; ///Set to `true` to launch the Custom Tab as a Trusted Web Activity. The default value is `false`. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs bool? isTrustedWebActivity; ///Set to `true` to enable Keep Alive. The default value is `false`. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs bool? keepAliveEnabled; ///Sets the navigation bar color. Has no effect on Android API versions below L. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs Color? navigationBarColor; ///Sets the navigation bar divider color. Has no effect on Android API versions below P. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs Color? navigationBarDividerColor; ///Set to `true` to launch the Android intent with the flag `FLAG_ACTIVITY_NO_HISTORY`. The default value is `false`. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs bool? noHistory; ///Set an explicit application package name that limits @@ -138,59 +136,52 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///application package. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs String? packageName; ///Set the custom background color of the navigation bar and the toolbar. /// - ///**NOTE**: available on iOS 10.0+. - /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS SFSafariViewController 10.0+ Color? preferredBarTintColor; ///Set the custom color of the control buttons on the navigation bar and the toolbar. /// - ///**NOTE**: available on iOS 10.0+. - /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS SFSafariViewController 10.0+ Color? preferredControlTintColor; ///Set the custom modal presentation style when presenting the WebView. The default value is [ModalPresentationStyle.FULL_SCREEN]. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS SFSafariViewController ModalPresentationStyle? presentationStyle; ///Sets a screen orientation. This can be used e.g. to enable the locking of an orientation lock type. /// - ///**NOTE**: Available only in a Trusted Web Activity. - /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. TrustedWebActivityScreenOrientation? screenOrientation; ///Sets the color of the secondary toolbar. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs Color? secondaryToolbarColor; ///The share state that should be applied to the custom tab. The default value is [CustomTabsShareState.SHARE_STATE_DEFAULT]. /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. CustomTabsShareState? shareState; ///Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`. /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. bool? showTitle; ///Sets the start animations. @@ -198,20 +189,25 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { ///and the second one represents the "exit" animation for the application. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs List? startAnimations; ///Set the custom background color of the toolbar. /// ///**Officially Supported Platforms/Implementations**: - ///- Android + ///- Android Chrome Custom Tabs Color? toolbarBackgroundColor; ///Set to the custom transition style when presenting the WebView. The default value is [ModalTransitionStyle.COVER_VERTICAL]. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS SFSafariViewController ModalTransitionStyle? transitionStyle; + + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + ///- iOS SFSafariViewController ChromeSafariBrowserSettings( {this.shareState = CustomTabsShareState.SHARE_STATE_DEFAULT, this.showTitle = true, @@ -349,6 +345,13 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { return instance; } + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported(ChromeSafariBrowserSettingsProperty property, + {TargetPlatform? platform}) => + _ChromeSafariBrowserSettingsPropertySupported.isPropertySupported( + property, + platform: platform); + ///Converts instance to a map. Map toMap({EnumMethod? enumMethod}) { return { @@ -421,3 +424,437 @@ class ChromeSafariBrowserSettings implements ChromeSafariBrowserOptions { return 'ChromeSafariBrowserSettings{activityButton: $activityButton, additionalTrustedOrigins: $additionalTrustedOrigins, alwaysUseBrowserUI: $alwaysUseBrowserUI, barCollapsingEnabled: $barCollapsingEnabled, dismissButtonStyle: $dismissButtonStyle, displayMode: $displayMode, enableUrlBarHiding: $enableUrlBarHiding, entersReaderIfAvailable: $entersReaderIfAvailable, eventAttribution: $eventAttribution, exitAnimations: $exitAnimations, instantAppsEnabled: $instantAppsEnabled, isSingleInstance: $isSingleInstance, isTrustedWebActivity: $isTrustedWebActivity, keepAliveEnabled: $keepAliveEnabled, navigationBarColor: $navigationBarColor, navigationBarDividerColor: $navigationBarDividerColor, noHistory: $noHistory, packageName: $packageName, preferredBarTintColor: $preferredBarTintColor, preferredControlTintColor: $preferredControlTintColor, presentationStyle: $presentationStyle, screenOrientation: $screenOrientation, secondaryToolbarColor: $secondaryToolbarColor, shareState: $shareState, showTitle: $showTitle, startAnimations: $startAnimations, toolbarBackgroundColor: $toolbarBackgroundColor, transitionStyle: $transitionStyle}'; } } + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +///List of [ChromeSafariBrowserSettings]'s properties that can be used to check i they are supported or not by the current platform. +enum ChromeSafariBrowserSettingsProperty { + ///Can be used to check if the [ChromeSafariBrowserSettings.activityButton] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.activityButton.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController 15.0+ + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + activityButton, + + ///Can be used to check if the [ChromeSafariBrowserSettings.additionalTrustedOrigins] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.additionalTrustedOrigins.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + additionalTrustedOrigins, + + ///Can be used to check if the [ChromeSafariBrowserSettings.alwaysUseBrowserUI] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.alwaysUseBrowserUI.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + alwaysUseBrowserUI, + + ///Can be used to check if the [ChromeSafariBrowserSettings.barCollapsingEnabled] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.barCollapsingEnabled.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + barCollapsingEnabled, + + ///Can be used to check if the [ChromeSafariBrowserSettings.dismissButtonStyle] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.dismissButtonStyle.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController 11.0+ + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + dismissButtonStyle, + + ///Can be used to check if the [ChromeSafariBrowserSettings.displayMode] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.displayMode.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + displayMode, + + ///Can be used to check if the [ChromeSafariBrowserSettings.enableUrlBarHiding] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.enableUrlBarHiding.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + enableUrlBarHiding, + + ///Can be used to check if the [ChromeSafariBrowserSettings.entersReaderIfAvailable] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.entersReaderIfAvailable.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + entersReaderIfAvailable, + + ///Can be used to check if the [ChromeSafariBrowserSettings.eventAttribution] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.eventAttribution.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController 15.2+ + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + eventAttribution, + + ///Can be used to check if the [ChromeSafariBrowserSettings.exitAnimations] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.exitAnimations.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + exitAnimations, + + ///Can be used to check if the [ChromeSafariBrowserSettings.instantAppsEnabled] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.instantAppsEnabled.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + instantAppsEnabled, + + ///Can be used to check if the [ChromeSafariBrowserSettings.isSingleInstance] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.isSingleInstance.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + isSingleInstance, + + ///Can be used to check if the [ChromeSafariBrowserSettings.isTrustedWebActivity] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.isTrustedWebActivity.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + isTrustedWebActivity, + + ///Can be used to check if the [ChromeSafariBrowserSettings.keepAliveEnabled] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.keepAliveEnabled.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + keepAliveEnabled, + + ///Can be used to check if the [ChromeSafariBrowserSettings.navigationBarColor] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.navigationBarColor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + navigationBarColor, + + ///Can be used to check if the [ChromeSafariBrowserSettings.navigationBarDividerColor] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.navigationBarDividerColor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + navigationBarDividerColor, + + ///Can be used to check if the [ChromeSafariBrowserSettings.noHistory] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.noHistory.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + noHistory, + + ///Can be used to check if the [ChromeSafariBrowserSettings.packageName] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.packageName.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + packageName, + + ///Can be used to check if the [ChromeSafariBrowserSettings.preferredBarTintColor] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.preferredBarTintColor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController 10.0+ + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + preferredBarTintColor, + + ///Can be used to check if the [ChromeSafariBrowserSettings.preferredControlTintColor] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.preferredControlTintColor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController 10.0+ + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + preferredControlTintColor, + + ///Can be used to check if the [ChromeSafariBrowserSettings.presentationStyle] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.presentationStyle.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + presentationStyle, + + ///Can be used to check if the [ChromeSafariBrowserSettings.screenOrientation] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.screenOrientation.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + screenOrientation, + + ///Can be used to check if the [ChromeSafariBrowserSettings.secondaryToolbarColor] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.secondaryToolbarColor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + secondaryToolbarColor, + + ///Can be used to check if the [ChromeSafariBrowserSettings.shareState] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.shareState.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + shareState, + + ///Can be used to check if the [ChromeSafariBrowserSettings.showTitle] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.showTitle.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showTitle, + + ///Can be used to check if the [ChromeSafariBrowserSettings.startAnimations] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.startAnimations.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + startAnimations, + + ///Can be used to check if the [ChromeSafariBrowserSettings.toolbarBackgroundColor] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.toolbarBackgroundColor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + toolbarBackgroundColor, + + ///Can be used to check if the [ChromeSafariBrowserSettings.transitionStyle] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ChromeSafariBrowserSettings.transitionStyle.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController + /// + ///Use the [ChromeSafariBrowserSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + transitionStyle, +} + +extension _ChromeSafariBrowserSettingsPropertySupported + on ChromeSafariBrowserSettings { + static bool isPropertySupported(ChromeSafariBrowserSettingsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case ChromeSafariBrowserSettingsProperty.activityButton: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.additionalTrustedOrigins: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.alwaysUseBrowserUI: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.barCollapsingEnabled: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.dismissButtonStyle: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.displayMode: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.enableUrlBarHiding: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.entersReaderIfAvailable: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.eventAttribution: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.exitAnimations: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.instantAppsEnabled: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.isSingleInstance: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.isTrustedWebActivity: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.keepAliveEnabled: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.navigationBarColor: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.navigationBarDividerColor: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.noHistory: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.packageName: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.preferredBarTintColor: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.preferredControlTintColor: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.presentationStyle: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.screenOrientation: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.secondaryToolbarColor: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.shareState: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.showTitle: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.startAnimations: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.toolbarBackgroundColor: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ChromeSafariBrowserSettingsProperty.transitionStyle: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart index 651e38cb2..9eb3caa92 100755 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart @@ -1,9 +1,12 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +part 'platform_chrome_safari_browser.g.dart'; + /// Object specifying creation parameters for creating a [PlatformChromeSafariBrowser]. /// /// Platform specific implementations can add additional fields by extending @@ -19,18 +22,23 @@ class PlatformChromeSafariBrowserCreationParams { ///It presents a self-contained web interface inside your app. /// ///If you need to customize or interact with the web content, use the `InAppWebView` widget. -/// -///This class uses native [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary) on Android -///and [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) on iOS. -/// -///**NOTE**: If you want to use the `ChromeSafariBrowser` class on Android 11+ you need to specify your app querying for -///`android.support.customtabs.action.CustomTabsService` in your `AndroidManifest.xml` -///(you can read more about it here: https://developers.google.com/web/android/custom-tabs/best-practices#applications_targeting_android_11_api_level_30_or_above). -/// -///**Officially Supported Platforms/Implementations**: -///- Android -///- iOS ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform( + note: + """This class uses native [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary). +If you want to use the `ChromeSafariBrowser` class on Android 11+ you need to specify your app querying for +`android.support.customtabs.action.CustomTabsService` in your `AndroidManifest.xml` +(you can read more about it here: https://developers.google.com/web/android/custom-tabs/best-practices#applications_targeting_android_11_api_level_30_or_above).""", + name: 'Android Chrome Custom Tabs', + ), + IOSPlatform( + note: + 'This class uses native [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller)', + name: 'iOS SFSafariViewController'), +]) abstract class PlatformChromeSafariBrowser extends PlatformInterface implements Disposable { ///Debug settings. @@ -97,26 +105,37 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// ///[url] - The [url] to load. On iOS, the [url] is required and must use the `http` or `https` scheme. /// - ///[headers] (Supported only on Android) - [whitelisted](https://fetch.spec.whatwg.org/#cors-safelisted-request-header) cross-origin request headers. + ///[headers] - [whitelisted](https://fetch.spec.whatwg.org/#cors-safelisted-request-header) cross-origin request headers. ///It is possible to attach non-whitelisted headers to cross-origin requests, when the server and client are related using a ///[digital asset link](https://developers.google.com/digital-asset-links/v1/getting-started). /// - ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. Supported only on Android. + ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. /// - ///[referrer] - referrer header. Supported only on Android. + ///[referrer] - referrer header. /// ///[options] - Deprecated. Use `settings` instead. /// ///[settings] - Settings for the [PlatformChromeSafariBrowser]. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.open.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) Future open( {WebUri? url, + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) Map? headers, + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) List? otherLikelyURLs, + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) WebUri? referrer, @Deprecated('Use settings instead') // ignore: deprecated_member_use_from_same_package @@ -130,17 +149,19 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// ///[url] - initial url. /// - ///[headers] (Supported only on Android) - [whitelisted](https://fetch.spec.whatwg.org/#cors-safelisted-request-header) cross-origin request headers. + ///[headers] - [whitelisted](https://fetch.spec.whatwg.org/#cors-safelisted-request-header) cross-origin request headers. ///It is possible to attach non-whitelisted headers to cross-origin requests, when the server and client are related using a ///[digital asset link](https://developers.google.com/digital-asset-links/v1/getting-started). /// ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. /// - ///[referrer] - referrer header. Supported only on Android. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android + ///[referrer] - referrer header. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.launchUrl.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) Future launchUrl({ required WebUri url, Map? headers, @@ -161,10 +182,16 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///[url] - Most likely URL, may be null if otherLikelyBundles is provided. /// ///[otherLikelyURLs] - Other likely destinations, sorted in decreasing likelihood order. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsSession.mayLaunchUrl](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List%3Candroid.os.Bundle%3E))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.mayLaunchUrl.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsSession.mayLaunchUrl', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List%3Candroid.os.Bundle%3E)', + ), + ]) Future mayLaunchUrl({WebUri? url, List? otherLikelyURLs}) { throw UnimplementedError( 'mayLaunchUrl is not implemented on the current platform'); @@ -184,10 +211,16 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///[origin] – Origin. /// ///[extras] – Reserved for future use. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsSession.validateRelationship](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.validateRelationship.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsSession.validateRelationship', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle)', + ), + ]) Future validateRelationship( {required CustomTabsRelationType relation, required WebUri origin}) { throw UnimplementedError( @@ -196,11 +229,13 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.close} ///Closes the [PlatformChromeSafariBrowser] instance. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.close.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) Future close() { throw UnimplementedError( 'close is not implemented on the current platform'); @@ -208,12 +243,17 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setActionButton} ///Set a custom action button. - /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsIntent.Builder.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setActionButton(android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setActionButton.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsSession.setActionButton', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setActionButton(android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean)', + note: 'Not available in a Trusted Web Activity.', + ), + ]) void setActionButton(ChromeSafariBrowserActionButton actionButton) { throw UnimplementedError( 'setActionButton is not implemented on the current platform'); @@ -221,12 +261,17 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateActionButton} ///Updates the [ChromeSafariBrowserActionButton.icon] and [ChromeSafariBrowserActionButton.description]. - /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsSession.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setActionButton(android.graphics.Bitmap,java.lang.String))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateActionButton.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsSession.setActionButton', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setActionButton(android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean)', + note: 'Not available in a Trusted Web Activity.', + ), + ]) Future updateActionButton( {required Uint8List icon, required String description}) { throw UnimplementedError( @@ -235,12 +280,17 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setSecondaryToolbar} ///Sets the remote views displayed in the secondary toolbar in a custom tab. - /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsIntent.Builder.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setSecondaryToolbar.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsIntent.Builder.setSecondaryToolbarViews', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent)', + note: 'Not available in a Trusted Web Activity.', + ), + ]) void setSecondaryToolbar( ChromeSafariBrowserSecondaryToolbar secondaryToolbar) { throw UnimplementedError( @@ -249,12 +299,17 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateSecondaryToolbar} ///Sets or updates (if already present) the Remote Views of the secondary toolbar in an existing custom tab session. - /// - ///**NOTE**: Not available in a Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsSession.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateSecondaryToolbar.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsIntent.Builder.setSecondaryToolbarViews', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent)', + note: 'Not available in a Trusted Web Activity.', + ), + ]) Future updateSecondaryToolbar( ChromeSafariBrowserSecondaryToolbar secondaryToolbar) { throw UnimplementedError( @@ -263,13 +318,15 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItem} ///Adds a [ChromeSafariBrowserMenuItem] to the menu. - /// - ///**NOTE**: Not available in an Android Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItem.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + note: 'Not available in a Trusted Web Activity.', + ), + IOSPlatform(), + ]) void addMenuItem(ChromeSafariBrowserMenuItem menuItem) { throw UnimplementedError( 'addMenuItem is not implemented on the current platform'); @@ -277,13 +334,15 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItems} ///Adds a list of [ChromeSafariBrowserMenuItem] to the menu. - /// - ///**NOTE**: Not available in an Android Trusted Web Activity. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItems.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + note: 'Not available in a Trusted Web Activity.', + ), + IOSPlatform(), + ]) void addMenuItems(List menuItems) { throw UnimplementedError( 'addMenuItems is not implemented on the current platform'); @@ -304,10 +363,16 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///Returns whether the implementation accepted the request. ///Note that returning true here doesn't mean an origin has already been ///assigned as the validation is asynchronous. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsSession.requestPostMessageChannel](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#requestPostMessageChannel(android.net.Uri,android.net.Uri,android.os.Bundle))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.requestPostMessageChannel.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsSession.requestPostMessageChannel', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#requestPostMessageChannel(android.net.Uri,android.net.Uri,android.os.Bundle)', + ), + ]) Future requestPostMessageChannel( {required WebUri sourceOrigin, WebUri? targetOrigin}) { throw UnimplementedError( @@ -321,11 +386,17 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///[message] – The message that is being sent. /// ///Returns an integer constant about the postMessage request result. - ///Will return CustomTabsService.RESULT_SUCCESS if successful. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsSession.postMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#postMessage(java.lang.String,android.os.Bundle))) + ///Will return [CustomTabsPostMessageResultType.SUCCESS] if successful. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.postMessage.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsSession.postMessage', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#postMessage(java.lang.String,android.os.Bundle)', + ), + ]) Future postMessage(String message) { throw UnimplementedError( 'postMessage is not implemented on the current platform'); @@ -338,10 +409,16 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///signal will be sent if the API becomes unavailable later. /// ///Returns whether the Engagement Signals API is available. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsSession.isEngagementSignalsApiAvailable](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#isEngagementSignalsApiAvailable(android.os.Bundle))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsSession.isEngagementSignalsApiAvailable', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#isEngagementSignalsApiAvailable(android.os.Bundle)', + ), + ]) Future isEngagementSignalsApiAvailable() { throw UnimplementedError( 'isEngagementSignalsApiAvailable is not implemented on the current platform'); @@ -349,11 +426,13 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isOpened} ///Returns `true` if the [PlatformChromeSafariBrowser] instance is opened, otherwise `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isOpened.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) bool isOpened() { throw UnimplementedError( 'isOpened is not implemented on the current platform'); @@ -363,11 +442,13 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///On Android, returns `true` if Chrome Custom Tabs is available. ///On iOS, returns `true` if SFSafariViewController is available. ///Otherwise returns `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isAvailable.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) Future isAvailable() { throw UnimplementedError( 'isAvailable is not implemented on the current platform'); @@ -375,10 +456,12 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getMaxToolbarItems} ///The maximum number of allowed secondary toolbar items. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getMaxToolbarItems.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) Future getMaxToolbarItems() { throw UnimplementedError( 'getMaxToolbarItems is not implemented on the current platform'); @@ -397,11 +480,17 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// ///[ignoreDefault] – If set, the default VIEW handler won't get priority over other browsers. /// - ///Returns the preferred package name for handling Custom Tabs, or null. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsClient.getPackageName](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsClient#getPackageName(android.content.Context,java.util.List%3Cjava.lang.String%3E,boolean)))) + ///Returns the preferred package name for handling Custom Tabs, or `null`. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getPackageName.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsClient.getPackageName', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsClient#getPackageName(android.content.Context,java.util.List%3Cjava.lang.String%3E,boolean)', + ), + ]) Future getPackageName( {List? packages, bool ignoreDefault = false}) { throw UnimplementedError( @@ -411,12 +500,17 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.clearWebsiteData} ///Clear associated website data accrued from browsing activity within your app. ///This includes all local storage, cached resources, and cookies. - /// - ///**NOTE for iOS**: available on iOS 16.0+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - SFSafariViewController.DataStore.clearWebsiteData](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/datastore/3981117-clearwebsitedata)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.clearWebsiteData.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + apiName: 'SFSafariViewController.DataStore.clearWebsiteData', + apiUrl: + 'https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/datastore/3981117-clearwebsitedata', + available: '16.0', + ), + ]) Future clearWebsiteData() { throw UnimplementedError( 'clearWebsiteData is not implemented on the current platform'); @@ -438,12 +532,17 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface /// ///[URLs] - the URLs of servers that the browser should prewarm connections to. ///Only supports URLs with `http://` or `https://` schemes. - /// - ///**NOTE for iOS**: available on iOS 15.0+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.prewarmConnections.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + apiName: 'SFSafariViewController.prewarmConnections', + apiUrl: + 'https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections', + available: '15.0', + ), + ]) Future prewarmConnections(List URLs) { throw UnimplementedError( 'prewarmConnections is not implemented on the current platform'); @@ -451,12 +550,17 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.invalidatePrewarmingToken} ///Ends all prewarmed connections associated with the token, except for connections that are also kept alive by other tokens. - /// - ///**NOTE for iOS**: available on iOS 15.0+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.invalidatePrewarmingToken.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + apiName: 'SFSafariViewController.PrewarmingToken.invalidate', + apiUrl: + 'https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/prewarmingtoken/invalidate()', + available: '15.0', + ), + ]) Future invalidatePrewarmingToken(PrewarmingToken prewarmingToken) { throw UnimplementedError( 'invalidatePrewarmingToken is not implemented on the current platform'); @@ -465,59 +569,116 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.dispose} ///Disposes the channel and event handler. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.dispose.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) @override @mustCallSuper void dispose() { eventHandler = null; } + + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformChromeSafariBrowserClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isMethodSupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformChromeSafariBrowserMethod method, + {TargetPlatform? platform}) => + _PlatformChromeSafariBrowserMethodSupported.isMethodSupported(method, + platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.isMethodSupported} + bool isEventMethodSupported(PlatformChromeSafariBrowserEventsMethod method, + {TargetPlatform? platform}) => + PlatformChromeSafariBrowserEvents.isMethodSupported(method, + platform: platform); } +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), +]) abstract class PlatformChromeSafariBrowserEvents { - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onServiceConnected} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onServiceConnected} ///Event fired when the when connecting from Android Custom Tabs Service. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onServiceConnected.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) void onServiceConnected() {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onOpened} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onOpened} ///Event fired when the [PlatformChromeSafariBrowser] is opened. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onOpened.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) void onOpened() {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onCompletedInitialLoad} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onCompletedInitialLoad} ///Event fired when the initial URL load is complete. /// - ///[didLoadSuccessfully] - `true` if loading completed successfully; otherwise, `false`. Supported only on iOS. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android - ///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/1621215-safariviewcontroller)) - ///{@endtemplate} - void onCompletedInitialLoad(bool? didLoadSuccessfully) {} - - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onInitialLoadDidRedirect} + ///[didLoadSuccessfully] - `true` if loading completed successfully; otherwise, `false`. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onCompletedInitialLoad.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform( + apiName: 'SFSafariViewControllerDelegate.safariViewController', + apiUrl: + 'https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/1621215-safariviewcontroller', + ), + ]) + void onCompletedInitialLoad( + @SupportedPlatforms(platforms: [ + IOSPlatform(), + ]) + bool? didLoadSuccessfully) {} + + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onInitialLoadDidRedirect} ///Event fired when the initial URL load is complete. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/2923545-safariviewcontroller)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onInitialLoadDidRedirect.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + apiName: 'SFSafariViewControllerDelegate.safariViewController', + apiUrl: + 'https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/2923545-safariviewcontroller', + ), + ]) void onInitialLoadDidRedirect(WebUri? url) {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onNavigationEvent} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onNavigationEvent} ///Event fired when a navigation event happens. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsCallback.onNavigationEvent](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onNavigationEvent(int,android.os.Bundle))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onNavigationEvent.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsCallback.onNavigationEvent', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onNavigationEvent(int,android.os.Bundle)', + ), + ]) void onNavigationEvent(CustomTabsNavigationEventType? navigationEvent) {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onRelationshipValidationResult} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onRelationshipValidationResult} ///Event fired when a relationship validation result is available. /// ///[relation] - Relation for which the result is available. Value previously passed to [PlatformChromeSafariBrowser.validateRelationship]. @@ -525,56 +686,85 @@ abstract class PlatformChromeSafariBrowserEvents { ///[requestedOrigin] - Origin requested. Value previously passed to [PlatformChromeSafariBrowser.validateRelationship]. /// ///[result] - Whether the relation was validated. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsCallback.onRelationshipValidationResult](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onRelationshipValidationResult(int,android.net.Uri,boolean,android.os.Bundle))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onRelationshipValidationResult.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsCallback.onRelationshipValidationResult', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onRelationshipValidationResult(int,android.net.Uri,boolean,android.os.Bundle)', + ), + ]) void onRelationshipValidationResult( CustomTabsRelationType? relation, WebUri? requestedOrigin, bool result) {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onWillOpenInBrowser} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onWillOpenInBrowser} ///Event fired when the user opens the current page in the default browser by tapping the toolbar button. - /// - ///**NOTE for iOS**: available on iOS 14.0+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - SFSafariViewControllerDelegate.safariViewControllerWillOpenInBrowser](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/3650426-safariviewcontrollerwillopeninbr)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onWillOpenInBrowser.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + apiName: + 'SFSafariViewControllerDelegate.safariViewControllerWillOpenInBrowser', + apiUrl: + 'https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/3650426-safariviewcontrollerwillopeninbr', + available: '14.0', + ), + ]) void onWillOpenInBrowser() {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onMessageChannelReady} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onMessageChannelReady} ///Called when the [PlatformChromeSafariBrowser] has requested a postMessage channel through ///[PlatformChromeSafariBrowser.requestPostMessageChannel] and the channel is ready for sending and receiving messages on both ends. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsCallback.onMessageChannelReady](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onMessageChannelReady(android.os.Bundle))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onMessageChannelReady.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsCallback.onMessageChannelReady', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onMessageChannelReady(android.os.Bundle)', + ), + ]) void onMessageChannelReady() {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onPostMessage} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onPostMessage} ///Called when a tab controlled by this [PlatformChromeSafariBrowser] has sent a postMessage. ///If [PlatformChromeSafariBrowser.postMessage] is called from a single thread, then the messages will be posted in the same order. ///When received on the client side, it is the client's responsibility to preserve the ordering further. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - CustomTabsCallback.onPostMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onPostMessage(java.lang.String,android.os.Bundle))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onPostMessage.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'CustomTabsCallback.onPostMessage', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onPostMessage(java.lang.String,android.os.Bundle)', + ), + ]) void onPostMessage(String message) {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onVerticalScrollEvent} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onVerticalScrollEvent} ///Called when a user scrolls the tab. /// ///[isDirectionUp] - `false` when the user scrolls farther down the page, ///and `true` when the user scrolls back up toward the top of the page. /// ///**NOTE**: available only if [PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable] returns `true`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - EngagementSignalsCallback.onVerticalScrollEvent](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onVerticalScrollEvent(boolean,android.os.Bundle))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onVerticalScrollEvent.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'EngagementSignalsCallback.onVerticalScrollEvent', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onVerticalScrollEvent(boolean,android.os.Bundle)'), + ]) void onVerticalScrollEvent(bool isDirectionUp) {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onGreatestScrollPercentageIncreased} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onGreatestScrollPercentageIncreased} ///Called when a user has reached a greater scroll percentage on the page. The greatest scroll ///percentage is reset if the user navigates to a different page. If the current page's total ///height changes, this method will be called again only if the scroll progress reaches a @@ -584,31 +774,53 @@ abstract class PlatformChromeSafariBrowserEvents { ///the user hasmade down the current page. /// ///**NOTE**: available only if [PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable] returns `true`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - EngagementSignalsCallback.onGreatestScrollPercentageIncreased](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onGreatestScrollPercentageIncreased(int,android.os.Bundle))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onGreatestScrollPercentageIncreased.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: + 'EngagementSignalsCallback.onGreatestScrollPercentageIncreased', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onGreatestScrollPercentageIncreased(int,android.os.Bundle)'), + ]) void onGreatestScrollPercentageIncreased(int scrollPercentage) {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onSessionEnded} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onSessionEnded} ///Called when a `CustomTabsSession` is ending or when no further Engagement Signals ///callbacks are expected to report whether any user action has occurred during the session. /// ///[didUserInteract] - Whether the user has interacted with the page in any way, e.g. scrolling. /// ///**NOTE**: available only if [PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable] returns `true`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android ([Official API - EngagementSignalsCallback.onSessionEnded](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onSessionEnded(boolean,android.os.Bundle))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onSessionEnded.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'EngagementSignalsCallback.onSessionEnded', + apiUrl: + 'https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onSessionEnded(boolean,android.os.Bundle)'), + ]) void onSessionEnded(bool didUserInteract) {} - ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.onClosed} + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onClosed} ///Event fired when the [PlatformChromeSafariBrowser] is closed. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onClosed.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) void onClosed() {} + + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isMethodSupported(PlatformChromeSafariBrowserEventsMethod method, + {TargetPlatform? platform}) => + _PlatformChromeSafariBrowserEventsMethodSupported.isMethodSupported( + method, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.g.dart new file mode 100644 index 000000000..0fcdd6a56 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.g.dart @@ -0,0 +1,675 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_chrome_safari_browser.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformChromeSafariBrowserClassSupported + on PlatformChromeSafariBrowser { + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs: + /// - This class uses native [Chrome Custom Tabs](https://developer.android.com/reference/android/support/customtabs/package-summary). If you want to use the `ChromeSafariBrowser` class on Android 11+ you need to specify your app querying for `android.support.customtabs.action.CustomTabsService` in your `AndroidManifest.xml` (you can read more about it here: https://developers.google.com/web/android/custom-tabs/best-practices#applications_targeting_android_11_api_level_30_or_above). + ///- iOS SFSafariViewController: + /// - This class uses native [SFSafariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller) + /// + ///Use the [PlatformChromeSafariBrowser.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformChromeSafariBrowser]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformChromeSafariBrowserMethod { + ///Can be used to check if the [PlatformChromeSafariBrowser.addMenuItem] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItem.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. + ///- iOS SFSafariViewController + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [menuItem]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + addMenuItem, + + ///Can be used to check if the [PlatformChromeSafariBrowser.addMenuItems] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.addMenuItems.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs: + /// - Not available in a Trusted Web Activity. + ///- iOS SFSafariViewController + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [menuItems]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + addMenuItems, + + ///Can be used to check if the [PlatformChromeSafariBrowser.clearWebsiteData] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.clearWebsiteData.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController 16.0+ ([Official API - SFSafariViewController.DataStore.clearWebsiteData](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/datastore/3981117-clearwebsitedata)) + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + clearWebsiteData, + + ///Can be used to check if the [PlatformChromeSafariBrowser.close] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.close.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + ///- iOS SFSafariViewController + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + close, + + ///Can be used to check if the [PlatformChromeSafariBrowser.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + ///- iOS SFSafariViewController + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, + + ///Can be used to check if the [PlatformChromeSafariBrowser.getMaxToolbarItems] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getMaxToolbarItems.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getMaxToolbarItems, + + ///Can be used to check if the [PlatformChromeSafariBrowser.getPackageName] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.getPackageName.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs ([Official API - CustomTabsClient.getPackageName](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsClient#getPackageName(android.content.Context,java.util.List%3Cjava.lang.String%3E,boolean))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [packages]: all platforms + ///- [ignoreDefault]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getPackageName, + + ///Can be used to check if the [PlatformChromeSafariBrowser.invalidatePrewarmingToken] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.invalidatePrewarmingToken.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController 15.0+ ([Official API - SFSafariViewController.PrewarmingToken.invalidate](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/prewarmingtoken/invalidate())) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [prewarmingToken]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + invalidatePrewarmingToken, + + ///Can be used to check if the [PlatformChromeSafariBrowser.isAvailable] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isAvailable.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + ///- iOS SFSafariViewController + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + isAvailable, + + ///Can be used to check if the [PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isEngagementSignalsApiAvailable.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs ([Official API - CustomTabsSession.isEngagementSignalsApiAvailable](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#isEngagementSignalsApiAvailable(android.os.Bundle))) + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + isEngagementSignalsApiAvailable, + + ///Can be used to check if the [PlatformChromeSafariBrowser.isOpened] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isOpened.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + ///- iOS SFSafariViewController + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + isOpened, + + ///Can be used to check if the [PlatformChromeSafariBrowser.launchUrl] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.launchUrl.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + ///- [headers]: all platforms + ///- [otherLikelyURLs]: all platforms + ///- [referrer]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + launchUrl, + + ///Can be used to check if the [PlatformChromeSafariBrowser.mayLaunchUrl] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.mayLaunchUrl.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs ([Official API - CustomTabsSession.mayLaunchUrl](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#mayLaunchUrl(android.net.Uri,android.os.Bundle,java.util.List%3Candroid.os.Bundle%3E))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + ///- [otherLikelyURLs]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + mayLaunchUrl, + + ///Can be used to check if the [PlatformChromeSafariBrowser.open] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.open.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs + ///- iOS SFSafariViewController + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + ///- [headers]: + /// - Android Chrome Custom Tabs + ///- [otherLikelyURLs]: + /// - Android Chrome Custom Tabs + ///- [referrer]: + /// - Android Chrome Custom Tabs + ///- [settings]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + open, + + ///Can be used to check if the [PlatformChromeSafariBrowser.postMessage] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.postMessage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs ([Official API - CustomTabsSession.postMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#postMessage(java.lang.String,android.os.Bundle))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [message]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + postMessage, + + ///Can be used to check if the [PlatformChromeSafariBrowser.prewarmConnections] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.prewarmConnections.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS SFSafariViewController 15.0+ ([Official API - SFSafariViewController.prewarmConnections](https://developer.apple.com/documentation/safariservices/sfsafariviewcontroller/3752133-prewarmconnections)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [URLs]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + prewarmConnections, + + ///Can be used to check if the [PlatformChromeSafariBrowser.requestPostMessageChannel] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.requestPostMessageChannel.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs ([Official API - CustomTabsSession.requestPostMessageChannel](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#requestPostMessageChannel(android.net.Uri,android.net.Uri,android.os.Bundle))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [sourceOrigin]: all platforms + ///- [targetOrigin]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + requestPostMessageChannel, + + ///Can be used to check if the [PlatformChromeSafariBrowser.setActionButton] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setActionButton.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs ([Official API - CustomTabsSession.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setActionButton(android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean))): + /// - Not available in a Trusted Web Activity. + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [actionButton]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setActionButton, + + ///Can be used to check if the [PlatformChromeSafariBrowser.setSecondaryToolbar] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.setSecondaryToolbar.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs ([Official API - CustomTabsIntent.Builder.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))): + /// - Not available in a Trusted Web Activity. + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [secondaryToolbar]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setSecondaryToolbar, + + ///Can be used to check if the [PlatformChromeSafariBrowser.updateActionButton] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateActionButton.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs ([Official API - CustomTabsSession.setActionButton](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setActionButton(android.graphics.Bitmap,%20java.lang.String,%20android.app.PendingIntent,%20boolean))): + /// - Not available in a Trusted Web Activity. + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [icon]: all platforms + ///- [description]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + updateActionButton, + + ///Can be used to check if the [PlatformChromeSafariBrowser.updateSecondaryToolbar] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.updateSecondaryToolbar.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs ([Official API - CustomTabsIntent.Builder.setSecondaryToolbarViews](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsIntent.Builder#setSecondaryToolbarViews(android.widget.RemoteViews,int[],android.app.PendingIntent))): + /// - Not available in a Trusted Web Activity. + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [secondaryToolbar]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + updateSecondaryToolbar, + + ///Can be used to check if the [PlatformChromeSafariBrowser.validateRelationship] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.validateRelationship.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android Chrome Custom Tabs ([Official API - CustomTabsSession.validateRelationship](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsSession#validateRelationship(int,android.net.Uri,android.os.Bundle))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [relation]: all platforms + ///- [origin]: all platforms + /// + ///Use the [PlatformChromeSafariBrowser.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + validateRelationship, +} + +extension _PlatformChromeSafariBrowserMethodSupported + on PlatformChromeSafariBrowser { + static bool isMethodSupported(PlatformChromeSafariBrowserMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformChromeSafariBrowserMethod.addMenuItem: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.addMenuItems: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.clearWebsiteData: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.close: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.dispose: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.getMaxToolbarItems: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.getPackageName: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.invalidatePrewarmingToken: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.isAvailable: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.isEngagementSignalsApiAvailable: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.isOpened: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.launchUrl: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.mayLaunchUrl: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.open: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.postMessage: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.prewarmConnections: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.requestPostMessageChannel: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.setActionButton: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.setSecondaryToolbar: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.updateActionButton: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.updateSecondaryToolbar: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserMethod.validateRelationship: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +///List of [PlatformChromeSafariBrowserEvents]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformChromeSafariBrowserEventsMethod { + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onClosed] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onClosed.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onClosed, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onCompletedInitialLoad] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onCompletedInitialLoad.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView ([Official API - SFSafariViewControllerDelegate.safariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/1621215-safariviewcontroller)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [didLoadSuccessfully]: + /// - iOS WKWebView + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onCompletedInitialLoad, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onGreatestScrollPercentageIncreased] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onGreatestScrollPercentageIncreased.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - EngagementSignalsCallback.onGreatestScrollPercentageIncreased](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onGreatestScrollPercentageIncreased(int,android.os.Bundle))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [scrollPercentage]: all platforms + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onGreatestScrollPercentageIncreased, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onInitialLoadDidRedirect] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onInitialLoadDidRedirect.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView ([Official API - SFSafariViewControllerDelegate.safariViewController](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/2923545-safariviewcontroller)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onInitialLoadDidRedirect, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onMessageChannelReady] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onMessageChannelReady.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CustomTabsCallback.onMessageChannelReady](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onMessageChannelReady(android.os.Bundle))) + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onMessageChannelReady, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onNavigationEvent] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onNavigationEvent.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CustomTabsCallback.onNavigationEvent](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onNavigationEvent(int,android.os.Bundle))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [navigationEvent]: all platforms + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onNavigationEvent, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onOpened] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onOpened.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onOpened, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onPostMessage] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onPostMessage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CustomTabsCallback.onPostMessage](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onPostMessage(java.lang.String,android.os.Bundle))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [message]: all platforms + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onPostMessage, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onRelationshipValidationResult] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onRelationshipValidationResult.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CustomTabsCallback.onRelationshipValidationResult](https://developer.android.com/reference/androidx/browser/customtabs/CustomTabsCallback#onRelationshipValidationResult(int,android.net.Uri,boolean,android.os.Bundle))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [relation]: all platforms + ///- [requestedOrigin]: all platforms + ///- [result]: all platforms + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onRelationshipValidationResult, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onServiceConnected] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onServiceConnected.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onServiceConnected, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onSessionEnded] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onSessionEnded.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - EngagementSignalsCallback.onSessionEnded](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onSessionEnded(boolean,android.os.Bundle))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [didUserInteract]: all platforms + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onSessionEnded, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onVerticalScrollEvent] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onVerticalScrollEvent.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - EngagementSignalsCallback.onVerticalScrollEvent](https://developer.android.com/reference/androidx/browser/customtabs/EngagementSignalsCallback#onVerticalScrollEvent(boolean,android.os.Bundle))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [isDirectionUp]: all platforms + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onVerticalScrollEvent, + + ///Can be used to check if the [PlatformChromeSafariBrowserEvents.onWillOpenInBrowser] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.onWillOpenInBrowser.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 14.0+ ([Official API - SFSafariViewControllerDelegate.safariViewControllerWillOpenInBrowser](https://developer.apple.com/documentation/safariservices/sfsafariviewcontrollerdelegate/3650426-safariviewcontrollerwillopeninbr)) + /// + ///Use the [PlatformChromeSafariBrowserEvents.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + onWillOpenInBrowser, +} + +extension _PlatformChromeSafariBrowserEventsMethodSupported + on PlatformChromeSafariBrowserEvents { + static bool isMethodSupported(PlatformChromeSafariBrowserEventsMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformChromeSafariBrowserEventsMethod.onClosed: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod.onCompletedInitialLoad: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod + .onGreatestScrollPercentageIncreased: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod.onInitialLoadDidRedirect: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod.onMessageChannelReady: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod.onNavigationEvent: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod.onOpened: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod.onPostMessage: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod + .onRelationshipValidationResult: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod.onServiceConnected: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod.onSessionEnded: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod.onVerticalScrollEvent: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformChromeSafariBrowserEventsMethod.onWillOpenInBrowser: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart index a3e4ef194..bdd065b9d 100644 --- a/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/context_menu/context_menu.g.dart @@ -9,7 +9,7 @@ part of 'context_menu.dart'; ///Class that represents the WebView context menu. It used by [PlatformWebViewCreationParams.contextMenu]. /// ///**Officially Supported Platforms/Implementations**: -///- Android WebView : +///- Android WebView: /// - To make it work properly on Android, JavaScript should be enabled! ///- iOS WKWebView class ContextMenu { @@ -38,7 +38,7 @@ class ContextMenu { /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - To make it work properly on Android, JavaScript should be enabled! ///- iOS WKWebView ContextMenu( diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart index 427208332..ea09e771d 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart @@ -40,27 +40,39 @@ class PlatformInAppBrowserCreationParams { this.webViewEnvironment, }); - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.contextMenu} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.contextMenu} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.contextMenu.supported_platforms} final ContextMenu? contextMenu; - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.pullToRefreshController} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.pullToRefreshController} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.pullToRefreshController.supported_platforms} final PlatformPullToRefreshController? pullToRefreshController; - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.findInteractionController} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.findInteractionController} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.findInteractionController.supported_platforms} final PlatformFindInteractionController? findInteractionController; - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.initialUserScripts} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.initialUserScripts} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.initialUserScripts.supported_platforms} final UnmodifiableListView? initialUserScripts; - ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.windowId.supported_platforms} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.windowId} /// - ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.windowId.supported_platforms} + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.windowId.supported_platforms} final int? windowId; + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowserCreationParams.webViewEnvironment} ///Used to create the [PlatformInAppBrowser] using the specified environment. + ///{@endtemplate} /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserCreationParams.webViewEnvironment.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) final PlatformWebViewEnvironment? webViewEnvironment; } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart index 47a5c1491..e0f0c78ca 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart @@ -75,9 +75,9 @@ enum PlatformInAppBrowserProperty { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This property will be ignored if the [PlatformWebViewCreationParams.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 WebKit APIs. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This property will be ignored if the [PlatformWebViewCreationParams.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 WebKit APIs. ///- Windows WebView2 /// @@ -893,7 +893,7 @@ enum PlatformInAppBrowserEventsMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onAjaxProgress.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxProgress] settings documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. In that case, after the `window.addEventListener("flutterInAppWebViewPlatformReady")` event is dispatched, the ajax requests can be intercept for sure. ///- iOS WKWebView ///- macOS WKWebView @@ -910,7 +910,7 @@ enum PlatformInAppBrowserEventsMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onAjaxReadyStateChange.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxReadyStateChange] settings documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. In that case, after the `window.addEventListener("flutterInAppWebViewPlatformReady")` event is dispatched, the ajax requests can be intercept for sure. ///- iOS WKWebView ///- macOS WKWebView @@ -973,9 +973,9 @@ enum PlatformInAppBrowserEventsMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebChromeClient.onConsoleMessage](https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage))) - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This event is implemented using JavaScript. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This event is implemented using JavaScript. ///- Web \ but requires same origin ///- Windows WebView2 @@ -1273,11 +1273,11 @@ enum PlatformInAppBrowserEventsMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onLoadResource.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - This event is implemented using JavaScript. - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This event is implemented using JavaScript. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This event is implemented using JavaScript. /// ///**Parameters - Officially Supported Platforms/Implementations**: @@ -1452,9 +1452,9 @@ enum PlatformInAppBrowserEventsMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView 21+ ([Official API - WebChromeClient.onPermissionRequest](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest))) - ///- iOS WKWebView 15.0+ : + ///- iOS WKWebView 15.0+: /// - The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT]. - ///- macOS WKWebView 12.0+ : + ///- macOS WKWebView 12.0+: /// - The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT]. ///- Windows WebView2 ([Official API - ICoreWebView2.add_PermissionRequested](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_permissionrequested)) /// @@ -1502,7 +1502,7 @@ enum PlatformInAppBrowserEventsMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - View.scrollBy](https://developer.android.com/reference/android/view/View#scrollBy(int,%20int))) ///- iOS WKWebView ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset)) - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. /// ///**Parameters - Officially Supported Platforms/Implementations**: @@ -1753,7 +1753,7 @@ enum PlatformInAppBrowserEventsMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebView.onScrollChanged](https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int))) ///- iOS WKWebView ([Official API - UIScrollViewDelegate.scrollViewDidScroll](https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll)) - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This event is implemented using JavaScript. /// ///**Parameters - Officially Supported Platforms/Implementations**: @@ -1890,7 +1890,7 @@ enum PlatformInAppBrowserEventsMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.shouldInterceptAjaxRequest.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. In that case, after the `window.addEventListener("flutterInAppWebViewPlatformReady")` event is dispatched, the ajax requests can be intercept for sure. ///- iOS WKWebView ///- macOS WKWebView @@ -1907,7 +1907,7 @@ enum PlatformInAppBrowserEventsMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.shouldInterceptFetchRequest.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptFetchRequest] setting documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. In that case, after the `window.addEventListener("flutterInAppWebViewPlatformReady")` event is dispatched, the ajax requests can be intercept for sure. ///- iOS WKWebView ///- macOS WKWebView diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart index ed76e8d48..bf448a58c 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart @@ -503,7 +503,7 @@ class InAppWebViewSettings { ///The default value is `true`. /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - available on Android only if [WebViewFeature.ENTERPRISE_AUTHENTICATION_APP_LINK_POLICY] feature is supported. bool? enterpriseAuthenticationAppLinkPolicyEnabled; @@ -679,7 +679,7 @@ class InAppWebViewSettings { ///Set to `true` to open a browser window with incognito mode. The default value is `false`. /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - setting this to `true`, it will clear all the cookies of all WebView instances, because there isn't any way to make the website data store non-persistent for the specific WebView instance such as on iOS. ///- iOS WKWebView ///- macOS WKWebView @@ -1393,7 +1393,7 @@ class InAppWebViewSettings { ///Hybrid Composition is supported starting with Flutter v1.20+. /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - It is recommended to use Hybrid Composition only on Android 10+ for a release app, as it can cause framerate drops on animations in Android 9 and lower (see [Hybrid-Composition#performance](https://github.com/flutter/flutter/wiki/Hybrid-Composition#performance)). bool? useHybridComposition; @@ -2995,7 +2995,7 @@ enum InAppWebViewSettingsProperty { ///{@template flutter_inappwebview_platform_interface.InAppWebViewSettings.enterpriseAuthenticationAppLinkPolicyEnabled.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - available on Android only if [WebViewFeature.ENTERPRISE_AUTHENTICATION_APP_LINK_POLICY] feature is supported. /// ///Use the [InAppWebViewSettings.isPropertySupported] method to check if this property is supported at runtime. @@ -3245,7 +3245,7 @@ enum InAppWebViewSettingsProperty { ///{@template flutter_inappwebview_platform_interface.InAppWebViewSettings.incognito.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - setting this to `true`, it will clear all the cookies of all WebView instances, because there isn't any way to make the website data store non-persistent for the specific WebView instance such as on iOS. ///- iOS WKWebView ///- macOS WKWebView @@ -4105,7 +4105,7 @@ enum InAppWebViewSettingsProperty { ///{@template flutter_inappwebview_platform_interface.InAppWebViewSettings.useHybridComposition.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - It is recommended to use Hybrid Composition only on Android 10+ for a release app, as it can cause framerate drops on animations in Android 9 and lower (see [Hybrid-Composition#performance](https://github.com/flutter/flutter/wiki/Hybrid-Composition#performance)). /// ///Use the [InAppWebViewSettings.isPropertySupported] method to check if this property is supported at runtime. diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.g.dart index ec425e3aa..d8447bdd1 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.g.dart @@ -39,7 +39,7 @@ enum PlatformHeadlessInAppWebViewCreationParamsProperty { ///{@template flutter_inappwebview_platform_interface.PlatformHeadlessInAppWebViewCreationParams.initialSize.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - `Size` width and height values will be converted to `int` values because they cannot have `double` values. ///- iOS WKWebView ///- macOS WKWebView @@ -167,7 +167,7 @@ enum PlatformHeadlessInAppWebViewMethod { ///- Android WebView ///- iOS WKWebView ///- macOS WKWebView - ///- Web \ : + ///- Web \: /// - It will append a new `iframe` to the body. ///- Windows WebView2 /// @@ -180,7 +180,7 @@ enum PlatformHeadlessInAppWebViewMethod { ///{@template flutter_inappwebview_platform_interface.PlatformHeadlessInAppWebView.setSize.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - `Size` width and height values will be converted to `int` values because they cannot have `double` values. ///- iOS WKWebView ///- macOS WKWebView diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.g.dart index 3d2eca785..b9013903a 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.g.dart @@ -182,9 +182,9 @@ enum PlatformInAppWebViewControllerMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs. ///- Web \ but requires same origin ///- Windows WebView2 @@ -203,9 +203,9 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebViewCompat.WebMessageListener](https://developer.android.com/reference/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,%20java.lang.String,%20java.util.Set%3Cjava.lang.String%3E,%20androidx.webkit.WebViewCompat.WebMessageListener))): /// - This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.WEB_MESSAGE_LISTENER]. - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. /// ///**Parameters - Officially Supported Platforms/Implementations**: @@ -301,7 +301,7 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ///- iOS WKWebView - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin /// @@ -316,7 +316,7 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ///- iOS WKWebView - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin /// @@ -472,9 +472,9 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebViewCompat.createWebMessageChannel](https://developer.android.com/reference/androidx/webkit/WebViewCompat#createWebMessageChannel(android.webkit.WebView))): /// - This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL]. - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. /// ///Use the [PlatformInAppWebViewController.isMethodSupported] method to check if this method is supported at runtime. @@ -629,7 +629,7 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebView.getContentHeight](https://developer.android.com/reference/android/webkit/WebView#getContentHeight())) ///- iOS WKWebView ([Official API - UIScrollView.contentSize](https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize)) - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin ([Official API - Document.documentElement.scrollHeight](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight)) /// @@ -642,10 +642,10 @@ enum PlatformInAppWebViewControllerMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getContentWidth.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - This method is implemented using JavaScript. ///- iOS WKWebView ([Official API - UIScrollView.contentSize](https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize)) - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin ([Official API - Document.documentElement.scrollWidth](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth)) /// @@ -713,7 +713,7 @@ enum PlatformInAppWebViewControllerMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebView.getHitTestResult](https://developer.android.com/reference/android/webkit/WebView#getHitTestResult())) - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript. /// ///Use the [PlatformInAppWebViewController.isMethodSupported] method to check if this method is supported at runtime. @@ -766,15 +766,15 @@ enum PlatformInAppWebViewControllerMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getMetaTags.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - This method is implemented using JavaScript. - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin: /// - This method is implemented using JavaScript. - ///- Windows WebView2 : + ///- Windows WebView2: /// - This method is implemented using JavaScript. /// ///Use the [PlatformInAppWebViewController.isMethodSupported] method to check if this method is supported at runtime. @@ -786,7 +786,7 @@ enum PlatformInAppWebViewControllerMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getMetaThemeColor.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - This method is implemented using JavaScript. ///- iOS WKWebView ([Official API - WKWebView.themeColor](https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor)): /// - On iOS < 15.0, this method is implemented using JavaScript. @@ -794,7 +794,7 @@ enum PlatformInAppWebViewControllerMethod { /// - On iOS < 12.0, this method is implemented using JavaScript. ///- Web \ but requires same origin: /// - This method is implemented using JavaScript. - ///- Windows WebView2 : + ///- Windows WebView2: /// - This method is implemented using JavaScript. /// ///Use the [PlatformInAppWebViewController.isMethodSupported] method to check if this method is supported at runtime. @@ -890,7 +890,7 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - View.getScrollX](https://developer.android.com/reference/android/view/View#getScrollX())) ///- iOS WKWebView ([Official API - UIScrollView.contentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset)) - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin ([Official API - Window.scrollX](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX)) /// @@ -905,7 +905,7 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - View.getScrollY](https://developer.android.com/reference/android/view/View#getScrollY())) ///- iOS WKWebView ([Official API - UIScrollView.contentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset)) - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin ([Official API - Window.scrollY](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY)) /// @@ -918,11 +918,11 @@ enum PlatformInAppWebViewControllerMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getSelectedText.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - This method is implemented using JavaScript. - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin: /// - This method is implemented using JavaScript. @@ -1353,11 +1353,11 @@ enum PlatformInAppWebViewControllerMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.isSecureContext.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView 21+ : + ///- Android WebView 21+: /// - This method is implemented using JavaScript. - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin ([Official API - Window.isSecureContext](https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext)) /// @@ -1534,9 +1534,9 @@ enum PlatformInAppWebViewControllerMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebView.pauseTimers](https://developer.android.com/reference/android/webkit/WebView#pauseTimers())) - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript and it is restricted to just this WebView. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript and it is restricted to just this WebView. /// ///Use the [PlatformInAppWebViewController.isMethodSupported] method to check if this method is supported at runtime. @@ -1570,9 +1570,9 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebView.postWebMessage](https://developer.android.com/reference/androidx/webkit/WebViewCompat#postWebMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri))): /// - This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.POST_WEB_MESSAGE]. - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. /// ///**Parameters - Officially Supported Platforms/Implementations**: @@ -1685,9 +1685,9 @@ enum PlatformInAppWebViewControllerMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs. ///- Web \ but requires same origin ///- Windows WebView2 @@ -1705,9 +1705,9 @@ enum PlatformInAppWebViewControllerMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs. ///- Web \ but requires same origin ///- Windows WebView2 @@ -1725,9 +1725,9 @@ enum PlatformInAppWebViewControllerMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs. ///- Web \ but requires same origin ///- Windows WebView2 @@ -1764,7 +1764,7 @@ enum PlatformInAppWebViewControllerMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebView.requestFocusNodeHref](https://developer.android.com/reference/android/webkit/WebView#requestFocusNodeHref(android.os.Message))) - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript. /// ///Use the [PlatformInAppWebViewController.isMethodSupported] method to check if this method is supported at runtime. @@ -1777,7 +1777,7 @@ enum PlatformInAppWebViewControllerMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebView.requestImageRef](https://developer.android.com/reference/android/webkit/WebView#requestImageRef(android.os.Message))) - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript. /// ///Use the [PlatformInAppWebViewController.isMethodSupported] method to check if this method is supported at runtime. @@ -1831,9 +1831,9 @@ enum PlatformInAppWebViewControllerMethod { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebView.resumeTimers](https://developer.android.com/reference/android/webkit/WebView#resumeTimers())) - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This method is implemented using JavaScript and it is restricted to just this WebView. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript and it is restricted to just this WebView. /// ///Use the [PlatformInAppWebViewController.isMethodSupported] method to check if this method is supported at runtime. @@ -1861,9 +1861,9 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebView.saveWebArchive](https://developer.android.com/reference/android/webkit/WebView#saveWebArchive(java.lang.String,%20boolean,%20android.webkit.ValueCallback%3Cjava.lang.String%3E))): /// - if [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension. - ///- iOS WKWebView 14.0+ : + ///- iOS WKWebView 14.0+: /// - If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension. - ///- macOS WKWebView 11.0+ : + ///- macOS WKWebView 11.0+: /// - If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension. /// ///**Parameters - Officially Supported Platforms/Implementations**: @@ -1881,7 +1881,7 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - View.scrollBy](https://developer.android.com/reference/android/view/View#scrollBy(int,%20int))) ///- iOS WKWebView ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset)) - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin ([Official API - Window.scrollBy](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy)) /// @@ -1901,7 +1901,7 @@ enum PlatformInAppWebViewControllerMethod { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - View.scrollTo](https://developer.android.com/reference/android/webkit/WebView#scrollTo(int,%20int))) ///- iOS WKWebView ([Official API - UIScrollView.setContentOffset](https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset)) - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This method is implemented using JavaScript. ///- Web \ but requires same origin ([Official API - Window.scrollTo](https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo)) /// @@ -2130,7 +2130,7 @@ enum PlatformInAppWebViewControllerMethod { ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.takeScreenshot.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - To be able to take screenshots outside the visible viewport, you must call [PlatformInAppWebViewController.enableSlowWholeDocumentDraw] before any WebViews are created. ///- iOS WKWebView 11.0+ ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot)) ///- macOS WKWebView 10.13+ ([Official API - WKWebView.takeSnapshot](https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot)) diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.g.dart index b7a7f6af1..58c6d50ac 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.g.dart @@ -333,7 +333,7 @@ enum PlatformWebViewCreationParamsProperty { ///{@template flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.initialUrlRequest.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - When loading an URL Request using "POST" method, headers are ignored. ///- iOS WKWebView ///- macOS WKWebView @@ -350,9 +350,9 @@ enum PlatformWebViewCreationParamsProperty { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This property will be ignored if the [PlatformWebViewCreationParams.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 WebKit APIs. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This property will be ignored if the [PlatformWebViewCreationParams.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 WebKit APIs. ///- Web \ but requires same origin ///- Windows WebView2 @@ -434,7 +434,7 @@ enum PlatformWebViewCreationParamsProperty { ///{@template flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onAjaxProgress.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxProgress] settings documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. In that case, after the `window.addEventListener("flutterInAppWebViewPlatformReady")` event is dispatched, the ajax requests can be intercept for sure. ///- iOS WKWebView ///- macOS WKWebView @@ -451,7 +451,7 @@ enum PlatformWebViewCreationParamsProperty { ///{@template flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onAjaxReadyStateChange.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxReadyStateChange] settings documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. In that case, after the `window.addEventListener("flutterInAppWebViewPlatformReady")` event is dispatched, the ajax requests can be intercept for sure. ///- iOS WKWebView ///- macOS WKWebView @@ -500,9 +500,9 @@ enum PlatformWebViewCreationParamsProperty { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebChromeClient.onConsoleMessage](https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage))) - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This event is implemented using JavaScript. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This event is implemented using JavaScript. ///- Web \ but requires same origin ///- Windows WebView2 @@ -804,11 +804,11 @@ enum PlatformWebViewCreationParamsProperty { ///{@template flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onLoadResource.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - This event is implemented using JavaScript. - ///- iOS WKWebView : + ///- iOS WKWebView: /// - This event is implemented using JavaScript. - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This event is implemented using JavaScript. /// ///**Parameters - Officially Supported Platforms/Implementations**: @@ -976,9 +976,9 @@ enum PlatformWebViewCreationParamsProperty { /// ///**Officially Supported Platforms/Implementations**: ///- Android WebView 21+ ([Official API - WebChromeClient.onPermissionRequest](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest))) - ///- iOS WKWebView 15.0+ : + ///- iOS WKWebView 15.0+: /// - The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT]. - ///- macOS WKWebView 12.0+ : + ///- macOS WKWebView 12.0+: /// - The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT]. ///- Windows WebView2 ([Official API - ICoreWebView2.add_PermissionRequested](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_permissionrequested)) /// @@ -1280,7 +1280,7 @@ enum PlatformWebViewCreationParamsProperty { ///**Officially Supported Platforms/Implementations**: ///- Android WebView ([Official API - WebView.onScrollChanged](https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int))) ///- iOS WKWebView ([Official API - UIScrollViewDelegate.scrollViewDidScroll](https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll)) - ///- macOS WKWebView : + ///- macOS WKWebView: /// - This event is implemented using JavaScript. ///- Web \ but requires same origin ([Official API - Window.onscroll](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onscroll)) /// @@ -1423,7 +1423,7 @@ enum PlatformWebViewCreationParamsProperty { ///{@template flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.pullToRefreshController.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - To be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`. ///- iOS WKWebView /// @@ -1451,7 +1451,7 @@ enum PlatformWebViewCreationParamsProperty { ///{@template flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.shouldInterceptAjaxRequest.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. In that case, after the `window.addEventListener("flutterInAppWebViewPlatformReady")` event is dispatched, the ajax requests can be intercept for sure. ///- iOS WKWebView ///- macOS WKWebView @@ -1468,7 +1468,7 @@ enum PlatformWebViewCreationParamsProperty { ///{@template flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.shouldInterceptFetchRequest.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView : + ///- Android WebView: /// - In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptFetchRequest] setting documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. In that case, after the `window.addEventListener("flutterInAppWebViewPlatformReady")` event is dispatched, the ajax requests can be intercept for sure. ///- iOS WKWebView ///- macOS WKWebView diff --git a/flutter_inappwebview_platform_interface/lib/src/types/cookie.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/cookie.g.dart index 13c92dc96..e1e5c18ec 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/cookie.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/cookie.g.dart @@ -13,7 +13,7 @@ class Cookie { ///**Officially Supported Platforms/Implementations**: ///- iOS WKWebView ///- macOS WKWebView - ///- Android WebView : + ///- Android WebView: /// - available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported. ///- Windows WebView2 String? domain; @@ -23,7 +23,7 @@ class Cookie { ///**Officially Supported Platforms/Implementations**: ///- iOS WKWebView ///- macOS WKWebView - ///- Android WebView : + ///- Android WebView: /// - available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported. ///- Windows WebView2 int? expiresDate; @@ -33,7 +33,7 @@ class Cookie { ///**Officially Supported Platforms/Implementations**: ///- iOS WKWebView ///- macOS WKWebView - ///- Android WebView : + ///- Android WebView: /// - available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported. ///- Windows WebView2 bool? isHttpOnly; @@ -43,7 +43,7 @@ class Cookie { ///**Officially Supported Platforms/Implementations**: ///- iOS WKWebView ///- macOS WKWebView - ///- Android WebView : + ///- Android WebView: /// - available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported. ///- Windows WebView2 bool? isSecure; @@ -71,7 +71,7 @@ class Cookie { ///**Officially Supported Platforms/Implementations**: ///- iOS WKWebView ///- macOS WKWebView - ///- Android WebView : + ///- Android WebView: /// - available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported. ///- Windows WebView2 String? path; @@ -81,7 +81,7 @@ class Cookie { ///**Officially Supported Platforms/Implementations**: ///- iOS WKWebView ///- macOS WKWebView - ///- Android WebView : + ///- Android WebView: /// - available on Android only if [WebViewFeature.GET_COOKIE_INFO] feature is supported. ///- Windows WebView2 HTTPCookieSameSitePolicy? sameSite; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.g.dart b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.g.dart index ddbb26920..6588434a8 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/navigation_action.g.dart @@ -24,7 +24,7 @@ class NavigationAction { ///**Officially Supported Platforms/Implementations**: ///- Android WebView 21+ ([Official API - WebResourceRequest.hasGesture](https://developer.android.com/reference/android/webkit/WebResourceRequest#hasGesture())): /// - On Android < 21, this is always `false` - ///- Windows WebView2 : + ///- Windows WebView2: /// - Available only if the request is associated to the [PlatformWebViewCreationParams.onCreateWindow] event bool? hasGesture; diff --git a/flutter_inappwebview_web/lib/src/in_app_browser/in_app_browser.dart b/flutter_inappwebview_web/lib/src/in_app_browser/in_app_browser.dart deleted file mode 100755 index f14ff81fe..000000000 --- a/flutter_inappwebview_web/lib/src/in_app_browser/in_app_browser.dart +++ /dev/null @@ -1,17 +0,0 @@ -import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; - -///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser} -class WebPlatformInAppBrowser extends PlatformInAppBrowser with ChannelController { - /// Constructs a [WebPlatformInAppBrowser]. - WebPlatformInAppBrowser(PlatformInAppBrowserCreationParams params) - : super.implementation(params) { - } - - static final WebPlatformInAppBrowser _staticValue = - WebPlatformInAppBrowser(PlatformInAppBrowserCreationParams()); - - /// Provide static access. - factory WebPlatformInAppBrowser.static() { - return _staticValue; - } -} \ No newline at end of file diff --git a/flutter_inappwebview_web/lib/src/in_app_browser/main.dart b/flutter_inappwebview_web/lib/src/in_app_browser/main.dart deleted file mode 100644 index e11eb8b18..000000000 --- a/flutter_inappwebview_web/lib/src/in_app_browser/main.dart +++ /dev/null @@ -1 +0,0 @@ -export 'in_app_browser.dart' hide InternalInAppBrowser; diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index 6dd6ac73d..7aaf95314 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -2,7 +2,6 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla import 'cookie_manager.dart'; import 'in_app_webview/main.dart'; -import 'in_app_browser/main.dart'; /// Implementation of [InAppWebViewPlatform] using the Web API. class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { @@ -63,7 +62,6 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { return WebPlatformInAppWebViewWidget.static(); } - /// Creates a new [WebPlatformHeadlessInAppWebView]. /// /// This function should only be called by the app-facing package. @@ -84,12 +82,45 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { return WebPlatformHeadlessInAppWebView.static(); } - /// Creates a new empty [WebPlatformInAppBrowser] to access static methods. + // ************************************************************************ // + // Create static instances of unsupported classes to be able to call // + // isClassSupported, isMethodSupported, isPropertySupported, etc. // + // static methods without throwing a missing platform implementation // + // exception. // + // ************************************************************************ // + + /// Creates a new empty [PlatformInAppBrowser] to access static methods. /// /// This function should only be called by the app-facing package. /// Look at using [InAppBrowser] in `flutter_inappwebview` instead. @override - WebPlatformInAppBrowser createPlatformInAppBrowserStatic() { - return WebPlatformInAppBrowser.static(); + PlatformInAppBrowser createPlatformInAppBrowserStatic() { + return _PlatformInAppBrowser.static(); + } + + /// Creates a new empty [PlatformChromeSafariBrowser] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ChromeSafariBrowser] in `flutter_inappwebview` instead. + PlatformChromeSafariBrowser createPlatformChromeSafariBrowserStatic() { + return _PlatformChromeSafariBrowser.static(); } } + +class _PlatformInAppBrowser extends PlatformInAppBrowser { + _PlatformInAppBrowser(PlatformInAppBrowserCreationParams params) + : super.implementation(params); + static final _PlatformInAppBrowser _staticValue = + _PlatformInAppBrowser(PlatformInAppBrowserCreationParams()); + + factory _PlatformInAppBrowser.static() => _staticValue; +} + +class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { + _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams params) + : super.implementation(params); + static final _PlatformChromeSafariBrowser _staticValue = + _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams()); + + factory _PlatformChromeSafariBrowser.static() => _staticValue; +} \ No newline at end of file diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index a20d71a1a..c5b8e398a 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -2,11 +2,11 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla import 'cookie_manager.dart'; import 'in_app_browser/in_app_browser.dart'; +import 'in_app_webview/headless_in_app_webview.dart'; import 'in_app_webview/in_app_webview.dart'; import 'in_app_webview/in_app_webview_controller.dart'; -import 'in_app_webview/headless_in_app_webview.dart'; -import 'webview_environment/webview_environment.dart'; import 'web_storage/web_storage.dart'; +import 'webview_environment/webview_environment.dart'; /// Implementation of [InAppWebViewPlatform] using the WebKit API. class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { @@ -158,4 +158,28 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { ) { return WindowsSessionStorage(params); } + + // ************************************************************************ // + // Create static instances of unsupported classes to be able to call // + // isClassSupported, isMethodSupported, isPropertySupported, etc. // + // static methods without throwing a missing platform implementation // + // exception. // + // ************************************************************************ // + + /// Creates a new empty [PlatformChromeSafariBrowser] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ChromeSafariBrowser] in `flutter_inappwebview` instead. + PlatformChromeSafariBrowser createPlatformChromeSafariBrowserStatic() { + return _PlatformChromeSafariBrowser.static(); + } +} + +class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { + _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams params) + : super.implementation(params); + static final _PlatformChromeSafariBrowser _staticValue = + _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams()); + + factory _PlatformChromeSafariBrowser.static() => _staticValue; } From 3706e7a222e00ac05412d77b7d1cc6e71200b57d Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 6 Dec 2024 22:26:45 +0100 Subject: [PATCH 142/181] added support methods for CookieManager class --- .../lib/src/cookie_manager.dart | 38 ++ .../lib/src/cookie_manager.dart | 9 +- .../lib/src/inappwebview_platform.dart | 9 + .../lib/src/cookie_manager.dart | 8 + .../lib/src/inappwebview_platform.dart | 9 + .../lib/src/cookie_manager.dart | 8 + .../lib/src/inappwebview_platform.dart | 9 + .../platform_in_app_browser.dart | 17 +- .../platform_in_app_browser.g.dart | 15 + .../lib/src/inappwebview_platform.dart | 9 + .../lib/src/platform_cookie_manager.dart | 412 +++++++++++------- .../lib/src/platform_cookie_manager.g.dart | 371 ++++++++++++++++ .../lib/src/cookie_manager.dart | 8 + .../lib/src/inappwebview_platform.dart | 9 + .../lib/src/cookie_manager.dart | 8 +- .../lib/src/inappwebview_platform.dart | 9 + 16 files changed, 785 insertions(+), 163 deletions(-) create mode 100644 flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.g.dart diff --git a/flutter_inappwebview/lib/src/cookie_manager.dart b/flutter_inappwebview/lib/src/cookie_manager.dart index bebf0f303..9dac3f830 100755 --- a/flutter_inappwebview/lib/src/cookie_manager.dart +++ b/flutter_inappwebview/lib/src/cookie_manager.dart @@ -1,13 +1,18 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; import 'in_app_webview/in_app_webview_controller.dart'; import 'webview_environment/webview_environment.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.supported_platforms} class CookieManager { ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.supported_platforms} CookieManager() : this.fromPlatformCreationParams( const PlatformCookieManagerCreationParams(), @@ -51,6 +56,8 @@ class CookieManager { } ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.setCookie} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.setCookie.supported_platforms} Future setCookie( {required WebUri url, required String name, @@ -80,6 +87,8 @@ class CookieManager { webViewController: webViewController?.platform); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getCookies} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getCookies.supported_platforms} Future> getCookies( {required WebUri url, @Deprecated("Use webViewController instead") @@ -91,6 +100,8 @@ class CookieManager { webViewController: webViewController?.platform); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getCookie} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getCookie.supported_platforms} Future getCookie( {required WebUri url, required String name, @@ -104,6 +115,8 @@ class CookieManager { webViewController: webViewController?.platform); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteCookie} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteCookie.supported_platforms} Future deleteCookie( {required WebUri url, required String name, @@ -121,6 +134,8 @@ class CookieManager { webViewController: webViewController?.platform); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteCookies} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteCookies.supported_platforms} Future deleteCookies( {required WebUri url, String path = "/", @@ -136,16 +151,39 @@ class CookieManager { webViewController: webViewController?.platform); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteAllCookies} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteAllCookies.supported_platforms} Future deleteAllCookies() => platform.deleteAllCookies(); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getAllCookies} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getAllCookies.supported_platforms} Future> getAllCookies() => platform.getAllCookies(); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.removeSessionCookies} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.removeSessionCookies.supported_platforms} Future removeSessionCookies() => platform.removeSessionCookies(); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.flush} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.flush.supported_platforms} Future flush() => platform.flush(); + + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformCookieManager.static().isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isPropertySupported} + static bool isPropertySupported(PlatformCookieManagerCreationParamsProperty property, {TargetPlatform? platform}) => + PlatformCookieManager.static().isPropertySupported(property, platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.isMethodSupported} + static bool isMethodSupported(PlatformCookieManagerMethod method, + {TargetPlatform? platform}) => + PlatformCookieManager.static().isMethodSupported( + method, + platform: platform); } ///Class that contains only iOS-specific methods of [CookieManager]. diff --git a/flutter_inappwebview_android/lib/src/cookie_manager.dart b/flutter_inappwebview_android/lib/src/cookie_manager.dart index 86ae5fe81..4deecb25e 100755 --- a/flutter_inappwebview_android/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_android/lib/src/cookie_manager.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; - import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; /// Object specifying creation parameters for creating a [AndroidCookieManager]. @@ -44,6 +43,14 @@ class AndroidCookieManager extends PlatformCookieManager initMethodCallHandler(); } + static final AndroidCookieManager _staticValue = AndroidCookieManager( + AndroidCookieManagerCreationParams( + PlatformCookieManagerCreationParams())); + + factory AndroidCookieManager.static() { + return _staticValue; + } + static AndroidCookieManager? _instance; ///Gets the [AndroidCookieManager] shared instance. diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index 86d5cd060..854f96e9a 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -35,6 +35,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidCookieManager(params); } + /// Creates a new empty [AndroidCookieManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [CookieManager] in `flutter_inappwebview` instead. + @override + AndroidCookieManager createPlatformCookieManagerStatic() { + return AndroidCookieManager.static(); + } + /// Creates a new [AndroidInAppWebViewController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_ios/lib/src/cookie_manager.dart b/flutter_inappwebview_ios/lib/src/cookie_manager.dart index 2c0eea9cd..53be2ab90 100755 --- a/flutter_inappwebview_ios/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_ios/lib/src/cookie_manager.dart @@ -46,6 +46,14 @@ class IOSCookieManager extends PlatformCookieManager with ChannelController { initMethodCallHandler(); } + static final IOSCookieManager _staticValue = IOSCookieManager( + IOSCookieManagerCreationParams( + PlatformCookieManagerCreationParams())); + + factory IOSCookieManager.static() { + return _staticValue; + } + static IOSCookieManager? _instance; ///Gets the [IOSCookieManager] shared instance. diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index c14808bcd..c6519d63c 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -31,6 +31,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSCookieManager(params); } + /// Creates a new empty [IOSCookieManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [CookieManager] in `flutter_inappwebview` instead. + @override + IOSCookieManager createPlatformCookieManagerStatic() { + return IOSCookieManager.static(); + } + /// Creates a new [IOSInAppWebViewController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_macos/lib/src/cookie_manager.dart b/flutter_inappwebview_macos/lib/src/cookie_manager.dart index 6078cb526..9c019f393 100755 --- a/flutter_inappwebview_macos/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_macos/lib/src/cookie_manager.dart @@ -46,6 +46,14 @@ class MacOSCookieManager extends PlatformCookieManager with ChannelController { initMethodCallHandler(); } + static final MacOSCookieManager _staticValue = MacOSCookieManager( + MacOSCookieManagerCreationParams( + PlatformCookieManagerCreationParams())); + + factory MacOSCookieManager.static() { + return _staticValue; + } + static MacOSCookieManager? _instance; ///Gets the [MacOSCookieManager] shared instance. diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index a611599ed..b10586801 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -29,6 +29,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSCookieManager(params); } + /// Creates a new empty [MacOSCookieManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [CookieManager] in `flutter_inappwebview` instead. + @override + MacOSCookieManager createPlatformCookieManagerStatic() { + return MacOSCookieManager.static(); + } + /// Creates a new [MacOSInAppWebViewController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart index ea09e771d..838404a3f 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart @@ -24,10 +24,12 @@ import 'in_app_browser_settings.dart'; part 'platform_in_app_browser.g.dart'; +///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowserCreationParams} /// Object specifying creation parameters for creating a [PlatformInAppBrowser]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} @immutable class PlatformInAppBrowserCreationParams { /// Used by the platform implementation to create a new [PlatformInAppBrowser]. @@ -69,10 +71,7 @@ class PlatformInAppBrowserCreationParams { ///Used to create the [PlatformInAppBrowser] using the specified environment. ///{@endtemplate} /// - ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserCreationParams.webViewEnvironment.supported_platforms} - @SupportedPlatforms(platforms: [ - WindowsPlatform(), - ]) + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.webViewEnvironment.supported_platforms} final PlatformWebViewEnvironment? webViewEnvironment; } @@ -170,6 +169,14 @@ This is a limitation of the native WebKit APIs."""), ]) int? get windowId => params.windowId; + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserCreationParams.webViewEnvironment} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.webViewEnvironment.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) + PlatformWebViewEnvironment? get webViewEnvironment => params.webViewEnvironment; + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.webViewController} ///WebView Controller that can be used to access the [PlatformInAppWebViewController] API. ///When [onExit] is fired, this will be `null` and cannot be used anymore. @@ -630,7 +637,7 @@ This is a limitation of the native WebKit APIs."""), platform: platform); ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.isMethodSupported} - ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isMethodSupported(PlatformInAppBrowserMethod method, {TargetPlatform? platform}) => diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart index e0f0c78ca..7028adf0d 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart @@ -97,6 +97,17 @@ enum PlatformInAppBrowserProperty { ///{@endtemplate} pullToRefreshController, + ///Can be used to check if the [PlatformInAppBrowser.webViewEnvironment] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.webViewEnvironment.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 + /// + ///Use the [PlatformInAppBrowser.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + webViewEnvironment, + ///Can be used to check if the [PlatformInAppBrowser.windowId] property is supported at runtime. /// ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.windowId.supported_platforms} @@ -144,6 +155,10 @@ extension _PlatformInAppBrowserPropertySupported on PlatformInAppBrowser { return !kIsWeb && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); + case PlatformInAppBrowserProperty.webViewEnvironment: + return !kIsWeb && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserProperty.windowId: return !kIsWeb && [ diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index e9cae86b8..944d5a4b1 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -61,6 +61,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformCookieManager is not implemented on the current platform.'); } + /// Creates a new empty [PlatformCookieManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [CookieManager] in `flutter_inappwebview` instead. + PlatformCookieManager createPlatformCookieManagerStatic() { + throw UnimplementedError( + 'createPlatformCookieManagerStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformInAppWebViewController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart index 018f2ebcf..ec14fe887 100755 --- a/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart @@ -1,47 +1,79 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; +import 'in_app_webview/platform_headless_in_app_webview.dart'; import 'in_app_webview/platform_inappwebview_controller.dart'; +import 'inappwebview_platform.dart'; import 'types/main.dart'; import 'web_uri.dart'; -import 'inappwebview_platform.dart'; -import 'in_app_webview/platform_headless_in_app_webview.dart'; import 'webview_environment/platform_webview_environment.dart'; +part 'platform_cookie_manager.g.dart'; + +///{@template flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams} /// Object specifying creation parameters for creating a [PlatformCookieManager]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform(), +]) @immutable class PlatformCookieManagerCreationParams { /// Used by the platform implementation to create a new [PlatformCookieManager]. const PlatformCookieManagerCreationParams({this.webViewEnvironment}); + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.webViewEnvironment} ///Used to create the [PlatformCookieManager] using the specified environment. + ///{@endtemplate} /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.webViewEnvironment.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform(), + ]) final PlatformWebViewEnvironment? webViewEnvironment; + + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformCookieManagerCreationParamsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported(PlatformCookieManagerCreationParamsProperty property, {TargetPlatform? platform}) => + _PlatformCookieManagerCreationParamsPropertySupported + .isPropertySupported(property, platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager} ///Class that implements a singleton object (shared instance) which manages the cookies used by WebView instances. -///On Android, it is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager). -///On iOS, it is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore). -/// -///**NOTE for iOS below 11.0 and Web platform (LIMITED SUPPORT!)**: in this case, almost all of the methods ([PlatformCookieManager.deleteAllCookies] and [PlatformCookieManager.getAllCookies] are not supported!) -///has been implemented using JavaScript because there is no other way to work with them on iOS below 11.0. -///See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS -///- Web -///- Windows ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(note: 'It is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager).',), + IOSPlatform(note: """It is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore). +On iOS below 11.0, it is implemented using JavaScript. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. + """,), + MacOSPlatform(note: 'It is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore).'), + WebPlatform(note: """It is implemented using JavaScript. +See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. + """,), + WindowsPlatform(), +]) abstract class PlatformCookieManager extends PlatformInterface { /// Creates a new [PlatformCookieManager] factory PlatformCookieManager(PlatformCookieManagerCreationParams params) { @@ -58,6 +90,21 @@ abstract class PlatformCookieManager extends PlatformInterface { return cookieManager; } + /// Creates a new [PlatformCookieManager] to access static methods. + factory PlatformCookieManager.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformCookieManager cookieManagerStatic = + InAppWebViewPlatform.instance!.createPlatformCookieManagerStatic(); + PlatformInterface.verify(cookieManagerStatic, _token); + return cookieManagerStatic; + } + /// Used by the platform implementation to create a new /// [PlatformCookieManager]. /// @@ -77,30 +124,34 @@ abstract class PlatformCookieManager extends PlatformInterface { /// ///The default value of [path] is `"/"`. /// - ///On Windows, the [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, - ///such as cookie with partition key. - /// - ///When you need to target iOS below 11, MacOS below 10.13 and Web platform, - ///[webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) - ///on the current URL of the `WebView` managed by that controller. JavaScript must be enabled in order to work. - /// ///The return value indicates whether the cookie was set successfully. - ///Note that it will return always `true` for Web platform, iOS below 11.0 and MacOS below 10.13. - /// - ///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] - ///to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] - ///to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - CookieManager.setCookie](https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) - ///- iOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie)) - ///- MacOS ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie)) - ///- Web - ///- Windows ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.setCookie.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( apiName: 'CookieManager.setCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)'), + IOSPlatform( apiName: 'WKHTTPCookieStore.setCookie', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie', + note: """On iOS below 11.0, the [webViewController] could be used if you need to set a session-only cookie using JavaScript +(so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) on +the current URL of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). +In this case, this method will return always `true`.""",), + MacOSPlatform( apiName: 'WKHTTPCookieStore.setCookie', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie', + note: """On macOS below 10.13, the [webViewController] could be used if you need to set a session-only cookie using JavaScript +(so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) on +the current URL of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). +In this case, this method will return always `true`.""",), + WebPlatform(note: """The [webViewController] could be used if you need to set a session-only cookie using JavaScript +(so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) on +the current URL of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). +In this case, this method will return always `true`.""",), + WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), + ]) Future setCookie( {required WebUri url, required String name, @@ -114,6 +165,7 @@ abstract class PlatformCookieManager extends PlatformInterface { HTTPCookieSameSitePolicy? sameSite, @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, + @SupportedPlatforms(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) PlatformInAppWebViewController? webViewController}) { throw UnimplementedError( 'setCookie is not implemented on the current platform'); @@ -121,34 +173,40 @@ abstract class PlatformCookieManager extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.getCookies} ///Gets all the cookies for the given [url]. - /// - ///On Windows, the [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, - ///such as cookie with partition key. - /// - ///When you need to target iOS below 11, MacOS below 10.13 and Web platform, - ///[webViewController] is used for getting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) - ///from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. - ///In this case the [url] parameter is ignored. - /// - ///**NOTE for iOS below 11.0 and MacOS below 10.13**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. - ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] - ///to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!). - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] - ///to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!). - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - CookieManager.getCookie](https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String))) - ///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) - ///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) - ///- Web - ///- Windows ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getCookies.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( apiName: 'CookieManager.getCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), + IOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + note: """On iOS below 11.0, the [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript +(cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!).""",), + MacOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + note: """On macOS below 10.13, the [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript +(cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!).""",), + WebPlatform(note: """The [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript +(cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!).""",), + WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), + ]) Future> getCookies( {required WebUri url, @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, + @SupportedPlatforms(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) PlatformInAppWebViewController? webViewController}) { throw UnimplementedError( 'getCookies is not implemented on the current platform'); @@ -156,35 +214,41 @@ abstract class PlatformCookieManager extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.getCookie} ///Gets a cookie by its [name] for the given [url]. - /// - ///On Windows, the [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, - ///such as cookie with partition key. - /// - ///When you need to target iOS below 11, MacOS below 10.13 and Web platform, - ///[webViewController] is used for getting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) - ///from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. - ///In this case the [url] parameter is ignored. - /// - ///**NOTE for iOS below 11.0 and MacOS below 10.13**: All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. - ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] - ///to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!). - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] - ///to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!). - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web - ///- Windows ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getCookie.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( apiName: 'CookieManager.getCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), + IOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + note: """On iOS below 11.0, the [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript +(cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!).""",), + MacOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + note: """On macOS below 10.13, the [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript +(cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!).""",), + WebPlatform(note: """The [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript +(cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!).""",), + WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), + ]) Future getCookie( {required WebUri url, required String name, @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, + @SupportedPlatforms(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) PlatformInAppWebViewController? webViewController}) { throw UnimplementedError( 'getCookie is not implemented on the current platform'); @@ -195,31 +259,37 @@ abstract class PlatformCookieManager extends PlatformInterface { /// ///The default value of [path] is `"/"`. /// - ///On Windows, the [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, - ///such as cookie with partition key. - /// - ///When you need to target iOS below 11, MacOS below 10.13 and Web platform, - ///[webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) - ///from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. - ///In this case the [url] parameter is ignored. - /// ///The return value indicates whether the cookie was deleted successfully. - ///Note that it will return always `true` for Web platform, iOS below 11.0 and MacOS below 10.13. - /// - ///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] - ///to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] - ///to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete) - ///- MacOS ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete) - ///- Web - ///- Windows ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteCookie.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( apiName: 'CookieManager.getCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), + IOSPlatform( apiName: 'WKHTTPCookieStore.delete', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', + note: """On iOS below 11.0, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript +(cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). +In this case, this method will return always `true`.""",), + MacOSPlatform( apiName: 'WKHTTPCookieStore.delete', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', + note: """On macOS below 10.13, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript +(cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). +In this case, this method will return always `true`.""",), + WebPlatform(note: """The [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript +(cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). +In this case, this method will return always `true`.""",), + WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), + ]) Future deleteCookie( {required WebUri url, required String name, @@ -227,6 +297,7 @@ abstract class PlatformCookieManager extends PlatformInterface { String? domain, @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, + @SupportedPlatforms(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) PlatformInAppWebViewController? webViewController}) { throw UnimplementedError( 'deleteCookie is not implemented on the current platform'); @@ -237,37 +308,44 @@ abstract class PlatformCookieManager extends PlatformInterface { /// ///The default value of [path] is `"/"`. /// - ///On Windows, the [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, - ///such as cookie with partition key. - /// - ///When you need to target iOS below 11, MacOS below 10.13 and Web platform, - ///[webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) - ///from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. - ///In this case the [url] parameter is ignored. - /// ///The return value indicates whether cookies were deleted successfully. - ///Note that it will return always `true` for Web platform, iOS below 11.0 and MacOS below 10.13. - /// - ///**NOTE for iOS below 11.0 and MacOS below 10.13**: If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] - ///to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - ///If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] - ///to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web - ///- Windows ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteCookies.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( apiName: 'CookieManager.getCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), + IOSPlatform( apiName: 'WKHTTPCookieStore.delete', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', + note: """On iOS below 11.0, the [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript +(cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). +In this case, this method will return always `true`.""",), + MacOSPlatform( apiName: 'WKHTTPCookieStore.delete', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', + note: """On macOS below 10.13, the [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript +(cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). +In this case, this method will return always `true`.""",), + WebPlatform(note: """The [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript +(cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) +from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. +In this case the [url] parameter is ignored. +If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] +to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). +In this case, this method will return always `true`.""",), + WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), + ]) Future deleteCookies( {required WebUri url, String path = "/", String? domain, @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, + @SupportedPlatforms(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) PlatformInAppWebViewController? webViewController}) { throw UnimplementedError( 'deleteCookies is not implemented on the current platform'); @@ -277,18 +355,19 @@ abstract class PlatformCookieManager extends PlatformInterface { ///Removes all cookies. /// ///The return value indicates whether any cookies were removed. - ///Note that it will return always `true` for Web, iOS and MacOS platforms. - /// - ///**NOTE for iOS**: available from iOS 11.0+. - /// - ///**NOTE for MacOS**: available from iOS 10.13+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - CookieManager.removeAllCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) - ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) - ///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) - ///- Windows ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteAllCookies.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( apiName: 'CookieManager.removeAllCookies', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)'), + IOSPlatform( apiName: 'WKWebsiteDataStore.removeData', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata', + available: '11.0', + note: """It will return always `true`.""",), + MacOSPlatform( apiName: 'WKWebsiteDataStore.removeData', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata', + available: '10.13', + note: """It will return always `true`.""",), + WindowsPlatform(), + ]) Future deleteAllCookies() { throw UnimplementedError( 'deleteAllCookies is not implemented on the current platform'); @@ -296,15 +375,15 @@ abstract class PlatformCookieManager extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.getAllCookies} ///Fetches all stored cookies. - /// - ///**NOTE for iOS**: available on iOS 11.0+. - /// - ///**NOTE for MacOS**: available from iOS 10.13+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) - ///- MacOS ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getAllCookies.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + available: '11.0',), + MacOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + available: '10.13',), + ]) Future> getAllCookies() { throw UnimplementedError( 'getAllCookies is not implemented on the current platform'); @@ -314,10 +393,12 @@ abstract class PlatformCookieManager extends PlatformInterface { ///Removes all session cookies, which are cookies without an expiration date. /// ///The return value indicates whether any cookies were removed. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - CookieManager.removeSessionCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeSessionCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.removeSessionCookies.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( apiName: 'CookieManager.removeSessionCookies', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#removeSessionCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)',), + ]) Future removeSessionCookies() { throw UnimplementedError( 'removeSessionCookies is not implemented on the current platform'); @@ -326,12 +407,31 @@ abstract class PlatformCookieManager extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.flush} ///Ensures all cookies currently accessible through the getCookie API are written to persistent storage. ///This call will block the caller until it is done and may perform I/O. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - CookieManager.flush](https://developer.android.com/reference/android/webkit/CookieManager#flush())) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.flush.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( apiName: 'CookieManager.flush', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#flush()',), + ]) Future flush() { throw UnimplementedError( 'flush is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + params.isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isPropertySupported} + bool isPropertySupported(PlatformCookieManagerCreationParamsProperty property, {TargetPlatform? platform}) => + params.isPropertySupported(property, platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformCookieManagerMethod method, + {TargetPlatform? platform}) => + _PlatformCookieManagerMethodSupported.isMethodSupported( + method, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.g.dart new file mode 100644 index 000000000..f1930a6e4 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.g.dart @@ -0,0 +1,371 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_cookie_manager.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformCookieManagerCreationParamsClassSupported + on PlatformCookieManagerCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformCookieManagerCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return kIsWeb + ? true + : !kIsWeb && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformCookieManagerCreationParams]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformCookieManagerCreationParamsProperty { + ///Can be used to check if the [PlatformCookieManagerCreationParams.webViewEnvironment] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.webViewEnvironment.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 + /// + ///Use the [PlatformCookieManagerCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + webViewEnvironment, +} + +extension _PlatformCookieManagerCreationParamsPropertySupported + on PlatformCookieManagerCreationParams { + static bool isPropertySupported( + PlatformCookieManagerCreationParamsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformCookieManagerCreationParamsProperty.webViewEnvironment: + return !kIsWeb && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformCookieManagerClassSupported on PlatformCookieManager { + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView: + /// - It is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager). + ///- iOS WKWebView: + /// - It is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore). On iOS below 11.0, it is implemented using JavaScript. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. + ///- macOS WKWebView: + /// - It is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore). + ///- Web \ but requires same origin: + /// - It is implemented using JavaScript. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. + ///- Windows WebView2 + /// + ///Use the [PlatformCookieManager.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return kIsWeb + ? true + : !kIsWeb && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformCookieManager]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformCookieManagerMethod { + ///Can be used to check if the [PlatformCookieManager.deleteAllCookies] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.deleteAllCookies.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CookieManager.removeAllCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + ///- iOS WKWebView 11.0+ ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)): + /// - It will return always `true`. + ///- macOS WKWebView 10.13+ ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)): + /// - It will return always `true`. + ///- Windows WebView2 + /// + ///Use the [PlatformCookieManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + deleteAllCookies, + + ///Can be used to check if the [PlatformCookieManager.deleteCookie] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.deleteCookie.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CookieManager.getCookie](https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String))) + ///- iOS WKWebView ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)): + /// - On iOS below 11.0, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). In this case, this method will return always `true`. + ///- macOS WKWebView ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)): + /// - On macOS below 10.13, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). In this case, this method will return always `true`. + ///- Web \ but requires same origin: + /// - The [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). In this case, this method will return always `true`. + ///- Windows WebView2: + /// - The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key. + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + ///- [name]: all platforms + ///- [path]: all platforms + ///- [domain]: all platforms + ///- [webViewController]: + /// - macOS WKWebView + /// - iOS WKWebView + /// - Web \ but requires same origin + /// - Windows WebView2 + /// + ///Use the [PlatformCookieManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + deleteCookie, + + ///Can be used to check if the [PlatformCookieManager.deleteCookies] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.deleteCookies.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CookieManager.getCookie](https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String))) + ///- iOS WKWebView ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)): + /// - On iOS below 11.0, the [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). In this case, this method will return always `true`. + ///- macOS WKWebView ([Official API - WKHTTPCookieStore.delete](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete)): + /// - On macOS below 10.13, the [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). In this case, this method will return always `true`. + ///- Web \ but requires same origin: + /// - The [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). In this case, this method will return always `true`. + ///- Windows WebView2: + /// - The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key. + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + ///- [path]: all platforms + ///- [domain]: all platforms + ///- [webViewController]: + /// - macOS WKWebView + /// - iOS WKWebView + /// - Web \ but requires same origin + /// - Windows WebView2 + /// + ///Use the [PlatformCookieManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + deleteCookies, + + ///Can be used to check if the [PlatformCookieManager.flush] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.flush.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CookieManager.flush](https://developer.android.com/reference/android/webkit/CookieManager#flush())) + /// + ///Use the [PlatformCookieManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + flush, + + ///Can be used to check if the [PlatformCookieManager.getAllCookies] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.getAllCookies.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 11.0+ ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) + ///- macOS WKWebView 10.13+ ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)) + /// + ///Use the [PlatformCookieManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getAllCookies, + + ///Can be used to check if the [PlatformCookieManager.getCookie] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.getCookie.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CookieManager.getCookie](https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String))) + ///- iOS WKWebView ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)): + /// - On iOS below 11.0, the [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!). + ///- macOS WKWebView ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)): + /// - On macOS below 10.13, the [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!). + ///- Web \ but requires same origin: + /// - The [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!). + ///- Windows WebView2: + /// - The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key. + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + ///- [name]: all platforms + ///- [webViewController]: + /// - macOS WKWebView + /// - iOS WKWebView + /// - Web \ but requires same origin + /// - Windows WebView2 + /// + ///Use the [PlatformCookieManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getCookie, + + ///Can be used to check if the [PlatformCookieManager.getCookies] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.getCookies.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CookieManager.getCookie](https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String))) + ///- iOS WKWebView ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)): + /// - On iOS below 11.0, the [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!). + ///- macOS WKWebView ([Official API - WKHTTPCookieStore.getAllCookies](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies)): + /// - On macOS below 10.13, the [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!). + ///- Web \ but requires same origin: + /// - The [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!). + ///- Windows WebView2: + /// - The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key. + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + ///- [webViewController]: + /// - macOS WKWebView + /// - iOS WKWebView + /// - Web \ but requires same origin + /// - Windows WebView2 + /// + ///Use the [PlatformCookieManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getCookies, + + ///Can be used to check if the [PlatformCookieManager.removeSessionCookies] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.removeSessionCookies.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CookieManager.removeSessionCookies](https://developer.android.com/reference/android/webkit/CookieManager#removeSessionCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + /// + ///Use the [PlatformCookieManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + removeSessionCookies, + + ///Can be used to check if the [PlatformCookieManager.setCookie] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.setCookie.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - CookieManager.setCookie](https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E))) + ///- iOS WKWebView ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie)): + /// - On iOS below 11.0, the [webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) on the current URL of the `WebView` managed by that controller. JavaScript must be enabled in order to work. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). In this case, this method will return always `true`. + ///- macOS WKWebView ([Official API - WKHTTPCookieStore.setCookie](https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie)): + /// - On macOS below 10.13, the [webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) on the current URL of the `WebView` managed by that controller. JavaScript must be enabled in order to work. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). In this case, this method will return always `true`. + ///- Web \ but requires same origin: + /// - The [webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) on the current URL of the `WebView` managed by that controller. JavaScript must be enabled in order to work. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). In this case, this method will return always `true`. + ///- Windows WebView2: + /// - The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key. + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + ///- [name]: all platforms + ///- [value]: all platforms + ///- [path]: all platforms + ///- [domain]: all platforms + ///- [expiresDate]: all platforms + ///- [maxAge]: all platforms + ///- [isSecure]: all platforms + ///- [isHttpOnly]: all platforms + ///- [sameSite]: all platforms + ///- [webViewController]: + /// - macOS WKWebView + /// - iOS WKWebView + /// - Web \ but requires same origin + /// - Windows WebView2 + /// + ///Use the [PlatformCookieManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setCookie, +} + +extension _PlatformCookieManagerMethodSupported on PlatformCookieManager { + static bool isMethodSupported(PlatformCookieManagerMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformCookieManagerMethod.deleteAllCookies: + return !kIsWeb && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformCookieManagerMethod.deleteCookie: + return kIsWeb + ? true + : !kIsWeb && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformCookieManagerMethod.deleteCookies: + return kIsWeb + ? true + : !kIsWeb && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformCookieManagerMethod.flush: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformCookieManagerMethod.getAllCookies: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformCookieManagerMethod.getCookie: + return kIsWeb + ? true + : !kIsWeb && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformCookieManagerMethod.getCookies: + return kIsWeb + ? true + : !kIsWeb && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformCookieManagerMethod.removeSessionCookies: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformCookieManagerMethod.setCookie: + return kIsWeb + ? true + : !kIsWeb && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/cookie_manager.dart b/flutter_inappwebview_web/lib/src/cookie_manager.dart index a173b471e..ff06f81be 100755 --- a/flutter_inappwebview_web/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_web/lib/src/cookie_manager.dart @@ -47,6 +47,14 @@ class WebPlatformCookieManager extends PlatformCookieManager initMethodCallHandler(); } + static final WebPlatformCookieManager _staticValue = WebPlatformCookieManager( + WebPlatformCookieManagerCreationParams( + PlatformCookieManagerCreationParams())); + + factory WebPlatformCookieManager.static() { + return _staticValue; + } + static WebPlatformCookieManager? _instance; ///Gets the [WebPlatformCookieManager] shared instance. diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index 7aaf95314..76cc274a2 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -21,6 +21,15 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { return WebPlatformCookieManager(params); } + /// Creates a new empty [WebPlatformCookieManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [CookieManager] in `flutter_inappwebview` instead. + @override + WebPlatformCookieManager createPlatformCookieManagerStatic() { + return WebPlatformCookieManager.static(); + } + /// Creates a new [WebPlatformInAppWebViewController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_windows/lib/src/cookie_manager.dart b/flutter_inappwebview_windows/lib/src/cookie_manager.dart index f77c3bf49..cf47c3561 100644 --- a/flutter_inappwebview_windows/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_windows/lib/src/cookie_manager.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; - import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; import 'webview_environment/webview_environment.dart'; @@ -49,6 +48,13 @@ class WindowsCookieManager extends PlatformCookieManager initMethodCallHandler(); } + static final WindowsCookieManager _staticValue = + WindowsCookieManager(WindowsCookieManagerCreationParams()); + + factory WindowsCookieManager.static() { + return _staticValue; + } + static WindowsCookieManager? _instance; ///Gets the [WindowsCookieManager] shared instance. diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index c5b8e398a..f640a49f1 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -26,6 +26,15 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { return WindowsCookieManager(params); } + /// Creates a new empty [WindowsCookieManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [CookieManager] in `flutter_inappwebview` instead. + @override + WindowsCookieManager createPlatformCookieManagerStatic() { + return WindowsCookieManager.static(); + } + /// Creates a new [WindowsInAppWebViewController]. /// /// This function should only be called by the app-facing package. From 8ea3cdc7e11dfe96bf50bdd8b58a2206b122e8bd Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 9 Dec 2024 11:39:09 +0100 Subject: [PATCH 143/181] added support methods for HttpAuthCredentialDatabase class --- .../src/supported_platforms_generator.dart | 2 +- .../src/http_auth_credentials_database.dart | 13 ++ .../src/http_auth_credentials_database.dart | 10 + .../lib/src/inappwebview_platform.dart | 9 + .../src/http_auth_credentials_database.dart | 10 + .../lib/src/inappwebview_platform.dart | 9 + .../src/http_auth_credentials_database.dart | 10 + .../lib/src/inappwebview_platform.dart | 13 +- .../lib/src/inappwebview_platform.dart | 9 + ...atform_http_auth_credentials_database.dart | 135 ++++++++++---- ...form_http_auth_credentials_database.g.dart | 174 ++++++++++++++++++ .../lib/src/inappwebview_platform.dart | 28 ++- .../lib/src/inappwebview_platform.dart | 24 ++- 13 files changed, 401 insertions(+), 45 deletions(-) create mode 100644 flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.g.dart diff --git a/dev_packages/generators/lib/src/supported_platforms_generator.dart b/dev_packages/generators/lib/src/supported_platforms_generator.dart index 58726f261..c6d8cd81d 100644 --- a/dev_packages/generators/lib/src/supported_platforms_generator.dart +++ b/dev_packages/generators/lib/src/supported_platforms_generator.dart @@ -71,7 +71,7 @@ class SupportedPlatformsGenerator }).toList(); methodEntriesSorted.sort((a, b) => a.key.compareTo(b.key)); - if (fieldEntriesSorted.isEmpty && methodEntriesSorted.isEmpty) { + if (!hasClassSupportedFunction && fieldEntriesSorted.isEmpty && methodEntriesSorted.isEmpty) { return ''; } diff --git a/flutter_inappwebview/lib/src/http_auth_credentials_database.dart b/flutter_inappwebview/lib/src/http_auth_credentials_database.dart index a221382ad..aba5c52f8 100755 --- a/flutter_inappwebview/lib/src/http_auth_credentials_database.dart +++ b/flutter_inappwebview/lib/src/http_auth_credentials_database.dart @@ -1,4 +1,6 @@ import 'dart:async'; + +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase} @@ -62,4 +64,15 @@ class HttpAuthCredentialDatabase { ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.clearAllAuthCredentials} Future clearAllAuthCredentials() => platform.clearAllAuthCredentials(); + + ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabaseCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformHttpAuthCredentialDatabase.static() + .isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.isMethodSupported} + static bool isMethodSupported(PlatformHttpAuthCredentialDatabaseMethod method, + {TargetPlatform? platform}) => + PlatformHttpAuthCredentialDatabase.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart b/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart index 06ec37ac9..f96553b83 100755 --- a/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart +++ b/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart @@ -57,6 +57,16 @@ class AndroidHttpAuthCredentialDatabase return _instance!; } + static final AndroidHttpAuthCredentialDatabase _staticValue = + AndroidHttpAuthCredentialDatabase( + AndroidHttpAuthCredentialDatabaseCreationParams( + const PlatformHttpAuthCredentialDatabaseCreationParams() + )); + + factory AndroidHttpAuthCredentialDatabase.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async {} @override diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index 854f96e9a..04ba7f2e1 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -234,6 +234,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidHttpAuthCredentialDatabase(params); } + /// Creates a new empty [AndroidHttpAuthCredentialDatabase] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. + @override + AndroidHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { + return AndroidHttpAuthCredentialDatabase.static(); + } + /// Creates a new [AndroidInAppBrowser]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_ios/lib/src/http_auth_credentials_database.dart b/flutter_inappwebview_ios/lib/src/http_auth_credentials_database.dart index cc2dc8dfd..cef274dfa 100755 --- a/flutter_inappwebview_ios/lib/src/http_auth_credentials_database.dart +++ b/flutter_inappwebview_ios/lib/src/http_auth_credentials_database.dart @@ -57,6 +57,16 @@ class IOSHttpAuthCredentialDatabase extends PlatformHttpAuthCredentialDatabase return _instance!; } + static final IOSHttpAuthCredentialDatabase _staticValue = + IOSHttpAuthCredentialDatabase( + IOSHttpAuthCredentialDatabaseCreationParams( + const PlatformHttpAuthCredentialDatabaseCreationParams() + )); + + factory IOSHttpAuthCredentialDatabase.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async {} @override diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index c6519d63c..57241b0fb 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -230,6 +230,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSHttpAuthCredentialDatabase(params); } + /// Creates a new empty [IOSHttpAuthCredentialDatabase] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. + @override + IOSHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { + return IOSHttpAuthCredentialDatabase.static(); + } + /// Creates a new [IOSInAppBrowser]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_macos/lib/src/http_auth_credentials_database.dart b/flutter_inappwebview_macos/lib/src/http_auth_credentials_database.dart index 28c9126fd..4bc4f5d51 100755 --- a/flutter_inappwebview_macos/lib/src/http_auth_credentials_database.dart +++ b/flutter_inappwebview_macos/lib/src/http_auth_credentials_database.dart @@ -57,6 +57,16 @@ class MacOSHttpAuthCredentialDatabase extends PlatformHttpAuthCredentialDatabase return _instance!; } + static final MacOSHttpAuthCredentialDatabase _staticValue = + MacOSHttpAuthCredentialDatabase( + MacOSHttpAuthCredentialDatabaseCreationParams( + const PlatformHttpAuthCredentialDatabaseCreationParams() + )); + + factory MacOSHttpAuthCredentialDatabase.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async {} @override diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index b10586801..91c8d468c 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -217,6 +217,16 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSHttpAuthCredentialDatabase(params); } + /// Creates a new empty [MacOSHttpAuthCredentialDatabase] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. + @override + MacOSHttpAuthCredentialDatabase + createPlatformHttpAuthCredentialDatabaseStatic() { + return MacOSHttpAuthCredentialDatabase.static(); + } + /// Creates a new [MacOSInAppBrowser]. /// /// This function should only be called by the app-facing package. @@ -292,7 +302,8 @@ class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams params) : super.implementation(params); static final _PlatformChromeSafariBrowser _staticValue = - _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams()); + _PlatformChromeSafariBrowser( + const PlatformChromeSafariBrowserCreationParams()); factory _PlatformChromeSafariBrowser.static() => _staticValue; } diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index 944d5a4b1..f11ebfa41 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -292,6 +292,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformHttpAuthCredentialDatabase is not implemented on the current platform.'); } + /// Creates a new empty [PlatformHttpAuthCredentialDatabase] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. + PlatformHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { + throw UnimplementedError( + 'createPlatformHttpAuthCredentialDatabaseStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformInAppBrowser]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart index 5f2da4ee1..12d27ee01 100755 --- a/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart @@ -1,32 +1,49 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'inappwebview_platform.dart'; import 'types/main.dart'; +part 'platform_http_auth_credentials_database.g.dart'; + +///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabaseCreationParams} /// Object specifying creation parameters for creating a [PlatformHttpAuthCredentialDatabase]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabaseCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), +]) @immutable class PlatformHttpAuthCredentialDatabaseCreationParams { /// Used by the platform implementation to create a new [PlatformHttpAuthCredentialDatabase]. const PlatformHttpAuthCredentialDatabaseCreationParams(); + + ///{@template flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformHttpAuthCredentialDatabaseCreationParamsClassSupported.isClassSupported( + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase} ///Class that implements a singleton object (shared instance) which manages the shared HTTP auth credentials cache. -///On iOS and MacOS, this class uses the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class. -///On Android, this class has a custom implementation using `android.database.sqlite.SQLiteDatabase` because -///[WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase) -///doesn't offer the same functionalities as iOS `URLCredentialStorage`. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(note: 'It has a custom implementation using `android.database.sqlite.SQLiteDatabase` because [WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase) doesn\'t offer the same functionalities as iOS/macOS `URLCredentialStorage`.'), + IOSPlatform(note: 'It is implemented using the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.'), + MacOSPlatform(note: 'It is implemented using the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.'), +]) abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { /// Creates a new [PlatformHttpAuthCredentialDatabase] factory PlatformHttpAuthCredentialDatabase( @@ -45,6 +62,21 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { return cookieManager; } + /// Creates a new [PlatformHttpAuthCredentialDatabase] to access static methods. + factory PlatformHttpAuthCredentialDatabase.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformHttpAuthCredentialDatabase httpAuthCredentialDatabaseStatic = + InAppWebViewPlatform.instance!.createPlatformHttpAuthCredentialDatabaseStatic(); + PlatformInterface.verify(httpAuthCredentialDatabaseStatic, _token); + return httpAuthCredentialDatabaseStatic; + } + /// Used by the platform implementation to create a new /// [PlatformHttpAuthCredentialDatabase]. /// @@ -63,12 +95,14 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { ///Gets a map list of all HTTP auth credentials saved. ///Each map contains the key `protectionSpace` of type [URLProtectionSpace] ///and the key `credentials` of type List<[URLCredential]> that contains all the HTTP auth credentials saved for that `protectionSpace`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - URLCredentialStorage.allCredentials](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials)) - ///- MacOS ([Official API - URLCredentialStorage.allCredentials](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.getAllAuthCredentials.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(apiName: 'URLCredentialStorage.allCredentials', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials',), + MacOSPlatform(apiName: 'URLCredentialStorage.allCredentials', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials',), + ]) Future> getAllAuthCredentials() { throw UnimplementedError( 'getAllAuthCredentials is not implemented on the current platform'); @@ -76,12 +110,14 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.getHttpAuthCredentials} ///Gets all the HTTP auth credentials saved for that [protectionSpace]. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.getHttpAuthCredentials.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) Future> getHttpAuthCredentials( {required URLProtectionSpace protectionSpace}) { throw UnimplementedError( @@ -90,12 +126,14 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.setHttpAuthCredential} ///Saves an HTTP auth [credential] for that [protectionSpace]. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - URLCredentialStorage.set](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set)) - ///- MacOS ([Official API - URLCredentialStorage.set](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.setHttpAuthCredential.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(apiName: 'URLCredentialStorage.set', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set',), + MacOSPlatform(apiName: 'URLCredentialStorage.set', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set',), + ]) Future setHttpAuthCredential( {required URLProtectionSpace protectionSpace, required URLCredential credential}) { @@ -105,12 +143,14 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.removeHttpAuthCredential} ///Removes an HTTP auth [credential] for that [protectionSpace]. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - URLCredentialStorage.remove](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove)) - ///- MacOS ([Official API - URLCredentialStorage.remove](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.removeHttpAuthCredential.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(apiName: 'URLCredentialStorage.remove', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove',), + MacOSPlatform(apiName: 'URLCredentialStorage.remove', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove',), + ]) Future removeHttpAuthCredential( {required URLProtectionSpace protectionSpace, required URLCredential credential}) { @@ -120,12 +160,14 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.removeHttpAuthCredentials} ///Removes all the HTTP auth credentials saved for that [protectionSpace]. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.removeHttpAuthCredentials.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) Future removeHttpAuthCredentials( {required URLProtectionSpace protectionSpace}) { throw UnimplementedError( @@ -134,14 +176,29 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.clearAllAuthCredentials} ///Removes all the HTTP auth credentials saved in the database. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.clearAllAuthCredentials.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) Future clearAllAuthCredentials() { throw UnimplementedError( 'clearAllAuthCredentials is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabaseCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + params.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformHttpAuthCredentialDatabaseMethod method, + {TargetPlatform? platform}) => + _PlatformHttpAuthCredentialDatabaseMethodSupported.isMethodSupported( + method, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.g.dart new file mode 100644 index 000000000..7d81a8e5e --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.g.dart @@ -0,0 +1,174 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_http_auth_credentials_database.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformHttpAuthCredentialDatabaseCreationParamsClassSupported + on PlatformHttpAuthCredentialDatabaseCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabaseCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformHttpAuthCredentialDatabaseCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +extension _PlatformHttpAuthCredentialDatabaseClassSupported + on PlatformHttpAuthCredentialDatabase { + ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView: + /// - It has a custom implementation using `android.database.sqlite.SQLiteDatabase` because [WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase) doesn't offer the same functionalities as iOS/macOS `URLCredentialStorage`. + ///- iOS WKWebView: + /// - It is implemented using the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class. + ///- macOS WKWebView: + /// - It is implemented using the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class. + /// + ///Use the [PlatformHttpAuthCredentialDatabase.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformHttpAuthCredentialDatabase]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformHttpAuthCredentialDatabaseMethod { + ///Can be used to check if the [PlatformHttpAuthCredentialDatabase.clearAllAuthCredentials] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.clearAllAuthCredentials.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformHttpAuthCredentialDatabase.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + clearAllAuthCredentials, + + ///Can be used to check if the [PlatformHttpAuthCredentialDatabase.getAllAuthCredentials] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.getAllAuthCredentials.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView ([Official API - URLCredentialStorage.allCredentials](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials)) + ///- macOS WKWebView ([Official API - URLCredentialStorage.allCredentials](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials)) + /// + ///Use the [PlatformHttpAuthCredentialDatabase.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getAllAuthCredentials, + + ///Can be used to check if the [PlatformHttpAuthCredentialDatabase.getHttpAuthCredentials] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.getHttpAuthCredentials.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [protectionSpace]: all platforms + /// + ///Use the [PlatformHttpAuthCredentialDatabase.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getHttpAuthCredentials, + + ///Can be used to check if the [PlatformHttpAuthCredentialDatabase.removeHttpAuthCredential] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.removeHttpAuthCredential.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView ([Official API - URLCredentialStorage.remove](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove)) + ///- macOS WKWebView ([Official API - URLCredentialStorage.remove](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [protectionSpace]: all platforms + ///- [credential]: all platforms + /// + ///Use the [PlatformHttpAuthCredentialDatabase.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + removeHttpAuthCredential, + + ///Can be used to check if the [PlatformHttpAuthCredentialDatabase.removeHttpAuthCredentials] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.removeHttpAuthCredentials.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [protectionSpace]: all platforms + /// + ///Use the [PlatformHttpAuthCredentialDatabase.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + removeHttpAuthCredentials, + + ///Can be used to check if the [PlatformHttpAuthCredentialDatabase.setHttpAuthCredential] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.setHttpAuthCredential.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView ([Official API - URLCredentialStorage.set](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set)) + ///- macOS WKWebView ([Official API - URLCredentialStorage.set](https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [protectionSpace]: all platforms + ///- [credential]: all platforms + /// + ///Use the [PlatformHttpAuthCredentialDatabase.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setHttpAuthCredential, +} + +extension _PlatformHttpAuthCredentialDatabaseMethodSupported + on PlatformHttpAuthCredentialDatabase { + static bool isMethodSupported(PlatformHttpAuthCredentialDatabaseMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformHttpAuthCredentialDatabaseMethod.clearAllAuthCredentials: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformHttpAuthCredentialDatabaseMethod.getAllAuthCredentials: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformHttpAuthCredentialDatabaseMethod.getHttpAuthCredentials: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformHttpAuthCredentialDatabaseMethod.removeHttpAuthCredential: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformHttpAuthCredentialDatabaseMethod.removeHttpAuthCredentials: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformHttpAuthCredentialDatabaseMethod.setHttpAuthCredential: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index 76cc274a2..f2f82cd3a 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -114,13 +114,22 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { PlatformChromeSafariBrowser createPlatformChromeSafariBrowserStatic() { return _PlatformChromeSafariBrowser.static(); } + + /// Creates a new empty [PlatformHttpAuthCredentialDatabase] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. + @override + PlatformHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { + return _PlatformHttpAuthCredentialDatabase.static(); + } } class _PlatformInAppBrowser extends PlatformInAppBrowser { _PlatformInAppBrowser(PlatformInAppBrowserCreationParams params) : super.implementation(params); static final _PlatformInAppBrowser _staticValue = - _PlatformInAppBrowser(PlatformInAppBrowserCreationParams()); + _PlatformInAppBrowser(const PlatformInAppBrowserCreationParams()); factory _PlatformInAppBrowser.static() => _staticValue; } @@ -129,7 +138,20 @@ class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams params) : super.implementation(params); static final _PlatformChromeSafariBrowser _staticValue = - _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams()); + _PlatformChromeSafariBrowser( + const PlatformChromeSafariBrowserCreationParams()); factory _PlatformChromeSafariBrowser.static() => _staticValue; -} \ No newline at end of file +} + +class _PlatformHttpAuthCredentialDatabase + extends PlatformHttpAuthCredentialDatabase { + _PlatformHttpAuthCredentialDatabase( + PlatformHttpAuthCredentialDatabaseCreationParams params) + : super.implementation(params); + static final _PlatformHttpAuthCredentialDatabase _staticValue = + _PlatformHttpAuthCredentialDatabase( + const PlatformHttpAuthCredentialDatabaseCreationParams()); + + factory _PlatformHttpAuthCredentialDatabase.static() => _staticValue; +} diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index f640a49f1..b798e9e81 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -182,13 +182,35 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { PlatformChromeSafariBrowser createPlatformChromeSafariBrowserStatic() { return _PlatformChromeSafariBrowser.static(); } + + /// Creates a new empty [PlatformHttpAuthCredentialDatabase] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. + @override + PlatformHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { + return _PlatformHttpAuthCredentialDatabase.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams params) : super.implementation(params); static final _PlatformChromeSafariBrowser _staticValue = - _PlatformChromeSafariBrowser(PlatformChromeSafariBrowserCreationParams()); + _PlatformChromeSafariBrowser( + const PlatformChromeSafariBrowserCreationParams()); factory _PlatformChromeSafariBrowser.static() => _staticValue; } + +class _PlatformHttpAuthCredentialDatabase + extends PlatformHttpAuthCredentialDatabase { + _PlatformHttpAuthCredentialDatabase( + PlatformHttpAuthCredentialDatabaseCreationParams params) + : super.implementation(params); + static final _PlatformHttpAuthCredentialDatabase _staticValue = + _PlatformHttpAuthCredentialDatabase( + const PlatformHttpAuthCredentialDatabaseCreationParams()); + + factory _PlatformHttpAuthCredentialDatabase.static() => _staticValue; +} From 9581f000756f63e0b9151c7639ed48b587da83bc Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 9 Dec 2024 12:18:44 +0100 Subject: [PATCH 144/181] added support methods for ProcessGlobalConfig class --- .../lib/src/process_global_config.dart | 12 ++ .../lib/src/inappwebview_platform.dart | 9 + .../lib/src/process_global_config.dart | 10 ++ .../lib/src/inappwebview_platform.dart | 38 ++++- .../lib/src/inappwebview_platform.dart | 23 +++ .../lib/src/inappwebview_platform.dart | 9 + ...atform_http_auth_credentials_database.dart | 2 +- .../src/platform_process_global_config.dart | 109 ++++++++++-- .../src/platform_process_global_config.g.dart | 161 +++++++++++++++++- .../lib/src/inappwebview_platform.dart | 19 +++ .../lib/src/inappwebview_platform.dart | 19 +++ 11 files changed, 391 insertions(+), 20 deletions(-) diff --git a/flutter_inappwebview/lib/src/process_global_config.dart b/flutter_inappwebview/lib/src/process_global_config.dart index cd5442ac0..17767a1f5 100644 --- a/flutter_inappwebview/lib/src/process_global_config.dart +++ b/flutter_inappwebview/lib/src/process_global_config.dart @@ -1,4 +1,5 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig} @@ -35,4 +36,15 @@ class ProcessGlobalConfig { ///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig.apply} Future apply({required ProcessGlobalConfigSettings settings}) => platform.apply(settings: settings); + + ///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfigCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformProcessGlobalConfig.static() + .isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig.isMethodSupported} + static bool isMethodSupported(PlatformProcessGlobalConfigMethod method, + {TargetPlatform? platform}) => + PlatformProcessGlobalConfig.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index 04ba7f2e1..a5c724708 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -274,6 +274,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidProcessGlobalConfig(params); } + /// Creates a new empty [AndroidProcessGlobalConfig] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProcessGlobalConfig] in `flutter_inappwebview` instead. + @override + AndroidProcessGlobalConfig createPlatformProcessGlobalConfigStatic() { + return AndroidProcessGlobalConfig.static(); + } + /// Creates a new [AndroidProxyController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_android/lib/src/process_global_config.dart b/flutter_inappwebview_android/lib/src/process_global_config.dart index 1f4d6fe07..49cba80bb 100644 --- a/flutter_inappwebview_android/lib/src/process_global_config.dart +++ b/flutter_inappwebview_android/lib/src/process_global_config.dart @@ -1,4 +1,5 @@ import 'dart:async'; + import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; @@ -56,6 +57,15 @@ class AndroidProcessGlobalConfig extends PlatformProcessGlobalConfig return _instance!; } + static final AndroidProcessGlobalConfig _staticValue = + AndroidProcessGlobalConfig(AndroidProcessGlobalConfigCreationParams( + const PlatformProcessGlobalConfigCreationParams())); + + /// Provide static access. + factory AndroidProcessGlobalConfig.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async {} @override diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index 57241b0fb..16e2629b9 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -2,16 +2,16 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla import 'chrome_safari_browser/chrome_safari_browser.dart'; import 'cookie_manager.dart'; -import 'http_auth_credentials_database.dart'; import 'find_interaction/main.dart'; +import 'http_auth_credentials_database.dart'; import 'in_app_browser/in_app_browser.dart'; import 'in_app_webview/main.dart'; import 'print_job/main.dart'; +import 'proxy_controller.dart'; import 'pull_to_refresh/main.dart'; +import 'web_authentication_session/main.dart'; import 'web_message/main.dart'; import 'web_storage/main.dart'; -import 'web_authentication_session/main.dart'; -import 'proxy_controller.dart'; /// Implementation of [InAppWebViewPlatform] using the WebKit API. class IOSInAppWebViewPlatform extends InAppWebViewPlatform { @@ -235,7 +235,8 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. @override - IOSHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { + IOSHttpAuthCredentialDatabase + createPlatformHttpAuthCredentialDatabaseStatic() { return IOSHttpAuthCredentialDatabase.static(); } @@ -313,7 +314,34 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [ProxyController] in `flutter_inappwebview` instead. @override - PlatformProxyController createPlatformProxyController(PlatformProxyControllerCreationParams params) { + PlatformProxyController createPlatformProxyController( + PlatformProxyControllerCreationParams params) { return IOSProxyController(params); } + + // ************************************************************************ // + // Create static instances of unsupported classes to be able to call // + // isClassSupported, isMethodSupported, isPropertySupported, etc. // + // static methods without throwing a missing platform implementation // + // exception. // + // ************************************************************************ // + + /// Creates a new empty [PlatformProcessGlobalConfig] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProcessGlobalConfig] in `flutter_inappwebview` instead. + @override + PlatformProcessGlobalConfig createPlatformProcessGlobalConfigStatic() { + return _PlatformProcessGlobalConfig.static(); + } +} + +class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { + _PlatformProcessGlobalConfig(PlatformProcessGlobalConfigCreationParams params) + : super.implementation(params); + static final _PlatformProcessGlobalConfig _staticValue = + _PlatformProcessGlobalConfig( + const PlatformProcessGlobalConfigCreationParams()); + + factory _PlatformProcessGlobalConfig.static() => _staticValue; } diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index 91c8d468c..625c9abab 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -293,9 +293,22 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { // exception. // // ************************************************************************ // + /// Creates a new empty [PlatformChromeSafariBrowser] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ChromeSafariBrowser] in `flutter_inappwebview` instead. PlatformChromeSafariBrowser createPlatformChromeSafariBrowserStatic() { return _PlatformChromeSafariBrowser.static(); } + + /// Creates a new empty [PlatformProcessGlobalConfig] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProcessGlobalConfig] in `flutter_inappwebview` instead. + @override + PlatformProcessGlobalConfig createPlatformProcessGlobalConfigStatic() { + return _PlatformProcessGlobalConfig.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -307,3 +320,13 @@ class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { factory _PlatformChromeSafariBrowser.static() => _staticValue; } + +class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { + _PlatformProcessGlobalConfig(PlatformProcessGlobalConfigCreationParams params) + : super.implementation(params); + static final _PlatformProcessGlobalConfig _staticValue = + _PlatformProcessGlobalConfig( + const PlatformProcessGlobalConfigCreationParams()); + + factory _PlatformProcessGlobalConfig.static() => _staticValue; +} \ No newline at end of file diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index f11ebfa41..8d4d0c133 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -332,6 +332,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformProcessGlobalConfig is not implemented on the current platform.'); } + /// Creates a new empty [PlatformProcessGlobalConfig] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProcessGlobalConfig] in `flutter_inappwebview` instead. + PlatformProcessGlobalConfig createPlatformProcessGlobalConfigStatic() { + throw UnimplementedError( + 'createPlatformProcessGlobalConfigStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformProxyController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart index 12d27ee01..695be35eb 100755 --- a/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart @@ -26,7 +26,7 @@ class PlatformHttpAuthCredentialDatabaseCreationParams { /// Used by the platform implementation to create a new [PlatformHttpAuthCredentialDatabase]. const PlatformHttpAuthCredentialDatabaseCreationParams(); - ///{@template flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isClassSupported} + ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabaseCreationParams.isClassSupported} ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isClassSupported({TargetPlatform? platform}) => diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.dart b/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.dart index 91cc29d18..70aea1d36 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.dart @@ -1,22 +1,38 @@ import 'dart:async'; + import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; -import 'inappwebview_platform.dart'; + import 'in_app_webview/platform_inappwebview_controller.dart'; +import 'inappwebview_platform.dart'; import 'platform_webview_feature.dart'; import 'types/enum_method.dart'; part 'platform_process_global_config.g.dart'; +///{@template flutter_inappwebview_platform_interface.PlatformProcessGlobalConfigCreationParams} /// Object specifying creation parameters for creating a [PlatformProcessGlobalConfig]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfigCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), +]) @immutable class PlatformProcessGlobalConfigCreationParams { /// Used by the platform implementation to create a new [PlatformProcessGlobalConfig]. const PlatformProcessGlobalConfigCreationParams(); + + ///{@template flutter_inappwebview_platform_interface.PlatformProcessGlobalConfigCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformProcessGlobalConfigCreationParamsClassSupported.isClassSupported( + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig} @@ -39,10 +55,15 @@ class PlatformProcessGlobalConfigCreationParams { /// ///The configuration should be set up as early as possible during application startup, ///to ensure that it happens before any other thread can call a method that loads `WebView`. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView ([Official API - ProcessGlobalConfig](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig)) ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ProcessGlobalConfig', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig'), +]) abstract class PlatformProcessGlobalConfig extends PlatformInterface { /// Creates a new [PlatformProcessGlobalConfig] factory PlatformProcessGlobalConfig( @@ -61,6 +82,22 @@ abstract class PlatformProcessGlobalConfig extends PlatformInterface { return processGlobalConfig; } + /// Creates a new [PlatformProcessGlobalConfig] to access static methods. + factory PlatformProcessGlobalConfig.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformProcessGlobalConfig processGlobalConfigStatic = + InAppWebViewPlatform.instance! + .createPlatformProcessGlobalConfigStatic(); + PlatformInterface.verify(processGlobalConfigStatic, _token); + return processGlobalConfigStatic; + } + /// Used by the platform implementation to create a new /// [PlatformProcessGlobalConfig]. /// @@ -80,20 +117,44 @@ abstract class PlatformProcessGlobalConfig extends PlatformInterface { ///This method can only be called once. /// ///Calling this method will not cause `WebView` to be loaded and will not block the calling thread. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - ProcessGlobalConfig.apply](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig#apply(androidx.webkit.ProcessGlobalConfig))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig.apply.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ProcessGlobalConfig.apply', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig#apply(androidx.webkit.ProcessGlobalConfig)'), + ]) Future apply({required ProcessGlobalConfigSettings settings}) { throw UnimplementedError( 'apply is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfigCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + params.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformProcessGlobalConfigMethod method, + {TargetPlatform? platform}) => + _PlatformProcessGlobalConfigMethodSupported.isMethodSupported(method, + platform: platform); } +///{@template flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings} ///Class that represents the settings used to configure the [PlatformProcessGlobalConfig]. +///{@endtemplate} /// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView +///{@macro flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ProcessGlobalConfig.apply', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig#apply(androidx.webkit.ProcessGlobalConfig)'), +]) @ExchangeableObject(copyMethod: true) class ProcessGlobalConfigSettings_ { ///The directory name suffix to be used for the current process. @@ -116,7 +177,12 @@ class ProcessGlobalConfigSettings_ { ///on WebView are in the same process, to avoid needing multiple data directories. ///The [PlatformInAppWebViewController.disableWebView] method can be used to ensure that the other processes do not use WebView by accident in this case. /// - ///**NOTE**: available only if [WebViewFeature.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX] feature is supported. + ///{@macro flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.dataDirectorySuffix.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + note: + 'Available only if [WebViewFeature.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX] feature is supported.'), + ]) String? dataDirectorySuffix; ///Set the base directories that `WebView` will use for the current process. @@ -137,11 +203,32 @@ class ProcessGlobalConfigSettings_ { ///If they do not already exist, `WebView` will attempt to create them during initialization, along with any missing parent directories. ///In such a case, the directory in which `WebView` creates missing directories must be readable and writable by the current process. /// - ///**NOTE**: available only if [WebViewFeature.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS] feature is supported. + ///{@macro flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.directoryBasePaths.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + note: + 'Available only if [WebViewFeature.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS] feature is supported.'), + ]) ProcessGlobalConfigDirectoryBasePaths_? directoryBasePaths; ProcessGlobalConfigSettings_( {this.dataDirectorySuffix, this.directoryBasePaths}); + + ///{@template flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) => + _ProcessGlobalConfigSettingsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.isPropertySupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isPropertySupported(ProcessGlobalConfigSettingsProperty property, + {TargetPlatform? platform}) => + _ProcessGlobalConfigSettingsPropertySupported.isPropertySupported( + property, + platform: platform); } ///Class that represents the settings used to configure the [ProcessGlobalConfigSettings.directoryBasePaths]. diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart index 9ded3ba87..3b730203e 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart @@ -6,10 +6,14 @@ part of 'platform_process_global_config.dart'; // ExchangeableObjectGenerator // ************************************************************************** +///{@template flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings} ///Class that represents the settings used to configure the [PlatformProcessGlobalConfig]. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: -///- Android native WebView +///- Android WebView ([Official API - ProcessGlobalConfig.apply](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig#apply(androidx.webkit.ProcessGlobalConfig))) class ProcessGlobalConfigSettings { ///The directory name suffix to be used for the current process. ///Must not contain a path separator and should not be empty. @@ -31,7 +35,11 @@ class ProcessGlobalConfigSettings { ///on WebView are in the same process, to avoid needing multiple data directories. ///The [PlatformInAppWebViewController.disableWebView] method can be used to ensure that the other processes do not use WebView by accident in this case. /// - ///**NOTE**: available only if [WebViewFeature.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX] feature is supported. + ///{@macro flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.dataDirectorySuffix.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView: + /// - Available only if [WebViewFeature.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX] feature is supported. String? dataDirectorySuffix; ///Set the base directories that `WebView` will use for the current process. @@ -52,8 +60,16 @@ class ProcessGlobalConfigSettings { ///If they do not already exist, `WebView` will attempt to create them during initialization, along with any missing parent directories. ///In such a case, the directory in which `WebView` creates missing directories must be readable and writable by the current process. /// - ///**NOTE**: available only if [WebViewFeature.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS] feature is supported. + ///{@macro flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.directoryBasePaths.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView: + /// - Available only if [WebViewFeature.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS] feature is supported. ProcessGlobalConfigDirectoryBasePaths? directoryBasePaths; + + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ProcessGlobalConfig.apply](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig#apply(androidx.webkit.ProcessGlobalConfig))) ProcessGlobalConfigSettings( {this.dataDirectorySuffix, this.directoryBasePaths}); @@ -72,6 +88,22 @@ class ProcessGlobalConfigSettings { return instance; } + ///{@template flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) => + _ProcessGlobalConfigSettingsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.isPropertySupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isPropertySupported(ProcessGlobalConfigSettingsProperty property, + {TargetPlatform? platform}) => + _ProcessGlobalConfigSettingsPropertySupported.isPropertySupported( + property, + platform: platform); + ///Converts instance to a map. Map toMap({EnumMethod? enumMethod}) { return { @@ -143,3 +175,126 @@ class ProcessGlobalConfigDirectoryBasePaths { return 'ProcessGlobalConfigDirectoryBasePaths{cacheDirectoryBasePath: $cacheDirectoryBasePath, dataDirectoryBasePath: $dataDirectoryBasePath}'; } } + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformProcessGlobalConfigCreationParamsClassSupported + on PlatformProcessGlobalConfigCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformProcessGlobalConfigCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [PlatformProcessGlobalConfigCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); + } +} + +extension _PlatformProcessGlobalConfigClassSupported + on PlatformProcessGlobalConfig { + ///{@template flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ProcessGlobalConfig](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig)) + /// + ///Use the [PlatformProcessGlobalConfig.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformProcessGlobalConfig]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformProcessGlobalConfigMethod { + ///Can be used to check if the [PlatformProcessGlobalConfig.apply] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig.apply.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ProcessGlobalConfig.apply](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig#apply(androidx.webkit.ProcessGlobalConfig))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [settings]: all platforms + /// + ///Use the [PlatformProcessGlobalConfig.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + apply, +} + +extension _PlatformProcessGlobalConfigMethodSupported + on PlatformProcessGlobalConfig { + static bool isMethodSupported(PlatformProcessGlobalConfigMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformProcessGlobalConfigMethod.apply: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _ProcessGlobalConfigSettingsClassSupported + on ProcessGlobalConfigSettings { + ///{@template flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ProcessGlobalConfig.apply](https://developer.android.com/reference/androidx/webkit/ProcessGlobalConfig#apply(androidx.webkit.ProcessGlobalConfig))) + /// + ///Use the [ProcessGlobalConfigSettings.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [ProcessGlobalConfigSettings]'s properties that can be used to check i they are supported or not by the current platform. +enum ProcessGlobalConfigSettingsProperty { + ///Can be used to check if the [ProcessGlobalConfigSettings.dataDirectorySuffix] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.dataDirectorySuffix.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView: + /// - Available only if [WebViewFeature.STARTUP_FEATURE_SET_DATA_DIRECTORY_SUFFIX] feature is supported. + /// + ///Use the [ProcessGlobalConfigSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + dataDirectorySuffix, + + ///Can be used to check if the [ProcessGlobalConfigSettings.directoryBasePaths] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ProcessGlobalConfigSettings.directoryBasePaths.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView: + /// - Available only if [WebViewFeature.STARTUP_FEATURE_SET_DIRECTORY_BASE_PATHS] feature is supported. + /// + ///Use the [ProcessGlobalConfigSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + directoryBasePaths, +} + +extension _ProcessGlobalConfigSettingsPropertySupported + on ProcessGlobalConfigSettings { + static bool isPropertySupported(ProcessGlobalConfigSettingsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case ProcessGlobalConfigSettingsProperty.dataDirectorySuffix: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ProcessGlobalConfigSettingsProperty.directoryBasePaths: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index f2f82cd3a..64947c9d0 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -123,6 +123,15 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { PlatformHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { return _PlatformHttpAuthCredentialDatabase.static(); } + + /// Creates a new empty [PlatformProcessGlobalConfig] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProcessGlobalConfig] in `flutter_inappwebview` instead. + @override + PlatformProcessGlobalConfig createPlatformProcessGlobalConfigStatic() { + return _PlatformProcessGlobalConfig.static(); + } } class _PlatformInAppBrowser extends PlatformInAppBrowser { @@ -155,3 +164,13 @@ class _PlatformHttpAuthCredentialDatabase factory _PlatformHttpAuthCredentialDatabase.static() => _staticValue; } + +class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { + _PlatformProcessGlobalConfig(PlatformProcessGlobalConfigCreationParams params) + : super.implementation(params); + static final _PlatformProcessGlobalConfig _staticValue = + _PlatformProcessGlobalConfig( + const PlatformProcessGlobalConfigCreationParams()); + + factory _PlatformProcessGlobalConfig.static() => _staticValue; +} \ No newline at end of file diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index b798e9e81..8e4d6f8b5 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -191,6 +191,15 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { PlatformHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { return _PlatformHttpAuthCredentialDatabase.static(); } + + /// Creates a new empty [PlatformProcessGlobalConfig] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProcessGlobalConfig] in `flutter_inappwebview` instead. + @override + PlatformProcessGlobalConfig createPlatformProcessGlobalConfigStatic() { + return _PlatformProcessGlobalConfig.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -214,3 +223,13 @@ class _PlatformHttpAuthCredentialDatabase factory _PlatformHttpAuthCredentialDatabase.static() => _staticValue; } + +class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { + _PlatformProcessGlobalConfig(PlatformProcessGlobalConfigCreationParams params) + : super.implementation(params); + static final _PlatformProcessGlobalConfig _staticValue = + _PlatformProcessGlobalConfig( + const PlatformProcessGlobalConfigCreationParams()); + + factory _PlatformProcessGlobalConfig.static() => _staticValue; +} \ No newline at end of file From fdf9cd9770f0c38c10511a1ce86ac4eef282f1ac Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 9 Dec 2024 12:37:43 +0100 Subject: [PATCH 145/181] added support methods for ProxyController class --- .../lib/src/proxy_controller.dart | 12 + .../lib/src/inappwebview_platform.dart | 20 +- .../lib/src/proxy_controller.dart | 10 + .../lib/src/inappwebview_platform.dart | 9 + .../lib/src/proxy_controller.dart | 10 + .../lib/src/inappwebview_platform.dart | 9 + .../lib/src/proxy_controller.dart | 9 + .../lib/src/inappwebview_platform.dart | 9 + .../lib/src/platform_proxy_controller.dart | 165 ++++++++++-- .../lib/src/platform_proxy_controller.g.dart | 237 +++++++++++++++++- .../lib/src/inappwebview_platform.dart | 27 +- .../lib/src/inappwebview_platform.dart | 27 +- 12 files changed, 506 insertions(+), 38 deletions(-) diff --git a/flutter_inappwebview/lib/src/proxy_controller.dart b/flutter_inappwebview/lib/src/proxy_controller.dart index 810f49e6d..95f6b49b9 100644 --- a/flutter_inappwebview/lib/src/proxy_controller.dart +++ b/flutter_inappwebview/lib/src/proxy_controller.dart @@ -1,4 +1,6 @@ import 'dart:async'; + +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformProxyController} @@ -38,4 +40,14 @@ class ProxyController { ///{@macro flutter_inappwebview_platform_interface.PlatformProxyController.clearProxyOverride} Future clearProxyOverride() => platform.clearProxyOverride(); + + ///{@macro flutter_inappwebview_platform_interface.PlatformProxyControllerCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformProxyController.static().isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformProxyController.isMethodSupported} + static bool isMethodSupported(PlatformProxyControllerMethod method, + {TargetPlatform? platform}) => + PlatformProxyController.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index a5c724708..2d1852f30 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -2,18 +2,18 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla import 'chrome_safari_browser/chrome_safari_browser.dart'; import 'cookie_manager.dart'; -import 'http_auth_credentials_database.dart'; import 'find_interaction/main.dart'; +import 'http_auth_credentials_database.dart'; import 'in_app_browser/in_app_browser.dart'; import 'in_app_webview/main.dart'; import 'print_job/main.dart'; -import 'pull_to_refresh/main.dart'; -import 'web_message/main.dart'; -import 'web_storage/main.dart'; import 'process_global_config.dart'; import 'proxy_controller.dart'; +import 'pull_to_refresh/main.dart'; import 'service_worker_controller.dart'; import 'tracing_controller.dart'; +import 'web_message/main.dart'; +import 'web_storage/main.dart'; import 'webview_asset_loader.dart'; import 'webview_feature.dart' as wv; @@ -239,7 +239,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. @override - AndroidHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { + AndroidHttpAuthCredentialDatabase + createPlatformHttpAuthCredentialDatabaseStatic() { return AndroidHttpAuthCredentialDatabase.static(); } @@ -294,6 +295,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidProxyController(params); } + /// Creates a new empty [AndroidProxyController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProxyController] in `flutter_inappwebview` instead. + @override + AndroidProxyController createPlatformProxyControllerStatic() { + return AndroidProxyController.static(); + } + /// Creates a new [AndroidServiceWorkerController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_android/lib/src/proxy_controller.dart b/flutter_inappwebview_android/lib/src/proxy_controller.dart index 07649ac8c..a324ab9fc 100644 --- a/flutter_inappwebview_android/lib/src/proxy_controller.dart +++ b/flutter_inappwebview_android/lib/src/proxy_controller.dart @@ -1,4 +1,5 @@ import 'dart:async'; + import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; @@ -55,6 +56,15 @@ class AndroidProxyController extends PlatformProxyController return _instance!; } + static final AndroidProxyController _staticValue = AndroidProxyController( + AndroidProxyControllerCreationParams( + const PlatformProxyControllerCreationParams())); + + /// Provide static access. + factory AndroidProxyController.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async {} @override diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index 16e2629b9..ad641f8af 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -319,6 +319,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSProxyController(params); } + /// Creates a new empty [IOSProxyController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProxyController] in `flutter_inappwebview` instead. + @override + IOSProxyController createPlatformProxyControllerStatic() { + return IOSProxyController.static(); + } + // ************************************************************************ // // Create static instances of unsupported classes to be able to call // // isClassSupported, isMethodSupported, isPropertySupported, etc. // diff --git a/flutter_inappwebview_ios/lib/src/proxy_controller.dart b/flutter_inappwebview_ios/lib/src/proxy_controller.dart index a94bdef2d..4da435325 100644 --- a/flutter_inappwebview_ios/lib/src/proxy_controller.dart +++ b/flutter_inappwebview_ios/lib/src/proxy_controller.dart @@ -1,4 +1,5 @@ import 'dart:async'; + import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; @@ -55,6 +56,15 @@ class IOSProxyController extends PlatformProxyController return _instance!; } + static final IOSProxyController _staticValue = IOSProxyController( + IOSProxyControllerCreationParams( + const PlatformProxyControllerCreationParams())); + + /// Provide static access. + factory IOSProxyController.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async {} @override diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index 625c9abab..140f01c3c 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -286,6 +286,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSProxyController(params); } + /// Creates a new empty [MacOSProxyController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProxyController] in `flutter_inappwebview` instead. + @override + MacOSProxyController createPlatformProxyControllerStatic() { + return MacOSProxyController.static(); + } + // ************************************************************************ // // Create static instances of unsupported classes to be able to call // // isClassSupported, isMethodSupported, isPropertySupported, etc. // diff --git a/flutter_inappwebview_macos/lib/src/proxy_controller.dart b/flutter_inappwebview_macos/lib/src/proxy_controller.dart index 6f0382b90..f40f440a2 100644 --- a/flutter_inappwebview_macos/lib/src/proxy_controller.dart +++ b/flutter_inappwebview_macos/lib/src/proxy_controller.dart @@ -55,6 +55,15 @@ class MacOSProxyController extends PlatformProxyController return _instance!; } + static final MacOSProxyController _staticValue = MacOSProxyController( + MacOSProxyControllerCreationParams( + const PlatformProxyControllerCreationParams())); + + /// Provide static access. + factory MacOSProxyController.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async {} @override diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index 8d4d0c133..cdf38c3d0 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -352,6 +352,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformProxyController is not implemented on the current platform.'); } + /// Creates a new empty [PlatformProxyController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProxyController] in `flutter_inappwebview` instead. + PlatformProxyController createPlatformProxyControllerStatic() { + throw UnimplementedError( + 'createPlatformProxyControllerStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformServiceWorkerController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.dart b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.dart index e4606e3dc..e84f5e937 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.dart @@ -1,38 +1,70 @@ import 'dart:async'; + import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + import 'inappwebview_platform.dart'; -import 'types/proxy_rule.dart'; import 'platform_webview_feature.dart'; import 'types/enum_method.dart'; +import 'types/proxy_rule.dart'; part 'platform_proxy_controller.g.dart'; +///{@template flutter_inappwebview_platform_interface.PlatformProxyControllerCreationParams} /// Object specifying creation parameters for creating a [PlatformProxyController]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformProxyControllerCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), +]) @immutable class PlatformProxyControllerCreationParams { /// Used by the platform implementation to create a new [PlatformProxyController]. const PlatformProxyControllerCreationParams(); + + ///{@template flutter_inappwebview_platform_interface.PlatformProxyControllerCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformProxyControllerCreationParamsClassSupported.isClassSupported( + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformProxyController} ///Manages setting and clearing a process-specific override for the WebView system-wide proxy settings that govern network requests made by `WebView`. /// ///`WebView` may make network requests in order to fetch content that is not otherwise read from the file system or provided directly by application code. -///In this case by default the system-wide Android network proxy settings are used to redirect requests to appropriate proxy servers. +///In this case by default the system-wide network proxy settings are used to redirect requests to appropriate proxy servers. /// ///In the rare case that it is necessary for an application to explicitly specify its proxy configuration, ///this API may be used to explicitly specify the proxy rules that govern WebView initiated network requests. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView ([Official API - ProxyController](https://developer.android.com/reference/androidx/webkit/ProxyController)) -///- iOS 17.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) -///- MacOS 14.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformProxyController.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ProxyController', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ProxyController', + ), + IOSPlatform( + apiName: 'WKWebsiteDataStore.proxyConfigurations', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations', + available: '17.0'), + MacOSPlatform( + apiName: 'WKWebsiteDataStore.proxyConfigurations', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations', + available: '14.0'), +]) abstract class PlatformProxyController extends PlatformInterface { /// Creates a new [PlatformProxyController] factory PlatformProxyController( @@ -50,6 +82,21 @@ abstract class PlatformProxyController extends PlatformInterface { return proxyController; } + /// Creates a new [PlatformProxyController] to access static methods. + factory PlatformProxyController.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformProxyController proxyControllerStatic = + InAppWebViewPlatform.instance!.createPlatformProxyControllerStatic(); + PlatformInterface.verify(proxyControllerStatic, _token); + return proxyControllerStatic; + } + /// Used by the platform implementation to create a new /// [PlatformProxyController]. /// @@ -68,12 +115,27 @@ abstract class PlatformProxyController extends PlatformInterface { ///URLs that match patterns in the bypass list will not be directed to any proxy. ///Instead, the request will be made directly to the origin specified by the URL. ///Network connections are not guaranteed to immediately use the new proxy setting; wait for the method to return before loading a page. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - ProxyController.setProxyOverride](https://developer.android.com/reference/androidx/webkit/ProxyController#setProxyOverride(androidx.webkit.ProxyConfig,%20java.util.concurrent.Executor,%20java.lang.Runnable))) - ///- iOS 17.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) - ///- MacOS 14.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformProxyController.setProxyOverride.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ProxyController.setProxyOverride', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ProxyController#setProxyOverride(androidx.webkit.ProxyConfig,%20java.util.concurrent.Executor,%20java.lang.Runnable)'), + IOSPlatform( + apiName: 'WKWebsiteDataStore.proxyConfigurations', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations', + available: '17.0', + ), + MacOSPlatform( + apiName: 'WKWebsiteDataStore.proxyConfigurations', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations', + available: '14.0', + ), + ]) Future setProxyOverride({required ProxySettings settings}) { throw UnimplementedError( 'setProxyOverride is not implemented on the current platform'); @@ -81,25 +143,70 @@ abstract class PlatformProxyController extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformProxyController.clearProxyOverride} ///Clears the proxy settings. - ///Network connections are not guaranteed to immediately use the new proxy setting; wait for the method to return before loading a page. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - ProxyController.clearProxyOverride](https://developer.android.com/reference/androidx/webkit/ProxyController#clearProxyOverride(java.util.concurrent.Executor,%20java.lang.Runnable))) - ///- iOS 17.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) - ///- MacOS 14.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) + ///Network connections are not guaranteed to immediately use the new proxy setting; + ///wait for the method to return before loading a page. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformProxyController.clearProxyOverride.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ProxyController.clearProxyOverride', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ProxyController#clearProxyOverride(java.util.concurrent.Executor,%20java.lang.Runnable)'), + IOSPlatform( + apiName: 'WKWebsiteDataStore.proxyConfigurations', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations', + available: '17.0', + ), + MacOSPlatform( + apiName: 'WKWebsiteDataStore.proxyConfigurations', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations', + available: '14.0', + ), + ]) Future clearProxyOverride() { throw UnimplementedError( 'clearProxyOverride is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformProxyControllerCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + params.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformProxyController.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformProxyControllerMethod method, + {TargetPlatform? platform}) => + _PlatformProxyControllerMethodSupported.isMethodSupported(method, + platform: platform); } +///{@template flutter_inappwebview_platform_interface.ProxySettings} ///Class that represents the settings used to configure the [PlatformProxyController]. +///{@endtemplate} /// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView ([Official API - ProxyConfig](https://developer.android.com/reference/androidx/webkit/ProxyConfig)) -///- iOS 17.0+ ([Official API - ProxyConfiguration](https://developer.apple.com/documentation/network/proxyconfiguration)) -///- MacOS 14.0+ ([Official API - ProxyConfiguration](https://developer.apple.com/documentation/network/proxyconfiguration)) +///{@macro flutter_inappwebview_platform_interface.ProxySettings.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ProxyConfig', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ProxyConfig'), + IOSPlatform( + apiName: 'ProxyConfiguration', + apiUrl: + 'https://developer.apple.com/documentation/network/proxyconfiguration', + available: '17.0', + ), + MacOSPlatform( + apiName: 'ProxyConfiguration', + apiUrl: + 'https://developer.apple.com/documentation/network/proxyconfiguration', + available: '14.0', + ), +]) @ExchangeableObject(copyMethod: true) class ProxySettings_ { ///List of bypass rules. @@ -178,4 +285,18 @@ class ProxySettings_ { this.bypassSimpleHostnames, this.removeImplicitRules, this.reverseBypassEnabled = false}); + + ///{@template flutter_inappwebview_platform_interface.ProxySettings.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) => + _ProxySettingsClassSupported.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.ProxySettings.isPropertySupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isPropertySupported(ProxySettingsProperty property, + {TargetPlatform? platform}) => + _ProxySettingsPropertySupported.isPropertySupported(property, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart index 26c06fe0b..189f7ba89 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart @@ -6,12 +6,16 @@ part of 'platform_proxy_controller.dart'; // ExchangeableObjectGenerator // ************************************************************************** +///{@template flutter_inappwebview_platform_interface.ProxySettings} ///Class that represents the settings used to configure the [PlatformProxyController]. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.ProxySettings.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: -///- Android native WebView ([Official API - ProxyConfig](https://developer.android.com/reference/androidx/webkit/ProxyConfig)) -///- iOS 17.0+ ([Official API - ProxyConfiguration](https://developer.apple.com/documentation/network/proxyconfiguration)) -///- MacOS 14.0+ ([Official API - ProxyConfiguration](https://developer.apple.com/documentation/network/proxyconfiguration)) +///- Android WebView ([Official API - ProxyConfig](https://developer.android.com/reference/androidx/webkit/ProxyConfig)) +///- iOS WKWebView 17.0+ ([Official API - ProxyConfiguration](https://developer.apple.com/documentation/network/proxyconfiguration)) +///- macOS WKWebView 14.0+ ([Official API - ProxyConfiguration](https://developer.apple.com/documentation/network/proxyconfiguration)) class ProxySettings { ///List of bypass rules. /// @@ -81,6 +85,12 @@ class ProxySettings { ///**Officially Supported Platforms/Implementations**: ///- Android WebView bool reverseBypassEnabled; + + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ProxyConfig](https://developer.android.com/reference/androidx/webkit/ProxyConfig)) + ///- iOS WKWebView 17.0+ ([Official API - ProxyConfiguration](https://developer.apple.com/documentation/network/proxyconfiguration)) + ///- macOS WKWebView 14.0+ ([Official API - ProxyConfiguration](https://developer.apple.com/documentation/network/proxyconfiguration)) ProxySettings( {this.bypassRules = const [], this.bypassSimpleHostnames, @@ -117,6 +127,20 @@ class ProxySettings { return instance; } + ///{@template flutter_inappwebview_platform_interface.ProxySettings.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) => + _ProxySettingsClassSupported.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.ProxySettings.isPropertySupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isPropertySupported(ProxySettingsProperty property, + {TargetPlatform? platform}) => + _ProxySettingsPropertySupported.isPropertySupported(property, + platform: platform); + ///Converts instance to a map. Map toMap({EnumMethod? enumMethod}) { return { @@ -145,3 +169,210 @@ class ProxySettings { return 'ProxySettings{bypassRules: $bypassRules, bypassSimpleHostnames: $bypassSimpleHostnames, directs: $directs, proxyRules: $proxyRules, removeImplicitRules: $removeImplicitRules, reverseBypassEnabled: $reverseBypassEnabled}'; } } + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformProxyControllerCreationParamsClassSupported + on PlatformProxyControllerCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformProxyControllerCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformProxyControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +extension _PlatformProxyControllerClassSupported on PlatformProxyController { + ///{@template flutter_inappwebview_platform_interface.PlatformProxyController.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ProxyController](https://developer.android.com/reference/androidx/webkit/ProxyController)) + ///- iOS WKWebView 17.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) + ///- macOS WKWebView 14.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) + /// + ///Use the [PlatformProxyController.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformProxyController]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformProxyControllerMethod { + ///Can be used to check if the [PlatformProxyController.clearProxyOverride] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformProxyController.clearProxyOverride.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ProxyController.clearProxyOverride](https://developer.android.com/reference/androidx/webkit/ProxyController#clearProxyOverride(java.util.concurrent.Executor,%20java.lang.Runnable))) + ///- iOS WKWebView 17.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) + ///- macOS WKWebView 14.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) + /// + ///Use the [PlatformProxyController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + clearProxyOverride, + + ///Can be used to check if the [PlatformProxyController.setProxyOverride] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformProxyController.setProxyOverride.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ProxyController.setProxyOverride](https://developer.android.com/reference/androidx/webkit/ProxyController#setProxyOverride(androidx.webkit.ProxyConfig,%20java.util.concurrent.Executor,%20java.lang.Runnable))) + ///- iOS WKWebView 17.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) + ///- macOS WKWebView 14.0+ ([Official API - WKWebsiteDataStore.proxyConfigurations](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/4264546-proxyconfigurations)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [settings]: all platforms + /// + ///Use the [PlatformProxyController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setProxyOverride, +} + +extension _PlatformProxyControllerMethodSupported on PlatformProxyController { + static bool isMethodSupported(PlatformProxyControllerMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformProxyControllerMethod.clearProxyOverride: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformProxyControllerMethod.setProxyOverride: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _ProxySettingsClassSupported on ProxySettings { + ///{@template flutter_inappwebview_platform_interface.ProxySettings.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ProxyConfig](https://developer.android.com/reference/androidx/webkit/ProxyConfig)) + ///- iOS WKWebView 17.0+ ([Official API - ProxyConfiguration](https://developer.apple.com/documentation/network/proxyconfiguration)) + ///- macOS WKWebView 14.0+ ([Official API - ProxyConfiguration](https://developer.apple.com/documentation/network/proxyconfiguration)) + /// + ///Use the [ProxySettings.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [ProxySettings]'s properties that can be used to check i they are supported or not by the current platform. +enum ProxySettingsProperty { + ///Can be used to check if the [ProxySettings.bypassRules] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ProxySettings.bypassRules.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [ProxySettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + bypassRules, + + ///Can be used to check if the [ProxySettings.bypassSimpleHostnames] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ProxySettings.bypassSimpleHostnames.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [ProxySettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + bypassSimpleHostnames, + + ///Can be used to check if the [ProxySettings.directs] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ProxySettings.directs.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [ProxySettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + directs, + + ///Can be used to check if the [ProxySettings.proxyRules] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ProxySettings.proxyRules.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [ProxySettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + proxyRules, + + ///Can be used to check if the [ProxySettings.removeImplicitRules] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ProxySettings.removeImplicitRules.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [ProxySettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + removeImplicitRules, + + ///Can be used to check if the [ProxySettings.reverseBypassEnabled] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ProxySettings.reverseBypassEnabled.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [ProxySettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + reverseBypassEnabled, +} + +extension _ProxySettingsPropertySupported on ProxySettings { + static bool isPropertySupported(ProxySettingsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case ProxySettingsProperty.bypassRules: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ProxySettingsProperty.bypassSimpleHostnames: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ProxySettingsProperty.directs: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ProxySettingsProperty.proxyRules: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case ProxySettingsProperty.removeImplicitRules: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case ProxySettingsProperty.reverseBypassEnabled: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index 64947c9d0..47423a210 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -120,7 +120,8 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. @override - PlatformHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { + PlatformHttpAuthCredentialDatabase + createPlatformHttpAuthCredentialDatabaseStatic() { return _PlatformHttpAuthCredentialDatabase.static(); } @@ -132,6 +133,15 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { PlatformProcessGlobalConfig createPlatformProcessGlobalConfigStatic() { return _PlatformProcessGlobalConfig.static(); } + + /// Creates a new empty [PlatformProxyController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProxyController] in `flutter_inappwebview` instead. + @override + PlatformProxyController createPlatformProxyControllerStatic() { + return _PlatformProxyController.static(); + } } class _PlatformInAppBrowser extends PlatformInAppBrowser { @@ -169,8 +179,17 @@ class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { _PlatformProcessGlobalConfig(PlatformProcessGlobalConfigCreationParams params) : super.implementation(params); static final _PlatformProcessGlobalConfig _staticValue = - _PlatformProcessGlobalConfig( - const PlatformProcessGlobalConfigCreationParams()); + _PlatformProcessGlobalConfig( + const PlatformProcessGlobalConfigCreationParams()); factory _PlatformProcessGlobalConfig.static() => _staticValue; -} \ No newline at end of file +} + +class _PlatformProxyController extends PlatformProxyController { + _PlatformProxyController(PlatformProxyControllerCreationParams params) + : super.implementation(params); + static final _PlatformProxyController _staticValue = + _PlatformProxyController(const PlatformProxyControllerCreationParams()); + + factory _PlatformProxyController.static() => _staticValue; +} diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index 8e4d6f8b5..685e6466c 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -188,7 +188,8 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. @override - PlatformHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { + PlatformHttpAuthCredentialDatabase + createPlatformHttpAuthCredentialDatabaseStatic() { return _PlatformHttpAuthCredentialDatabase.static(); } @@ -200,6 +201,15 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { PlatformProcessGlobalConfig createPlatformProcessGlobalConfigStatic() { return _PlatformProcessGlobalConfig.static(); } + + /// Creates a new empty [PlatformProxyController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ProxyController] in `flutter_inappwebview` instead. + @override + PlatformProxyController createPlatformProxyControllerStatic() { + return _PlatformProxyController.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -228,8 +238,17 @@ class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { _PlatformProcessGlobalConfig(PlatformProcessGlobalConfigCreationParams params) : super.implementation(params); static final _PlatformProcessGlobalConfig _staticValue = - _PlatformProcessGlobalConfig( - const PlatformProcessGlobalConfigCreationParams()); + _PlatformProcessGlobalConfig( + const PlatformProcessGlobalConfigCreationParams()); factory _PlatformProcessGlobalConfig.static() => _staticValue; -} \ No newline at end of file +} + +class _PlatformProxyController extends PlatformProxyController { + _PlatformProxyController(PlatformProxyControllerCreationParams params) + : super.implementation(params); + static final _PlatformProxyController _staticValue = + _PlatformProxyController(const PlatformProxyControllerCreationParams()); + + factory _PlatformProxyController.static() => _staticValue; +} From 875b1055e982b6ff9b37327b848f0e76ceb54a3a Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 9 Dec 2024 14:51:47 +0100 Subject: [PATCH 146/181] added support methods for ServiceWorkerController class --- .../lib/src/service_worker_controller.dart | 13 + .../lib/src/inappwebview_platform.dart | 22 ++ .../lib/src/inappwebview_platform.dart | 22 ++ .../platform_service_worker_controller.dart | 202 +++++++++++---- .../platform_service_worker_controller.g.dart | 242 ++++++++++++++++++ .../lib/src/inappwebview_platform.dart | 22 ++ .../lib/src/inappwebview_platform.dart | 22 ++ 7 files changed, 498 insertions(+), 47 deletions(-) create mode 100644 flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.g.dart diff --git a/flutter_inappwebview/lib/src/service_worker_controller.dart b/flutter_inappwebview/lib/src/service_worker_controller.dart index 1d271fab9..a789a24ba 100644 --- a/flutter_inappwebview/lib/src/service_worker_controller.dart +++ b/flutter_inappwebview/lib/src/service_worker_controller.dart @@ -1,4 +1,6 @@ import 'dart:async'; + +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController} @@ -70,6 +72,17 @@ class ServiceWorkerController { ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setCacheMode} static Future setCacheMode(CacheMode mode) => PlatformServiceWorkerController.static().setCacheMode(mode); + + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerControllerCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformServiceWorkerController.static() + .isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.isMethodSupported} + static bool isMethodSupported(PlatformServiceWorkerControllerMethod method, + {TargetPlatform? platform}) => + PlatformServiceWorkerController.static() + .isMethodSupported(method, platform: platform); } ///Class that represents an Android-specific class that manages Service Workers used by `WebView`. diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index ad641f8af..5707fdce2 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -343,6 +343,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { PlatformProcessGlobalConfig createPlatformProcessGlobalConfigStatic() { return _PlatformProcessGlobalConfig.static(); } + + /// Creates a new empty [PlatformServiceWorkerController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. + @override + PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { + return _PlatformServiceWorkerController.static(); + } } class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { @@ -354,3 +363,16 @@ class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { factory _PlatformProcessGlobalConfig.static() => _staticValue; } + +class _PlatformServiceWorkerController extends PlatformServiceWorkerController { + _PlatformServiceWorkerController(PlatformServiceWorkerControllerCreationParams params) + : super.implementation(params); + static final _PlatformServiceWorkerController _staticValue = + _PlatformServiceWorkerController( + const PlatformServiceWorkerControllerCreationParams()); + + factory _PlatformServiceWorkerController.static() => _staticValue; + + @override + ServiceWorkerClient? get serviceWorkerClient => throw UnimplementedError(); +} diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index 140f01c3c..0a1b8285b 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -318,6 +318,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { PlatformProcessGlobalConfig createPlatformProcessGlobalConfigStatic() { return _PlatformProcessGlobalConfig.static(); } + + /// Creates a new empty [PlatformServiceWorkerController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. + @override + PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { + return _PlatformServiceWorkerController.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -338,4 +347,17 @@ class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { const PlatformProcessGlobalConfigCreationParams()); factory _PlatformProcessGlobalConfig.static() => _staticValue; +} + +class _PlatformServiceWorkerController extends PlatformServiceWorkerController { + _PlatformServiceWorkerController(PlatformServiceWorkerControllerCreationParams params) + : super.implementation(params); + static final _PlatformServiceWorkerController _staticValue = + _PlatformServiceWorkerController( + const PlatformServiceWorkerControllerCreationParams()); + + factory _PlatformServiceWorkerController.static() => _staticValue; + + @override + ServiceWorkerClient? get serviceWorkerClient => throw UnimplementedError(); } \ No newline at end of file diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart b/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart index 6d88af6ae..1e4fbb3ed 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart @@ -1,27 +1,51 @@ import 'dart:async'; + import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; + import 'inappwebview_platform.dart'; +import 'platform_webview_feature.dart'; import 'types/main.dart'; +part 'platform_service_worker_controller.g.dart'; + +///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerControllerCreationParams} /// Object specifying creation parameters for creating a [PlatformServiceWorkerController]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerControllerCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), +]) @immutable class PlatformServiceWorkerControllerCreationParams { /// Used by the platform implementation to create a new [PlatformServiceWorkerController]. const PlatformServiceWorkerControllerCreationParams(); + + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerControllerCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformServiceWorkerControllerCreationParamsClassSupported.isClassSupported( + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController} ///Class that manages Service Workers used by `WebView`. -/// -///**NOTE**: available on Android 24+. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView ([Official API - ServiceWorkerControllerCompat](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat)) ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerControllerCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerControllerCompat', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat', + ), +]) abstract class PlatformServiceWorkerController extends PlatformInterface { /// Creates a new [PlatformServiceWorkerController] factory PlatformServiceWorkerController( @@ -78,10 +102,16 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setServiceWorkerClient} ///Sets the client to capture service worker related callbacks. ///A [ServiceWorkerClient] should be set before any service workers are active, e.g. a safe place is before any WebView instances are created or pages loaded. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - ServiceWorkerControllerCompat.setServiceWorkerClient](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat#setServiceWorkerClient(androidx.webkit.ServiceWorkerClientCompat))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setServiceWorkerClient.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerControllerCompat.setServiceWorkerClient', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat#setServiceWorkerClient(androidx.webkit.ServiceWorkerClientCompat)', + ), + ]) Future setServiceWorkerClient(ServiceWorkerClient? value) { throw UnimplementedError( 'setServiceWorkerClient is not implemented on the current platform'); @@ -90,11 +120,16 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getAllowContentAccess} ///Gets whether Service Workers support content URL access. ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowContentAccess() ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getAllowContentAccess.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerWebSettingsCompat.getAllowContentAccess', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowContentAccess()', + ), + ]) Future getAllowContentAccess() { throw UnimplementedError( 'getAllowContentAccess is not implemented on the current platform'); @@ -103,11 +138,16 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getAllowFileAccess} ///Gets whether Service Workers support file access. ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_FILE_ACCESS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowFileAccess() ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getAllowFileAccess.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerWebSettingsCompat.getAllowFileAccess', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowFileAccess()', + ), + ]) Future getAllowFileAccess() { throw UnimplementedError( 'getAllowFileAccess is not implemented on the current platform'); @@ -116,11 +156,16 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getBlockNetworkLoads} ///Gets whether Service Workers are prohibited from loading any resources from the network. ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getBlockNetworkLoads() ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getBlockNetworkLoads.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerWebSettingsCompat.getBlockNetworkLoads', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getBlockNetworkLoads()', + ), + ]) Future getBlockNetworkLoads() { throw UnimplementedError( 'getBlockNetworkLoads is not implemented on the current platform'); @@ -129,11 +174,16 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getCacheMode} ///Gets the current setting for overriding the cache mode. ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CACHE_MODE]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getCacheMode() ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getCacheMode.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerWebSettingsCompat.getCacheMode', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getCacheMode()', + ), + ]) Future getCacheMode() { throw UnimplementedError( 'getCacheMode is not implemented on the current platform'); @@ -142,11 +192,16 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setAllowContentAccess} ///Enables or disables content URL access from Service Workers. ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CONTENT_ACCESS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setAllowContentAccess.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerWebSettingsCompat.setAllowContentAccess', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean)', + ), + ]) Future setAllowContentAccess(bool allow) { throw UnimplementedError( 'setAllowContentAccess is not implemented on the current platform'); @@ -155,11 +210,16 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setAllowFileAccess} ///Enables or disables file access within Service Workers. ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_FILE_ACCESS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setAllowFileAccess.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerWebSettingsCompat.setAllowFileAccess', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean)', + ), + ]) Future setAllowFileAccess(bool allow) { throw UnimplementedError( 'setAllowFileAccess is not implemented on the current platform'); @@ -168,11 +228,16 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setBlockNetworkLoads} ///Sets whether Service Workers should not load resources from the network. ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_BLOCK_NETWORK_LOADS]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setBlockNetworkLoads.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerWebSettingsCompat.setBlockNetworkLoads', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean)', + ), + ]) Future setBlockNetworkLoads(bool flag) { throw UnimplementedError( 'setBlockNetworkLoads is not implemented on the current platform'); @@ -181,25 +246,46 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setCacheMode} ///Overrides the way the cache is used. ///This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SERVICE_WORKER_CACHE_MODE]. - /// - ///**NOTE**: available on Android 24+. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setCacheMode(int) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setCacheMode.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerWebSettingsCompat.setCacheMode', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setCacheMode(int)', + ), + ]) Future setCacheMode(CacheMode mode) { throw UnimplementedError( 'setCacheMode is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformServiceWorkerControllerCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + params.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformServiceWorkerControllerMethod method, + {TargetPlatform? platform}) => + _PlatformServiceWorkerControllerMethodSupported.isMethodSupported(method, + platform: platform); } ///{@template flutter_inappwebview_platform_interface.ServiceWorkerClient} ///Class used by clients to capture Service Worker related callbacks. -/// -///**NOTE**: available on Android 24+. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView ([Official API - ServiceWorkerClientCompat](https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat)) ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.ServiceWorkerClient.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerClientCompat', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat', + ), +]) class ServiceWorkerClient { ///{@template flutter_inappwebview_platform_interface.ServiceWorkerClient.shouldInterceptRequest} ///Notify the host application of a resource request and allow the application to return the data. @@ -210,11 +296,33 @@ class ServiceWorkerClient { ///You can check whether that flag is supported using [WebViewFeature.isFeatureSupported]. /// ///[request] represents an object containing the details of the request. - /// - ///**NOTE**: available on Android 24+. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.ServiceWorkerClient.shouldInterceptRequest.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'ServiceWorkerClientCompat.shouldInterceptRequest', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat#shouldInterceptRequest(android.webkit.WebResourceRequest)', + ), + ]) final Future Function(WebResourceRequest request)? shouldInterceptRequest; ServiceWorkerClient({this.shouldInterceptRequest}); + + ///{@template flutter_inappwebview_platform_interface.ServiceWorkerClient.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) => + _PlatformServiceWorkerControllerCreationParamsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.ServiceWorkerClient.isPropertySupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isPropertySupported(ServiceWorkerClientProperty property, + {TargetPlatform? platform}) => + _ServiceWorkerClientPropertySupported.isPropertySupported(property, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.g.dart new file mode 100644 index 000000000..23f4f64cc --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.g.dart @@ -0,0 +1,242 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_service_worker_controller.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformServiceWorkerControllerCreationParamsClassSupported + on PlatformServiceWorkerControllerCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerControllerCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [PlatformServiceWorkerControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); + } +} + +extension _PlatformServiceWorkerControllerClassSupported + on PlatformServiceWorkerController { + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerControllerCompat](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat)) + /// + ///Use the [PlatformServiceWorkerController.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformServiceWorkerController]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformServiceWorkerControllerMethod { + ///Can be used to check if the [PlatformServiceWorkerController.getAllowContentAccess] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getAllowContentAccess.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerWebSettingsCompat.getAllowContentAccess](https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowContentAccess())) + /// + ///Use the [PlatformServiceWorkerController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getAllowContentAccess, + + ///Can be used to check if the [PlatformServiceWorkerController.getAllowFileAccess] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getAllowFileAccess.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerWebSettingsCompat.getAllowFileAccess](https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getAllowFileAccess())) + /// + ///Use the [PlatformServiceWorkerController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getAllowFileAccess, + + ///Can be used to check if the [PlatformServiceWorkerController.getBlockNetworkLoads] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getBlockNetworkLoads.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerWebSettingsCompat.getBlockNetworkLoads](https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getBlockNetworkLoads())) + /// + ///Use the [PlatformServiceWorkerController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getBlockNetworkLoads, + + ///Can be used to check if the [PlatformServiceWorkerController.getCacheMode] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.getCacheMode.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerWebSettingsCompat.getCacheMode](https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#getCacheMode())) + /// + ///Use the [PlatformServiceWorkerController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getCacheMode, + + ///Can be used to check if the [PlatformServiceWorkerController.setAllowContentAccess] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setAllowContentAccess.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerWebSettingsCompat.setAllowContentAccess](https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [allow]: all platforms + /// + ///Use the [PlatformServiceWorkerController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setAllowContentAccess, + + ///Can be used to check if the [PlatformServiceWorkerController.setAllowFileAccess] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setAllowFileAccess.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerWebSettingsCompat.setAllowFileAccess](https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [allow]: all platforms + /// + ///Use the [PlatformServiceWorkerController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setAllowFileAccess, + + ///Can be used to check if the [PlatformServiceWorkerController.setBlockNetworkLoads] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setBlockNetworkLoads.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerWebSettingsCompat.setBlockNetworkLoads](https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [flag]: all platforms + /// + ///Use the [PlatformServiceWorkerController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setBlockNetworkLoads, + + ///Can be used to check if the [PlatformServiceWorkerController.setCacheMode] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setCacheMode.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerWebSettingsCompat.setCacheMode](https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setCacheMode(int))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [mode]: all platforms + /// + ///Use the [PlatformServiceWorkerController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setCacheMode, + + ///Can be used to check if the [PlatformServiceWorkerController.setServiceWorkerClient] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController.setServiceWorkerClient.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerControllerCompat.setServiceWorkerClient](https://developer.android.com/reference/androidx/webkit/ServiceWorkerControllerCompat#setServiceWorkerClient(androidx.webkit.ServiceWorkerClientCompat))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [value]: all platforms + /// + ///Use the [PlatformServiceWorkerController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setServiceWorkerClient, +} + +extension _PlatformServiceWorkerControllerMethodSupported + on PlatformServiceWorkerController { + static bool isMethodSupported(PlatformServiceWorkerControllerMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformServiceWorkerControllerMethod.getAllowContentAccess: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformServiceWorkerControllerMethod.getAllowFileAccess: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformServiceWorkerControllerMethod.getBlockNetworkLoads: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformServiceWorkerControllerMethod.getCacheMode: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformServiceWorkerControllerMethod.setAllowContentAccess: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformServiceWorkerControllerMethod.setAllowFileAccess: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformServiceWorkerControllerMethod.setBlockNetworkLoads: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformServiceWorkerControllerMethod.setCacheMode: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformServiceWorkerControllerMethod.setServiceWorkerClient: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _ServiceWorkerClientClassSupported on ServiceWorkerClient { + ///{@template flutter_inappwebview_platform_interface.ServiceWorkerClient.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerClientCompat](https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat)) + /// + ///Use the [ServiceWorkerClient.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [ServiceWorkerClient]'s properties that can be used to check i they are supported or not by the current platform. +enum ServiceWorkerClientProperty { + ///Can be used to check if the [ServiceWorkerClient.shouldInterceptRequest] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.ServiceWorkerClient.shouldInterceptRequest.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - ServiceWorkerClientCompat.shouldInterceptRequest](https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat#shouldInterceptRequest(android.webkit.WebResourceRequest))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [request]: all platforms + /// + ///Use the [ServiceWorkerClient.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + shouldInterceptRequest, +} + +extension _ServiceWorkerClientPropertySupported on ServiceWorkerClient { + static bool isPropertySupported(ServiceWorkerClientProperty property, + {TargetPlatform? platform}) { + switch (property) { + case ServiceWorkerClientProperty.shouldInterceptRequest: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index 47423a210..4bd9a048e 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -142,6 +142,15 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { PlatformProxyController createPlatformProxyControllerStatic() { return _PlatformProxyController.static(); } + + /// Creates a new empty [PlatformServiceWorkerController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. + @override + PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { + return _PlatformServiceWorkerController.static(); + } } class _PlatformInAppBrowser extends PlatformInAppBrowser { @@ -193,3 +202,16 @@ class _PlatformProxyController extends PlatformProxyController { factory _PlatformProxyController.static() => _staticValue; } + +class _PlatformServiceWorkerController extends PlatformServiceWorkerController { + _PlatformServiceWorkerController(PlatformServiceWorkerControllerCreationParams params) + : super.implementation(params); + static final _PlatformServiceWorkerController _staticValue = + _PlatformServiceWorkerController( + const PlatformServiceWorkerControllerCreationParams()); + + factory _PlatformServiceWorkerController.static() => _staticValue; + + @override + ServiceWorkerClient? get serviceWorkerClient => throw UnimplementedError(); +} diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index 685e6466c..bed83f993 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -210,6 +210,15 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { PlatformProxyController createPlatformProxyControllerStatic() { return _PlatformProxyController.static(); } + + /// Creates a new empty [PlatformServiceWorkerController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. + @override + PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { + return _PlatformServiceWorkerController.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -252,3 +261,16 @@ class _PlatformProxyController extends PlatformProxyController { factory _PlatformProxyController.static() => _staticValue; } + +class _PlatformServiceWorkerController extends PlatformServiceWorkerController { + _PlatformServiceWorkerController(PlatformServiceWorkerControllerCreationParams params) + : super.implementation(params); + static final _PlatformServiceWorkerController _staticValue = + _PlatformServiceWorkerController( + const PlatformServiceWorkerControllerCreationParams()); + + factory _PlatformServiceWorkerController.static() => _staticValue; + + @override + ServiceWorkerClient? get serviceWorkerClient => throw UnimplementedError(); +} From 45c9ab18f6e838a63a72d1f0423bb74f1b519290 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Mon, 9 Dec 2024 15:04:43 +0100 Subject: [PATCH 147/181] added support methods for TracingController class --- .../lib/src/tracing_controller.dart | 12 ++ .../lib/src/inappwebview_platform.dart | 9 + .../lib/src/tracing_controller.dart | 9 + .../lib/src/inappwebview_platform.dart | 19 ++ .../lib/src/inappwebview_platform.dart | 19 ++ .../lib/src/inappwebview_platform.dart | 26 ++- .../platform_service_worker_controller.dart | 24 +-- .../lib/src/platform_tracing_controller.dart | 103 +++++++++-- .../src/platform_tracing_controller.g.dart | 166 +++++++++++++++++- .../lib/src/inappwebview_platform.dart | 19 ++ .../lib/src/inappwebview_platform.dart | 19 ++ 11 files changed, 390 insertions(+), 35 deletions(-) diff --git a/flutter_inappwebview/lib/src/tracing_controller.dart b/flutter_inappwebview/lib/src/tracing_controller.dart index 4635e987a..1a4e0e530 100644 --- a/flutter_inappwebview/lib/src/tracing_controller.dart +++ b/flutter_inappwebview/lib/src/tracing_controller.dart @@ -1,4 +1,6 @@ import 'dart:async'; + +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformTracingController} @@ -41,4 +43,14 @@ class TracingController { ///{@macro flutter_inappwebview_platform_interface.PlatformTracingController.isTracing} Future isTracing() => platform.isTracing(); + + ///{@macro flutter_inappwebview_platform_interface.PlatformTracingControllerCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformTracingController.static().isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformTracingController.isMethodSupported} + static bool isMethodSupported(PlatformTracingControllerMethod method, + {TargetPlatform? platform}) => + PlatformTracingController.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index 2d1852f30..d8504ea7d 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -335,6 +335,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidTracingController(params); } + /// Creates a new empty [AndroidTracingController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [TracingController] in `flutter_inappwebview` instead. + @override + AndroidTracingController createPlatformTracingControllerStatic() { + return AndroidTracingController.static(); + } + /// Creates a new [AndroidAssetsPathHandler]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_android/lib/src/tracing_controller.dart b/flutter_inappwebview_android/lib/src/tracing_controller.dart index 9d619f073..edf135103 100644 --- a/flutter_inappwebview_android/lib/src/tracing_controller.dart +++ b/flutter_inappwebview_android/lib/src/tracing_controller.dart @@ -55,6 +55,15 @@ class AndroidTracingController extends PlatformTracingController return _instance!; } + static final AndroidTracingController _staticValue = AndroidTracingController( + AndroidTracingControllerCreationParams( + const PlatformTracingControllerCreationParams())); + + /// Provide static access. + factory AndroidTracingController.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async {} @override diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index 5707fdce2..6c0565161 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -352,6 +352,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { return _PlatformServiceWorkerController.static(); } + + /// Creates a new empty [PlatformTracingController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [TracingController] in `flutter_inappwebview` instead. + @override + PlatformTracingController createPlatformTracingControllerStatic() { + return _PlatformTracingController.static(); + } } class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { @@ -376,3 +385,13 @@ class _PlatformServiceWorkerController extends PlatformServiceWorkerController { @override ServiceWorkerClient? get serviceWorkerClient => throw UnimplementedError(); } + +class _PlatformTracingController extends PlatformTracingController { + _PlatformTracingController(PlatformTracingControllerCreationParams params) + : super.implementation(params); + static final _PlatformTracingController _staticValue = + _PlatformTracingController( + const PlatformTracingControllerCreationParams()); + + factory _PlatformTracingController.static() => _staticValue; +} \ No newline at end of file diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index 0a1b8285b..417545122 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -327,6 +327,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { return _PlatformServiceWorkerController.static(); } + + /// Creates a new empty [PlatformTracingController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [TracingController] in `flutter_inappwebview` instead. + @override + PlatformTracingController createPlatformTracingControllerStatic() { + return _PlatformTracingController.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -360,4 +369,14 @@ class _PlatformServiceWorkerController extends PlatformServiceWorkerController { @override ServiceWorkerClient? get serviceWorkerClient => throw UnimplementedError(); +} + +class _PlatformTracingController extends PlatformTracingController { + _PlatformTracingController(PlatformTracingControllerCreationParams params) + : super.implementation(params); + static final _PlatformTracingController _staticValue = + _PlatformTracingController( + const PlatformTracingControllerCreationParams()); + + factory _PlatformTracingController.static() => _staticValue; } \ No newline at end of file diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index cdf38c3d0..c600db0de 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -3,12 +3,19 @@ import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import 'chrome_safari_browser/platform_chrome_safari_browser.dart'; import 'find_interaction/platform_find_interaction_controller.dart'; import 'in_app_browser/platform_in_app_browser.dart'; +import 'in_app_localhost_server.dart'; import 'in_app_webview/platform_headless_in_app_webview.dart'; import 'in_app_webview/platform_inappwebview_controller.dart'; import 'in_app_webview/platform_inappwebview_widget.dart'; import 'platform_cookie_manager.dart'; import 'platform_http_auth_credentials_database.dart'; import 'platform_in_app_localhost_server.dart'; +import 'platform_process_global_config.dart'; +import 'platform_proxy_controller.dart'; +import 'platform_service_worker_controller.dart'; +import 'platform_tracing_controller.dart'; +import 'platform_webview_asset_loader.dart'; +import 'platform_webview_feature.dart'; import 'print_job/platform_print_job_controller.dart'; import 'pull_to_refresh/platform_pull_to_refresh_controller.dart'; import 'web_authentication_session/platform_web_authenticate_session.dart'; @@ -17,13 +24,6 @@ import 'web_message/platform_web_message_listener.dart'; import 'web_message/platform_web_message_port.dart'; import 'web_storage/platform_web_storage.dart'; import 'web_storage/platform_web_storage_manager.dart'; -import 'platform_process_global_config.dart'; -import 'platform_proxy_controller.dart'; -import 'platform_service_worker_controller.dart'; -import 'platform_tracing_controller.dart'; -import 'platform_webview_asset_loader.dart'; -import 'platform_webview_feature.dart'; -import 'in_app_localhost_server.dart'; import 'webview_environment/platform_webview_environment.dart'; /// Interface for a platform implementation of a WebView. @@ -296,7 +296,8 @@ abstract class InAppWebViewPlatform extends PlatformInterface { /// /// This function should only be called by the app-facing package. /// Look at using [HttpAuthCredentialDatabase] in `flutter_inappwebview` instead. - PlatformHttpAuthCredentialDatabase createPlatformHttpAuthCredentialDatabaseStatic() { + PlatformHttpAuthCredentialDatabase + createPlatformHttpAuthCredentialDatabaseStatic() { throw UnimplementedError( 'createPlatformHttpAuthCredentialDatabaseStatic is not implemented on the current platform.'); } @@ -393,6 +394,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformTracingController is not implemented on the current platform.'); } + /// Creates a new empty [PlatformTracingController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [TracingController] in `flutter_inappwebview` instead. + PlatformTracingController createPlatformTracingControllerStatic() { + throw UnimplementedError( + 'createPlatformTracingControllerStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformAssetsPathHandler]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart b/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart index 1e4fbb3ed..d3e20fba6 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.dart @@ -30,8 +30,8 @@ class PlatformServiceWorkerControllerCreationParams { ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isClassSupported({TargetPlatform? platform}) => - _PlatformServiceWorkerControllerCreationParamsClassSupported.isClassSupported( - platform: platform); + _PlatformServiceWorkerControllerCreationParamsClassSupported + .isClassSupported(platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformServiceWorkerController} @@ -199,7 +199,7 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { AndroidPlatform( apiName: 'ServiceWorkerWebSettingsCompat.setAllowContentAccess', apiUrl: - 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean)', + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowContentAccess(boolean)', ), ]) Future setAllowContentAccess(bool allow) { @@ -217,7 +217,7 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { AndroidPlatform( apiName: 'ServiceWorkerWebSettingsCompat.setAllowFileAccess', apiUrl: - 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean)', + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setAllowFileAccess(boolean)', ), ]) Future setAllowFileAccess(bool allow) { @@ -235,7 +235,7 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { AndroidPlatform( apiName: 'ServiceWorkerWebSettingsCompat.setBlockNetworkLoads', apiUrl: - 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean)', + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setBlockNetworkLoads(boolean)', ), ]) Future setBlockNetworkLoads(bool flag) { @@ -253,7 +253,7 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { AndroidPlatform( apiName: 'ServiceWorkerWebSettingsCompat.setCacheMode', apiUrl: - 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setCacheMode(int)', + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerWebSettingsCompat#setCacheMode(int)', ), ]) Future setCacheMode(CacheMode mode) { @@ -269,7 +269,7 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isMethodSupported(PlatformServiceWorkerControllerMethod method, - {TargetPlatform? platform}) => + {TargetPlatform? platform}) => _PlatformServiceWorkerControllerMethodSupported.isMethodSupported(method, platform: platform); } @@ -283,7 +283,7 @@ abstract class PlatformServiceWorkerController extends PlatformInterface { AndroidPlatform( apiName: 'ServiceWorkerClientCompat', apiUrl: - 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat', + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat', ), ]) class ServiceWorkerClient { @@ -303,7 +303,7 @@ class ServiceWorkerClient { AndroidPlatform( apiName: 'ServiceWorkerClientCompat.shouldInterceptRequest', apiUrl: - 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat#shouldInterceptRequest(android.webkit.WebResourceRequest)', + 'https://developer.android.com/reference/androidx/webkit/ServiceWorkerClientCompat#shouldInterceptRequest(android.webkit.WebResourceRequest)', ), ]) final Future Function(WebResourceRequest request)? @@ -315,14 +315,14 @@ class ServiceWorkerClient { ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) => - _PlatformServiceWorkerControllerCreationParamsClassSupported.isClassSupported( - platform: platform); + _PlatformServiceWorkerControllerCreationParamsClassSupported + .isClassSupported(platform: platform); ///{@template flutter_inappwebview_platform_interface.ServiceWorkerClient.isPropertySupported} ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} static bool isPropertySupported(ServiceWorkerClientProperty property, - {TargetPlatform? platform}) => + {TargetPlatform? platform}) => _ServiceWorkerClientPropertySupported.isPropertySupported(property, platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart index b26814e28..3e843900a 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart @@ -8,14 +8,28 @@ import 'types/main.dart'; part 'platform_tracing_controller.g.dart'; +///{@template flutter_inappwebview_platform_interface.PlatformTracingControllerCreationParams} /// Object specifying creation parameters for creating a [PlatformTracingController]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformTracingControllerCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), +]) @immutable class PlatformTracingControllerCreationParams { /// Used by the platform implementation to create a new [PlatformTracingController]. const PlatformTracingControllerCreationParams(); + + ///{@template flutter_inappwebview_platform_interface.PlatformTracingControllerCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformTracingControllerCreationParamsClassSupported.isClassSupported( + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformTracingController} @@ -25,10 +39,12 @@ class PlatformTracingControllerCreationParams { /// ///The resulting trace data is sent back as a byte sequence in json format. ///This file can be loaded in "chrome://tracing" for further analysis. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView ([Official API - TracingController](https://developer.android.com/reference/androidx/webkit/TracingController)) ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformTracingController.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'TracingController', apiUrl: 'https://developer.android.com/reference/androidx/webkit/TracingController'), +]) abstract class PlatformTracingController extends PlatformInterface { /// Creates a new [PlatformTracingController] factory PlatformTracingController( @@ -46,6 +62,22 @@ abstract class PlatformTracingController extends PlatformInterface { return tracingController; } + /// Creates a new [PlatformTracingController] + factory PlatformTracingController.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformTracingController tracingControllerStatic = + InAppWebViewPlatform.instance! + .createPlatformTracingControllerStatic(); + PlatformInterface.verify(tracingControllerStatic, _token); + return tracingControllerStatic; + } + /// Used by the platform implementation to create a new /// [PlatformTracingController]. /// @@ -65,10 +97,12 @@ abstract class PlatformTracingController extends PlatformInterface { ///For tracing modes [TracingMode.RECORD_UNTIL_FULL] and [TracingMode.RECORD_CONTINUOUSLY] ///the events are recorded using an internal buffer and flushed to the outputStream ///when [stop] is called. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - TracingController.start](https://developer.android.com/reference/android/webkit/TracingController#start(android.webkit.TracingConfig))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformTracingController.start.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'TracingController.start', apiUrl: 'https://developer.android.com/reference/android/webkit/TracingController#start(android.webkit.TracingConfig)'), + ]) Future start({required TracingSettings settings}) { throw UnimplementedError( 'start is not implemented on the current platform'); @@ -81,24 +115,40 @@ abstract class PlatformTracingController extends PlatformInterface { /// ///Returns `false` if the WebView framework was not tracing at the time of the call, ///`true` otherwise. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - TracingController.stop](https://developer.android.com/reference/android/webkit/TracingController#stop(java.io.OutputStream,%20java.util.concurrent.Executor))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformTracingController.stop.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'TracingController.stop', apiUrl: 'https://developer.android.com/reference/android/webkit/TracingController#stop(java.io.OutputStream,%20java.util.concurrent.Executor)'), + ]) Future stop({String? filePath}) { throw UnimplementedError('stop is not implemented on the current platform'); } ///{@template flutter_inappwebview_platform_interface.PlatformTracingController.isTracing} ///Returns whether the WebView framework is tracing. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - TracingController.isTracing](https://developer.android.com/reference/android/webkit/TracingController#isTracing())) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformTracingController.isTracing.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'TracingController.isTracing', apiUrl: 'https://developer.android.com/reference/android/webkit/TracingController#isTracing()'), + ]) Future isTracing() { throw UnimplementedError( 'isTracing is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformTracingControllerCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + params.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformTracingController.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformTracingControllerMethod method, + {TargetPlatform? platform}) => + _PlatformTracingControllerMethodSupported.isMethodSupported(method, + platform: platform); } List _deserializeCategories(List categories, @@ -138,10 +188,14 @@ List _serializeCategories(List categories, return serializedCategories; } +///{@template flutter_inappwebview_platform_interface.TracingSettings} ///Class that represents the settings used to configure the [PlatformTracingController]. +///{@endtemplate} /// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView ([Official API - TracingConfig](https://developer.android.com/reference/androidx/webkit/TracingConfig)) +///{@macro flutter_inappwebview_platform_interface.TracingSettings.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'TracingConfig', apiUrl: 'https://developer.android.com/reference/androidx/webkit/TracingConfig'), +]) @ExchangeableObject(copyMethod: true) class TracingSettings_ { ///Adds predefined [TracingCategory] and/or custom [String] sets of categories to be included in the trace output. @@ -158,6 +212,11 @@ class TracingSettings_ { ///The tracing mode for this configuration. ///When tracingMode is not set explicitly, the default is [TracingMode.RECORD_CONTINUOUSLY]. + /// + ///{@macro flutter_inappwebview_platform_interface.TracingSettings.tracingMode.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) TracingMode_? tracingMode; @ExchangeableObjectConstructor() @@ -170,4 +229,20 @@ class TracingSettings_ { .contains(false), "categories must contain only String or TracingCategory items"); } + + ///{@template flutter_inappwebview_platform_interface.TracingSettings.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) => + _TracingSettingsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.TracingSettings.isPropertySupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isPropertySupported(TracingSettingsProperty property, + {TargetPlatform? platform}) => + _TracingSettingsPropertySupported.isPropertySupported( + property, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart index 139f29d26..d4f6c20fd 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart @@ -6,10 +6,14 @@ part of 'platform_tracing_controller.dart'; // ExchangeableObjectGenerator // ************************************************************************** +///{@template flutter_inappwebview_platform_interface.TracingSettings} ///Class that represents the settings used to configure the [PlatformTracingController]. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.TracingSettings.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: -///- Android native WebView ([Official API - TracingConfig](https://developer.android.com/reference/androidx/webkit/TracingConfig)) +///- Android WebView ([Official API - TracingConfig](https://developer.android.com/reference/androidx/webkit/TracingConfig)) class TracingSettings { ///Adds predefined [TracingCategory] and/or custom [String] sets of categories to be included in the trace output. /// @@ -23,7 +27,16 @@ class TracingSettings { ///The tracing mode for this configuration. ///When tracingMode is not set explicitly, the default is [TracingMode.RECORD_CONTINUOUSLY]. + /// + ///{@macro flutter_inappwebview_platform_interface.TracingSettings.tracingMode.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView TracingMode? tracingMode; + + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - TracingConfig](https://developer.android.com/reference/androidx/webkit/TracingConfig)) TracingSettings({this.categories = const [], this.tracingMode}) { assert( this @@ -55,6 +68,20 @@ class TracingSettings { return instance; } + ///{@template flutter_inappwebview_platform_interface.TracingSettings.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) => + _TracingSettingsClassSupported.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.TracingSettings.isPropertySupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isPropertySupported(TracingSettingsProperty property, + {TargetPlatform? platform}) => + _TracingSettingsPropertySupported.isPropertySupported(property, + platform: platform); + ///Converts instance to a map. Map toMap({EnumMethod? enumMethod}) { return { @@ -82,3 +109,140 @@ class TracingSettings { return 'TracingSettings{categories: $categories, tracingMode: $tracingMode}'; } } + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformTracingControllerCreationParamsClassSupported + on PlatformTracingControllerCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformTracingControllerCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [PlatformTracingControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); + } +} + +extension _PlatformTracingControllerClassSupported + on PlatformTracingController { + ///{@template flutter_inappwebview_platform_interface.PlatformTracingController.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - TracingController](https://developer.android.com/reference/androidx/webkit/TracingController)) + /// + ///Use the [PlatformTracingController.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformTracingController]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformTracingControllerMethod { + ///Can be used to check if the [PlatformTracingController.isTracing] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformTracingController.isTracing.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - TracingController.isTracing](https://developer.android.com/reference/android/webkit/TracingController#isTracing())) + /// + ///Use the [PlatformTracingController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + isTracing, + + ///Can be used to check if the [PlatformTracingController.start] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformTracingController.start.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - TracingController.start](https://developer.android.com/reference/android/webkit/TracingController#start(android.webkit.TracingConfig))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [settings]: all platforms + /// + ///Use the [PlatformTracingController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + start, + + ///Can be used to check if the [PlatformTracingController.stop] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformTracingController.stop.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - TracingController.stop](https://developer.android.com/reference/android/webkit/TracingController#stop(java.io.OutputStream,%20java.util.concurrent.Executor))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [filePath]: all platforms + /// + ///Use the [PlatformTracingController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + stop, +} + +extension _PlatformTracingControllerMethodSupported + on PlatformTracingController { + static bool isMethodSupported(PlatformTracingControllerMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformTracingControllerMethod.isTracing: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformTracingControllerMethod.start: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformTracingControllerMethod.stop: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _TracingSettingsClassSupported on TracingSettings { + ///{@template flutter_inappwebview_platform_interface.TracingSettings.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - TracingConfig](https://developer.android.com/reference/androidx/webkit/TracingConfig)) + /// + ///Use the [TracingSettings.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [TracingSettings]'s properties that can be used to check i they are supported or not by the current platform. +enum TracingSettingsProperty { + ///Can be used to check if the [TracingSettings.tracingMode] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.TracingSettings.tracingMode.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [TracingSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + tracingMode, +} + +extension _TracingSettingsPropertySupported on TracingSettings { + static bool isPropertySupported(TracingSettingsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case TracingSettingsProperty.tracingMode: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index 4bd9a048e..134182965 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -151,6 +151,15 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { return _PlatformServiceWorkerController.static(); } + + /// Creates a new empty [PlatformTracingController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [TracingController] in `flutter_inappwebview` instead. + @override + PlatformTracingController createPlatformTracingControllerStatic() { + return _PlatformTracingController.static(); + } } class _PlatformInAppBrowser extends PlatformInAppBrowser { @@ -215,3 +224,13 @@ class _PlatformServiceWorkerController extends PlatformServiceWorkerController { @override ServiceWorkerClient? get serviceWorkerClient => throw UnimplementedError(); } + +class _PlatformTracingController extends PlatformTracingController { + _PlatformTracingController(PlatformTracingControllerCreationParams params) + : super.implementation(params); + static final _PlatformTracingController _staticValue = + _PlatformTracingController( + const PlatformTracingControllerCreationParams()); + + factory _PlatformTracingController.static() => _staticValue; +} diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index bed83f993..45865022f 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -219,6 +219,15 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { return _PlatformServiceWorkerController.static(); } + + /// Creates a new empty [PlatformTracingController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [TracingController] in `flutter_inappwebview` instead. + @override + PlatformTracingController createPlatformTracingControllerStatic() { + return _PlatformTracingController.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -274,3 +283,13 @@ class _PlatformServiceWorkerController extends PlatformServiceWorkerController { @override ServiceWorkerClient? get serviceWorkerClient => throw UnimplementedError(); } + +class _PlatformTracingController extends PlatformTracingController { + _PlatformTracingController(PlatformTracingControllerCreationParams params) + : super.implementation(params); + static final _PlatformTracingController _staticValue = + _PlatformTracingController( + const PlatformTracingControllerCreationParams()); + + factory _PlatformTracingController.static() => _staticValue; +} From bc3197fcb059e102988e6c85721c53c1e38cef81 Mon Sep 17 00:00:00 2001 From: roho Date: Tue, 10 Dec 2024 10:27:58 +0100 Subject: [PATCH 148/181] Fixed recursive calling toMap in AndroidInternalStoragePathHandler --- flutter_inappwebview_android/lib/src/webview_asset_loader.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter_inappwebview_android/lib/src/webview_asset_loader.dart b/flutter_inappwebview_android/lib/src/webview_asset_loader.dart index 8c3d0320f..f3eb4a9e7 100644 --- a/flutter_inappwebview_android/lib/src/webview_asset_loader.dart +++ b/flutter_inappwebview_android/lib/src/webview_asset_loader.dart @@ -195,7 +195,7 @@ class AndroidInternalStoragePathHandler @override Map toMap({EnumMethod? enumMethod}) { - return {...toMap(), 'directory': directory}; + return {...super.toMap(), 'directory': directory}; } } From 93a04a5f3a284ff20dae5dff90027f1f78c15f49 Mon Sep 17 00:00:00 2001 From: imoyakin Date: Sat, 28 Dec 2024 08:01:41 +0800 Subject: [PATCH 149/181] =?UTF-8?q?=F0=9F=90=9B=20fix=20macos:=20message?= =?UTF-8?q?=20extraction=20logic=20in=20userContentController=20data=20han?= =?UTF-8?q?dling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../macos/Classes/InAppWebView/InAppWebView.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift b/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift index 425ce3551..1aa41bfc8 100755 --- a/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift +++ b/flutter_inappwebview_macos/macos/Classes/InAppWebView/InAppWebView.swift @@ -2317,7 +2317,7 @@ public class InAppWebView: WKWebView, WKUIDelegate, let jsonArgs = try? JSONSerialization.jsonObject(with: data, options: .mutableContainers) as? [[String: Any]] if let jsonData = jsonArgs?.first, let jsObjectName = jsonData["jsObjectName"] as? String { var webMessage: WebMessage? = nil - if let webMessageMap = body["message"] as? [String : Any?] { + if let webMessageMap = jsonData["message"] as? [String : Any?] { webMessage = WebMessage.fromMap(map: webMessageMap) } From d92bb6c4e1d0edadcb7c45c36b5fefcb2d484330 Mon Sep 17 00:00:00 2001 From: lai Date: Tue, 31 Dec 2024 16:07:47 +0800 Subject: [PATCH 150/181] fix #2484, Remove not-empty assert for Cookie.value --- .../cookie_manager/set_get_delete.dart | 10 +++++++++- .../lib/src/cookie_manager.dart | 1 - flutter_inappwebview_ios/lib/src/cookie_manager.dart | 1 - flutter_inappwebview_macos/lib/src/cookie_manager.dart | 1 - flutter_inappwebview_web/lib/src/cookie_manager.dart | 1 - .../lib/src/cookie_manager.dart | 1 - 6 files changed, 9 insertions(+), 6 deletions(-) diff --git a/flutter_inappwebview/example/integration_test/cookie_manager/set_get_delete.dart b/flutter_inappwebview/example/integration_test/cookie_manager/set_get_delete.dart index 4c6d04d2b..13f637793 100644 --- a/flutter_inappwebview/example/integration_test/cookie_manager/set_get_delete.dart +++ b/flutter_inappwebview/example/integration_test/cookie_manager/set_get_delete.dart @@ -55,11 +55,19 @@ void setGetDelete() { expect(await cookieManager.removeSessionCookies(), isTrue); } - await cookieManager.setCookie(url: url, name: "myCookie", value: "myValue"); + // Empty cookie-value is allowed according to https://datatracker.ietf.org/doc/html/rfc6265#section-4.1.1 + await cookieManager.setCookie(url: url, name: "myCookie", value: ""); List cookies = await cookieManager.getCookies(url: url); expect(cookies, isNotEmpty); Cookie? cookie = await cookieManager.getCookie(url: url, name: "myCookie"); + expect(cookie?.value.toString(), ""); + + await cookieManager.setCookie(url: url, name: "myCookie", value: "myValue"); + cookies = await cookieManager.getCookies(url: url); + expect(cookies, isNotEmpty); + + cookie = await cookieManager.getCookie(url: url, name: "myCookie"); expect(cookie?.value.toString(), "myValue"); expect( diff --git a/flutter_inappwebview_android/lib/src/cookie_manager.dart b/flutter_inappwebview_android/lib/src/cookie_manager.dart index 86ae5fe81..af6dc9a5e 100755 --- a/flutter_inappwebview_android/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_android/lib/src/cookie_manager.dart @@ -76,7 +76,6 @@ class AndroidCookieManager extends PlatformCookieManager PlatformInAppWebViewController? webViewController}) async { assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - assert(value.isNotEmpty); assert(path.isNotEmpty); Map args = {}; diff --git a/flutter_inappwebview_ios/lib/src/cookie_manager.dart b/flutter_inappwebview_ios/lib/src/cookie_manager.dart index 2c0eea9cd..faad567c6 100755 --- a/flutter_inappwebview_ios/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_ios/lib/src/cookie_manager.dart @@ -80,7 +80,6 @@ class IOSCookieManager extends PlatformCookieManager with ChannelController { assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - assert(value.isNotEmpty); assert(path.isNotEmpty); if (await _shouldUseJavascript()) { diff --git a/flutter_inappwebview_macos/lib/src/cookie_manager.dart b/flutter_inappwebview_macos/lib/src/cookie_manager.dart index 6078cb526..ecfd306de 100755 --- a/flutter_inappwebview_macos/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_macos/lib/src/cookie_manager.dart @@ -80,7 +80,6 @@ class MacOSCookieManager extends PlatformCookieManager with ChannelController { assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - assert(value.isNotEmpty); assert(path.isNotEmpty); if (await _shouldUseJavascript()) { diff --git a/flutter_inappwebview_web/lib/src/cookie_manager.dart b/flutter_inappwebview_web/lib/src/cookie_manager.dart index a173b471e..7686f7699 100755 --- a/flutter_inappwebview_web/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_web/lib/src/cookie_manager.dart @@ -81,7 +81,6 @@ class WebPlatformCookieManager extends PlatformCookieManager assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - assert(value.isNotEmpty); assert(path.isNotEmpty); await _setCookieWithJavaScript( diff --git a/flutter_inappwebview_windows/lib/src/cookie_manager.dart b/flutter_inappwebview_windows/lib/src/cookie_manager.dart index f77c3bf49..386082d03 100644 --- a/flutter_inappwebview_windows/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_windows/lib/src/cookie_manager.dart @@ -89,7 +89,6 @@ class WindowsCookieManager extends PlatformCookieManager PlatformInAppWebViewController? webViewController}) async { assert(url.toString().isNotEmpty); assert(name.isNotEmpty); - assert(value.isNotEmpty); assert(path.isNotEmpty); Map args = {}; From 7192fde5b390d4fec0c15862cbaef009d2ada4bb Mon Sep 17 00:00:00 2001 From: Muccy Date: Fri, 21 Feb 2025 20:34:29 +0100 Subject: [PATCH 151/181] ios: fix gesture recognition delay prevention for latest Flutter versions --- .../ios/Classes/InAppWebView/InAppWebView.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift index 43ac03776..e6e6d771b 100755 --- a/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift +++ b/flutter_inappwebview_ios/ios/Classes/InAppWebView/InAppWebView.swift @@ -247,7 +247,8 @@ public class InAppWebView: WKWebView, UIScrollViewDelegate, WKUIDelegate, // https://github.com/pichillilorenzo/flutter_inappwebview/pull/1665 if preventGestureDelay, let gestures = superview?.superview?.gestureRecognizers { for gesture in gestures { - if NSStringFromClass(type(of: gesture)) == "DelayingGestureRecognizer" { + let gestureType = NSStringFromClass(type(of: gesture)) + if gestureType == "DelayingGestureRecognizer" || gestureType == "FlutterDelayingGestureRecognizer" { gesture.isEnabled = false } } From 6a5afe137a5e63d28b52f903541de50c8895d36d Mon Sep 17 00:00:00 2001 From: momadvisor <77181890+momadvisor@users.noreply.github.com> Date: Tue, 25 Feb 2025 22:06:06 +0900 Subject: [PATCH 152/181] Update in_app_webview_manager.cpp --- .../windows/in_app_webview/in_app_webview_manager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.cpp b/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.cpp index 8a03dbd33..ec013646e 100644 --- a/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.cpp +++ b/flutter_inappwebview_windows/windows/in_app_webview/in_app_webview_manager.cpp @@ -54,6 +54,7 @@ namespace flutter_inappwebview_plugin windowClass_.lpszClassName = CustomPlatformView::CLASS_NAME; windowClass_.lpfnWndProc = &DefWindowProc; + windowClass_.style = CS_NOCLOSE; RegisterClass(&windowClass_); } From c43c1d01442ee16d4f9d4953beecc1b1f0bec463 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Wed, 5 Mar 2025 10:31:34 +0100 Subject: [PATCH 153/181] added support methods for FindInteractionController class --- .../find_interaction_controller.dart | 17 + .../find_interaction_controller.dart | 9 + .../lib/src/inappwebview_platform.dart | 9 + .../find_interaction_controller.dart | 9 + .../lib/src/inappwebview_platform.dart | 9 + .../find_interaction_controller.dart | 9 + .../lib/src/inappwebview_platform.dart | 9 + .../platform_chrome_safari_browser.dart | 2 +- .../platform_find_interaction_controller.dart | 247 +++++++++------ ...latform_find_interaction_controller.g.dart | 290 ++++++++++++++++++ .../lib/src/inappwebview_platform.dart | 9 + .../lib/src/inappwebview_platform.dart | 19 ++ .../lib/src/inappwebview_platform.dart | 19 ++ 13 files changed, 564 insertions(+), 93 deletions(-) create mode 100644 flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.g.dart diff --git a/flutter_inappwebview/lib/src/find_interaction/find_interaction_controller.dart b/flutter_inappwebview/lib/src/find_interaction/find_interaction_controller.dart index 35ad7fa90..5624af98d 100644 --- a/flutter_inappwebview/lib/src/find_interaction/find_interaction_controller.dart +++ b/flutter_inappwebview/lib/src/find_interaction/find_interaction_controller.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController} @@ -65,4 +66,20 @@ class FindInteractionController { ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.dispose} void dispose({bool isKeepAlive = false}) => platform.dispose(); + + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformFindInteractionController.static().isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.isPropertySupported} + static bool isPropertySupported(PlatformFindInteractionControllerCreationParamsProperty property, + {TargetPlatform? platform}) => + PlatformFindInteractionController.static() + .isPropertySupported(property, platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.isMethodSupported} + static bool isMethodSupported(PlatformFindInteractionControllerMethod method, + {TargetPlatform? platform}) => + PlatformFindInteractionController.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_android/lib/src/find_interaction/find_interaction_controller.dart b/flutter_inappwebview_android/lib/src/find_interaction/find_interaction_controller.dart index 943176a50..900871554 100644 --- a/flutter_inappwebview_android/lib/src/find_interaction/find_interaction_controller.dart +++ b/flutter_inappwebview_android/lib/src/find_interaction/find_interaction_controller.dart @@ -37,6 +37,15 @@ class AndroidFindInteractionController extends PlatformFindInteractionController .fromPlatformFindInteractionControllerCreationParams(params), ); + static final AndroidFindInteractionController _staticValue = + AndroidFindInteractionController( + AndroidFindInteractionControllerCreationParams()); + + /// Provide static access. + factory AndroidFindInteractionController.static() { + return _staticValue; + } + _debugLog(String method, dynamic args) { debugLog( className: this.runtimeType.toString(), diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index d8504ea7d..c7cad0afe 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -95,6 +95,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidFindInteractionController(params); } + /// Creates a new empty [AndroidFindInteractionController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. + @override + AndroidFindInteractionController createPlatformFindInteractionControllerStatic() { + return AndroidFindInteractionController.static(); + } + /// Creates a new [AndroidPrintJobController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_ios/lib/src/find_interaction/find_interaction_controller.dart b/flutter_inappwebview_ios/lib/src/find_interaction/find_interaction_controller.dart index b262a12f1..d1d080d45 100644 --- a/flutter_inappwebview_ios/lib/src/find_interaction/find_interaction_controller.dart +++ b/flutter_inappwebview_ios/lib/src/find_interaction/find_interaction_controller.dart @@ -37,6 +37,15 @@ class IOSFindInteractionController extends PlatformFindInteractionController .fromPlatformFindInteractionControllerCreationParams(params), ); + static final IOSFindInteractionController _staticValue = + IOSFindInteractionController( + IOSFindInteractionControllerCreationParams()); + + /// Provide static access. + factory IOSFindInteractionController.static() { + return _staticValue; + } + _debugLog(String method, dynamic args) { debugLog( className: this.runtimeType.toString(), diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index 6c0565161..d26254b6d 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -91,6 +91,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSFindInteractionController(params); } + /// Creates a new empty [IOSFindInteractionController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. + @override + IOSFindInteractionController createPlatformFindInteractionControllerStatic() { + return IOSFindInteractionController.static(); + } + /// Creates a new [IOSPrintJobController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_macos/lib/src/find_interaction/find_interaction_controller.dart b/flutter_inappwebview_macos/lib/src/find_interaction/find_interaction_controller.dart index ca291cbc4..fde68c033 100644 --- a/flutter_inappwebview_macos/lib/src/find_interaction/find_interaction_controller.dart +++ b/flutter_inappwebview_macos/lib/src/find_interaction/find_interaction_controller.dart @@ -37,6 +37,15 @@ class MacOSFindInteractionController extends PlatformFindInteractionController .fromPlatformFindInteractionControllerCreationParams(params), ); + static final MacOSFindInteractionController _staticValue = + MacOSFindInteractionController( + MacOSFindInteractionControllerCreationParams()); + + /// Provide static access. + factory MacOSFindInteractionController.static() { + return _staticValue; + } + _debugLog(String method, dynamic args) { debugLog( className: this.runtimeType.toString(), diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index 417545122..e544f4632 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -89,6 +89,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSFindInteractionController(params); } + /// Creates a new empty [MacOSFindInteractionController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. + @override + MacOSFindInteractionController createPlatformFindInteractionControllerStatic() { + return MacOSFindInteractionController.static(); + } + /// Creates a new [MacOSPrintJobController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart index 9eb3caa92..c63d1ff0b 100755 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.dart @@ -589,7 +589,7 @@ abstract class PlatformChromeSafariBrowser extends PlatformInterface platform: platform); ///{@template flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isMethodSupported} - ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isMethodSupported(PlatformChromeSafariBrowserMethod method, {TargetPlatform? platform}) => diff --git a/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart index cad92e443..093b585b7 100644 --- a/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart @@ -1,4 +1,5 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_platform_interface/src/types/disposable.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import '../in_app_webview/in_app_webview_settings.dart'; @@ -6,33 +7,78 @@ import '../debug_logging_settings.dart'; import '../inappwebview_platform.dart'; import '../types/main.dart'; +part 'platform_find_interaction_controller.g.dart'; + +///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams} /// Object specifying creation parameters for creating a [PlatformFindInteractionController]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform() +]) @immutable class PlatformFindInteractionControllerCreationParams { /// Used by the platform implementation to create a new [PlatformFindInteractionController]. const PlatformFindInteractionControllerCreationParams( {this.onFindResultReceived}); - ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.onFindResultReceived} + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.onFindResultReceived} + ///Event fired as find-on-page operations progress. + ///The listener may be notified multiple times while the operation is underway, and the [numberOfMatches] value should not be considered final unless [isDoneCounting] is true. + /// + ///[activeMatchOrdinal] represents the zero-based ordinal of the currently selected match. + /// + ///[numberOfMatches] represents how many matches have been found. + /// + ///[isDoneCounting] whether the find operation has actually completed. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.onFindResultReceived.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'WebView.FindListener.onFindResultReceived', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView.FindListener#onFindResultReceived(int,%20int,%20boolean)'), + IOSPlatform(note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, this event will not be called.'), + MacOSPlatform() + ]) final void Function( PlatformFindInteractionController controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting)? onFindResultReceived; + + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformFindInteractionControllerCreationParamsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported(PlatformFindInteractionControllerCreationParamsProperty property, + {TargetPlatform? platform}) => + _PlatformFindInteractionControllerCreationParamsPropertySupported.isPropertySupported( + property, + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController} ///This class represents the controller used by the `WebView` to add ///text-finding capabilities, such as the "Find on page" feature. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform() +]) abstract class PlatformFindInteractionController extends PlatformInterface implements Disposable { ///Debug settings. @@ -55,6 +101,22 @@ abstract class PlatformFindInteractionController extends PlatformInterface return webViewControllerDelegate; } + /// Creates a new [PlatformFindInteractionController] + factory PlatformFindInteractionController.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformFindInteractionController findInteractionControllerStatic = + InAppWebViewPlatform.instance! + .createPlatformFindInteractionControllerStatic(); + PlatformInterface.verify(findInteractionControllerStatic, _token); + return findInteractionControllerStatic; + } + /// Used by the platform implementation to create a new [PlatformFindInteractionController]. /// /// Should only be used by platform implementations because they can't extend @@ -68,23 +130,9 @@ abstract class PlatformFindInteractionController extends PlatformInterface /// The parameters used to initialize the [PlatformFindInteractionController]. final PlatformFindInteractionControllerCreationParams params; - ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.onFindResultReceived} - ///Event fired as find-on-page operations progress. - ///The listener may be notified multiple times while the operation is underway, and the [numberOfMatches] value should not be considered final unless [isDoneCounting] is true. + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.onFindResultReceived} /// - ///[activeMatchOrdinal] represents the zero-based ordinal of the currently selected match. - /// - ///[numberOfMatches] represents how many matches have been found. - /// - ///[isDoneCounting] whether the find operation has actually completed. - /// - ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, this event will not be called. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.FindListener.onFindResultReceived](https://developer.android.com/reference/android/webkit/WebView.FindListener#onFindResultReceived(int,%20int,%20boolean))) - ///- iOS - ///- MacOS - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.onFindResultReceived.supported_platforms} void Function(PlatformFindInteractionController controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting)? get onFindResultReceived => params.onFindResultReceived; @@ -93,18 +141,14 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///Finds all instances of find on the page and highlights them. Notifies [PlatformFindInteractionController.onFindResultReceived] listener. /// ///[find] represents the string to find. - /// - ///**NOTE**: on Android native WebView, it finds all instances asynchronously. Successive calls to this will cancel any pending searches. - /// - ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, - ///it uses the built-in find interaction native UI, - ///otherwise this is implemented using CSS and Javascript. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.findAllAsync](https://developer.android.com/reference/android/webkit/WebView#findAllAsync(java.lang.String))) - ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2) with [Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.findAll.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'WebView.findAllAsync', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#findAllAsync(java.lang.String)', note: 'It finds all instances asynchronously. Successive calls to this will cancel any pending searches.'), + IOSPlatform(note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2) with [Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)'), + MacOSPlatform() + ]) Future findAll({String? find}) { throw UnimplementedError( 'findAll is not implemented on the current platform'); @@ -114,16 +158,14 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///Highlights and scrolls to the next match found by [findAll]. Notifies [PlatformFindInteractionController.onFindResultReceived] listener. /// ///[forward] represents the direction to search. The default value is `true`, meaning forward. - /// - ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, - ///it uses the built-in find interaction native UI, - ///otherwise this is implemented using CSS and Javascript. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.findNext](https://developer.android.com/reference/android/webkit/WebView#findNext(boolean))) - ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.findNext](https://developer.apple.com/documentation/uikit/uifindinteraction/3975829-findnext?changes=_2) and ([Official API - UIFindInteraction.findPrevious](https://developer.apple.com/documentation/uikit/uifindinteraction/3975830-findprevious?changes=_2))) - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.findNext.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'WebView.findNext', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#findNext(boolean)'), + IOSPlatform(note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.findNext](https://developer.apple.com/documentation/uikit/uifindinteraction/3975829-findnext?changes=_2) and ([Official API - UIFindInteraction.findPrevious](https://developer.apple.com/documentation/uikit/uifindinteraction/3975830-findprevious?changes=_2)'), + MacOSPlatform() + ]) Future findNext({bool forward = true}) { throw UnimplementedError( 'findNext is not implemented on the current platform'); @@ -131,16 +173,14 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.clearMatches} ///Clears the highlighting surrounding text matches created by [findAll]. - /// - ///**NOTE**: on iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true`, - ///it uses the built-in find interaction native UI, - ///otherwise this is implemented using CSS and Javascript. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebView.clearMatches](https://developer.android.com/reference/android/webkit/WebView#clearMatches())) - ///- iOS (if [InAppWebViewSettings.isFindInteractionEnabled] is `true`: [Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)) - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.clearMatches.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'WebView.clearMatches', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#clearMatches()'), + IOSPlatform(note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)'), + MacOSPlatform() + ]) Future clearMatches() { throw UnimplementedError( 'clearMatches is not implemented on the current platform'); @@ -148,15 +188,14 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.setSearchText} ///Pre-populate the search text to be used. - /// - ///On iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true, - ///it will pre-populate the system find panel's search text field with a search query. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.setSearchText.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(apiName: 'UIFindInteraction.searchText', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2', note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it will pre-populate the system find panel\'s search text field with a search query.'), + MacOSPlatform() + ]) Future setSearchText(String? searchText) { throw UnimplementedError( 'setSearchText is not implemented on the current platform'); @@ -164,15 +203,14 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.getSearchText} ///Get the search text used. - /// - ///On iOS, if [InAppWebViewSettings.isFindInteractionEnabled] is `true, - ///it will get the system find panel's search text field value. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)) - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.getSearchText.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(apiName: 'UIFindInteraction.getSearchText', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2', note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it will get the system find panel\'s search text field value.'), + MacOSPlatform() + ]) Future getSearchText() { throw UnimplementedError( 'getSearchText is not implemented on the current platform'); @@ -180,12 +218,12 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.isFindNavigatorVisible} ///A Boolean value that indicates when the find panel displays onscreen. - /// - ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - UIFindInteraction.isFindNavigatorVisible](https://developer.apple.com/documentation/uikit/uifindinteraction/3975828-isfindnavigatorvisible?changes=_2)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.isFindNavigatorVisible.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(apiName: 'UIFindInteraction.isFindNavigatorVisible', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975828-isfindnavigatorvisible?changes=_2', note: 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), + ]) Future isFindNavigatorVisible() { throw UnimplementedError( 'isFindNavigatorVisible is not implemented on the current platform'); @@ -193,12 +231,12 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.updateResultCount} ///Updates the results the interface displays for the active search. - /// - ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - UIFindInteraction.updateResultCount](https://developer.apple.com/documentation/uikit/uifindinteraction/3975835-updateresultcount?changes=_2)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.updateResultCount.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(apiName: 'UIFindInteraction.updateResultCount', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975835-updateresultcount?changes=_2', note: 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), + ]) Future updateResultCount() { throw UnimplementedError( 'updateResultCount is not implemented on the current platform'); @@ -206,12 +244,12 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.presentFindNavigator} ///Begins a search, displaying the find panel. - /// - ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.presentFindNavigator.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(apiName: 'UIFindInteraction.presentFindNavigator', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2', note: 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), + ]) Future presentFindNavigator() { throw UnimplementedError( 'presentFindNavigator is not implemented on the current platform'); @@ -219,12 +257,12 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.dismissFindNavigator} ///Dismisses the find panel, if present. - /// - ///**NOTE**: available only on iOS and only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.dismissFindNavigator.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(apiName: 'UIFindInteraction.dismissFindNavigator', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2', note: 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), + ]) Future dismissFindNavigator() { throw UnimplementedError( 'dismissFindNavigator is not implemented on the current platform'); @@ -232,12 +270,14 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.getActiveFindSession} ///If there's a currently active find session, returns the active find session. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ([Official API - UIFindInteraction.activeFindSession](https://developer.apple.com/documentation/uikit/uifindinteraction/3975825-activefindsession?changes=_7____4_8&language=objc)) - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.getActiveFindSession.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(apiName: 'UIFindInteraction.activeFindSession', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975825-activefindsession?changes=_7____4_8&language=objc'), + MacOSPlatform() + ]) Future getActiveFindSession() { throw UnimplementedError( 'getActiveFindSession is not implemented on the current platform'); @@ -246,9 +286,32 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.dispose} ///Disposes the controller. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.dispose.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform() + ]) @override void dispose({bool isKeepAlive = false}) { throw UnimplementedError( 'dispose is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + params.isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.isPropertySupported} + bool isPropertySupported(PlatformFindInteractionControllerCreationParamsProperty property, {TargetPlatform? platform}) => + params.isPropertySupported(property, platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformFindInteractionControllerMethod method, + {TargetPlatform? platform}) => + _PlatformFindInteractionControllerMethodSupported.isMethodSupported(method, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.g.dart new file mode 100644 index 000000000..33caae367 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.g.dart @@ -0,0 +1,290 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_find_interaction_controller.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformFindInteractionControllerCreationParamsClassSupported + on PlatformFindInteractionControllerCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformFindInteractionControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformFindInteractionControllerCreationParams]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformFindInteractionControllerCreationParamsProperty { + ///Can be used to check if the [PlatformFindInteractionControllerCreationParams.onFindResultReceived] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.onFindResultReceived.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebView.FindListener.onFindResultReceived](https://developer.android.com/reference/android/webkit/WebView.FindListener#onFindResultReceived(int,%20int,%20boolean))) + ///- iOS WKWebView: + /// - If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, this event will not be called. + ///- macOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [controller]: all platforms + ///- [activeMatchOrdinal]: all platforms + ///- [numberOfMatches]: all platforms + ///- [isDoneCounting]: all platforms + /// + ///Use the [PlatformFindInteractionControllerCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + onFindResultReceived, +} + +extension _PlatformFindInteractionControllerCreationParamsPropertySupported + on PlatformFindInteractionControllerCreationParams { + static bool isPropertySupported( + PlatformFindInteractionControllerCreationParamsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformFindInteractionControllerCreationParamsProperty + .onFindResultReceived: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformFindInteractionControllerClassSupported + on PlatformFindInteractionController { + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformFindInteractionController.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformFindInteractionController]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformFindInteractionControllerMethod { + ///Can be used to check if the [PlatformFindInteractionController.clearMatches] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.clearMatches.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebView.clearMatches](https://developer.android.com/reference/android/webkit/WebView#clearMatches())) + ///- iOS WKWebView: + /// - If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2) + ///- macOS WKWebView + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + clearMatches, + + ///Can be used to check if the [PlatformFindInteractionController.dismissFindNavigator] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.dismissFindNavigator.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView ([Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)): + /// - Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dismissFindNavigator, + + ///Can be used to check if the [PlatformFindInteractionController.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [isKeepAlive]: all platforms + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, + + ///Can be used to check if the [PlatformFindInteractionController.findAll] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.findAll.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebView.findAllAsync](https://developer.android.com/reference/android/webkit/WebView#findAllAsync(java.lang.String))): + /// - It finds all instances asynchronously. Successive calls to this will cancel any pending searches. + ///- iOS WKWebView: + /// - If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2) with [Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2) + ///- macOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [find]: all platforms + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + findAll, + + ///Can be used to check if the [PlatformFindInteractionController.findNext] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.findNext.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebView.findNext](https://developer.android.com/reference/android/webkit/WebView#findNext(boolean))) + ///- iOS WKWebView: + /// - If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.findNext](https://developer.apple.com/documentation/uikit/uifindinteraction/3975829-findnext?changes=_2) and ([Official API - UIFindInteraction.findPrevious](https://developer.apple.com/documentation/uikit/uifindinteraction/3975830-findprevious?changes=_2) + ///- macOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [forward]: all platforms + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + findNext, + + ///Can be used to check if the [PlatformFindInteractionController.getActiveFindSession] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.getActiveFindSession.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView ([Official API - UIFindInteraction.activeFindSession](https://developer.apple.com/documentation/uikit/uifindinteraction/3975825-activefindsession?changes=_7____4_8&language=objc)) + ///- macOS WKWebView + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getActiveFindSession, + + ///Can be used to check if the [PlatformFindInteractionController.getSearchText] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.getSearchText.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView ([Official API - UIFindInteraction.getSearchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)): + /// - If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it will get the system find panel's search text field value. + ///- macOS WKWebView + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getSearchText, + + ///Can be used to check if the [PlatformFindInteractionController.isFindNavigatorVisible] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.isFindNavigatorVisible.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView ([Official API - UIFindInteraction.isFindNavigatorVisible](https://developer.apple.com/documentation/uikit/uifindinteraction/3975828-isfindnavigatorvisible?changes=_2)): + /// - Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + isFindNavigatorVisible, + + ///Can be used to check if the [PlatformFindInteractionController.presentFindNavigator] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.presentFindNavigator.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView ([Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2)): + /// - Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + presentFindNavigator, + + ///Can be used to check if the [PlatformFindInteractionController.setSearchText] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.setSearchText.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView ([Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)): + /// - If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it will pre-populate the system find panel's search text field with a search query. + ///- macOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [searchText]: all platforms + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setSearchText, + + ///Can be used to check if the [PlatformFindInteractionController.updateResultCount] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.updateResultCount.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView ([Official API - UIFindInteraction.updateResultCount](https://developer.apple.com/documentation/uikit/uifindinteraction/3975835-updateresultcount?changes=_2)): + /// - Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`. + /// + ///Use the [PlatformFindInteractionController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + updateResultCount, +} + +extension _PlatformFindInteractionControllerMethodSupported + on PlatformFindInteractionController { + static bool isMethodSupported(PlatformFindInteractionControllerMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformFindInteractionControllerMethod.clearMatches: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformFindInteractionControllerMethod.dismissFindNavigator: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PlatformFindInteractionControllerMethod.dispose: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformFindInteractionControllerMethod.findAll: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformFindInteractionControllerMethod.findNext: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformFindInteractionControllerMethod.getActiveFindSession: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformFindInteractionControllerMethod.getSearchText: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformFindInteractionControllerMethod.isFindNavigatorVisible: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PlatformFindInteractionControllerMethod.presentFindNavigator: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PlatformFindInteractionControllerMethod.setSearchText: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformFindInteractionControllerMethod.updateResultCount: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index c600db0de..c3c5fcd23 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -121,6 +121,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformFindInteractionController is not implemented on the current platform.'); } + /// Creates a new empty [PlatformFindInteractionController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. + PlatformFindInteractionController createPlatformFindInteractionControllerStatic() { + throw UnimplementedError( + 'createPlatformFindInteractionControllerStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformPrintJobController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index 134182965..018372569 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -160,6 +160,15 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { PlatformTracingController createPlatformTracingControllerStatic() { return _PlatformTracingController.static(); } + + /// Creates a new empty [PlatformFindInteractionController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. + @override + PlatformFindInteractionController createPlatformFindInteractionControllerStatic() { + return _PlatformFindInteractionController.static(); + } } class _PlatformInAppBrowser extends PlatformInAppBrowser { @@ -234,3 +243,13 @@ class _PlatformTracingController extends PlatformTracingController { factory _PlatformTracingController.static() => _staticValue; } + +class _PlatformFindInteractionController extends PlatformFindInteractionController { + _PlatformFindInteractionController(PlatformFindInteractionControllerCreationParams params) + : super.implementation(params); + static final _PlatformFindInteractionController _staticValue = + _PlatformFindInteractionController( + const PlatformFindInteractionControllerCreationParams()); + + factory _PlatformFindInteractionController.static() => _staticValue; +} diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index 45865022f..c6cd9eacb 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -228,6 +228,15 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { PlatformTracingController createPlatformTracingControllerStatic() { return _PlatformTracingController.static(); } + + /// Creates a new empty [PlatformFindInteractionController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. + @override + PlatformFindInteractionController createPlatformFindInteractionControllerStatic() { + return _PlatformFindInteractionController.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -293,3 +302,13 @@ class _PlatformTracingController extends PlatformTracingController { factory _PlatformTracingController.static() => _staticValue; } + +class _PlatformFindInteractionController extends PlatformFindInteractionController { + _PlatformFindInteractionController(PlatformFindInteractionControllerCreationParams params) + : super.implementation(params); + static final _PlatformFindInteractionController _staticValue = + _PlatformFindInteractionController( + const PlatformFindInteractionControllerCreationParams()); + + factory _PlatformFindInteractionController.static() => _staticValue; +} From 48e93c9833006a0a410106fcc84ae14a955130f9 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Wed, 1 Oct 2025 18:50:29 +0200 Subject: [PATCH 154/181] added support methods for PrintJobController class --- flutter_inappwebview/CHANGELOG.md | 2 +- .../example/android/app/build.gradle | 5 +- .../example/android/settings.gradle | 2 +- .../ios/Flutter/AppFrameworkInfo.plist | 2 +- flutter_inappwebview/example/ios/Podfile | 2 +- .../ios/Runner.xcodeproj/project.pbxproj | 4 +- .../xcshareddata/xcschemes/Runner.xcscheme | 3 + flutter_inappwebview/example/macos/Podfile | 2 +- .../macos/Runner.xcodeproj/project.pbxproj | 6 +- .../xcshareddata/xcschemes/Runner.xcscheme | 1 + .../example/macos/Runner/AppDelegate.swift | 4 + .../src/print_job/print_job_controller.dart | 17 ++ .../example/pubspec.lock | 11 +- .../lib/src/inappwebview_platform.dart | 20 ++ flutter_inappwebview_ios/example/pubspec.lock | 11 +- .../lib/src/inappwebview_platform.dart | 22 +- .../example/pubspec.lock | 11 +- .../lib/src/inappwebview_platform.dart | 22 +- .../lib/src/inappwebview_platform.dart | 9 + .../platform_print_job_controller.dart | 166 +++++++++++---- .../platform_print_job_controller.g.dart | 199 ++++++++++++++++++ .../lib/src/inappwebview_platform.dart | 20 ++ .../example/pubspec.lock | 9 +- .../lib/src/inappwebview_platform.dart | 20 ++ 24 files changed, 495 insertions(+), 75 deletions(-) create mode 100644 flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart diff --git a/flutter_inappwebview/CHANGELOG.md b/flutter_inappwebview/CHANGELOG.md index da826a08d..17d5683f2 100755 --- a/flutter_inappwebview/CHANGELOG.md +++ b/flutter_inappwebview/CHANGELOG.md @@ -41,7 +41,7 @@ - Implemented `onCloseWindow`, `onCallJsHandler` WebView events - Implemented `addJavaScriptHandler`, `removeJavaScriptHandler`, `hasJavaScriptHandler`, `addUserScript`, `addUserScripts`, `removeUserScript`, `removeUserScriptsByGroupName`, `removeUserScripts`, `hasUserScript` InAppWebViewController methods - Implemented `setJavaScriptBridgeName`, `getJavaScriptBridgeName`, `getDefaultUserAgent` InAppWebViewController static methods -- Implemented `javaScriptHandlersOriginAllowList`, `javaScriptBridgeEnabled`, `javaScriptBridgeOriginAllowList`, `hasJavaScriptHandler`, `addUserScript`, `addUserScripts`, `removeUserScript` InAppWebViewSettings event +- Implemented `javaScriptHandlersOriginAllowList`, `javaScriptBridgeEnabled`, `javaScriptBridgeOriginAllowList`, `hasJavaScriptHandler`, `addUserScript`, `addUserScripts`, `removeUserScript` of `InAppWebViewSettings` ## 6.2.0-beta.2 diff --git a/flutter_inappwebview/example/android/app/build.gradle b/flutter_inappwebview/example/android/app/build.gradle index a50a94003..9d4f7a9b7 100755 --- a/flutter_inappwebview/example/android/app/build.gradle +++ b/flutter_inappwebview/example/android/app/build.gradle @@ -30,13 +30,14 @@ android { targetCompatibility 1.8 } - compileSdk 34 + compileSdk 36 + ndkVersion = "27.0.12077973" defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.pichillilorenzo.flutter_inappwebviewexample" minSdkVersion flutter.minSdkVersion - targetSdkVersion 34 + targetSdkVersion 36 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/flutter_inappwebview/example/android/settings.gradle b/flutter_inappwebview/example/android/settings.gradle index cf222bf6f..4de9128ab 100755 --- a/flutter_inappwebview/example/android/settings.gradle +++ b/flutter_inappwebview/example/android/settings.gradle @@ -19,7 +19,7 @@ pluginManagement { plugins { id "dev.flutter.flutter-plugin-loader" version "1.0.0" id "com.android.application" version '8.6.1' apply false - id "org.jetbrains.kotlin.android" version "1.7.10" apply false + id "org.jetbrains.kotlin.android" version "2.2.20" apply false } include ":app" \ No newline at end of file diff --git a/flutter_inappwebview/example/ios/Flutter/AppFrameworkInfo.plist b/flutter_inappwebview/example/ios/Flutter/AppFrameworkInfo.plist index 7c5696400..1dc6cf765 100755 --- a/flutter_inappwebview/example/ios/Flutter/AppFrameworkInfo.plist +++ b/flutter_inappwebview/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 12.0 + 13.0 diff --git a/flutter_inappwebview/example/ios/Podfile b/flutter_inappwebview/example/ios/Podfile index 2c068c404..10f3c9b47 100644 --- a/flutter_inappwebview/example/ios/Podfile +++ b/flutter_inappwebview/example/ios/Podfile @@ -1,5 +1,5 @@ # Uncomment this line to define a global platform for your project -platform :ios, '12.0' +platform :ios, '13.0' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj b/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj index 2e0efe407..fa11ab491 100644 --- a/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj +++ b/flutter_inappwebview/example/ios/Runner.xcodeproj/project.pbxproj @@ -578,7 +578,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -631,7 +631,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 12.0; + IPHONEOS_DEPLOYMENT_TARGET = 13.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/flutter_inappwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/flutter_inappwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index cdef6845d..684be6afb 100755 --- a/flutter_inappwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/flutter_inappwebview/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -26,6 +26,7 @@ buildConfiguration = "Debug" selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" + customLLDBInitFile = "$(SRCROOT)/Flutter/ephemeral/flutter_lldbinit" shouldUseLaunchSchemeArgsEnv = "YES"> diff --git a/flutter_inappwebview/example/macos/Podfile b/flutter_inappwebview/example/macos/Podfile index 049abe295..9ec46f8cd 100644 --- a/flutter_inappwebview/example/macos/Podfile +++ b/flutter_inappwebview/example/macos/Podfile @@ -1,4 +1,4 @@ -platform :osx, '10.14' +platform :osx, '10.15' # CocoaPods analytics sends network stats synchronously affecting flutter build latency. ENV['COCOAPODS_DISABLE_STATS'] = 'true' diff --git a/flutter_inappwebview/example/macos/Runner.xcodeproj/project.pbxproj b/flutter_inappwebview/example/macos/Runner.xcodeproj/project.pbxproj index 4df2c9849..7fc2ecc96 100644 --- a/flutter_inappwebview/example/macos/Runner.xcodeproj/project.pbxproj +++ b/flutter_inappwebview/example/macos/Runner.xcodeproj/project.pbxproj @@ -404,7 +404,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -483,7 +483,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -530,7 +530,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; diff --git a/flutter_inappwebview/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/flutter_inappwebview/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 05ad528d0..d436b294f 100644 --- a/flutter_inappwebview/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/flutter_inappwebview/example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -48,6 +48,7 @@ ignoresPersistentStateOnLaunch = "NO" debugDocumentVersioning = "YES" debugServiceExtension = "internal" + enableGPUValidationMode = "1" allowLocationSimulation = "YES"> diff --git a/flutter_inappwebview/example/macos/Runner/AppDelegate.swift b/flutter_inappwebview/example/macos/Runner/AppDelegate.swift index 8e02df288..b3c176141 100644 --- a/flutter_inappwebview/example/macos/Runner/AppDelegate.swift +++ b/flutter_inappwebview/example/macos/Runner/AppDelegate.swift @@ -6,4 +6,8 @@ class AppDelegate: FlutterAppDelegate { override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { return true } + + override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { + return true + } } diff --git a/flutter_inappwebview/lib/src/print_job/print_job_controller.dart b/flutter_inappwebview/lib/src/print_job/print_job_controller.dart index ded9521e0..0b0c9e8f3 100644 --- a/flutter_inappwebview/lib/src/print_job/print_job_controller.dart +++ b/flutter_inappwebview/lib/src/print_job/print_job_controller.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController} @@ -46,4 +47,20 @@ class PrintJobController { ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.dispose} void dispose() => platform.dispose(); + + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformPrintJobController.static().isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.isPropertySupported} + static bool isPropertySupported(dynamic property, + {TargetPlatform? platform}) => + PlatformPrintJobController.static() + .isPropertySupported(property, platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.isMethodSupported} + static bool isMethodSupported(PlatformPrintJobControllerMethod method, + {TargetPlatform? platform}) => + PlatformPrintJobController.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_android/example/pubspec.lock b/flutter_inappwebview_android/example/pubspec.lock index 27dad23d8..590841b63 100644 --- a/flutter_inappwebview_android/example/pubspec.lock +++ b/flutter_inappwebview_android/example/pubspec.lock @@ -85,18 +85,17 @@ packages: flutter_inappwebview_internal_annotations: dependency: transitive description: - name: flutter_inappwebview_internal_annotations - sha256: "787171d43f8af67864740b6f04166c13190aa74a1468a1f1f1e9ee5b90c359cd" - url: "https://pub.dev" - source: hosted - version: "1.2.0" + path: "../../dev_packages/flutter_inappwebview_internal_annotations" + relative: true + source: path + version: "1.3.0" flutter_inappwebview_platform_interface: dependency: transitive description: path: "../../flutter_inappwebview_platform_interface" relative: true source: path - version: "1.4.0-beta.2" + version: "1.4.0-beta.3" flutter_lints: dependency: "direct dev" description: diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index c7cad0afe..0a61763a1 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -115,6 +115,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidPrintJobController(params); } + /// Creates a new empty [PlatformPrintJobController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PrintJobController] in `flutter_inappwebview` instead. + @override + PlatformPrintJobController createPlatformPrintJobControllerStatic() { + return _PlatformPrintJobController.static(); + } + /// Creates a new [AndroidPullToRefreshController]. /// /// This function should only be called by the app-facing package. @@ -447,3 +456,14 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidWebStorageManager(params); } } + +class _PlatformPrintJobController extends PlatformPrintJobController { + _PlatformPrintJobController(PlatformPrintJobControllerCreationParams params) + : super.implementation(params); + + static final _PlatformPrintJobController _staticValue = + _PlatformPrintJobController( + const PlatformPrintJobControllerCreationParams(id: '')); + + factory _PlatformPrintJobController.static() => _staticValue; +} diff --git a/flutter_inappwebview_ios/example/pubspec.lock b/flutter_inappwebview_ios/example/pubspec.lock index 621957ae2..86485ac5a 100644 --- a/flutter_inappwebview_ios/example/pubspec.lock +++ b/flutter_inappwebview_ios/example/pubspec.lock @@ -78,11 +78,10 @@ packages: flutter_inappwebview_internal_annotations: dependency: transitive description: - name: flutter_inappwebview_internal_annotations - sha256: "787171d43f8af67864740b6f04166c13190aa74a1468a1f1f1e9ee5b90c359cd" - url: "https://pub.dev" - source: hosted - version: "1.2.0" + path: "../../dev_packages/flutter_inappwebview_internal_annotations" + relative: true + source: path + version: "1.3.0" flutter_inappwebview_ios: dependency: "direct main" description: @@ -96,7 +95,7 @@ packages: path: "../../flutter_inappwebview_platform_interface" relative: true source: path - version: "1.4.0-beta.2" + version: "1.4.0-beta.3" flutter_lints: dependency: "direct dev" description: diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index d26254b6d..f8f48e4a1 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -111,6 +111,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSPrintJobController(params); } + /// Creates a new empty [PlatformPrintJobController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PrintJobController] in `flutter_inappwebview` instead. + @override + PlatformPrintJobController createPlatformPrintJobControllerStatic() { + return _PlatformPrintJobController.static(); + } + /// Creates a new [IOSPullToRefreshController]. /// /// This function should only be called by the app-facing package. @@ -403,4 +412,15 @@ class _PlatformTracingController extends PlatformTracingController { const PlatformTracingControllerCreationParams()); factory _PlatformTracingController.static() => _staticValue; -} \ No newline at end of file +} + +class _PlatformPrintJobController extends PlatformPrintJobController { + _PlatformPrintJobController(PlatformPrintJobControllerCreationParams params) + : super.implementation(params); + + static final _PlatformPrintJobController _staticValue = + _PlatformPrintJobController( + const PlatformPrintJobControllerCreationParams(id: '')); + + factory _PlatformPrintJobController.static() => _staticValue; +} diff --git a/flutter_inappwebview_macos/example/pubspec.lock b/flutter_inappwebview_macos/example/pubspec.lock index 85b83c9fc..b0dad0dc4 100644 --- a/flutter_inappwebview_macos/example/pubspec.lock +++ b/flutter_inappwebview_macos/example/pubspec.lock @@ -78,11 +78,10 @@ packages: flutter_inappwebview_internal_annotations: dependency: transitive description: - name: flutter_inappwebview_internal_annotations - sha256: "787171d43f8af67864740b6f04166c13190aa74a1468a1f1f1e9ee5b90c359cd" - url: "https://pub.dev" - source: hosted - version: "1.2.0" + path: "../../dev_packages/flutter_inappwebview_internal_annotations" + relative: true + source: path + version: "1.3.0" flutter_inappwebview_macos: dependency: "direct main" description: @@ -96,7 +95,7 @@ packages: path: "../../flutter_inappwebview_platform_interface" relative: true source: path - version: "1.4.0-beta.2" + version: "1.4.0-beta.3" flutter_lints: dependency: "direct dev" description: diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index e544f4632..86d9b7dbe 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -109,6 +109,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSPrintJobController(params); } + /// Creates a new empty [PlatformPrintJobController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PrintJobController] in `flutter_inappwebview` instead. + @override + PlatformPrintJobController createPlatformPrintJobControllerStatic() { + return _PlatformPrintJobController.static(); + } + /// Creates a new [MacOSWebMessageChannel]. /// /// This function should only be called by the app-facing package. @@ -388,4 +397,15 @@ class _PlatformTracingController extends PlatformTracingController { const PlatformTracingControllerCreationParams()); factory _PlatformTracingController.static() => _staticValue; -} \ No newline at end of file +} + +class _PlatformPrintJobController extends PlatformPrintJobController { + _PlatformPrintJobController(PlatformPrintJobControllerCreationParams params) + : super.implementation(params); + + static final _PlatformPrintJobController _staticValue = + _PlatformPrintJobController( + const PlatformPrintJobControllerCreationParams(id: '')); + + factory _PlatformPrintJobController.static() => _staticValue; +} diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index c3c5fcd23..a63bd5f3a 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -141,6 +141,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformPrintJobController is not implemented on the current platform.'); } + /// Creates a new empty [PlatformPrintJobController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PrintJobController] in `flutter_inappwebview` instead. + PlatformPrintJobController createPlatformPrintJobControllerStatic() { + throw UnimplementedError( + 'createPlatformPrintJobControllerStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformPullToRefreshController]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart index 3ff12e68a..14244d85b 100644 --- a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart @@ -1,4 +1,5 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import '../in_app_webview/platform_inappwebview_controller.dart'; @@ -6,32 +7,71 @@ import '../inappwebview_platform.dart'; import '../types/disposable.dart'; import '../types/print_job_info.dart'; -///A completion handler for the [PlatformPrintJobController]. -typedef PrintJobCompletionHandler = Future Function( - bool completed, String? error)?; +// ignore: uri_has_not_been_generated +part 'platform_print_job_controller.g.dart'; +///{@template flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams} /// Object specifying creation parameters for creating a [PlatformPrintJobController]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), +]) @immutable class PlatformPrintJobControllerCreationParams { /// Used by the platform implementation to create a new [PlatformPrintJobController]. const PlatformPrintJobControllerCreationParams( {required this.id}); - ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.id} + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.id} + ///Print job ID. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.id.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) final String id; + + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformPrintJobControllerCreationParamsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported( + PlatformPrintJobControllerCreationParamsProperty property, + {TargetPlatform? platform}) => + _PlatformPrintJobControllerCreationParamsPropertySupported + .isPropertySupported(property, platform: platform); } +///A completion handler for the [PlatformPrintJobController]. +typedef PrintJobCompletionHandler = Future Function( + bool completed, String? error)?; + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController} ///Class representing a print job eventually returned by [PlatformInAppWebViewController.printCurrentPage]. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), +]) abstract class PlatformPrintJobController extends PlatformInterface implements Disposable { /// Creates a new [PlatformPrintJobController] @@ -50,6 +90,22 @@ abstract class PlatformPrintJobController extends PlatformInterface return printJobController; } + /// Creates a new empty [PlatformPrintJobController] to access static methods. + factory PlatformPrintJobController.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformPrintJobController printJobControllerStatic = + InAppWebViewPlatform.instance! + .createPlatformPrintJobControllerStatic(); + PlatformInterface.verify(printJobControllerStatic, _token); + return printJobControllerStatic; + } + /// Used by the platform implementation to create a new [PlatformPrintJobController]. /// /// Should only be used by platform implementations because they can't extend @@ -62,30 +118,34 @@ abstract class PlatformPrintJobController extends PlatformInterface /// The parameters used to initialize the [PlatformPrintJobController]. final PlatformPrintJobControllerCreationParams params; - ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.id} - ///Print job ID. - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.id} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.id.supported_platforms} String get id => params.id; ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.onComplete} ///A completion handler used to handle the conclusion of the print job (for instance, to reset state) and to handle any errors encountered in printing. /// - ///**NOTE for Android**: `completed` is always `true` and `error` is always `null`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintDocumentAdapter.onFinish](https://developer.android.com/reference/android/print/PrintDocumentAdapter#onFinish())) - ///- iOS ([Official API - UIPrintInteractionController.CompletionHandler](https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/completionhandler)) - ///- MacOS ([Official API - NSPrintOperation.runModal](https://developer.apple.com/documentation/appkit/nsprintoperation/1532065-runmodal)) + ///NOTE for Android: `completed` is always `true` and `error` is always `null`. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.onComplete.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'PrintDocumentAdapter.onFinish', apiUrl: 'https://developer.android.com/reference/android/print/PrintDocumentAdapter#onFinish()'), + IOSPlatform(apiName: 'UIPrintInteractionController.CompletionHandler', apiUrl: 'https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/completionhandler'), + MacOSPlatform(apiName: 'NSPrintOperation.runModal', apiUrl: 'https://developer.apple.com/documentation/appkit/nsprintoperation/1532065-runmodal'), + ]) PrintJobCompletionHandler? onComplete; ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.cancel} ///Cancels this print job. ///You can request cancellation of a queued, started, blocked, or failed print job. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJob.cancel](https://developer.android.com/reference/android/print/PrintJob#cancel())) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.cancel.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'PrintJob.cancel', apiUrl: 'https://developer.android.com/reference/android/print/PrintJob#cancel()'), + ]) Future cancel() { throw UnimplementedError( 'cancel is not implemented on the current platform'); @@ -94,10 +154,12 @@ abstract class PlatformPrintJobController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.restart} ///Restarts this print job. ///You can request restart of a failed print job. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJob.restart](https://developer.android.com/reference/android/print/PrintJob#restart())) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.restart.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'PrintJob.restart', apiUrl: 'https://developer.android.com/reference/android/print/PrintJob#restart()'), + ]) Future restart() { throw UnimplementedError( 'restart is not implemented on the current platform'); @@ -110,10 +172,12 @@ abstract class PlatformPrintJobController extends PlatformInterface ///animated from a rectangle and the user changes the orientation of the device. ///(This, of course, assumes your application responds to orientation changes.) ///You should then present the printing options again once the new orientation takes effect. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.dismiss.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(), + ]) Future dismiss({bool animated = true}) { throw UnimplementedError( 'dismiss is not implemented on the current platform'); @@ -122,15 +186,17 @@ abstract class PlatformPrintJobController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.getInfo} ///Gets the [PrintJobInfo] that describes this job. /// - ///**NOTE**: The returned info object is a snapshot of the + ///NOTE: The returned info object is a snapshot of the ///current print job state. Every call to this method returns a fresh ///info object that reflects the current print job state. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - PrintJob.getInfo](https://developer.android.com/reference/android/print/PrintJob#getInfo())) - ///- iOS - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.getInfo.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(apiName: 'PrintJob.getInfo', apiUrl: 'https://developer.android.com/reference/android/print/PrintJob#getInfo()'), + IOSPlatform(), + MacOSPlatform(), + ]) Future getInfo() { throw UnimplementedError( 'getInfo is not implemented on the current platform'); @@ -138,15 +204,39 @@ abstract class PlatformPrintJobController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.dispose} ///Disposes the print job. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.dispose.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) @override void dispose() { throw UnimplementedError( 'dispose is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + params.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///The property should be one of the [PlatformPrintJobControllerProperty] or [PlatformPrintJobControllerCreationParamsProperty] values. + ///{@endtemplate} + bool isPropertySupported(dynamic property, {TargetPlatform? platform}) => + property is PlatformPrintJobControllerCreationParamsProperty + ? params.isPropertySupported(property, platform: platform) + : _PlatformPrintJobControllerPropertySupported.isPropertySupported( + property, platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformPrintJobControllerMethod method, + {TargetPlatform? platform}) => + _PlatformPrintJobControllerMethodSupported.isMethodSupported(method, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart new file mode 100644 index 000000000..e8db52d6f --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart @@ -0,0 +1,199 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_print_job_controller.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformPrintJobControllerCreationParamsClassSupported + on PlatformPrintJobControllerCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformPrintJobControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformPrintJobControllerCreationParams]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformPrintJobControllerCreationParamsProperty { + ///Can be used to check if the [PlatformPrintJobControllerCreationParams.id] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.id.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformPrintJobControllerCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + id, +} + +extension _PlatformPrintJobControllerCreationParamsPropertySupported + on PlatformPrintJobControllerCreationParams { + static bool isPropertySupported( + PlatformPrintJobControllerCreationParamsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformPrintJobControllerCreationParamsProperty.id: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformPrintJobControllerClassSupported + on PlatformPrintJobController { + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformPrintJobController.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformPrintJobController]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformPrintJobControllerProperty { + ///Can be used to check if the [PlatformPrintJobController.onComplete] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.onComplete.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - PrintDocumentAdapter.onFinish](https://developer.android.com/reference/android/print/PrintDocumentAdapter#onFinish())) + ///- iOS WKWebView ([Official API - UIPrintInteractionController.CompletionHandler](https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/completionhandler)) + ///- macOS WKWebView ([Official API - NSPrintOperation.runModal](https://developer.apple.com/documentation/appkit/nsprintoperation/1532065-runmodal)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [completed]: all platforms + ///- [error]: all platforms + /// + ///Use the [PlatformPrintJobController.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + onComplete, +} + +extension _PlatformPrintJobControllerPropertySupported + on PlatformPrintJobController { + static bool isPropertySupported(PlatformPrintJobControllerProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformPrintJobControllerProperty.onComplete: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +///List of [PlatformPrintJobController]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformPrintJobControllerMethod { + ///Can be used to check if the [PlatformPrintJobController.cancel] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.cancel.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - PrintJob.cancel](https://developer.android.com/reference/android/print/PrintJob#cancel())) + /// + ///Use the [PlatformPrintJobController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + cancel, + + ///Can be used to check if the [PlatformPrintJobController.dismiss] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.dismiss.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [animated]: all platforms + /// + ///Use the [PlatformPrintJobController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dismiss, + + ///Can be used to check if the [PlatformPrintJobController.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformPrintJobController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, + + ///Can be used to check if the [PlatformPrintJobController.getInfo] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.getInfo.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - PrintJob.getInfo](https://developer.android.com/reference/android/print/PrintJob#getInfo())) + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformPrintJobController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getInfo, + + ///Can be used to check if the [PlatformPrintJobController.restart] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.restart.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - PrintJob.restart](https://developer.android.com/reference/android/print/PrintJob#restart())) + /// + ///Use the [PlatformPrintJobController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + restart, +} + +extension _PlatformPrintJobControllerMethodSupported + on PlatformPrintJobController { + static bool isMethodSupported(PlatformPrintJobControllerMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformPrintJobControllerMethod.cancel: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformPrintJobControllerMethod.dismiss: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PlatformPrintJobControllerMethod.dispose: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPrintJobControllerMethod.getInfo: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPrintJobControllerMethod.restart: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index 018372569..dced0b00b 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -169,6 +169,15 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { PlatformFindInteractionController createPlatformFindInteractionControllerStatic() { return _PlatformFindInteractionController.static(); } + + /// Creates a new empty [PlatformPrintJobController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PrintJobController] in `flutter_inappwebview` instead. + @override + PlatformPrintJobController createPlatformPrintJobControllerStatic() { + return _PlatformPrintJobController.static(); + } } class _PlatformInAppBrowser extends PlatformInAppBrowser { @@ -253,3 +262,14 @@ class _PlatformFindInteractionController extends PlatformFindInteractionControll factory _PlatformFindInteractionController.static() => _staticValue; } + +class _PlatformPrintJobController extends PlatformPrintJobController { + _PlatformPrintJobController(PlatformPrintJobControllerCreationParams params) + : super.implementation(params); + + static final _PlatformPrintJobController _staticValue = + _PlatformPrintJobController( + const PlatformPrintJobControllerCreationParams(id: '')); + + factory _PlatformPrintJobController.static() => _staticValue; +} diff --git a/flutter_inappwebview_windows/example/pubspec.lock b/flutter_inappwebview_windows/example/pubspec.lock index 7366198f1..685563839 100644 --- a/flutter_inappwebview_windows/example/pubspec.lock +++ b/flutter_inappwebview_windows/example/pubspec.lock @@ -78,11 +78,10 @@ packages: flutter_inappwebview_internal_annotations: dependency: transitive description: - name: flutter_inappwebview_internal_annotations - sha256: "787171d43f8af67864740b6f04166c13190aa74a1468a1f1f1e9ee5b90c359cd" - url: "https://pub.dev" - source: hosted - version: "1.2.0" + path: "../../dev_packages/flutter_inappwebview_internal_annotations" + relative: true + source: path + version: "1.3.0" flutter_inappwebview_platform_interface: dependency: transitive description: diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index c6cd9eacb..8cff08e2d 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -237,6 +237,15 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { PlatformFindInteractionController createPlatformFindInteractionControllerStatic() { return _PlatformFindInteractionController.static(); } + + /// Creates a new empty [PlatformPrintJobController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PrintJobController] in `flutter_inappwebview` instead. + @override + PlatformPrintJobController createPlatformPrintJobControllerStatic() { + return _PlatformPrintJobController.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -312,3 +321,14 @@ class _PlatformFindInteractionController extends PlatformFindInteractionControll factory _PlatformFindInteractionController.static() => _staticValue; } + +class _PlatformPrintJobController extends PlatformPrintJobController { + _PlatformPrintJobController(PlatformPrintJobControllerCreationParams params) + : super.implementation(params); + + static final _PlatformPrintJobController _staticValue = + _PlatformPrintJobController( + const PlatformPrintJobControllerCreationParams(id: '')); + + factory _PlatformPrintJobController.static() => _staticValue; +} From b877ed81141c54b13e45eb20e0835adc132758c1 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Thu, 2 Oct 2025 00:10:39 +0200 Subject: [PATCH 155/181] fixed print job controller method support static invocation, code format --- .../headless_in_app_webview/supported.dart | 7 +- .../in_app_browser/supported.dart | 21 +- .../in_app_webview/supported.dart | 4 +- .../chrome_safari_browser.dart | 18 +- .../lib/src/cookie_manager.dart | 14 +- .../find_interaction_controller.dart | 10 +- .../src/in_app_browser/in_app_browser.dart | 26 +- .../headless_in_app_webview.dart | 21 +- .../src/in_app_webview/in_app_webview.dart | 10 +- .../lib/src/process_global_config.dart | 5 +- .../src/http_auth_credentials_database.dart | 7 +- .../headless_in_app_webview.dart | 3 +- .../src/in_app_webview/in_app_webview.dart | 3 +- .../lib/src/inappwebview_platform.dart | 18 +- .../src/print_job/print_job_controller.dart | 15 +- .../lib/src/cookie_manager.dart | 3 +- .../find_interaction_controller.dart | 4 +- .../src/http_auth_credentials_database.dart | 6 +- .../headless_in_app_webview.dart | 6 +- .../src/in_app_webview/in_app_webview.dart | 3 +- .../in_app_webview_controller.dart | 6 +- .../lib/src/inappwebview_platform.dart | 29 +- .../src/print_job/print_job_controller.dart | 14 +- .../lib/src/cookie_manager.dart | 3 +- .../find_interaction_controller.dart | 4 +- .../src/http_auth_credentials_database.dart | 7 +- .../headless_in_app_webview.dart | 3 +- .../src/in_app_webview/in_app_webview.dart | 3 +- .../in_app_webview_controller.dart | 6 +- .../lib/src/inappwebview_platform.dart | 36 +- .../src/print_job/print_job_controller.dart | 14 +- .../chrome_safari_browser_settings.dart | 34 +- .../platform_find_interaction_controller.dart | 143 +- .../in_app_browser_settings.dart | 5 +- .../lib/src/in_app_browser/main.dart | 3 +- .../platform_in_app_browser.dart | 785 ++++++++--- .../in_app_webview_settings.dart | 5 +- .../lib/src/in_app_webview/main.dart | 3 +- .../platform_inappwebview_controller.dart | 1214 ++++++++++++++--- .../src/in_app_webview/platform_webview.dart | 788 +++++++++-- .../lib/src/inappwebview_platform.dart | 3 +- .../lib/src/platform_cookie_manager.dart | 324 +++-- ...atform_http_auth_credentials_database.dart | 67 +- .../lib/src/platform_tracing_controller.dart | 48 +- .../platform_print_job_controller.dart | 50 +- .../lib/src/print_job/print_job_settings.dart | 8 +- .../src/types/show_file_chooser_request.dart | 2 +- .../types/show_file_chooser_request_mode.dart | 16 +- .../src/types/show_file_chooser_response.dart | 2 +- .../headless_in_app_webview.dart | 4 +- .../src/in_app_webview/in_app_webview.dart | 4 +- .../lib/src/inappwebview_platform.dart | 27 +- .../lib/web/in_app_web_view_web_element.dart | 3 +- .../lib/web/js_bridge.dart | 7 +- .../headless_in_app_webview.dart | 3 +- .../src/in_app_webview/in_app_webview.dart | 3 +- .../in_app_webview_controller.dart | 6 +- .../lib/src/inappwebview_platform.dart | 27 +- .../src/print_job/print_job_controller.dart | 6 +- 59 files changed, 2963 insertions(+), 956 deletions(-) diff --git a/flutter_inappwebview/example/integration_test/headless_in_app_webview/supported.dart b/flutter_inappwebview/example/integration_test/headless_in_app_webview/supported.dart index b2aac0582..7d4e99fc0 100644 --- a/flutter_inappwebview/example/integration_test/headless_in_app_webview/supported.dart +++ b/flutter_inappwebview/example/integration_test/headless_in_app_webview/supported.dart @@ -5,10 +5,13 @@ void supported() { skippableTestWidgets('basic', (WidgetTester tester) async { expect(HeadlessInAppWebView.isClassSupported(), true); expect( - HeadlessInAppWebView.isPropertySupported(PlatformHeadlessInAppWebViewCreationParamsProperty.initialSize), + HeadlessInAppWebView.isPropertySupported( + PlatformHeadlessInAppWebViewCreationParamsProperty.initialSize), true); expect( - HeadlessInAppWebView.isPropertySupported(PlatformHeadlessInAppWebViewCreationParamsProperty.webViewEnvironment), + HeadlessInAppWebView.isPropertySupported( + PlatformHeadlessInAppWebViewCreationParamsProperty + .webViewEnvironment), defaultTargetPlatform == TargetPlatform.windows); expect( HeadlessInAppWebView.isMethodSupported( diff --git a/flutter_inappwebview/example/integration_test/in_app_browser/supported.dart b/flutter_inappwebview/example/integration_test/in_app_browser/supported.dart index 3979c98d7..04fece587 100644 --- a/flutter_inappwebview/example/integration_test/in_app_browser/supported.dart +++ b/flutter_inappwebview/example/integration_test/in_app_browser/supported.dart @@ -10,16 +10,14 @@ void supported() { true); expect( InAppBrowser.isMethodSupported( - PlatformInAppBrowserMethod.openUrlRequest), true); - expect( - InAppBrowser.isMethodSupported( - PlatformInAppBrowserMethod.close), true); - expect( - InAppBrowser.isMethodSupported( - PlatformInAppBrowserMethod.hide), true); - expect( - InAppBrowser.isMethodSupported( - PlatformInAppBrowserMethod.show), true); + PlatformInAppBrowserMethod.openUrlRequest), + true); + expect(InAppBrowser.isMethodSupported(PlatformInAppBrowserMethod.close), + true); + expect(InAppBrowser.isMethodSupported(PlatformInAppBrowserMethod.hide), + true); + expect(InAppBrowser.isMethodSupported(PlatformInAppBrowserMethod.show), + true); expect( InAppBrowser.isEventMethodSupported( PlatformInAppBrowserEventsMethod.onWebContentProcessDidTerminate), @@ -36,7 +34,8 @@ void supported() { defaultTargetPlatform == TargetPlatform.iOS); expect( InAppBrowserSettings.isPropertySupported( - InAppBrowserSettingsProperty.hidden), true); + InAppBrowserSettingsProperty.hidden), + true); expect( InAppBrowserSettings.isPropertySupported( InAppBrowserSettingsProperty.closeOnCannotGoBack), diff --git a/flutter_inappwebview/example/integration_test/in_app_webview/supported.dart b/flutter_inappwebview/example/integration_test/in_app_webview/supported.dart index 1aef50e73..bb491fa38 100644 --- a/flutter_inappwebview/example/integration_test/in_app_webview/supported.dart +++ b/flutter_inappwebview/example/integration_test/in_app_webview/supported.dart @@ -47,8 +47,8 @@ void supported() { [TargetPlatform.iOS, TargetPlatform.macOS, TargetPlatform.windows] .contains(defaultTargetPlatform)); expect( - InAppWebView.isPropertySupported(PlatformWebViewCreationParamsProperty - .onAcceleratorKeyPressed), + InAppWebView.isPropertySupported( + PlatformWebViewCreationParamsProperty.onAcceleratorKeyPressed), defaultTargetPlatform == TargetPlatform.windows); expect( diff --git a/flutter_inappwebview/lib/src/chrome_safari_browser/chrome_safari_browser.dart b/flutter_inappwebview/lib/src/chrome_safari_browser/chrome_safari_browser.dart index 81122ec76..f34c0c47e 100755 --- a/flutter_inappwebview/lib/src/chrome_safari_browser/chrome_safari_browser.dart +++ b/flutter_inappwebview/lib/src/chrome_safari_browser/chrome_safari_browser.dart @@ -243,20 +243,18 @@ class ChromeSafariBrowser implements PlatformChromeSafariBrowserEvents { ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isClassSupported} static bool isClassSupported({TargetPlatform? platform}) => - PlatformChromeSafariBrowser.static().isClassSupported( - platform: platform); + PlatformChromeSafariBrowser.static().isClassSupported(platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowser.isMethodSupported} static bool isMethodSupported(PlatformChromeSafariBrowserMethod property, - {TargetPlatform? platform}) => - PlatformChromeSafariBrowser.static().isMethodSupported( - property, - platform: platform); + {TargetPlatform? platform}) => + PlatformChromeSafariBrowser.static() + .isMethodSupported(property, platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformChromeSafariBrowserEvents.isMethodSupported} - static bool isEventMethodSupported(PlatformChromeSafariBrowserEventsMethod method, - {TargetPlatform? platform}) => - PlatformChromeSafariBrowserEvents.isMethodSupported( - method, + static bool isEventMethodSupported( + PlatformChromeSafariBrowserEventsMethod method, + {TargetPlatform? platform}) => + PlatformChromeSafariBrowserEvents.isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview/lib/src/cookie_manager.dart b/flutter_inappwebview/lib/src/cookie_manager.dart index 9dac3f830..079a5c48b 100755 --- a/flutter_inappwebview/lib/src/cookie_manager.dart +++ b/flutter_inappwebview/lib/src/cookie_manager.dart @@ -175,15 +175,17 @@ class CookieManager { PlatformCookieManager.static().isClassSupported(platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isPropertySupported} - static bool isPropertySupported(PlatformCookieManagerCreationParamsProperty property, {TargetPlatform? platform}) => - PlatformCookieManager.static().isPropertySupported(property, platform: platform); + static bool isPropertySupported( + PlatformCookieManagerCreationParamsProperty property, + {TargetPlatform? platform}) => + PlatformCookieManager.static() + .isPropertySupported(property, platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.isMethodSupported} static bool isMethodSupported(PlatformCookieManagerMethod method, - {TargetPlatform? platform}) => - PlatformCookieManager.static().isMethodSupported( - method, - platform: platform); + {TargetPlatform? platform}) => + PlatformCookieManager.static() + .isMethodSupported(method, platform: platform); } ///Class that contains only iOS-specific methods of [CookieManager]. diff --git a/flutter_inappwebview/lib/src/find_interaction/find_interaction_controller.dart b/flutter_inappwebview/lib/src/find_interaction/find_interaction_controller.dart index 5624af98d..e18c49515 100644 --- a/flutter_inappwebview/lib/src/find_interaction/find_interaction_controller.dart +++ b/flutter_inappwebview/lib/src/find_interaction/find_interaction_controller.dart @@ -69,17 +69,19 @@ class FindInteractionController { ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.isClassSupported} static bool isClassSupported({TargetPlatform? platform}) => - PlatformFindInteractionController.static().isClassSupported(platform: platform); + PlatformFindInteractionController.static() + .isClassSupported(platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.isPropertySupported} - static bool isPropertySupported(PlatformFindInteractionControllerCreationParamsProperty property, - {TargetPlatform? platform}) => + static bool isPropertySupported( + PlatformFindInteractionControllerCreationParamsProperty property, + {TargetPlatform? platform}) => PlatformFindInteractionController.static() .isPropertySupported(property, platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.isMethodSupported} static bool isMethodSupported(PlatformFindInteractionControllerMethod method, - {TargetPlatform? platform}) => + {TargetPlatform? platform}) => PlatformFindInteractionController.static() .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart b/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart index 2d0ac5e23..55a9ff716 100755 --- a/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart +++ b/flutter_inappwebview/lib/src/in_app_browser/in_app_browser.dart @@ -665,33 +665,29 @@ class InAppBrowser implements PlatformInAppBrowserEvents { void onAcceleratorKeyPressed(AcceleratorKeyPressedDetail detail) {} @override - FutureOr onShowFileChooser(ShowFileChooserRequest request) { + FutureOr onShowFileChooser( + ShowFileChooserRequest request) { return null; } ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isClassSupported} static bool isClassSupported({TargetPlatform? platform}) => - PlatformInAppBrowser.static().isClassSupported( - platform: platform); + PlatformInAppBrowser.static().isClassSupported(platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isPropertySupported} static bool isPropertySupported(PlatformInAppBrowserProperty property, - {TargetPlatform? platform}) => - PlatformInAppBrowser.static().isPropertySupported( - property, - platform: platform); + {TargetPlatform? platform}) => + PlatformInAppBrowser.static() + .isPropertySupported(property, platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.isMethodSupported} static bool isMethodSupported(PlatformInAppBrowserMethod property, - {TargetPlatform? platform}) => - PlatformInAppBrowser.static().isMethodSupported( - property, - platform: platform); + {TargetPlatform? platform}) => + PlatformInAppBrowser.static() + .isMethodSupported(property, platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.isMethodSupported} static bool isEventMethodSupported(PlatformInAppBrowserEventsMethod method, - {TargetPlatform? platform}) => - PlatformInAppBrowserEvents.isMethodSupported( - method, - platform: platform); + {TargetPlatform? platform}) => + PlatformInAppBrowserEvents.isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview/lib/src/in_app_webview/headless_in_app_webview.dart index f3ae4867a..080ee6a99 100644 --- a/flutter_inappwebview/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/flutter_inappwebview/lib/src/in_app_webview/headless_in_app_webview.dart @@ -560,20 +560,19 @@ class HeadlessInAppWebView { ///{@macro flutter_inappwebview_platform_interface.PlatformHeadlessInAppWebViewCreationParams.isClassSupported} static bool isClassSupported({TargetPlatform? platform}) => - PlatformHeadlessInAppWebView.static().isClassSupported( - platform: platform); + PlatformHeadlessInAppWebView.static() + .isClassSupported(platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformHeadlessInAppWebViewCreationParams.isPropertySupported} - static bool isPropertySupported(PlatformHeadlessInAppWebViewCreationParamsProperty property, - {TargetPlatform? platform}) => - PlatformHeadlessInAppWebView.static().isPropertySupported( - property, - platform: platform); + static bool isPropertySupported( + PlatformHeadlessInAppWebViewCreationParamsProperty property, + {TargetPlatform? platform}) => + PlatformHeadlessInAppWebView.static() + .isPropertySupported(property, platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformHeadlessInAppWebViewCreationParams.isMethodSupported} static bool isMethodSupported(PlatformHeadlessInAppWebViewMethod method, - {TargetPlatform? platform}) => - PlatformHeadlessInAppWebView.static().isMethodSupported( - method, - platform: platform); + {TargetPlatform? platform}) => + PlatformHeadlessInAppWebView.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart index 19d63792d..093aa531b 100755 --- a/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview/lib/src/in_app_webview/in_app_webview.dart @@ -560,15 +560,13 @@ class InAppWebView extends StatefulWidget { ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidgetCreationParams.isClassSupported} static bool isClassSupported({TargetPlatform? platform}) => - PlatformInAppWebViewWidget.static().isClassSupported( - platform: platform); + PlatformInAppWebViewWidget.static().isClassSupported(platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewWidgetCreationParams.isPropertySupported} static bool isPropertySupported(dynamic property, - {TargetPlatform? platform}) => - PlatformInAppWebViewWidget.static().isPropertySupported( - property, - platform: platform); + {TargetPlatform? platform}) => + PlatformInAppWebViewWidget.static() + .isPropertySupported(property, platform: platform); } class _InAppWebViewState extends State { diff --git a/flutter_inappwebview/lib/src/process_global_config.dart b/flutter_inappwebview/lib/src/process_global_config.dart index 17767a1f5..3ffe102fa 100644 --- a/flutter_inappwebview/lib/src/process_global_config.dart +++ b/flutter_inappwebview/lib/src/process_global_config.dart @@ -39,12 +39,11 @@ class ProcessGlobalConfig { ///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfigCreationParams.isClassSupported} static bool isClassSupported({TargetPlatform? platform}) => - PlatformProcessGlobalConfig.static() - .isClassSupported(platform: platform); + PlatformProcessGlobalConfig.static().isClassSupported(platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformProcessGlobalConfig.isMethodSupported} static bool isMethodSupported(PlatformProcessGlobalConfigMethod method, - {TargetPlatform? platform}) => + {TargetPlatform? platform}) => PlatformProcessGlobalConfig.static() .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart b/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart index f96553b83..516a3f621 100755 --- a/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart +++ b/flutter_inappwebview_android/lib/src/http_auth_credentials_database.dart @@ -58,10 +58,9 @@ class AndroidHttpAuthCredentialDatabase } static final AndroidHttpAuthCredentialDatabase _staticValue = - AndroidHttpAuthCredentialDatabase( - AndroidHttpAuthCredentialDatabaseCreationParams( - const PlatformHttpAuthCredentialDatabaseCreationParams() - )); + AndroidHttpAuthCredentialDatabase( + AndroidHttpAuthCredentialDatabaseCreationParams( + const PlatformHttpAuthCredentialDatabaseCreationParams())); factory AndroidHttpAuthCredentialDatabase.static() { return _staticValue; diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart index 08a4ad9e2..98366d357 100644 --- a/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/headless_in_app_webview.dart @@ -277,8 +277,7 @@ class AndroidHeadlessInAppWebView extends PlatformHeadlessInAppWebView } static final AndroidHeadlessInAppWebView _staticValue = - AndroidHeadlessInAppWebView( - AndroidHeadlessInAppWebViewCreationParams()); + AndroidHeadlessInAppWebView(AndroidHeadlessInAppWebViewCreationParams()); factory AndroidHeadlessInAppWebView.static() { return _staticValue; diff --git a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart index 12d6446e3..727fcd772 100755 --- a/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_android/lib/src/in_app_webview/in_app_webview.dart @@ -288,8 +288,7 @@ class AndroidInAppWebViewWidget extends PlatformInAppWebViewWidget { params.headlessWebView as AndroidHeadlessInAppWebView?; static final AndroidInAppWebViewWidget _staticValue = - AndroidInAppWebViewWidget( - AndroidInAppWebViewWidgetCreationParams()); + AndroidInAppWebViewWidget(AndroidInAppWebViewWidgetCreationParams()); factory AndroidInAppWebViewWidget.static() { return _staticValue; diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index 0a61763a1..c60d6403e 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -100,7 +100,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. @override - AndroidFindInteractionController createPlatformFindInteractionControllerStatic() { + AndroidFindInteractionController + createPlatformFindInteractionControllerStatic() { return AndroidFindInteractionController.static(); } @@ -120,8 +121,8 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [PrintJobController] in `flutter_inappwebview` instead. @override - PlatformPrintJobController createPlatformPrintJobControllerStatic() { - return _PlatformPrintJobController.static(); + AndroidPrintJobController createPlatformPrintJobControllerStatic() { + return AndroidPrintJobController.static(); } /// Creates a new [AndroidPullToRefreshController]. @@ -456,14 +457,3 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidWebStorageManager(params); } } - -class _PlatformPrintJobController extends PlatformPrintJobController { - _PlatformPrintJobController(PlatformPrintJobControllerCreationParams params) - : super.implementation(params); - - static final _PlatformPrintJobController _staticValue = - _PlatformPrintJobController( - const PlatformPrintJobControllerCreationParams(id: '')); - - factory _PlatformPrintJobController.static() => _staticValue; -} diff --git a/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart b/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart index cc92868d0..2f4b1a814 100644 --- a/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart +++ b/flutter_inappwebview_android/lib/src/print_job/print_job_controller.dart @@ -11,16 +11,14 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla class AndroidPrintJobControllerCreationParams extends PlatformPrintJobControllerCreationParams { /// Creates a new [AndroidPrintJobControllerCreationParams] instance. - const AndroidPrintJobControllerCreationParams( - {required super.id}); + const AndroidPrintJobControllerCreationParams({required super.id}); /// Creates a [AndroidPrintJobControllerCreationParams] instance based on [PlatformPrintJobControllerCreationParams]. factory AndroidPrintJobControllerCreationParams.fromPlatformPrintJobControllerCreationParams( // Recommended placeholder to prevent being broken by platform interface. // ignore: avoid_unused_constructor_parameters PlatformPrintJobControllerCreationParams params) { - return AndroidPrintJobControllerCreationParams( - id: params.id); + return AndroidPrintJobControllerCreationParams(id: params.id); } } @@ -41,6 +39,15 @@ class AndroidPrintJobController extends PlatformPrintJobController initMethodCallHandler(); } + static final AndroidPrintJobController _staticValue = + AndroidPrintJobController( + AndroidPrintJobControllerCreationParams(id: '')); + + /// Provide static access. + factory AndroidPrintJobController.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async { switch (call.method) { case "onComplete": diff --git a/flutter_inappwebview_ios/lib/src/cookie_manager.dart b/flutter_inappwebview_ios/lib/src/cookie_manager.dart index 53be2ab90..880843c5c 100755 --- a/flutter_inappwebview_ios/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_ios/lib/src/cookie_manager.dart @@ -47,8 +47,7 @@ class IOSCookieManager extends PlatformCookieManager with ChannelController { } static final IOSCookieManager _staticValue = IOSCookieManager( - IOSCookieManagerCreationParams( - PlatformCookieManagerCreationParams())); + IOSCookieManagerCreationParams(PlatformCookieManagerCreationParams())); factory IOSCookieManager.static() { return _staticValue; diff --git a/flutter_inappwebview_ios/lib/src/find_interaction/find_interaction_controller.dart b/flutter_inappwebview_ios/lib/src/find_interaction/find_interaction_controller.dart index d1d080d45..3c4a694e9 100644 --- a/flutter_inappwebview_ios/lib/src/find_interaction/find_interaction_controller.dart +++ b/flutter_inappwebview_ios/lib/src/find_interaction/find_interaction_controller.dart @@ -38,8 +38,8 @@ class IOSFindInteractionController extends PlatformFindInteractionController ); static final IOSFindInteractionController _staticValue = - IOSFindInteractionController( - IOSFindInteractionControllerCreationParams()); + IOSFindInteractionController( + IOSFindInteractionControllerCreationParams()); /// Provide static access. factory IOSFindInteractionController.static() { diff --git a/flutter_inappwebview_ios/lib/src/http_auth_credentials_database.dart b/flutter_inappwebview_ios/lib/src/http_auth_credentials_database.dart index cef274dfa..ba9452b3f 100755 --- a/flutter_inappwebview_ios/lib/src/http_auth_credentials_database.dart +++ b/flutter_inappwebview_ios/lib/src/http_auth_credentials_database.dart @@ -58,10 +58,8 @@ class IOSHttpAuthCredentialDatabase extends PlatformHttpAuthCredentialDatabase } static final IOSHttpAuthCredentialDatabase _staticValue = - IOSHttpAuthCredentialDatabase( - IOSHttpAuthCredentialDatabaseCreationParams( - const PlatformHttpAuthCredentialDatabaseCreationParams() - )); + IOSHttpAuthCredentialDatabase(IOSHttpAuthCredentialDatabaseCreationParams( + const PlatformHttpAuthCredentialDatabaseCreationParams())); factory IOSHttpAuthCredentialDatabase.static() { return _staticValue; diff --git a/flutter_inappwebview_ios/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview_ios/lib/src/in_app_webview/headless_in_app_webview.dart index 52d871ea5..023a9e3b7 100644 --- a/flutter_inappwebview_ios/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/flutter_inappwebview_ios/lib/src/in_app_webview/headless_in_app_webview.dart @@ -278,8 +278,7 @@ class IOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView } static final IOSHeadlessInAppWebView _staticValue = - IOSHeadlessInAppWebView( - IOSHeadlessInAppWebViewCreationParams()); + IOSHeadlessInAppWebView(IOSHeadlessInAppWebViewCreationParams()); factory IOSHeadlessInAppWebView.static() { return _staticValue; @@ -381,7 +380,8 @@ class IOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView if (settings.useShouldInterceptAjaxRequest == null) { settings.useShouldInterceptAjaxRequest = true; } - if (params.onAjaxReadyStateChange != null && settings.useOnAjaxReadyStateChange == null) { + if (params.onAjaxReadyStateChange != null && + settings.useOnAjaxReadyStateChange == null) { settings.useOnAjaxReadyStateChange = true; } if (params.onAjaxProgress != null && settings.useOnAjaxProgress == null) { diff --git a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview.dart index 664d6dec6..ea8e5f5de 100755 --- a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview.dart @@ -283,8 +283,7 @@ class IOSInAppWebViewWidget extends PlatformInAppWebViewWidget { params.headlessWebView as IOSHeadlessInAppWebView?; static final IOSInAppWebViewWidget _staticValue = - IOSInAppWebViewWidget( - IOSInAppWebViewWidgetCreationParams()); + IOSInAppWebViewWidget(IOSInAppWebViewWidgetCreationParams()); factory IOSInAppWebViewWidget.static() { return _staticValue; diff --git a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart index f807fb8ff..72e038a9b 100644 --- a/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_ios/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1474,9 +1474,9 @@ class IOSInAppWebViewController extends PlatformInAppWebViewController _controllerFromPlatform, request)) ?.toNativeValue()); else - return jsonEncode((await _inAppBrowserEventHandler! - .onAjaxProgress(request)) - ?.toNativeValue()); + return jsonEncode( + (await _inAppBrowserEventHandler!.onAjaxProgress(request)) + ?.toNativeValue()); } return null; case "shouldInterceptFetchRequest": diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index f8f48e4a1..a8009ec9d 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -116,8 +116,8 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [PrintJobController] in `flutter_inappwebview` instead. @override - PlatformPrintJobController createPlatformPrintJobControllerStatic() { - return _PlatformPrintJobController.static(); + IOSPrintJobController createPlatformPrintJobControllerStatic() { + return IOSPrintJobController.static(); } /// Creates a new [IOSPullToRefreshController]. @@ -367,7 +367,8 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. @override - PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { + PlatformServiceWorkerController + createPlatformServiceWorkerControllerStatic() { return _PlatformServiceWorkerController.static(); } @@ -392,11 +393,12 @@ class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { } class _PlatformServiceWorkerController extends PlatformServiceWorkerController { - _PlatformServiceWorkerController(PlatformServiceWorkerControllerCreationParams params) + _PlatformServiceWorkerController( + PlatformServiceWorkerControllerCreationParams params) : super.implementation(params); static final _PlatformServiceWorkerController _staticValue = - _PlatformServiceWorkerController( - const PlatformServiceWorkerControllerCreationParams()); + _PlatformServiceWorkerController( + const PlatformServiceWorkerControllerCreationParams()); factory _PlatformServiceWorkerController.static() => _staticValue; @@ -408,19 +410,8 @@ class _PlatformTracingController extends PlatformTracingController { _PlatformTracingController(PlatformTracingControllerCreationParams params) : super.implementation(params); static final _PlatformTracingController _staticValue = - _PlatformTracingController( - const PlatformTracingControllerCreationParams()); + _PlatformTracingController( + const PlatformTracingControllerCreationParams()); factory _PlatformTracingController.static() => _staticValue; } - -class _PlatformPrintJobController extends PlatformPrintJobController { - _PlatformPrintJobController(PlatformPrintJobControllerCreationParams params) - : super.implementation(params); - - static final _PlatformPrintJobController _staticValue = - _PlatformPrintJobController( - const PlatformPrintJobControllerCreationParams(id: '')); - - factory _PlatformPrintJobController.static() => _staticValue; -} diff --git a/flutter_inappwebview_ios/lib/src/print_job/print_job_controller.dart b/flutter_inappwebview_ios/lib/src/print_job/print_job_controller.dart index f817d8501..e1a36528c 100644 --- a/flutter_inappwebview_ios/lib/src/print_job/print_job_controller.dart +++ b/flutter_inappwebview_ios/lib/src/print_job/print_job_controller.dart @@ -11,16 +11,14 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla class IOSPrintJobControllerCreationParams extends PlatformPrintJobControllerCreationParams { /// Creates a new [IOSPrintJobControllerCreationParams] instance. - const IOSPrintJobControllerCreationParams( - {required super.id}); + const IOSPrintJobControllerCreationParams({required super.id}); /// Creates a [IOSPrintJobControllerCreationParams] instance based on [PlatformPrintJobControllerCreationParams]. factory IOSPrintJobControllerCreationParams.fromPlatformPrintJobControllerCreationParams( // Recommended placeholder to prevent being broken by platform interface. // ignore: avoid_unused_constructor_parameters PlatformPrintJobControllerCreationParams params) { - return IOSPrintJobControllerCreationParams( - id: params.id); + return IOSPrintJobControllerCreationParams(id: params.id); } } @@ -41,6 +39,14 @@ class IOSPrintJobController extends PlatformPrintJobController initMethodCallHandler(); } + static final IOSPrintJobController _staticValue = + IOSPrintJobController(IOSPrintJobControllerCreationParams(id: '')); + + /// Provide static access. + factory IOSPrintJobController.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async { switch (call.method) { case "onComplete": diff --git a/flutter_inappwebview_macos/lib/src/cookie_manager.dart b/flutter_inappwebview_macos/lib/src/cookie_manager.dart index 9c019f393..ff481667d 100755 --- a/flutter_inappwebview_macos/lib/src/cookie_manager.dart +++ b/flutter_inappwebview_macos/lib/src/cookie_manager.dart @@ -47,8 +47,7 @@ class MacOSCookieManager extends PlatformCookieManager with ChannelController { } static final MacOSCookieManager _staticValue = MacOSCookieManager( - MacOSCookieManagerCreationParams( - PlatformCookieManagerCreationParams())); + MacOSCookieManagerCreationParams(PlatformCookieManagerCreationParams())); factory MacOSCookieManager.static() { return _staticValue; diff --git a/flutter_inappwebview_macos/lib/src/find_interaction/find_interaction_controller.dart b/flutter_inappwebview_macos/lib/src/find_interaction/find_interaction_controller.dart index fde68c033..ab4437ae1 100644 --- a/flutter_inappwebview_macos/lib/src/find_interaction/find_interaction_controller.dart +++ b/flutter_inappwebview_macos/lib/src/find_interaction/find_interaction_controller.dart @@ -38,8 +38,8 @@ class MacOSFindInteractionController extends PlatformFindInteractionController ); static final MacOSFindInteractionController _staticValue = - MacOSFindInteractionController( - MacOSFindInteractionControllerCreationParams()); + MacOSFindInteractionController( + MacOSFindInteractionControllerCreationParams()); /// Provide static access. factory MacOSFindInteractionController.static() { diff --git a/flutter_inappwebview_macos/lib/src/http_auth_credentials_database.dart b/flutter_inappwebview_macos/lib/src/http_auth_credentials_database.dart index 4bc4f5d51..bb5bde43a 100755 --- a/flutter_inappwebview_macos/lib/src/http_auth_credentials_database.dart +++ b/flutter_inappwebview_macos/lib/src/http_auth_credentials_database.dart @@ -58,10 +58,9 @@ class MacOSHttpAuthCredentialDatabase extends PlatformHttpAuthCredentialDatabase } static final MacOSHttpAuthCredentialDatabase _staticValue = - MacOSHttpAuthCredentialDatabase( - MacOSHttpAuthCredentialDatabaseCreationParams( - const PlatformHttpAuthCredentialDatabaseCreationParams() - )); + MacOSHttpAuthCredentialDatabase( + MacOSHttpAuthCredentialDatabaseCreationParams( + const PlatformHttpAuthCredentialDatabaseCreationParams())); factory MacOSHttpAuthCredentialDatabase.static() { return _staticValue; diff --git a/flutter_inappwebview_macos/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview_macos/lib/src/in_app_webview/headless_in_app_webview.dart index e4581bd26..dfabc47a0 100644 --- a/flutter_inappwebview_macos/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_webview/headless_in_app_webview.dart @@ -273,8 +273,7 @@ class MacOSHeadlessInAppWebView extends PlatformHeadlessInAppWebView } static final MacOSHeadlessInAppWebView _staticValue = - MacOSHeadlessInAppWebView( - MacOSHeadlessInAppWebViewCreationParams()); + MacOSHeadlessInAppWebView(MacOSHeadlessInAppWebViewCreationParams()); factory MacOSHeadlessInAppWebView.static() { return _staticValue; diff --git a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart index a9b8238d8..23e13d2d5 100755 --- a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview.dart @@ -278,8 +278,7 @@ class MacOSInAppWebViewWidget extends PlatformInAppWebViewWidget { params.headlessWebView as MacOSHeadlessInAppWebView?; static final MacOSInAppWebViewWidget _staticValue = - MacOSInAppWebViewWidget( - MacOSInAppWebViewWidgetCreationParams()); + MacOSInAppWebViewWidget(MacOSInAppWebViewWidgetCreationParams()); factory MacOSInAppWebViewWidget.static() { return _staticValue; diff --git a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart index 428dbe9dc..d2a6c3ce7 100644 --- a/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_macos/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1481,9 +1481,9 @@ class MacOSInAppWebViewController extends PlatformInAppWebViewController _controllerFromPlatform, request)) ?.toNativeValue()); else - return jsonEncode((await _inAppBrowserEventHandler! - .onAjaxProgress(request)) - ?.toNativeValue()); + return jsonEncode( + (await _inAppBrowserEventHandler!.onAjaxProgress(request)) + ?.toNativeValue()); } return null; case "shouldInterceptFetchRequest": diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index 86d9b7dbe..b32634c06 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -94,7 +94,8 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. @override - MacOSFindInteractionController createPlatformFindInteractionControllerStatic() { + MacOSFindInteractionController + createPlatformFindInteractionControllerStatic() { return MacOSFindInteractionController.static(); } @@ -114,8 +115,8 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [PrintJobController] in `flutter_inappwebview` instead. @override - PlatformPrintJobController createPlatformPrintJobControllerStatic() { - return _PlatformPrintJobController.static(); + MacOSPrintJobController createPlatformPrintJobControllerStatic() { + return MacOSPrintJobController.static(); } /// Creates a new [MacOSWebMessageChannel]. @@ -342,7 +343,8 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. @override - PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { + PlatformServiceWorkerController + createPlatformServiceWorkerControllerStatic() { return _PlatformServiceWorkerController.static(); } @@ -370,18 +372,19 @@ class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig { _PlatformProcessGlobalConfig(PlatformProcessGlobalConfigCreationParams params) : super.implementation(params); static final _PlatformProcessGlobalConfig _staticValue = - _PlatformProcessGlobalConfig( - const PlatformProcessGlobalConfigCreationParams()); + _PlatformProcessGlobalConfig( + const PlatformProcessGlobalConfigCreationParams()); factory _PlatformProcessGlobalConfig.static() => _staticValue; } class _PlatformServiceWorkerController extends PlatformServiceWorkerController { - _PlatformServiceWorkerController(PlatformServiceWorkerControllerCreationParams params) + _PlatformServiceWorkerController( + PlatformServiceWorkerControllerCreationParams params) : super.implementation(params); static final _PlatformServiceWorkerController _staticValue = - _PlatformServiceWorkerController( - const PlatformServiceWorkerControllerCreationParams()); + _PlatformServiceWorkerController( + const PlatformServiceWorkerControllerCreationParams()); factory _PlatformServiceWorkerController.static() => _staticValue; @@ -393,19 +396,8 @@ class _PlatformTracingController extends PlatformTracingController { _PlatformTracingController(PlatformTracingControllerCreationParams params) : super.implementation(params); static final _PlatformTracingController _staticValue = - _PlatformTracingController( - const PlatformTracingControllerCreationParams()); + _PlatformTracingController( + const PlatformTracingControllerCreationParams()); factory _PlatformTracingController.static() => _staticValue; } - -class _PlatformPrintJobController extends PlatformPrintJobController { - _PlatformPrintJobController(PlatformPrintJobControllerCreationParams params) - : super.implementation(params); - - static final _PlatformPrintJobController _staticValue = - _PlatformPrintJobController( - const PlatformPrintJobControllerCreationParams(id: '')); - - factory _PlatformPrintJobController.static() => _staticValue; -} diff --git a/flutter_inappwebview_macos/lib/src/print_job/print_job_controller.dart b/flutter_inappwebview_macos/lib/src/print_job/print_job_controller.dart index adb6df7e7..8b507588c 100644 --- a/flutter_inappwebview_macos/lib/src/print_job/print_job_controller.dart +++ b/flutter_inappwebview_macos/lib/src/print_job/print_job_controller.dart @@ -11,16 +11,14 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla class MacOSPrintJobControllerCreationParams extends PlatformPrintJobControllerCreationParams { /// Creates a new [MacOSPrintJobControllerCreationParams] instance. - const MacOSPrintJobControllerCreationParams( - {required super.id}); + const MacOSPrintJobControllerCreationParams({required super.id}); /// Creates a [MacOSPrintJobControllerCreationParams] instance based on [PlatformPrintJobControllerCreationParams]. factory MacOSPrintJobControllerCreationParams.fromPlatformPrintJobControllerCreationParams( // Recommended placeholder to prevent being broken by platform interface. // ignore: avoid_unused_constructor_parameters PlatformPrintJobControllerCreationParams params) { - return MacOSPrintJobControllerCreationParams( - id: params.id); + return MacOSPrintJobControllerCreationParams(id: params.id); } } @@ -41,6 +39,14 @@ class MacOSPrintJobController extends PlatformPrintJobController initMethodCallHandler(); } + static final MacOSPrintJobController _staticValue = + MacOSPrintJobController(MacOSPrintJobControllerCreationParams(id: '')); + + /// Provide static access. + factory MacOSPrintJobController.static() { + return _staticValue; + } + Future _handleMethod(MethodCall call) async { switch (call.method) { case "onComplete": diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart index b95b582a4..e305de7d2 100755 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.dart @@ -73,13 +73,17 @@ class ChromeSafariBrowserOptions { class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { ///The share state that should be applied to the custom tab. The default value is [CustomTabsShareState.SHARE_STATE_DEFAULT]. @SupportedPlatforms(platforms: [ - AndroidPlatform(note: 'Not available in a Trusted Web Activity.',), + AndroidPlatform( + note: 'Not available in a Trusted Web Activity.', + ), ]) CustomTabsShareState_? shareState; ///Set to `false` if the title shouldn't be shown in the custom tab. The default value is `true`. @SupportedPlatforms(platforms: [ - AndroidPlatform(note: 'Not available in a Trusted Web Activity.',), + AndroidPlatform( + note: 'Not available in a Trusted Web Activity.', + ), ]) bool? showTitle; @@ -109,13 +113,17 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { ///Set to `true` to enable the url bar to hide as the user scrolls down on the page. The default value is `false`. @SupportedPlatforms(platforms: [ - AndroidPlatform( note: 'Not available in a Trusted Web Activity.',), + AndroidPlatform( + note: 'Not available in a Trusted Web Activity.', + ), ]) bool? enableUrlBarHiding; ///Set to `true` to enable Instant Apps. The default value is `false`. @SupportedPlatforms(platforms: [ - AndroidPlatform( note: 'Not available in a Trusted Web Activity.',), + AndroidPlatform( + note: 'Not available in a Trusted Web Activity.', + ), ]) bool? instantAppsEnabled; @@ -155,20 +163,26 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { ///Sets a list of additional trusted origins that the user may navigate or be redirected to from the starting uri. @SupportedPlatforms(platforms: [ - AndroidPlatform(note: 'Not available in a Trusted Web Activity.',), + AndroidPlatform( + note: 'Not available in a Trusted Web Activity.', + ), ]) List? additionalTrustedOrigins; ///Sets a display mode of a Trusted Web Activity. @SupportedPlatforms(platforms: [ - AndroidPlatform(note: 'Not available in a Trusted Web Activity.',), + AndroidPlatform( + note: 'Not available in a Trusted Web Activity.', + ), ]) @ExchangeableObjectProperty(deserializer: _deserializeDisplayMode) TrustedWebActivityDisplayMode_? displayMode; ///Sets a screen orientation. This can be used e.g. to enable the locking of an orientation lock type. @SupportedPlatforms(platforms: [ - AndroidPlatform(note: 'Not available in a Trusted Web Activity.',), + AndroidPlatform( + note: 'Not available in a Trusted Web Activity.', + ), ]) TrustedWebActivityScreenOrientation_? screenOrientation; @@ -313,8 +327,10 @@ class ChromeSafariBrowserSettings_ implements ChromeSafariBrowserOptions { ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. static bool isPropertySupported(ChromeSafariBrowserSettingsProperty property, - {TargetPlatform? platform}) => - _ChromeSafariBrowserSettingsPropertySupported.isPropertySupported(property, platform: platform); + {TargetPlatform? platform}) => + _ChromeSafariBrowserSettingsPropertySupported.isPropertySupported( + property, + platform: platform); } ///Class that represents the options that can be used for an [ChromeSafariBrowser] window. diff --git a/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart index 093b585b7..5eb0c3db7 100644 --- a/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.dart @@ -17,11 +17,8 @@ part 'platform_find_interaction_controller.g.dart'; ///{@endtemplate} /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.supported_platforms} -@SupportedPlatforms(platforms: [ - AndroidPlatform(), - IOSPlatform(), - MacOSPlatform() -]) +@SupportedPlatforms( + platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) @immutable class PlatformFindInteractionControllerCreationParams { /// Used by the platform implementation to create a new [PlatformFindInteractionController]. @@ -41,8 +38,13 @@ class PlatformFindInteractionControllerCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.onFindResultReceived.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'WebView.FindListener.onFindResultReceived', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView.FindListener#onFindResultReceived(int,%20int,%20boolean)'), - IOSPlatform(note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, this event will not be called.'), + AndroidPlatform( + apiName: 'WebView.FindListener.onFindResultReceived', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView.FindListener#onFindResultReceived(int,%20int,%20boolean)'), + IOSPlatform( + note: + 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, this event will not be called.'), MacOSPlatform() ]) final void Function( @@ -55,17 +57,17 @@ class PlatformFindInteractionControllerCreationParams { ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isClassSupported({TargetPlatform? platform}) => - _PlatformFindInteractionControllerCreationParamsClassSupported.isClassSupported( - platform: platform); + _PlatformFindInteractionControllerCreationParamsClassSupported + .isClassSupported(platform: platform); ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.isPropertySupported} ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} - bool isPropertySupported(PlatformFindInteractionControllerCreationParamsProperty property, - {TargetPlatform? platform}) => - _PlatformFindInteractionControllerCreationParamsPropertySupported.isPropertySupported( - property, - platform: platform); + bool isPropertySupported( + PlatformFindInteractionControllerCreationParamsProperty property, + {TargetPlatform? platform}) => + _PlatformFindInteractionControllerCreationParamsPropertySupported + .isPropertySupported(property, platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController} @@ -74,11 +76,8 @@ class PlatformFindInteractionControllerCreationParams { ///{@endtemplate} /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.supported_platforms} -@SupportedPlatforms(platforms: [ - AndroidPlatform(), - IOSPlatform(), - MacOSPlatform() -]) +@SupportedPlatforms( + platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) abstract class PlatformFindInteractionController extends PlatformInterface implements Disposable { ///Debug settings. @@ -104,15 +103,15 @@ abstract class PlatformFindInteractionController extends PlatformInterface /// Creates a new [PlatformFindInteractionController] factory PlatformFindInteractionController.static() { assert( - InAppWebViewPlatform.instance != null, - 'A platform implementation for `flutter_inappwebview` has not been set. Please ' - 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' - '`WebViewPlatform.instance` before use. For unit testing, ' - '`WebViewPlatform.instance` can be set with your own test implementation.', + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', ); final PlatformFindInteractionController findInteractionControllerStatic = - InAppWebViewPlatform.instance! - .createPlatformFindInteractionControllerStatic(); + InAppWebViewPlatform.instance! + .createPlatformFindInteractionControllerStatic(); PlatformInterface.verify(findInteractionControllerStatic, _token); return findInteractionControllerStatic; } @@ -145,8 +144,15 @@ abstract class PlatformFindInteractionController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.findAll.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'WebView.findAllAsync', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#findAllAsync(java.lang.String)', note: 'It finds all instances asynchronously. Successive calls to this will cancel any pending searches.'), - IOSPlatform(note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2) with [Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)'), + AndroidPlatform( + apiName: 'WebView.findAllAsync', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#findAllAsync(java.lang.String)', + note: + 'It finds all instances asynchronously. Successive calls to this will cancel any pending searches.'), + IOSPlatform( + note: + 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.presentFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2) with [Official API - UIFindInteraction.searchText](https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2)'), MacOSPlatform() ]) Future findAll({String? find}) { @@ -162,8 +168,13 @@ abstract class PlatformFindInteractionController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.findNext.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'WebView.findNext', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#findNext(boolean)'), - IOSPlatform(note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.findNext](https://developer.apple.com/documentation/uikit/uifindinteraction/3975829-findnext?changes=_2) and ([Official API - UIFindInteraction.findPrevious](https://developer.apple.com/documentation/uikit/uifindinteraction/3975830-findprevious?changes=_2)'), + AndroidPlatform( + apiName: 'WebView.findNext', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#findNext(boolean)'), + IOSPlatform( + note: + 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.findNext](https://developer.apple.com/documentation/uikit/uifindinteraction/3975829-findnext?changes=_2) and ([Official API - UIFindInteraction.findPrevious](https://developer.apple.com/documentation/uikit/uifindinteraction/3975830-findprevious?changes=_2)'), MacOSPlatform() ]) Future findNext({bool forward = true}) { @@ -177,8 +188,13 @@ abstract class PlatformFindInteractionController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.clearMatches.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'WebView.clearMatches', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#clearMatches()'), - IOSPlatform(note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)'), + AndroidPlatform( + apiName: 'WebView.clearMatches', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#clearMatches()'), + IOSPlatform( + note: + 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it uses the built-in find interaction native UI, otherwise this is implemented using CSS and Javascript. In this case, it will use the [Official API - UIFindInteraction.dismissFindNavigator](https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2)'), MacOSPlatform() ]) Future clearMatches() { @@ -193,7 +209,12 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.setSearchText.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(apiName: 'UIFindInteraction.searchText', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2', note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it will pre-populate the system find panel\'s search text field with a search query.'), + IOSPlatform( + apiName: 'UIFindInteraction.searchText', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2', + note: + 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it will pre-populate the system find panel\'s search text field with a search query.'), MacOSPlatform() ]) Future setSearchText(String? searchText) { @@ -208,7 +229,12 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.getSearchText.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(apiName: 'UIFindInteraction.getSearchText', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2', note: 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it will get the system find panel\'s search text field value.'), + IOSPlatform( + apiName: 'UIFindInteraction.getSearchText', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975834-searchtext?changes=_2', + note: + 'If [InAppWebViewSettings.isFindInteractionEnabled] is `true`, it will get the system find panel\'s search text field value.'), MacOSPlatform() ]) Future getSearchText() { @@ -222,7 +248,12 @@ abstract class PlatformFindInteractionController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.isFindNavigatorVisible.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform(apiName: 'UIFindInteraction.isFindNavigatorVisible', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975828-isfindnavigatorvisible?changes=_2', note: 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), + IOSPlatform( + apiName: 'UIFindInteraction.isFindNavigatorVisible', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975828-isfindnavigatorvisible?changes=_2', + note: + 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), ]) Future isFindNavigatorVisible() { throw UnimplementedError( @@ -235,7 +266,12 @@ abstract class PlatformFindInteractionController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.updateResultCount.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform(apiName: 'UIFindInteraction.updateResultCount', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975835-updateresultcount?changes=_2', note: 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), + IOSPlatform( + apiName: 'UIFindInteraction.updateResultCount', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975835-updateresultcount?changes=_2', + note: + 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), ]) Future updateResultCount() { throw UnimplementedError( @@ -248,7 +284,12 @@ abstract class PlatformFindInteractionController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.presentFindNavigator.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform(apiName: 'UIFindInteraction.presentFindNavigator', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2', note: 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), + IOSPlatform( + apiName: 'UIFindInteraction.presentFindNavigator', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975832-presentfindnavigator?changes=_2', + note: + 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), ]) Future presentFindNavigator() { throw UnimplementedError( @@ -261,7 +302,12 @@ abstract class PlatformFindInteractionController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.dismissFindNavigator.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform(apiName: 'UIFindInteraction.dismissFindNavigator', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2', note: 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), + IOSPlatform( + apiName: 'UIFindInteraction.dismissFindNavigator', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975827-dismissfindnavigator?changes=_2', + note: + 'Available only if [InAppWebViewSettings.isFindInteractionEnabled] is `true`.'), ]) Future dismissFindNavigator() { throw UnimplementedError( @@ -275,7 +321,10 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.getActiveFindSession.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(apiName: 'UIFindInteraction.activeFindSession', apiUrl: 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975825-activefindsession?changes=_7____4_8&language=objc'), + IOSPlatform( + apiName: 'UIFindInteraction.activeFindSession', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uifindinteraction/3975825-activefindsession?changes=_7____4_8&language=objc'), MacOSPlatform() ]) Future getActiveFindSession() { @@ -288,11 +337,8 @@ abstract class PlatformFindInteractionController extends PlatformInterface ///{@endtemplate} /// ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionController.dispose.supported_platforms} - @SupportedPlatforms(platforms: [ - AndroidPlatform(), - IOSPlatform(), - MacOSPlatform() - ]) + @SupportedPlatforms( + platforms: [AndroidPlatform(), IOSPlatform(), MacOSPlatform()]) @override void dispose({bool isKeepAlive = false}) { throw UnimplementedError( @@ -304,14 +350,17 @@ abstract class PlatformFindInteractionController extends PlatformInterface params.isClassSupported(platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformFindInteractionControllerCreationParams.isPropertySupported} - bool isPropertySupported(PlatformFindInteractionControllerCreationParamsProperty property, {TargetPlatform? platform}) => + bool isPropertySupported( + PlatformFindInteractionControllerCreationParamsProperty property, + {TargetPlatform? platform}) => params.isPropertySupported(property, platform: platform); ///{@template flutter_inappwebview_platform_interface.PlatformFindInteractionController.isMethodSupported} ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isMethodSupported(PlatformFindInteractionControllerMethod method, - {TargetPlatform? platform}) => - _PlatformFindInteractionControllerMethodSupported.isMethodSupported(method, + {TargetPlatform? platform}) => + _PlatformFindInteractionControllerMethodSupported.isMethodSupported( + method, platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart index 84420163c..4134bd6a2 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.dart @@ -289,8 +289,9 @@ class InAppBrowserSettings_ ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. static bool isPropertySupported(InAppBrowserSettingsProperty property, - {TargetPlatform? platform}) => - _InAppBrowserSettingsPropertySupported.isPropertySupported(property, platform: platform); + {TargetPlatform? platform}) => + _InAppBrowserSettingsPropertySupported.isPropertySupported(property, + platform: platform); } ///Class that represents the options that can be used for an [InAppBrowser] WebView. diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/main.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/main.dart index b175eabf2..6dba5c505 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/main.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/main.dart @@ -1,6 +1,5 @@ export 'platform_in_app_browser.dart'; -export 'in_app_browser_settings.dart' - hide InAppBrowserSettings_; +export 'in_app_browser_settings.dart' hide InAppBrowserSettings_; export 'android/main.dart'; export 'apple/main.dart'; export 'in_app_browser_menu_item.dart' show InAppBrowserMenuItem; diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart index 838404a3f..d99a3326c 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.dart @@ -147,10 +147,14 @@ abstract class PlatformInAppBrowser extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.initialUserScripts.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(note: """This property will be ignored if the [PlatformWebViewCreationParams.windowId] has been set. + IOSPlatform( + note: + """This property will be ignored if the [PlatformWebViewCreationParams.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 WebKit APIs."""), - MacOSPlatform(note: """This property will be ignored if the [PlatformWebViewCreationParams.windowId] has been set. + MacOSPlatform( + note: + """This property will be ignored if the [PlatformWebViewCreationParams.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 WebKit APIs."""), WindowsPlatform(), @@ -175,7 +179,8 @@ This is a limitation of the native WebKit APIs."""), @SupportedPlatforms(platforms: [ WindowsPlatform(), ]) - PlatformWebViewEnvironment? get webViewEnvironment => params.webViewEnvironment; + PlatformWebViewEnvironment? get webViewEnvironment => + params.webViewEnvironment; ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.webViewController} ///WebView Controller that can be used to access the [PlatformInAppWebViewController] API. @@ -371,8 +376,8 @@ This is a limitation of the native WebKit APIs."""), ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.addMenuItem.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( available: '14.0'), - MacOSPlatform( available: '10.15'), + IOSPlatform(available: '14.0'), + MacOSPlatform(available: '10.15'), ]) void addMenuItem(InAppBrowserMenuItem menuItem) { throw UnimplementedError( @@ -388,8 +393,8 @@ This is a limitation of the native WebKit APIs."""), ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.addMenuItems.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( available: '14.0'), - MacOSPlatform( available: '10.15'), + IOSPlatform(available: '14.0'), + MacOSPlatform(available: '10.15'), ]) void addMenuItems(List menuItems) { throw UnimplementedError( @@ -406,8 +411,8 @@ This is a limitation of the native WebKit APIs."""), ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeMenuItem.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( available: '14.0'), - MacOSPlatform( available: '10.15'), + IOSPlatform(available: '14.0'), + MacOSPlatform(available: '10.15'), ]) bool removeMenuItem(InAppBrowserMenuItem menuItem) { throw UnimplementedError( @@ -423,8 +428,8 @@ This is a limitation of the native WebKit APIs."""), ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeMenuItems.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( available: '14.0'), - MacOSPlatform( available: '10.15'), + IOSPlatform(available: '14.0'), + MacOSPlatform(available: '10.15'), ]) void removeMenuItems(List menuItems) { throw UnimplementedError( @@ -440,8 +445,8 @@ This is a limitation of the native WebKit APIs."""), ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.removeAllMenuItem.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( available: '14.0'), - MacOSPlatform( available: '10.15'), + IOSPlatform(available: '14.0'), + MacOSPlatform(available: '10.15'), ]) void removeAllMenuItem() { throw UnimplementedError( @@ -455,8 +460,8 @@ This is a limitation of the native WebKit APIs."""), ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowser.hasMenuItem.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( available: '14.0'), - MacOSPlatform( available: '10.15'), + IOSPlatform(available: '14.0'), + MacOSPlatform(available: '10.15'), ]) bool hasMenuItem(InAppBrowserMenuItem menuItem) { throw UnimplementedError( @@ -624,33 +629,28 @@ This is a limitation of the native WebKit APIs."""), ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isClassSupported({TargetPlatform? platform}) => - _PlatformInAppBrowserClassSupported.isClassSupported( - platform: platform); + _PlatformInAppBrowserClassSupported.isClassSupported(platform: platform); ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.isPropertySupported} ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isPropertySupported(PlatformInAppBrowserProperty property, - {TargetPlatform? platform}) => - _PlatformInAppBrowserPropertySupported.isPropertySupported( - property, + {TargetPlatform? platform}) => + _PlatformInAppBrowserPropertySupported.isPropertySupported(property, platform: platform); ///{@template flutter_inappwebview_platform_interface.PlatformInAppBrowser.isMethodSupported} ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isMethodSupported(PlatformInAppBrowserMethod method, - {TargetPlatform? platform}) => - _PlatformInAppBrowserMethodSupported.isMethodSupported( - method, + {TargetPlatform? platform}) => + _PlatformInAppBrowserMethodSupported.isMethodSupported(method, platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.isMethodSupported} bool isEventMethodSupported(PlatformInAppBrowserEventsMethod method, - {TargetPlatform? platform}) => - PlatformInAppBrowserEvents.isMethodSupported( - method, - platform: platform); + {TargetPlatform? platform}) => + PlatformInAppBrowserEvents.isMethodSupported(method, platform: platform); } @SupportedPlatforms(platforms: [ @@ -700,10 +700,26 @@ abstract class PlatformInAppBrowserEvents { /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onLoadStart.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onPageStarted', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview',), - WindowsPlatform( apiName: 'ICoreWebView2.add_NavigationStarting', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationstarting',), + AndroidPlatform( + apiName: 'WebViewClient.onPageStarted', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_NavigationStarting', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationstarting', + ), ]) void onLoadStart(WebUri? url) {} @@ -711,10 +727,26 @@ abstract class PlatformInAppBrowserEvents { /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onLoadStop.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onPageFinished', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview',), - WindowsPlatform( apiName: 'ICoreWebView2.add_NavigationCompleted', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted',), + AndroidPlatform( + apiName: 'WebViewClient.onPageFinished', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_NavigationCompleted', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted', + ), ]) void onLoadStop(WebUri? url) {} @@ -733,10 +765,26 @@ abstract class PlatformInAppBrowserEvents { /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onReceivedError.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedError', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview',), - WindowsPlatform( apiName: 'ICoreWebView2.add_NavigationCompleted', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted',), + AndroidPlatform( + apiName: 'WebViewClient.onReceivedError', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_NavigationCompleted', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted', + ), ]) void onReceivedError(WebResourceRequest request, WebResourceError error) {} @@ -755,10 +803,26 @@ abstract class PlatformInAppBrowserEvents { /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onReceivedHttpError.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedHttpError', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse)', available: '23'), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview',), - WindowsPlatform( apiName: 'ICoreWebView2.add_NavigationCompleted', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted',), + AndroidPlatform( + apiName: 'WebViewClient.onReceivedHttpError', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse)', + available: '23'), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_NavigationCompleted', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted', + ), ]) void onReceivedHttpError( WebResourceRequest request, WebResourceResponse errorResponse) {} @@ -767,7 +831,11 @@ abstract class PlatformInAppBrowserEvents { /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onProgressChanged.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onProgressChanged', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int)',), + AndroidPlatform( + apiName: 'WebChromeClient.onProgressChanged', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int)', + ), IOSPlatform(), MacOSPlatform(), WindowsPlatform(), @@ -778,9 +846,17 @@ abstract class PlatformInAppBrowserEvents { /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onConsoleMessage.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onConsoleMessage', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)',), - IOSPlatform( note: 'This event is implemented using JavaScript.',), - MacOSPlatform( note: 'This event is implemented using JavaScript.',), + AndroidPlatform( + apiName: 'WebChromeClient.onConsoleMessage', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)', + ), + IOSPlatform( + note: 'This event is implemented using JavaScript.', + ), + MacOSPlatform( + note: 'This event is implemented using JavaScript.', + ), WebPlatform(), WindowsPlatform(), ]) @@ -790,8 +866,12 @@ abstract class PlatformInAppBrowserEvents { /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.shouldOverrideUrlLoading.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.shouldOverrideUrlLoading', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)', - note: """There isn't any way to load an URL for a frame that is not the main frame, so if the request is not for the main frame, the navigation is allowed by default. + AndroidPlatform( + apiName: 'WebViewClient.shouldOverrideUrlLoading', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)', + note: + """There isn't any way to load an URL for a frame that is not the main frame, so if the request is not for the main frame, the navigation is allowed by default. However, if you want to cancel requests for subframes, you can use the [InAppWebViewSettings.regexToCancelSubFramesLoading] setting to write a Regular Expression that, if the url request of a subframe matches, then the request of that subframe is canceled. Instead, the [InAppWebViewSettings.regexToAllowSyncUrlLoading] setting could @@ -799,8 +879,16 @@ be used to allow navigation requests synchronously, as this event is synchronous and the current plugin implementation will always cancel the current request and load a new request if this event returns [NavigationActionPolicy.ALLOW] because Flutter method channels work only asynchronously. Also, this event is not called for POST requests and is not called on the first page load."""), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview',), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview', + ), WindowsPlatform(), ]) FutureOr? shouldOverrideUrlLoading( @@ -812,9 +900,15 @@ Also, this event is not called for POST requests and is not called on the first /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onLoadResource.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( note: 'This event is implemented using JavaScript.',), - IOSPlatform( note: 'This event is implemented using JavaScript.',), - MacOSPlatform( note: 'This event is implemented using JavaScript.',), + AndroidPlatform( + note: 'This event is implemented using JavaScript.', + ), + IOSPlatform( + note: 'This event is implemented using JavaScript.', + ), + MacOSPlatform( + note: 'This event is implemented using JavaScript.', + ), ]) void onLoadResource(LoadedResource resource) {} @@ -822,9 +916,19 @@ Also, this event is not called for POST requests and is not called on the first /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onScrollChanged.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.onScrollChanged', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int)',), - IOSPlatform( apiName: 'UIScrollViewDelegate.scrollViewDidScroll', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll',), - MacOSPlatform( note: 'This event is implemented using JavaScript.',), + AndroidPlatform( + apiName: 'WebView.onScrollChanged', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int)', + ), + IOSPlatform( + apiName: 'UIScrollViewDelegate.scrollViewDidScroll', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll', + ), + MacOSPlatform( + note: 'This event is implemented using JavaScript.', + ), ]) void onScrollChanged(int x, int y) {} @@ -853,10 +957,18 @@ Also, this event is not called for POST requests and is not called on the first /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onDownloadStarting.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.setDownloadListener', apiUrl: '(https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)',), + AndroidPlatform( + apiName: 'WebView.setDownloadListener', + apiUrl: + '(https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)', + ), IOSPlatform(), MacOSPlatform(), - WindowsPlatform( apiName: 'ICoreWebView2_4.add_DownloadStarting', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_4?view=webview2-1.0.2849.39#add_downloadstarting',), + WindowsPlatform( + apiName: 'ICoreWebView2_4.add_DownloadStarting', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_4?view=webview2-1.0.2849.39#add_downloadstarting', + ), ]) FutureOr? onDownloadStarting( DownloadStartRequest downloadStartRequest) { @@ -881,8 +993,16 @@ Also, this event is not called for POST requests and is not called on the first ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onLoadResourceWithCustomScheme.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( apiName: 'WKURLSchemeHandler', apiUrl: 'https://developer.apple.com/documentation/webkit/wkurlschemehandler',), - MacOSPlatform( apiName: 'WKURLSchemeHandler', apiUrl: 'https://developer.apple.com/documentation/webkit/wkurlschemehandler',), + IOSPlatform( + apiName: 'WKURLSchemeHandler', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkurlschemehandler', + ), + MacOSPlatform( + apiName: 'WKURLSchemeHandler', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkurlschemehandler', + ), WindowsPlatform(), ]) FutureOr? onLoadResourceWithCustomScheme( @@ -894,10 +1014,18 @@ Also, this event is not called for POST requests and is not called on the first /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onCreateWindow.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onCreateWindow', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)', - note: 'You need to set [InAppWebViewSettings.supportMultipleWindows] setting to `true`. Also, if the request has been created using JavaScript (`window.open()`), then there are some limitation: check the [NavigationAction] class.'), - IOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview', - note: """Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], + AndroidPlatform( + apiName: 'WebChromeClient.onCreateWindow', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)', + note: + 'You need to set [InAppWebViewSettings.supportMultipleWindows] setting to `true`. Also, if the request has been created using JavaScript (`window.open()`), then there are some limitation: check the [NavigationAction] class.'), + IOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview', + note: + """Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], [InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically], [InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito], [InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture], @@ -912,8 +1040,12 @@ with a different `WKWebViewConfiguration` instance (see https://developer.apple. So, these options will be inherited from the caller WebView. Also, note that calling [InAppWebViewController.setSettings] method using the controller of the new created WebView, it will update also the WebView options of the caller WebView."""), - MacOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview', - note: """Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], + MacOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview', + note: + """Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], [InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically], [InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito], [InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture], @@ -928,7 +1060,11 @@ with a different `WKWebViewConfiguration` instance (see https://developer.apple. So, these options will be inherited from the caller WebView. Also, note that calling [InAppWebViewController.setSettings] method using the controller of the new created WebView, it will update also the WebView options of the caller WebView."""), - WindowsPlatform( apiName: 'ICoreWebView2.add_NewWindowRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_newwindowrequested',), + WindowsPlatform( + apiName: 'ICoreWebView2.add_NewWindowRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_newwindowrequested', + ), ]) FutureOr? onCreateWindow(CreateWindowAction createWindowAction) { return null; @@ -938,11 +1074,27 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onCloseWindow.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onCloseWindow', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onCloseWindow(android.webkit.WebView)',), - IOSPlatform( apiName: 'WKUIDelegate.webViewDidClose', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose',), - MacOSPlatform( apiName: 'WKUIDelegate.webViewDidClose', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose',), + AndroidPlatform( + apiName: 'WebChromeClient.onCloseWindow', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onCloseWindow(android.webkit.WebView)', + ), + IOSPlatform( + apiName: 'WKUIDelegate.webViewDidClose', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose', + ), + MacOSPlatform( + apiName: 'WKUIDelegate.webViewDidClose', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose', + ), WebPlatform(), - WindowsPlatform( apiName: 'ICoreWebView2.add_WindowCloseRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_windowcloserequested',), + WindowsPlatform( + apiName: 'ICoreWebView2.add_WindowCloseRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_windowcloserequested', + ), ]) void onCloseWindow() {} @@ -970,9 +1122,21 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onJsAlert.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onJsAlert', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)',), - IOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview',), - MacOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview',), + AndroidPlatform( + apiName: 'WebChromeClient.onJsAlert', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)', + ), + IOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview', + ), + MacOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview', + ), ]) FutureOr? onJsAlert(JsAlertRequest jsAlertRequest) { return null; @@ -982,9 +1146,21 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onJsConfirm.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onJsConfirm', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsConfirm(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)',), - IOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview',), - MacOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview',), + AndroidPlatform( + apiName: 'WebChromeClient.onJsConfirm', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsConfirm(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)', + ), + IOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview', + ), + MacOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview', + ), ]) FutureOr? onJsConfirm(JsConfirmRequest jsConfirmRequest) { return null; @@ -994,9 +1170,21 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onJsPrompt.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onJsPrompt', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult)',), - IOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview',), - MacOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview',), + AndroidPlatform( + apiName: 'WebChromeClient.onJsPrompt', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult)', + ), + IOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview', + ), + MacOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview', + ), ]) FutureOr? onJsPrompt(JsPromptRequest jsPromptRequest) { return null; @@ -1006,10 +1194,26 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onReceivedHttpAuthRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedHttpAuthRequest', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview',), - WindowsPlatform( apiName: 'ICoreWebView2_10.add_BasicAuthenticationRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_10?view=webview2-1.0.2849.39#add_basicauthenticationrequested',), + AndroidPlatform( + apiName: 'WebViewClient.onReceivedHttpAuthRequest', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + ), + WindowsPlatform( + apiName: 'ICoreWebView2_10.add_BasicAuthenticationRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_10?view=webview2-1.0.2849.39#add_basicauthenticationrequested', + ), ]) FutureOr? onReceivedHttpAuthRequest( HttpAuthenticationChallenge challenge) { @@ -1020,14 +1224,30 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onReceivedServerTrustAuthRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedSslError', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', - note: """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. + AndroidPlatform( + apiName: 'WebViewClient.onReceivedSslError', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + note: + """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. See `NSAppTransportSecurity` in the [Information Property List Key Reference](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1) for details."""), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', - note: """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + note: + """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. See `NSAppTransportSecurity` in the [Information Property List Key Reference](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1) for details."""), - WindowsPlatform( apiName: 'ICoreWebView2_14.add_ServerCertificateErrorDetected', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_14?view=webview2-1.0.2792.45#add_servercertificateerrordetected',), + WindowsPlatform( + apiName: 'ICoreWebView2_14.add_ServerCertificateErrorDetected', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_14?view=webview2-1.0.2792.45#add_servercertificateerrordetected', + ), ]) FutureOr? onReceivedServerTrustAuthRequest( ServerTrustChallenge challenge) { @@ -1038,10 +1258,26 @@ See `NSAppTransportSecurity` in the [Information Property List Key Reference](ht /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onReceivedClientCertRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedClientCertRequest', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedClientCertRequest(android.webkit.WebView,%20android.webkit.ClientCertRequest)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview',), - WindowsPlatform( apiName: 'ICoreWebView2_5.add_ClientCertificateRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_5?view=webview2-1.0.2849.39#add_clientcertificaterequested',), + AndroidPlatform( + apiName: 'WebViewClient.onReceivedClientCertRequest', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedClientCertRequest(android.webkit.WebView,%20android.webkit.ClientCertRequest)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + ), + WindowsPlatform( + apiName: 'ICoreWebView2_5.add_ClientCertificateRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_5?view=webview2-1.0.2849.39#add_clientcertificaterequested', + ), ]) FutureOr? onReceivedClientCertRequest( ClientCertChallenge challenge) { @@ -1064,7 +1300,9 @@ See `NSAppTransportSecurity` in the [Information Property List Key Reference](ht /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.shouldInterceptAjaxRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting documentation. + AndroidPlatform( + note: + """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. @@ -1080,7 +1318,9 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onAjaxReadyStateChange.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxReadyStateChange] settings documentation. + AndroidPlatform( + note: + """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxReadyStateChange] settings documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. @@ -1097,7 +1337,9 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onAjaxProgress.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxProgress] settings documentation. + AndroidPlatform( + note: + """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxProgress] settings documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. @@ -1113,7 +1355,9 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.shouldInterceptFetchRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptFetchRequest] setting documentation. + AndroidPlatform( + note: + """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptFetchRequest] setting documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. @@ -1130,10 +1374,18 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onUpdateVisitedHistory.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.doUpdateVisitedHistory', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean)',), + AndroidPlatform( + apiName: 'WebViewClient.doUpdateVisitedHistory', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean)', + ), IOSPlatform(), MacOSPlatform(), - WindowsPlatform( apiName: 'ICoreWebView2.add_HistoryChanged', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_historychanged',), + WindowsPlatform( + apiName: 'ICoreWebView2.add_HistoryChanged', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_historychanged', + ), ]) void onUpdateVisitedHistory(WebUri? url, @SupportedPlatforms(platforms: [AndroidPlatform()]) bool? isReload) {} @@ -1152,9 +1404,19 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onPrintRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'View.scrollBy', apiUrl: 'https://developer.android.com/reference/android/view/View#scrollBy(int,%20int)',), - IOSPlatform( apiName: 'UIScrollView.setContentOffset', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset',), - MacOSPlatform( note: 'This method is implemented using JavaScript.',), + AndroidPlatform( + apiName: 'View.scrollBy', + apiUrl: + 'https://developer.android.com/reference/android/view/View#scrollBy(int,%20int)', + ), + IOSPlatform( + apiName: 'UIScrollView.setContentOffset', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), ]) FutureOr? onPrintRequest( WebUri? url, PlatformPrintJobController? printJobController) { @@ -1165,8 +1427,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onLongPressHitTestResult.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'View.setOnLongClickListener', apiUrl: 'https://developer.android.com/reference/android/view/View#setOnLongClickListener(android.view.View.OnLongClickListener)',), - IOSPlatform( apiName: 'UILongPressGestureRecognizer', apiUrl: 'https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer',), + AndroidPlatform( + apiName: 'View.setOnLongClickListener', + apiUrl: + 'https://developer.android.com/reference/android/view/View#setOnLongClickListener(android.view.View.OnLongClickListener)', + ), + IOSPlatform( + apiName: 'UILongPressGestureRecognizer', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer', + ), ]) void onLongPressHitTestResult(InAppWebViewHitTestResult hitTestResult) {} @@ -1174,9 +1444,21 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onEnterFullscreen.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onShowCustomView', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)',), - IOSPlatform( apiName: 'UIWindow.didBecomeVisibleNotification', apiUrl: 'https://developer.apple.com/documentation/uikit/uiwindow/1621621-didbecomevisiblenotification',), - MacOSPlatform( apiName: 'NSWindow.didEnterFullScreenNotification', apiUrl: 'https://developer.apple.com/documentation/appkit/nswindow/1419651-didenterfullscreennotification',), + AndroidPlatform( + apiName: 'WebChromeClient.onShowCustomView', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)', + ), + IOSPlatform( + apiName: 'UIWindow.didBecomeVisibleNotification', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiwindow/1621621-didbecomevisiblenotification', + ), + MacOSPlatform( + apiName: 'NSWindow.didEnterFullScreenNotification', + apiUrl: + 'https://developer.apple.com/documentation/appkit/nswindow/1419651-didenterfullscreennotification', + ), ]) void onEnterFullscreen() {} @@ -1184,9 +1466,21 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onExitFullscreen.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onHideCustomView', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()',), - IOSPlatform( apiName: 'UIWindow.didBecomeHiddenNotification', apiUrl: 'https://developer.apple.com/documentation/uikit/uiwindow/1621617-didbecomehiddennotification',), - MacOSPlatform( apiName: 'NSWindow.didExitFullScreenNotification', apiUrl: 'https://developer.apple.com/documentation/appkit/nswindow/1419177-didexitfullscreennotification',), + AndroidPlatform( + apiName: 'WebChromeClient.onHideCustomView', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()', + ), + IOSPlatform( + apiName: 'UIWindow.didBecomeHiddenNotification', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiwindow/1621617-didbecomehiddennotification', + ), + MacOSPlatform( + apiName: 'NSWindow.didExitFullScreenNotification', + apiUrl: + 'https://developer.apple.com/documentation/appkit/nswindow/1419177-didexitfullscreennotification', + ), ]) void onExitFullscreen() {} @@ -1194,9 +1488,21 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onPageCommitVisible.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onPageCommitVisible', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview',), + AndroidPlatform( + apiName: 'WebViewClient.onPageCommitVisible', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview', + ), ]) void onPageCommitVisible(WebUri? url) {} @@ -1204,10 +1510,18 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onTitleChanged.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onReceivedTitle', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)',), + AndroidPlatform( + apiName: 'WebChromeClient.onReceivedTitle', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)', + ), IOSPlatform(), MacOSPlatform(), - WindowsPlatform( apiName: 'ICoreWebView2.add_DocumentTitleChanged', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_documenttitlechanged',), + WindowsPlatform( + apiName: 'ICoreWebView2.add_DocumentTitleChanged', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_documenttitlechanged', + ), ]) void onTitleChanged(String? title) {} @@ -1215,7 +1529,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onOverScrolled.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.onOverScrolled', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean)',), + AndroidPlatform( + apiName: 'WebView.onOverScrolled', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean)', + ), IOSPlatform(), ]) void onOverScrolled(int x, int y, bool clampedX, bool clampedY) {} @@ -1224,9 +1542,21 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onZoomScaleChanged.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onScaleChanged', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onScaleChanged(android.webkit.WebView,%20float,%20float)',), - IOSPlatform( apiName: 'UIScrollViewDelegate.scrollViewDidZoom', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619409-scrollviewdidzoom',), - WindowsPlatform( apiName: 'ICoreWebView2Controller.add_ZoomFactorChanged', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.2849.39#add_zoomfactorchanged',), + AndroidPlatform( + apiName: 'WebViewClient.onScaleChanged', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onScaleChanged(android.webkit.WebView,%20float,%20float)', + ), + IOSPlatform( + apiName: 'UIScrollViewDelegate.scrollViewDidZoom', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619409-scrollviewdidzoom', + ), + WindowsPlatform( + apiName: 'ICoreWebView2Controller.add_ZoomFactorChanged', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.2849.39#add_zoomfactorchanged', + ), ]) void onZoomScaleChanged(double oldScale, double newScale) {} @@ -1246,7 +1576,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onSafeBrowsingHit.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onSafeBrowsingHit', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse)', available: '27'), + AndroidPlatform( + apiName: 'WebViewClient.onSafeBrowsingHit', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse)', + available: '27'), ]) FutureOr? onSafeBrowsingHit( WebUri url, SafeBrowsingThreat? threatType) { @@ -1269,10 +1603,26 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onPermissionRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onPermissionRequest', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)', available: '21'), - IOSPlatform( available: '15.0', note: 'The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].',), - MacOSPlatform( available: '12.0', note: 'The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].',), - WindowsPlatform( apiName: 'ICoreWebView2.add_PermissionRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_permissionrequested',), + AndroidPlatform( + apiName: 'WebChromeClient.onPermissionRequest', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)', + available: '21'), + IOSPlatform( + available: '15.0', + note: + 'The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].', + ), + MacOSPlatform( + available: '12.0', + note: + 'The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_PermissionRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_permissionrequested', + ), ]) FutureOr? onPermissionRequest( PermissionRequest permissionRequest) { @@ -1295,7 +1645,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onGeolocationPermissionsShowPrompt.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onGeolocationPermissionsShowPrompt', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)',), + AndroidPlatform( + apiName: 'WebChromeClient.onGeolocationPermissionsShowPrompt', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)', + ), ]) FutureOr? onGeolocationPermissionsShowPrompt(String origin) { @@ -1315,7 +1669,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onGeolocationPermissionsHidePrompt.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onGeolocationPermissionsHidePrompt', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt()',), + AndroidPlatform( + apiName: 'WebChromeClient.onGeolocationPermissionsHidePrompt', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt()', + ), ]) void onGeolocationPermissionsHidePrompt() {} @@ -1335,8 +1693,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.shouldInterceptRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.shouldInterceptRequest', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest)',), - WindowsPlatform( apiName: 'ICoreWebView2.add_WebResourceRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2478.35#add_webresourcerequested',), + AndroidPlatform( + apiName: 'WebViewClient.shouldInterceptRequest', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest)', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_WebResourceRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2478.35#add_webresourcerequested', + ), ]) FutureOr? shouldInterceptRequest( WebResourceRequest request) { @@ -1359,8 +1725,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onRenderProcessUnresponsive.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewRenderProcessClient.onRenderProcessUnresponsive', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)', available: '29'), - WindowsPlatform( apiName: 'ICoreWebView2.add_ProcessFailed', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed',), + AndroidPlatform( + apiName: 'WebViewRenderProcessClient.onRenderProcessUnresponsive', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)', + available: '29'), + WindowsPlatform( + apiName: 'ICoreWebView2.add_ProcessFailed', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed', + ), ]) FutureOr? onRenderProcessUnresponsive( WebUri? url) { @@ -1383,7 +1757,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onRenderProcessResponsive.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewRenderProcessClient.onRenderProcessResponsive', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)', available: '29'), + AndroidPlatform( + apiName: 'WebViewRenderProcessClient.onRenderProcessResponsive', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)', + available: '29'), ]) FutureOr? onRenderProcessResponsive( WebUri? url) { @@ -1403,8 +1781,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onRenderProcessGone.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onRenderProcessGone', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail)', available: '26'), - WindowsPlatform( apiName: 'ICoreWebView2.add_ProcessFailed', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed',), + AndroidPlatform( + apiName: 'WebViewClient.onRenderProcessGone', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail)', + available: '26'), + WindowsPlatform( + apiName: 'ICoreWebView2.add_ProcessFailed', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed', + ), ]) void onRenderProcessGone(RenderProcessGoneDetail detail) {} @@ -1423,7 +1809,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onFormResubmission.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onFormResubmission', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message)',), + AndroidPlatform( + apiName: 'WebViewClient.onFormResubmission', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message)', + ), ]) FutureOr? onFormResubmission(WebUri? url) { return null; @@ -1451,7 +1841,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onReceivedIcon.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onReceivedIcon', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap)',), + AndroidPlatform( + apiName: 'WebChromeClient.onReceivedIcon', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap)', + ), ]) void onReceivedIcon(Uint8List icon) {} @@ -1468,7 +1862,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.androidOnReceivedTouchIconUrl.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onReceivedTouchIconUrl', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)',), + AndroidPlatform( + apiName: 'WebChromeClient.onReceivedTouchIconUrl', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)', + ), ]) void onReceivedTouchIconUrl(WebUri url, bool precomposed) {} @@ -1505,7 +1903,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onReceivedLoginRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedLoginRequest', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String)',), + AndroidPlatform( + apiName: 'WebViewClient.onReceivedLoginRequest', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String)', + ), ]) void onReceivedLoginRequest(LoginRequest loginRequest) {} @@ -1513,7 +1915,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onPermissionRequestCanceled.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onPermissionRequestCanceled', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequestCanceled(android.webkit.PermissionRequest)', available: '21'), + AndroidPlatform( + apiName: 'WebChromeClient.onPermissionRequestCanceled', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequestCanceled(android.webkit.PermissionRequest)', + available: '21'), ]) void onPermissionRequestCanceled(PermissionRequest permissionRequest) {} @@ -1521,7 +1927,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onRequestFocus.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onRequestFocus', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onRequestFocus(android.webkit.WebView)',), + AndroidPlatform( + apiName: 'WebChromeClient.onRequestFocus', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onRequestFocus(android.webkit.WebView)', + ), ]) void onRequestFocus() {} @@ -1538,9 +1948,21 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onWebContentProcessDidTerminate.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKNavigationDelegate.webViewWebContentProcessDidTerminate', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webViewWebContentProcessDidTerminate', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi',), - WindowsPlatform( apiName: 'ICoreWebView2.add_ProcessFailed', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed',), + IOSPlatform( + apiName: 'WKNavigationDelegate.webViewWebContentProcessDidTerminate', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webViewWebContentProcessDidTerminate', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_ProcessFailed', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed', + ), ]) void onWebContentProcessDidTerminate() {} @@ -1557,8 +1979,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onDidReceiveServerRedirectForProvisionalNavigation.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview',), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview', + ), ]) void onDidReceiveServerRedirectForProvisionalNavigation() {} @@ -1578,8 +2008,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onNavigationResponse.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview',), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview', + ), ]) FutureOr? onNavigationResponse( NavigationResponse navigationResponse) { @@ -1602,8 +2040,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.shouldAllowDeprecatedTLS.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview', available: '14.0'), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview', available: '11.0'), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview', + available: '14.0'), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview', + available: '11.0'), ]) FutureOr? shouldAllowDeprecatedTLS( URLAuthenticationChallenge challenge) { @@ -1614,8 +2060,12 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onCameraCaptureStateChanged.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( available: '15.0',), - MacOSPlatform( available: '12.0',), + IOSPlatform( + available: '15.0', + ), + MacOSPlatform( + available: '12.0', + ), ]) void onCameraCaptureStateChanged( MediaCaptureState? oldState, @@ -1626,8 +2076,12 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onMicrophoneCaptureStateChanged.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( available: '15.0',), - MacOSPlatform( available: '12.0',), + IOSPlatform( + available: '15.0', + ), + MacOSPlatform( + available: '12.0', + ), ]) void onMicrophoneCaptureStateChanged( MediaCaptureState? oldState, @@ -1646,7 +2100,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onProcessFailed.supported_platforms} @SupportedPlatforms(platforms: [ - WindowsPlatform( apiName: 'ICoreWebView2.add_ProcessFailed', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed',), + WindowsPlatform( + apiName: 'ICoreWebView2.add_ProcessFailed', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed', + ), ]) void onProcessFailed(ProcessFailedDetail detail) {} @@ -1654,7 +2112,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onAcceleratorKeyPressed.supported_platforms} @SupportedPlatforms(platforms: [ - WindowsPlatform( apiName: 'ICoreWebView2Controller.add_AcceleratorKeyPressed', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.2849.39#add_acceleratorkeypressed',), + WindowsPlatform( + apiName: 'ICoreWebView2Controller.add_AcceleratorKeyPressed', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.2849.39#add_acceleratorkeypressed', + ), ]) void onAcceleratorKeyPressed(AcceleratorKeyPressedDetail detail) {} @@ -1662,7 +2124,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppBrowserEvents.onShowFileChooser.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onShowFileChooser', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onShowFileChooser(android.webkit.WebView,%20android.webkit.ValueCallback%3Candroid.net.Uri[]%3E,%20android.webkit.WebChromeClient.FileChooserParams)',), + AndroidPlatform( + apiName: 'WebChromeClient.onShowFileChooser', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onShowFileChooser(android.webkit.WebView,%20android.webkit.ValueCallback%3Candroid.net.Uri[]%3E,%20android.webkit.WebChromeClient.FileChooserParams)', + ), ]) FutureOr onShowFileChooser( ShowFileChooserRequest request) { @@ -1673,8 +2139,7 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} static bool isMethodSupported(PlatformInAppBrowserEventsMethod method, - {TargetPlatform? platform}) => - _PlatformInAppBrowserEventsMethodSupported.isMethodSupported( - method, + {TargetPlatform? platform}) => + _PlatformInAppBrowserEventsMethodSupported.isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart index dc64733c7..cfc4c6931 100755 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.dart @@ -2301,8 +2301,9 @@ as it can cause framerate drops on animations in Android 9 and lower (see [Hybri ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. static bool isPropertySupported(InAppWebViewSettingsProperty property, - {TargetPlatform? platform}) => - _InAppWebViewSettingsPropertySupported.isPropertySupported(property, platform: platform); + {TargetPlatform? platform}) => + _InAppWebViewSettingsPropertySupported.isPropertySupported(property, + platform: platform); } ///Class that represents the options that can be used for a `WebView`. diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/main.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/main.dart index 6c2af0a71..77dbb0298 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/main.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/main.dart @@ -1,8 +1,7 @@ export 'platform_inappwebview_controller.dart'; export 'platform_inappwebview_widget.dart'; export 'platform_webview.dart'; -export 'in_app_webview_settings.dart' - hide InAppWebViewSettings_; +export 'in_app_webview_settings.dart' hide InAppWebViewSettings_; export 'platform_headless_in_app_webview.dart'; export 'in_app_webview_keep_alive.dart'; export 'android/main.dart'; diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart index fe8b9cc8d..93cc601ad 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.dart @@ -515,7 +515,8 @@ abstract class PlatformInAppWebViewController extends PlatformInterface apiName: 'Location.reload', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Location/reload', - note: 'if `window.location.reload()` is not accessible inside the iframe, it will reload using the iframe `src` attribute.', + note: + 'if `window.location.reload()` is not accessible inside the iframe, it will reload using the iframe `src` attribute.', ), WindowsPlatform( apiName: 'ICoreWebView2.Reload', @@ -539,10 +540,25 @@ abstract class PlatformInAppWebViewController extends PlatformInterface apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#goBack()', ), - IOSPlatform( apiName: 'WKWebView.goBack', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback',), - MacOSPlatform( apiName: 'WKWebView.goBack', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback',), - WebPlatform( apiName: 'History.back', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/History/back',), - WindowsPlatform( apiName: 'ICoreWebView2.GoBack', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#goback',) + IOSPlatform( + apiName: 'WKWebView.goBack', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback', + ), + MacOSPlatform( + apiName: 'WKWebView.goBack', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414952-goback', + ), + WebPlatform( + apiName: 'History.back', + apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/History/back', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.GoBack', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#goback', + ) ]) Future goBack() { throw UnimplementedError( @@ -555,10 +571,26 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.canGoBack.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.canGoBack', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#canGoBack()',), - IOSPlatform( apiName: 'WKWebView.canGoBack', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback',), - MacOSPlatform( apiName: 'WKWebView.canGoBack', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback',), - WindowsPlatform( apiName: 'ICoreWebView2.get_CanGoBack', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#get_cangoback',) + AndroidPlatform( + apiName: 'WebView.canGoBack', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#canGoBack()', + ), + IOSPlatform( + apiName: 'WKWebView.canGoBack', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback', + ), + MacOSPlatform( + apiName: 'WKWebView.canGoBack', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414966-cangoback', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.get_CanGoBack', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#get_cangoback', + ) ]) Future canGoBack() { throw UnimplementedError( @@ -571,11 +603,31 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.goForward.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.goForward', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#goForward()',), - IOSPlatform( apiName: 'WKWebView.goForward', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward',), - MacOSPlatform( apiName: 'WKWebView.goForward', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward',), - WebPlatform( apiName: 'History.forward', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/History/forward',), - WindowsPlatform( apiName: 'ICoreWebView2.GoForward', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#goforward',) + AndroidPlatform( + apiName: 'WebView.goForward', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#goForward()', + ), + IOSPlatform( + apiName: 'WKWebView.goForward', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward', + ), + MacOSPlatform( + apiName: 'WKWebView.goForward', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414993-goforward', + ), + WebPlatform( + apiName: 'History.forward', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/History/forward', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.GoForward', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#goforward', + ) ]) Future goForward() { throw UnimplementedError( @@ -588,10 +640,26 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.canGoForward.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.canGoForward', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#canGoForward()',), - IOSPlatform( apiName: 'WKWebView.canGoForward', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward',), - MacOSPlatform( apiName: 'WKWebView.canGoForward', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward',), - WindowsPlatform( apiName: 'ICoreWebView2.get_CanGoForward', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#get_cangoforward',) + AndroidPlatform( + apiName: 'WebView.canGoForward', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#canGoForward()', + ), + IOSPlatform( + apiName: 'WKWebView.canGoForward', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward', + ), + MacOSPlatform( + apiName: 'WKWebView.canGoForward', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414962-cangoforward', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.get_CanGoForward', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#get_cangoforward', + ) ]) Future canGoForward() { throw UnimplementedError( @@ -604,10 +672,25 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.goBackOrForward.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.goBackOrForward', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#goBackOrForward(int)',), - IOSPlatform( apiName: 'WKWebView.go', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414991-go',), - MacOSPlatform( apiName: 'WKWebView.go', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414991-go',), - WebPlatform( apiName: 'History.go', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/History/go',), + AndroidPlatform( + apiName: 'WebView.goBackOrForward', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#goBackOrForward(int)', + ), + IOSPlatform( + apiName: 'WKWebView.go', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414991-go', + ), + MacOSPlatform( + apiName: 'WKWebView.go', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414991-go', + ), + WebPlatform( + apiName: 'History.go', + apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/History/go', + ), WindowsPlatform(), ]) Future goBackOrForward({required int steps}) { @@ -622,7 +705,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.canGoBackOrForward.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.canGoBackOrForward', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#canGoBackOrForward(int)',), + AndroidPlatform( + apiName: 'WebView.canGoBackOrForward', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#canGoBackOrForward(int)', + ), IOSPlatform(), MacOSPlatform(), WindowsPlatform(), @@ -645,7 +732,8 @@ abstract class PlatformInAppWebViewController extends PlatformInterface WindowsPlatform(), ]) Future goTo({required WebHistoryItem historyItem}) { - throw UnimplementedError('${PlatformInAppWebViewControllerMethod.goTo.name} is not implemented on the current platform'); + throw UnimplementedError( + '${PlatformInAppWebViewControllerMethod.goTo.name} is not implemented on the current platform'); } ///{@template flutter_inappwebview_platform_interface.PlatformInAppWebViewController.isLoading} @@ -657,7 +745,9 @@ abstract class PlatformInAppWebViewController extends PlatformInterface AndroidPlatform(), IOSPlatform(), MacOSPlatform(), - WebPlatform(requiresSameOrigin: false,), + WebPlatform( + requiresSameOrigin: false, + ), WindowsPlatform(), ]) Future isLoading() { @@ -671,11 +761,30 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.stopLoading.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.stopLoading', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#stopLoading()',), - IOSPlatform( apiName: 'WKWebView.stopLoading', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading',), - MacOSPlatform( apiName: 'WKWebView.stopLoading', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading',), - WebPlatform( apiName: 'Window.stop', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/stop',), - WindowsPlatform( apiName: 'ICoreWebView2.Stop', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#stop',) + AndroidPlatform( + apiName: 'WebView.stopLoading', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#stopLoading()', + ), + IOSPlatform( + apiName: 'WKWebView.stopLoading', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading', + ), + MacOSPlatform( + apiName: 'WKWebView.stopLoading', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414981-stoploading', + ), + WebPlatform( + apiName: 'Window.stop', + apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/stop', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.Stop', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#stop', + ) ]) Future stopLoading() { throw UnimplementedError( @@ -699,16 +808,41 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.evaluateJavascript.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.evaluateJavascript', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#evaluateJavascript(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.String%3E)',), - IOSPlatform( apiName: 'WKWebView.evaluateJavaScript', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript',), - MacOSPlatform( apiName: 'WKWebView.evaluateJavaScript', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript',), - WebPlatform( apiName: 'Window.eval', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval',), + AndroidPlatform( + apiName: 'WebView.evaluateJavascript', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#evaluateJavascript(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.String%3E)', + ), + IOSPlatform( + apiName: 'WKWebView.evaluateJavaScript', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript', + ), + MacOSPlatform( + apiName: 'WKWebView.evaluateJavaScript', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3656442-evaluatejavascript', + ), + WebPlatform( + apiName: 'Window.eval', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval', + ), WindowsPlatform(), ]) Future evaluateJavascript( {required String source, - @SupportedPlatforms(platforms: [AndroidPlatform(), IOSPlatform(available: '14.0',), MacOSPlatform(available: '11.0',), WindowsPlatform()]) - ContentWorld? contentWorld}) { + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform( + available: '14.0', + ), + MacOSPlatform( + available: '11.0', + ), + WindowsPlatform() + ]) + ContentWorld? contentWorld}) { throw UnimplementedError( '${PlatformInAppWebViewControllerMethod.evaluateJavascript.name} is not implemented on the current platform'); } @@ -942,9 +1076,22 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.takeScreenshot.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( note: 'To be able to take screenshots outside the visible viewport, you must call [PlatformInAppWebViewController.enableSlowWholeDocumentDraw] before any WebViews are created.',), - IOSPlatform( apiName: 'WKWebView.takeSnapshot', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot', available: '11.0',), - MacOSPlatform( apiName: 'WKWebView.takeSnapshot', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot', available: '10.13',), + AndroidPlatform( + note: + 'To be able to take screenshots outside the visible viewport, you must call [PlatformInAppWebViewController.enableSlowWholeDocumentDraw] before any WebViews are created.', + ), + IOSPlatform( + apiName: 'WKWebView.takeSnapshot', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot', + available: '11.0', + ), + MacOSPlatform( + apiName: 'WKWebView.takeSnapshot', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/2873260-takesnapshot', + available: '10.13', + ), WindowsPlatform(), ]) Future takeScreenshot( @@ -996,9 +1143,21 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getCopyBackForwardList.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.copyBackForwardList', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#copyBackForwardList()',), - IOSPlatform( apiName: 'WKWebView.backForwardList', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist',), - MacOSPlatform( apiName: 'WKWebView.backForwardList', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist',), + AndroidPlatform( + apiName: 'WebView.copyBackForwardList', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#copyBackForwardList()', + ), + IOSPlatform( + apiName: 'WKWebView.backForwardList', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist', + ), + MacOSPlatform( + apiName: 'WKWebView.backForwardList', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414977-backforwardlist', + ), WindowsPlatform(), ]) Future getCopyBackForwardList() { @@ -1034,10 +1193,24 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.scrollTo.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'View.scrollTo', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#scrollTo(int,%20int)',), - IOSPlatform( apiName: 'UIScrollView.setContentOffset', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset',), - MacOSPlatform( note: 'This method is implemented using JavaScript.',), - WebPlatform( apiName: 'Window.scrollTo', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo',), + AndroidPlatform( + apiName: 'View.scrollTo', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#scrollTo(int,%20int)', + ), + IOSPlatform( + apiName: 'UIScrollView.setContentOffset', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + WebPlatform( + apiName: 'Window.scrollTo', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollTo', + ), ]) Future scrollTo( {required int x, required int y, bool animated = false}) { @@ -1057,10 +1230,24 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.scrollBy.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'View.scrollBy', apiUrl: 'https://developer.android.com/reference/android/view/View#scrollBy(int,%20int)',), - IOSPlatform( apiName: 'UIScrollView.setContentOffset', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset',), - MacOSPlatform( note: 'This method is implemented using JavaScript.',), - WebPlatform( apiName: 'Window.scrollBy', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy',), + AndroidPlatform( + apiName: 'View.scrollBy', + apiUrl: + 'https://developer.android.com/reference/android/view/View#scrollBy(int,%20int)', + ), + IOSPlatform( + apiName: 'UIScrollView.setContentOffset', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/1619400-setcontentoffset', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + WebPlatform( + apiName: 'Window.scrollBy', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollBy', + ), ]) Future scrollBy( {required int x, required int y, bool animated = false}) { @@ -1075,9 +1262,19 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.pauseTimers.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.pauseTimers', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#pauseTimers()',), - IOSPlatform(note: 'This method is implemented using JavaScript and it is restricted to just this WebView.',), - MacOSPlatform(note: 'This method is implemented using JavaScript and it is restricted to just this WebView.',), + AndroidPlatform( + apiName: 'WebView.pauseTimers', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#pauseTimers()', + ), + IOSPlatform( + note: + 'This method is implemented using JavaScript and it is restricted to just this WebView.', + ), + MacOSPlatform( + note: + 'This method is implemented using JavaScript and it is restricted to just this WebView.', + ), ]) Future pauseTimers() { throw UnimplementedError( @@ -1090,9 +1287,19 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.resumeTimers.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.resumeTimers', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#resumeTimers()',), - IOSPlatform(note: 'This method is implemented using JavaScript and it is restricted to just this WebView.',), - MacOSPlatform(note: 'This method is implemented using JavaScript and it is restricted to just this WebView.',), + AndroidPlatform( + apiName: 'WebView.resumeTimers', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#resumeTimers()', + ), + IOSPlatform( + note: + 'This method is implemented using JavaScript and it is restricted to just this WebView.', + ), + MacOSPlatform( + note: + 'This method is implemented using JavaScript and it is restricted to just this WebView.', + ), ]) Future resumeTimers() { throw UnimplementedError( @@ -1108,10 +1315,27 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.printCurrentPage.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'PrintManager.print', apiUrl: 'https://developer.android.com/reference/android/print/PrintManager#print(java.lang.String,%20android.print.PrintDocumentAdapter,%20android.print.PrintAttributes)',), - IOSPlatform( apiName: 'UIPrintInteractionController.present', apiUrl: 'https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/1618149-present',), - MacOSPlatform( apiName: 'WKWebView.printOperation', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3516861-printoperation', note: 'If macOS version is less than 11.0, it will use [Official API - NSView.printView](https://developer.apple.com/documentation/appkit/nsview/1483705-printview).',), - WebPlatform( apiName: 'Window.print', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/print', note: '[PlatformPrintJobController] is always `null`.'), + AndroidPlatform( + apiName: 'PrintManager.print', + apiUrl: + 'https://developer.android.com/reference/android/print/PrintManager#print(java.lang.String,%20android.print.PrintDocumentAdapter,%20android.print.PrintAttributes)', + ), + IOSPlatform( + apiName: 'UIPrintInteractionController.present', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/1618149-present', + ), + MacOSPlatform( + apiName: 'WKWebView.printOperation', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3516861-printoperation', + note: + 'If macOS version is less than 11.0, it will use [Official API - NSView.printView](https://developer.apple.com/documentation/appkit/nsview/1483705-printview).', + ), + WebPlatform( + apiName: 'Window.print', + apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/print', + note: '[PlatformPrintJobController] is always `null`.'), ]) Future printCurrentPage( {PrintJobSettings? settings}) { @@ -1125,10 +1349,24 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getContentHeight.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.getContentHeight', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#getContentHeight()',), - IOSPlatform( apiName: 'UIScrollView.contentSize', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize',), - MacOSPlatform( note: 'This method is implemented using JavaScript.',), - WebPlatform( apiName: 'Document.documentElement.scrollHeight', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight',), + AndroidPlatform( + apiName: 'WebView.getContentHeight', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#getContentHeight()', + ), + IOSPlatform( + apiName: 'UIScrollView.contentSize', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + WebPlatform( + apiName: 'Document.documentElement.scrollHeight', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollHeight', + ), ]) Future getContentHeight() { throw UnimplementedError( @@ -1141,10 +1379,22 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getContentWidth.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( note: 'This method is implemented using JavaScript.',), - IOSPlatform( apiName: 'UIScrollView.contentSize', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize',), - MacOSPlatform( note: 'This method is implemented using JavaScript.',), - WebPlatform( apiName: 'Document.documentElement.scrollWidth', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth',), + AndroidPlatform( + note: 'This method is implemented using JavaScript.', + ), + IOSPlatform( + apiName: 'UIScrollView.contentSize', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/1619399-contentsize', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + WebPlatform( + apiName: 'Document.documentElement.scrollWidth', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollWidth', + ), ]) Future getContentWidth() { throw UnimplementedError( @@ -1161,14 +1411,22 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.zoomBy.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.zoomBy', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#zoomBy(float)', available: '21',), - IOSPlatform( apiName: 'UIScrollView.setZoomScale', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619412-setzoomscale',), + AndroidPlatform( + apiName: 'WebView.zoomBy', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#zoomBy(float)', + available: '21', + ), + IOSPlatform( + apiName: 'UIScrollView.setZoomScale', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/1619412-setzoomscale', + ), ]) Future zoomBy( {required double zoomFactor, @Deprecated('Use animated instead') bool? iosAnimated, - @SupportedPlatforms(platforms: [IOSPlatform()]) - bool animated = false}) { + @SupportedPlatforms(platforms: [IOSPlatform()]) bool animated = false}) { throw UnimplementedError( '${PlatformInAppWebViewControllerMethod.zoomBy.name} is not implemented on the current platform'); } @@ -1181,10 +1439,16 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getOriginalUrl.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.getOriginalUrl', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#getOriginalUrl()',), + AndroidPlatform( + apiName: 'WebView.getOriginalUrl', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#getOriginalUrl()', + ), IOSPlatform(), MacOSPlatform(), - WebPlatform(note: 'It will return the current value of the `iframe.src` attribute.',), + WebPlatform( + note: 'It will return the current value of the `iframe.src` attribute.', + ), ]) Future getOriginalUrl() { throw UnimplementedError( @@ -1198,8 +1462,16 @@ abstract class PlatformInAppWebViewController extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getZoomScale.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( apiName: 'UIScrollView.zoomScale', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619419-zoomscale',), - WindowsPlatform( apiName: 'ICoreWebView2Controller.get_ZoomFactor', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.2849.39#get_zoomfactor',), + IOSPlatform( + apiName: 'UIScrollView.zoomScale', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/1619419-zoomscale', + ), + WindowsPlatform( + apiName: 'ICoreWebView2Controller.get_ZoomFactor', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.2849.39#get_zoomfactor', + ), ]) Future getZoomScale() { throw UnimplementedError( @@ -1212,10 +1484,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getSelectedText.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: 'This method is implemented using JavaScript.',), - IOSPlatform(note: 'This method is implemented using JavaScript.',), - MacOSPlatform(note: 'This method is implemented using JavaScript.',), - WebPlatform(note: 'This method is implemented using JavaScript.',), + AndroidPlatform( + note: 'This method is implemented using JavaScript.', + ), + IOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + WebPlatform( + note: 'This method is implemented using JavaScript.', + ), ]) Future getSelectedText() { throw UnimplementedError( @@ -1228,8 +1508,14 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getHitTestResult.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.getHitTestResult', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#getHitTestResult()',), - IOSPlatform(note: 'This method is implemented using JavaScript.',), + AndroidPlatform( + apiName: 'WebView.getHitTestResult', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#getHitTestResult()', + ), + IOSPlatform( + note: 'This method is implemented using JavaScript.', + ), ]) Future getHitTestResult() { throw UnimplementedError( @@ -1249,13 +1535,27 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.requestFocus.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.requestFocus', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#requestFocus(int,%20android.graphics.Rect)',), - IOSPlatform( apiName: 'UIResponder.becomeFirstResponder', apiUrl: 'https://developer.apple.com/documentation/uikit/uiresponder/1621113-becomefirstresponder',), - MacOSPlatform( apiName: 'NSWindow.makeFirstResponder', apiUrl: 'https://developer.apple.com/documentation/appkit/nswindow/1419366-makefirstresponder',), + AndroidPlatform( + apiName: 'WebView.requestFocus', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#requestFocus(int,%20android.graphics.Rect)', + ), + IOSPlatform( + apiName: 'UIResponder.becomeFirstResponder', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiresponder/1621113-becomefirstresponder', + ), + MacOSPlatform( + apiName: 'NSWindow.makeFirstResponder', + apiUrl: + 'https://developer.apple.com/documentation/appkit/nswindow/1419366-makefirstresponder', + ), ]) Future requestFocus( - {@SupportedPlatforms(platforms: [AndroidPlatform()]) FocusDirection? direction, - @SupportedPlatforms(platforms: [AndroidPlatform()]) InAppWebViewRect? previouslyFocusedRect}) { + {@SupportedPlatforms(platforms: [AndroidPlatform()]) + FocusDirection? direction, + @SupportedPlatforms(platforms: [AndroidPlatform()]) + InAppWebViewRect? previouslyFocusedRect}) { throw UnimplementedError( '${PlatformInAppWebViewControllerMethod.requestFocus.name} is not implemented on the current platform'); } @@ -1266,9 +1566,21 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.clearFocus.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'ViewGroup.clearFocus', apiUrl: 'https://developer.android.com/reference/android/view/ViewGroup#clearFocus()',), - IOSPlatform( apiName: 'UIResponder.resignFirstResponder', apiUrl: 'https://developer.apple.com/documentation/uikit/uiresponder/1621097-resignfirstresponder',), - MacOSPlatform( apiName: 'NSWindow.makeFirstResponder', apiUrl: 'https://developer.apple.com/documentation/appkit/nswindow/1419366-makefirstresponder',), + AndroidPlatform( + apiName: 'ViewGroup.clearFocus', + apiUrl: + 'https://developer.android.com/reference/android/view/ViewGroup#clearFocus()', + ), + IOSPlatform( + apiName: 'UIResponder.resignFirstResponder', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiresponder/1621097-resignfirstresponder', + ), + MacOSPlatform( + apiName: 'NSWindow.makeFirstResponder', + apiUrl: + 'https://developer.apple.com/documentation/appkit/nswindow/1419366-makefirstresponder', + ), ]) Future clearFocus() { throw UnimplementedError( @@ -1281,7 +1593,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.setInputMethodEnabled.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'UIResponder.inputView', apiUrl: 'https://developer.apple.com/documentation/uikit/uiresponder/1621092-inputview',), + IOSPlatform( + apiName: 'UIResponder.inputView', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiresponder/1621092-inputview', + ), ]) Future setInputMethodEnabled(bool enabled) { throw UnimplementedError( @@ -1294,7 +1610,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.showInputMethod.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'InputMethodManager.showSoftInput', apiUrl: 'https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#showSoftInput(android.view.View,%20int)',), + AndroidPlatform( + apiName: 'InputMethodManager.showSoftInput', + apiUrl: + 'https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#showSoftInput(android.view.View,%20int)', + ), ]) Future showInputMethod() { throw UnimplementedError( @@ -1307,8 +1627,16 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.hideInputMethod.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'InputMethodManager.hideSoftInputFromWindow', apiUrl: 'https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#hideSoftInputFromWindow(android.os.IBinder,%20int)',), - IOSPlatform( apiName: 'UIView.endEditing', apiUrl: 'https://developer.apple.com/documentation/uikit/uiview/1619630-endediting',), + AndroidPlatform( + apiName: 'InputMethodManager.hideSoftInputFromWindow', + apiUrl: + 'https://developer.android.com/reference/android/view/inputmethod/InputMethodManager#hideSoftInputFromWindow(android.os.IBinder,%20int)', + ), + IOSPlatform( + apiName: 'UIView.endEditing', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiview/1619630-endediting', + ), ]) Future hideInputMethod() { throw UnimplementedError( @@ -1335,8 +1663,14 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.requestFocusNodeHref.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.requestFocusNodeHref', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#requestFocusNodeHref(android.os.Message)',), - IOSPlatform(note: 'This method is implemented using JavaScript.',), + AndroidPlatform( + apiName: 'WebView.requestFocusNodeHref', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#requestFocusNodeHref(android.os.Message)', + ), + IOSPlatform( + note: 'This method is implemented using JavaScript.', + ), ]) Future requestFocusNodeHref() { throw UnimplementedError( @@ -1349,8 +1683,14 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.requestImageRef.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.requestImageRef', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#requestImageRef(android.os.Message)',), - IOSPlatform( note: 'This method is implemented using JavaScript.',), + AndroidPlatform( + apiName: 'WebView.requestImageRef', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#requestImageRef(android.os.Message)', + ), + IOSPlatform( + note: 'This method is implemented using JavaScript.', + ), ]) Future requestImageRef() { throw UnimplementedError( @@ -1363,11 +1703,21 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getMetaTags.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( note: 'This method is implemented using JavaScript.',), - IOSPlatform( note: 'This method is implemented using JavaScript.',), - MacOSPlatform( note: 'This method is implemented using JavaScript.',), - WebPlatform( note: 'This method is implemented using JavaScript.',), - WindowsPlatform( note: 'This method is implemented using JavaScript.',), + AndroidPlatform( + note: 'This method is implemented using JavaScript.', + ), + IOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + WebPlatform( + note: 'This method is implemented using JavaScript.', + ), + WindowsPlatform( + note: 'This method is implemented using JavaScript.', + ), ]) Future> getMetaTags() { throw UnimplementedError( @@ -1381,11 +1731,27 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getMetaThemeColor.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( note: 'This method is implemented using JavaScript.',), - IOSPlatform( apiName: 'WKWebView.themeColor', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor', note: 'On iOS < 15.0, this method is implemented using JavaScript.',), - MacOSPlatform( apiName: 'WKWebView.themeColor', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor', note: 'On iOS < 12.0, this method is implemented using JavaScript.',), - WebPlatform( note: 'This method is implemented using JavaScript.',), - WindowsPlatform( note: 'This method is implemented using JavaScript.',), + AndroidPlatform( + note: 'This method is implemented using JavaScript.', + ), + IOSPlatform( + apiName: 'WKWebView.themeColor', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor', + note: 'On iOS < 15.0, this method is implemented using JavaScript.', + ), + MacOSPlatform( + apiName: 'WKWebView.themeColor', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3794258-themecolor', + note: 'On iOS < 12.0, this method is implemented using JavaScript.', + ), + WebPlatform( + note: 'This method is implemented using JavaScript.', + ), + WindowsPlatform( + note: 'This method is implemented using JavaScript.', + ), ]) Future getMetaThemeColor() { throw UnimplementedError( @@ -1398,10 +1764,23 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getScrollX.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'View.getScrollX', apiUrl: 'https://developer.android.com/reference/android/view/View#getScrollX()',), - IOSPlatform( apiName: 'UIScrollView.contentOffset', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset',), - MacOSPlatform(note: 'This method is implemented using JavaScript.',), - WebPlatform( apiName: 'Window.scrollX', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX',), + AndroidPlatform( + apiName: 'View.getScrollX', + apiUrl: + 'https://developer.android.com/reference/android/view/View#getScrollX()', + ), + IOSPlatform( + apiName: 'UIScrollView.contentOffset', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + WebPlatform( + apiName: 'Window.scrollX', + apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollX', + ), ]) Future getScrollX() { throw UnimplementedError( @@ -1414,10 +1793,23 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getScrollY.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'View.getScrollY', apiUrl: 'https://developer.android.com/reference/android/view/View#getScrollY()',), - IOSPlatform( apiName: 'UIScrollView.contentOffset', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset',), - MacOSPlatform(note: 'This method is implemented using JavaScript.',), - WebPlatform( apiName: 'Window.scrollY', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY',), + AndroidPlatform( + apiName: 'View.getScrollY', + apiUrl: + 'https://developer.android.com/reference/android/view/View#getScrollY()', + ), + IOSPlatform( + apiName: 'UIScrollView.contentOffset', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/1619404-contentoffset', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + WebPlatform( + apiName: 'Window.scrollY', + apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/scrollY', + ), ]) Future getScrollY() { throw UnimplementedError( @@ -1430,7 +1822,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getCertificate.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.getCertificate', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#getCertificate()',), + AndroidPlatform( + apiName: 'WebView.getCertificate', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#getCertificate()', + ), IOSPlatform(), MacOSPlatform(), WindowsPlatform(), @@ -1447,8 +1843,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.addUserScript.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( apiName: 'WKUserContentController.addUserScript', apiUrl: 'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript', note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), - MacOSPlatform( apiName: 'WKUserContentController.addUserScript', apiUrl: 'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript', note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + IOSPlatform( + apiName: 'WKUserContentController.addUserScript', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript', + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + MacOSPlatform( + apiName: 'WKUserContentController.addUserScript', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1537448-adduserscript', + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), WebPlatform(), WindowsPlatform(), ]) @@ -1464,8 +1870,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.addUserScripts.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), - MacOSPlatform(note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + IOSPlatform( + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + MacOSPlatform( + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), WebPlatform(), WindowsPlatform(), ]) @@ -1483,8 +1893,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.removeUserScript.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), - MacOSPlatform(note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + IOSPlatform( + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + MacOSPlatform( + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), WebPlatform(), WindowsPlatform(), ]) @@ -1501,8 +1915,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.removeUserScriptsByGroupName.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), - MacOSPlatform(note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + IOSPlatform( + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + MacOSPlatform( + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), WebPlatform(), WindowsPlatform(), ]) @@ -1519,8 +1937,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.removeUserScripts.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), - MacOSPlatform(note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + IOSPlatform( + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + MacOSPlatform( + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), WebPlatform(), WindowsPlatform(), ]) @@ -1536,8 +1958,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.removeAllUserScripts.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( apiName: 'WKUserContentController.removeAllUserScripts', apiUrl: 'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts', note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), - MacOSPlatform( apiName: 'WKUserContentController.removeAllUserScripts', apiUrl: 'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts', note: "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + IOSPlatform( + apiName: 'WKUserContentController.removeAllUserScripts', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts', + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), + MacOSPlatform( + apiName: 'WKUserContentController.removeAllUserScripts', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts', + note: + "This method will throw an error if the [PlatformWebViewCreationParams.windowId] has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs."), WebPlatform(), WindowsPlatform(), ]) @@ -1592,9 +2024,20 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.callAsyncJavaScript.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(available: '21',), - IOSPlatform( apiName: 'WKWebView.callAsyncJavaScript', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript', available: '10.3',), - MacOSPlatform( apiName: 'WKWebView.callAsyncJavaScript', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript',), + AndroidPlatform( + available: '21', + ), + IOSPlatform( + apiName: 'WKWebView.callAsyncJavaScript', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript', + available: '10.3', + ), + MacOSPlatform( + apiName: 'WKWebView.callAsyncJavaScript', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3656441-callasyncjavascript', + ), WindowsPlatform(), ]) Future callAsyncJavaScript( @@ -1617,9 +2060,23 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.saveWebArchive.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.saveWebArchive', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#saveWebArchive(java.lang.String,%20boolean,%20android.webkit.ValueCallback%3Cjava.lang.String%3E)', note: 'if [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension.',), - IOSPlatform(available: '14.0', note: 'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension.',), - MacOSPlatform(available: '11.0', note: 'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension.',), + AndroidPlatform( + apiName: 'WebView.saveWebArchive', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#saveWebArchive(java.lang.String,%20boolean,%20android.webkit.ValueCallback%3Cjava.lang.String%3E)', + note: + 'if [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.MHT] file extension.', + ), + IOSPlatform( + available: '14.0', + note: + 'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension.', + ), + MacOSPlatform( + available: '11.0', + note: + 'If [autoname] is `false`, the [filePath] must ends with the [WebArchiveFormat.WEBARCHIVE] file extension.', + ), ]) Future saveWebArchive( {required String filePath, bool autoname = false}) { @@ -1633,10 +2090,21 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.isSecureContext.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(available: '21', note: 'This method is implemented using JavaScript.',), - IOSPlatform(note: 'This method is implemented using JavaScript.',), - MacOSPlatform(note: 'This method is implemented using JavaScript.',), - WebPlatform(apiName: 'Window.isSecureContext', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext',), + AndroidPlatform( + available: '21', + note: 'This method is implemented using JavaScript.', + ), + IOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + WebPlatform( + apiName: 'Window.isSecureContext', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Window/isSecureContext', + ), ]) Future isSecureContext() { throw UnimplementedError( @@ -1654,9 +2122,19 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.createWebMessageChannel.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewCompat.createWebMessageChannel', apiUrl: 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#createWebMessageChannel(android.webkit.WebView)', note: 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL].',), - IOSPlatform(note: 'This method is implemented using JavaScript.',), - MacOSPlatform(note: 'This method is implemented using JavaScript.',), + AndroidPlatform( + apiName: 'WebViewCompat.createWebMessageChannel', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#createWebMessageChannel(android.webkit.WebView)', + note: + 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.CREATE_WEB_MESSAGE_CHANNEL].', + ), + IOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), ]) Future createWebMessageChannel() { throw UnimplementedError( @@ -1672,9 +2150,19 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.postWebMessage.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.postWebMessage', apiUrl: 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#postWebMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri)', note: 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.POST_WEB_MESSAGE].',), - IOSPlatform(note: 'This method is implemented using JavaScript.',), - MacOSPlatform(note: 'This method is implemented using JavaScript.',), + AndroidPlatform( + apiName: 'WebView.postWebMessage', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#postWebMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri)', + note: + 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.POST_WEB_MESSAGE].', + ), + IOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), ]) Future postWebMessage( {required WebMessage message, WebUri? targetOrigin}) { @@ -1840,9 +2328,19 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.addWebMessageListener.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewCompat.WebMessageListener', apiUrl: 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,%20java.lang.String,%20java.util.Set%3Cjava.lang.String%3E,%20androidx.webkit.WebViewCompat.WebMessageListener)', note: 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.WEB_MESSAGE_LISTENER].',), - IOSPlatform(note: 'This method is implemented using JavaScript.',), - MacOSPlatform(note: 'This method is implemented using JavaScript.',), + AndroidPlatform( + apiName: 'WebViewCompat.WebMessageListener', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#addWebMessageListener(android.webkit.WebView,%20java.lang.String,%20java.util.Set%3Cjava.lang.String%3E,%20androidx.webkit.WebViewCompat.WebMessageListener)', + note: + 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.WEB_MESSAGE_LISTENER].', + ), + IOSPlatform( + note: 'This method is implemented using JavaScript.', + ), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), ]) Future addWebMessageListener( PlatformWebMessageListener webMessageListener) { @@ -1873,7 +2371,9 @@ abstract class PlatformInAppWebViewController extends PlatformInterface @SupportedPlatforms(platforms: [ AndroidPlatform(), IOSPlatform(), - MacOSPlatform(note: 'This method is implemented using JavaScript.',), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), WebPlatform(), ]) Future canScrollVertically() { @@ -1889,7 +2389,9 @@ abstract class PlatformInAppWebViewController extends PlatformInterface @SupportedPlatforms(platforms: [ AndroidPlatform(), IOSPlatform(), - MacOSPlatform(note: 'This method is implemented using JavaScript.',), + MacOSPlatform( + note: 'This method is implemented using JavaScript.', + ), WebPlatform(), ]) Future canScrollHorizontally() { @@ -1909,7 +2411,13 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.startSafeBrowsing.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.startSafeBrowsing', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#startSafeBrowsing(android.content.Context,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)', note: 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.START_SAFE_BROWSING].',), + AndroidPlatform( + apiName: 'WebView.startSafeBrowsing', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#startSafeBrowsing(android.content.Context,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)', + note: + 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.START_SAFE_BROWSING].', + ), ]) Future startSafeBrowsing() { throw UnimplementedError( @@ -1922,8 +2430,16 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.clearSslPreferences.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.clearSslPreferences', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#clearSslPreferences()',), - WindowsPlatform( apiName: 'ICoreWebView2_3.ClearServerCertificateErrorActions', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_14?view=webview2-1.0.2792.45#clearservercertificateerroractions',), + AndroidPlatform( + apiName: 'WebView.clearSslPreferences', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#clearSslPreferences()', + ), + WindowsPlatform( + apiName: 'ICoreWebView2_3.ClearServerCertificateErrorActions', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_14?view=webview2-1.0.2792.45#clearservercertificateerroractions', + ), ]) Future clearSslPreferences() { throw UnimplementedError( @@ -1937,8 +2453,16 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.pause.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.onPause', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#onPause()',), - WindowsPlatform( apiName: 'ICoreWebView2_3.TrySuspend', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_3?view=webview2-1.0.2792.45#trysuspend',), + AndroidPlatform( + apiName: 'WebView.onPause', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#onPause()', + ), + WindowsPlatform( + apiName: 'ICoreWebView2_3.TrySuspend', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_3?view=webview2-1.0.2792.45#trysuspend', + ), ]) Future pause() { throw UnimplementedError( @@ -1951,8 +2475,16 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.resume.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.onResume', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#onResume()',), - WindowsPlatform( apiName: 'ICoreWebView2_3.Resume', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_3?view=webview2-1.0.2792.45#resume',), + AndroidPlatform( + apiName: 'WebView.onResume', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#onResume()', + ), + WindowsPlatform( + apiName: 'ICoreWebView2_3.Resume', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_3?view=webview2-1.0.2792.45#resume', + ), ]) Future resume() { throw UnimplementedError( @@ -1968,7 +2500,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.pageDown.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.pageDown', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#pageDown(boolean)',), + AndroidPlatform( + apiName: 'WebView.pageDown', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#pageDown(boolean)', + ), ]) Future pageDown({required bool bottom}) { throw UnimplementedError( @@ -1984,7 +2520,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.pageUp.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.pageUp', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#pageUp(boolean)',), + AndroidPlatform( + apiName: 'WebView.pageUp', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#pageUp(boolean)', + ), ]) Future pageUp({required bool top}) { throw UnimplementedError( @@ -1998,7 +2538,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.zoomIn.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.zoomIn', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#zoomIn()',), + AndroidPlatform( + apiName: 'WebView.zoomIn', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#zoomIn()', + ), ]) Future zoomIn() { throw UnimplementedError( @@ -2012,7 +2556,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.zoomOut.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.zoomOut', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#zoomOut()',), + AndroidPlatform( + apiName: 'WebView.zoomOut', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#zoomOut()', + ), ]) Future zoomOut() { throw UnimplementedError( @@ -2025,7 +2573,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.clearHistory.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.clearHistory', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#clearHistory()',), + AndroidPlatform( + apiName: 'WebView.clearHistory', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#clearHistory()', + ), ]) Future clearHistory() { throw UnimplementedError( @@ -2040,7 +2592,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.clearFormData.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.clearFormData', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#clearFormData()',), + AndroidPlatform( + apiName: 'WebView.clearFormData', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#clearFormData()', + ), ]) Future clearFormData() { throw UnimplementedError( @@ -2053,8 +2609,16 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.reloadFromOrigin.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.reloadFromOrigin', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin',), - MacOSPlatform( apiName: 'WKWebView.reloadFromOrigin', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin',), + IOSPlatform( + apiName: 'WKWebView.reloadFromOrigin', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin', + ), + MacOSPlatform( + apiName: 'WKWebView.reloadFromOrigin', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1414956-reloadfromorigin', + ), ]) Future reloadFromOrigin() { throw UnimplementedError( @@ -2070,8 +2634,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.createPdf.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.createPdf', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf', available: '14.0',), - MacOSPlatform( apiName: 'WKWebView.createPdf', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf', available: '11.0',), + IOSPlatform( + apiName: 'WKWebView.createPdf', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf', + available: '14.0', + ), + MacOSPlatform( + apiName: 'WKWebView.createPdf', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3650490-createpdf', + available: '11.0', + ), ]) Future createPdf( {@Deprecated("Use pdfConfiguration instead") @@ -2089,8 +2663,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.createWebArchiveData.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.createWebArchiveData', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata', available: '14.0',), - MacOSPlatform( apiName: 'WKWebView.createWebArchiveData', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata', available: '11.0',), + IOSPlatform( + apiName: 'WKWebView.createWebArchiveData', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata', + available: '14.0', + ), + MacOSPlatform( + apiName: 'WKWebView.createWebArchiveData', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3650491-createwebarchivedata', + available: '11.0', + ), ]) Future createWebArchiveData() { throw UnimplementedError( @@ -2103,8 +2687,16 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.hasOnlySecureContent.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.hasOnlySecureContent', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent',), - MacOSPlatform( apiName: 'WKWebView.hasOnlySecureContent', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent',), + IOSPlatform( + apiName: 'WKWebView.hasOnlySecureContent', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent', + ), + MacOSPlatform( + apiName: 'WKWebView.hasOnlySecureContent', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/1415002-hasonlysecurecontent', + ), ]) Future hasOnlySecureContent() { throw UnimplementedError( @@ -2117,8 +2709,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.pauseAllMediaPlayback.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.pauseAllMediaPlayback', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback', available: '15.0',), - MacOSPlatform( apiName: 'WKWebView.pauseAllMediaPlayback', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback', available: '12.0',), + IOSPlatform( + apiName: 'WKWebView.pauseAllMediaPlayback', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback', + available: '15.0', + ), + MacOSPlatform( + apiName: 'WKWebView.pauseAllMediaPlayback', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752240-pauseallmediaplayback', + available: '12.0', + ), ]) Future pauseAllMediaPlayback() { throw UnimplementedError( @@ -2134,8 +2736,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.setAllMediaPlaybackSuspended.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.setAllMediaPlaybackSuspended', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended', available: '15.0',), - MacOSPlatform( apiName: 'WKWebView.setAllMediaPlaybackSuspended', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended', available: '12.0',), + IOSPlatform( + apiName: 'WKWebView.setAllMediaPlaybackSuspended', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended', + available: '15.0', + ), + MacOSPlatform( + apiName: 'WKWebView.setAllMediaPlaybackSuspended', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752242-setallmediaplaybacksuspended', + available: '12.0', + ), ]) Future setAllMediaPlaybackSuspended({required bool suspended}) { throw UnimplementedError( @@ -2148,8 +2760,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.closeAllMediaPresentations.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.closeAllMediaPresentations', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations', available: '14.5',), - MacOSPlatform( apiName: 'WKWebView.closeAllMediaPresentations', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations', available: '11.3',), + IOSPlatform( + apiName: 'WKWebView.closeAllMediaPresentations', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations', + available: '14.5', + ), + MacOSPlatform( + apiName: 'WKWebView.closeAllMediaPresentations', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752235-closeallmediapresentations', + available: '11.3', + ), ]) Future closeAllMediaPresentations() { throw UnimplementedError( @@ -2164,8 +2786,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.requestMediaPlaybackState.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.requestMediaPlaybackState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate', available: '15.0',), - MacOSPlatform( apiName: 'WKWebView.requestMediaPlaybackState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate', available: '12.0',), + IOSPlatform( + apiName: 'WKWebView.requestMediaPlaybackState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate', + available: '15.0', + ), + MacOSPlatform( + apiName: 'WKWebView.requestMediaPlaybackState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752241-requestmediaplaybackstate', + available: '12.0', + ), ]) Future requestMediaPlaybackState() { throw UnimplementedError( @@ -2193,8 +2825,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getCameraCaptureState.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.cameraCaptureState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate', available: '15.0',), - MacOSPlatform( apiName: 'WKWebView.cameraCaptureState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate', available: '12.0',), + IOSPlatform( + apiName: 'WKWebView.cameraCaptureState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate', + available: '15.0', + ), + MacOSPlatform( + apiName: 'WKWebView.cameraCaptureState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3763093-cameracapturestate', + available: '12.0', + ), ]) Future getCameraCaptureState() { throw UnimplementedError( @@ -2207,8 +2849,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.setCameraCaptureState.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.setCameraCaptureState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate', available: '15.0',), - MacOSPlatform( apiName: 'WKWebView.setCameraCaptureState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate', available: '12.0',), + IOSPlatform( + apiName: 'WKWebView.setCameraCaptureState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate', + available: '15.0', + ), + MacOSPlatform( + apiName: 'WKWebView.setCameraCaptureState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3763097-setcameracapturestate', + available: '12.0', + ), ]) Future setCameraCaptureState({required MediaCaptureState state}) { throw UnimplementedError( @@ -2221,8 +2873,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getMicrophoneCaptureState.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.microphoneCaptureState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate', available: '15.0',), - MacOSPlatform( apiName: 'WKWebView.microphoneCaptureState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate', available: '12.0',), + IOSPlatform( + apiName: 'WKWebView.microphoneCaptureState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate', + available: '15.0', + ), + MacOSPlatform( + apiName: 'WKWebView.microphoneCaptureState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3763096-microphonecapturestate', + available: '12.0', + ), ]) Future getMicrophoneCaptureState() { throw UnimplementedError( @@ -2235,8 +2897,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.setMicrophoneCaptureState.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.setMicrophoneCaptureState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate', available: '15.0',), - MacOSPlatform( apiName: 'WKWebView.setMicrophoneCaptureState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate', available: '12.0',), + IOSPlatform( + apiName: 'WKWebView.setMicrophoneCaptureState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate', + available: '15.0', + ), + MacOSPlatform( + apiName: 'WKWebView.setMicrophoneCaptureState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3763098-setmicrophonecapturestate', + available: '12.0', + ), ]) Future setMicrophoneCaptureState({required MediaCaptureState state}) { throw UnimplementedError( @@ -2265,8 +2937,20 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.loadSimulatedRequest.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.loadSimulatedRequest(_:response:responseData:)', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest', available: '15.0', note: 'or [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)'), - MacOSPlatform( apiName: 'WKWebView.loadSimulatedRequest(_:response:responseData:)', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest', available: '12.0', note: 'or [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)'), + IOSPlatform( + apiName: 'WKWebView.loadSimulatedRequest(_:response:responseData:)', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest', + available: '15.0', + note: + 'or [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)'), + MacOSPlatform( + apiName: 'WKWebView.loadSimulatedRequest(_:response:responseData:)', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3763094-loadsimulatedrequest', + available: '12.0', + note: + 'or [Official API - WKWebView.loadSimulatedRequest(_:responseHTML:)](https://developer.apple.com/documentation/webkit/wkwebview/3763095-loadsimulatedrequest)'), ]) Future loadSimulatedRequest( {required URLRequest urlRequest, @@ -2283,7 +2967,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.openDevTools.supported_platforms} @SupportedPlatforms(platforms: [ - WindowsPlatform( apiName: 'ICoreWebView2.OpenDevToolsWindow', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#opendevtoolswindow',), + WindowsPlatform( + apiName: 'ICoreWebView2.OpenDevToolsWindow', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#opendevtoolswindow', + ), ]) Future openDevTools() { throw UnimplementedError( @@ -2307,7 +2995,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.callDevToolsProtocolMethod.supported_platforms} @SupportedPlatforms(platforms: [ - WindowsPlatform( apiName: 'ICoreWebView2.CallDevToolsProtocolMethod', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#calldevtoolsprotocolmethod',), + WindowsPlatform( + apiName: 'ICoreWebView2.CallDevToolsProtocolMethod', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#calldevtoolsprotocolmethod', + ), ]) Future callDevToolsProtocolMethod( {required String methodName, Map? parameters}) { @@ -2321,7 +3013,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.addDevToolsProtocolEventListener.supported_platforms} @SupportedPlatforms(platforms: [ - WindowsPlatform( apiName: 'ICoreWebView2DevToolsProtocolEventReceiver.add_DevToolsProtocolEventReceived', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2devtoolsprotocoleventreceiver?view=webview2-1.0.2210.55#add_devtoolsprotocoleventreceived',), + WindowsPlatform( + apiName: + 'ICoreWebView2DevToolsProtocolEventReceiver.add_DevToolsProtocolEventReceived', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2devtoolsprotocoleventreceiver?view=webview2-1.0.2210.55#add_devtoolsprotocoleventreceived', + ), ]) Future addDevToolsProtocolEventListener( {required String eventName, required Function(dynamic data) callback}) { @@ -2335,7 +3032,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.removeDevToolsProtocolEventListener.supported_platforms} @SupportedPlatforms(platforms: [ - WindowsPlatform( apiName: 'ICoreWebView2DevToolsProtocolEventReceiver.remove_DevToolsProtocolEventReceived', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2devtoolsprotocoleventreceiver?view=webview2-1.0.2210.55#remove_devtoolsprotocoleventreceived',), + WindowsPlatform( + apiName: + 'ICoreWebView2DevToolsProtocolEventReceiver.remove_DevToolsProtocolEventReceived', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2devtoolsprotocoleventreceiver?view=webview2-1.0.2210.55#remove_devtoolsprotocoleventreceived', + ), ]) Future removeDevToolsProtocolEventListener( {required String eventName}) { @@ -2363,9 +3065,23 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.saveState.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.saveState', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#saveState(android.os.Bundle)', note: 'This method doesn\'t store the display data for this WebView.'), - IOSPlatform( apiName: 'WKWebView.interactionState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752236-interactionstate', available: '15.0',), - MacOSPlatform( apiName: 'WKWebView.interactionState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752236-interactionstate', available: '12.0',), + AndroidPlatform( + apiName: 'WebView.saveState', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#saveState(android.os.Bundle)', + note: 'This method doesn\'t store the display data for this WebView.'), + IOSPlatform( + apiName: 'WKWebView.interactionState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752236-interactionstate', + available: '15.0', + ), + MacOSPlatform( + apiName: 'WKWebView.interactionState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752236-interactionstate', + available: '12.0', + ), ]) Future saveState() { throw UnimplementedError( @@ -2382,9 +3098,24 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.restoreState.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.restoreState', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#restoreState(android.os.Bundle)', note: 'This method doesn\'t restore the display data for this WebView.'), - IOSPlatform( apiName: 'WKWebView.interactionState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752236-interactionstate', available: '15.0',), - MacOSPlatform( apiName: 'WKWebView.interactionState', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/3752236-interactionstate', available: '12.0',), + AndroidPlatform( + apiName: 'WebView.restoreState', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#restoreState(android.os.Bundle)', + note: + 'This method doesn\'t restore the display data for this WebView.'), + IOSPlatform( + apiName: 'WKWebView.interactionState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752236-interactionstate', + available: '15.0', + ), + MacOSPlatform( + apiName: 'WKWebView.interactionState', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/3752236-interactionstate', + available: '12.0', + ), ]) Future restoreState(Uint8List state) { throw UnimplementedError( @@ -2427,10 +3158,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getDefaultUserAgent.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebSettings.getDefaultUserAgent', apiUrl: 'https://developer.android.com/reference/android/webkit/WebSettings#getDefaultUserAgent(android.content.Context)',), + AndroidPlatform( + apiName: 'WebSettings.getDefaultUserAgent', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebSettings#getDefaultUserAgent(android.content.Context)', + ), IOSPlatform(), MacOSPlatform(), - WebPlatform( apiName: 'Navigator.userAgent', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent',), + WebPlatform( + apiName: 'Navigator.userAgent', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Navigator/userAgent', + ), ]) Future getDefaultUserAgent() { throw UnimplementedError( @@ -2445,7 +3184,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.clearClientCertPreferences.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.clearClientCertPreferences', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#clearClientCertPreferences(java.lang.Runnable)', available: '21',), + AndroidPlatform( + apiName: 'WebView.clearClientCertPreferences', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#clearClientCertPreferences(java.lang.Runnable)', + available: '21', + ), ]) Future clearClientCertPreferences() { throw UnimplementedError( @@ -2458,7 +3202,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getSafeBrowsingPrivacyPolicyUrl.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewCompat.getSafeBrowsingPrivacyPolicyUrl', apiUrl: 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#getSafeBrowsingPrivacyPolicyUrl()', note: 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_PRIVACY_POLICY_URL].'), + AndroidPlatform( + apiName: 'WebViewCompat.getSafeBrowsingPrivacyPolicyUrl', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#getSafeBrowsingPrivacyPolicyUrl()', + note: + 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_PRIVACY_POLICY_URL].'), ]) Future getSafeBrowsingPrivacyPolicyUrl() { throw UnimplementedError( @@ -2483,7 +3232,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.setSafeBrowsingAllowlist.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewCompat.setSafeBrowsingAllowlist', apiUrl: 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set%3Cjava.lang.String%3E,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)', note: 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_ALLOWLIST].'), + AndroidPlatform( + apiName: 'WebViewCompat.setSafeBrowsingAllowlist', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#setSafeBrowsingAllowlist(java.util.Set%3Cjava.lang.String%3E,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)', + note: + 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.SAFE_BROWSING_ALLOWLIST].'), ]) Future setSafeBrowsingAllowlist({required List hosts}) { throw UnimplementedError( @@ -2502,7 +3256,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getCurrentWebViewPackage.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewCompat.getCurrentWebViewPackage', apiUrl: 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#getCurrentWebViewPackage(android.content.Context)', available: '21'), + AndroidPlatform( + apiName: 'WebViewCompat.getCurrentWebViewPackage', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#getCurrentWebViewPackage(android.content.Context)', + available: '21'), ]) Future getCurrentWebViewPackage() { throw UnimplementedError( @@ -2519,7 +3277,10 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.setWebContentsDebuggingEnabled.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.setWebContentsDebuggingEnabled', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#setWebContentsDebuggingEnabled(boolean)'), + AndroidPlatform( + apiName: 'WebView.setWebContentsDebuggingEnabled', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#setWebContentsDebuggingEnabled(boolean)'), ]) Future setWebContentsDebuggingEnabled(bool debuggingEnabled) { throw UnimplementedError( @@ -2539,7 +3300,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.getVariationsHeader.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewCompat.getVariationsHeader', apiUrl: 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#getVariationsHeader()', note: 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.GET_VARIATIONS_HEADER].'), + AndroidPlatform( + apiName: 'WebViewCompat.getVariationsHeader', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#getVariationsHeader()', + note: + 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.GET_VARIATIONS_HEADER].'), ]) Future getVariationsHeader() { throw UnimplementedError( @@ -2558,7 +3324,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.isMultiProcessEnabled.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewCompat.isMultiProcessEnabled', apiUrl: 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#isMultiProcessEnabled()', note: 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.MULTI_PROCESS].'), + AndroidPlatform( + apiName: 'WebViewCompat.isMultiProcessEnabled', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/WebViewCompat#isMultiProcessEnabled()', + note: + 'This method should only be called if [WebViewFeature.isFeatureSupported] returns `true` for [WebViewFeature.MULTI_PROCESS].'), ]) Future isMultiProcessEnabled() { throw UnimplementedError( @@ -2578,7 +3349,11 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.disableWebView.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.disableWebView', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#disableWebView()', available: '28'), + AndroidPlatform( + apiName: 'WebView.disableWebView', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#disableWebView()', + available: '28'), ]) Future disableWebView() { throw UnimplementedError( @@ -2593,8 +3368,18 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.handlesURLScheme.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKWebView.handlesURLScheme', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme', available: '11.0',), - MacOSPlatform( apiName: 'WKWebView.handlesURLScheme', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme', available: '10.13',), + IOSPlatform( + apiName: 'WKWebView.handlesURLScheme', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme', + available: '11.0', + ), + MacOSPlatform( + apiName: 'WKWebView.handlesURLScheme', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebview/2875370-handlesurlscheme', + available: '10.13', + ), ]) Future handlesURLScheme(String urlScheme) { throw UnimplementedError( @@ -2645,7 +3430,12 @@ abstract class PlatformInAppWebViewController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformInAppWebViewController.enableSlowWholeDocumentDraw.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.enableSlowWholeDocumentDraw', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#enableSlowWholeDocumentDraw()', available: '21', note: 'This method should be called before any WebViews are created.'), + AndroidPlatform( + apiName: 'WebView.enableSlowWholeDocumentDraw', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#enableSlowWholeDocumentDraw()', + available: '21', + note: 'This method should be called before any WebViews are created.'), ]) Future enableSlowWholeDocumentDraw() { throw UnimplementedError( diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart index 22921d70c..1fd0e7350 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.dart @@ -27,7 +27,9 @@ part 'platform_webview.g.dart'; ///{@endtemplate} /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.supported_platforms} -@SupportedPlatforms(ignoreParameterNames: ['controller'], platforms: [ +@SupportedPlatforms(ignoreParameterNames: [ + 'controller' +], platforms: [ AndroidPlatform(), IOSPlatform(), MacOSPlatform(), @@ -72,11 +74,29 @@ class PlatformWebViewCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onLoadStart.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onPageStarted', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview',), - WebPlatform(note: "It will be dispatched at the same time of [onLoadStop] event because there isn't any way to capture the real load start event from an iframe. If `window.location.href` isn't accessible inside the iframe, the [url] parameter will have the current value of the `iframe.src` attribute."), - WindowsPlatform( apiName: 'ICoreWebView2.add_NavigationStarting', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationstarting',), + AndroidPlatform( + apiName: 'WebViewClient.onPageStarted', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview', + ), + WebPlatform( + note: + "It will be dispatched at the same time of [onLoadStop] event because there isn't any way to capture the real load start event from an iframe. If `window.location.href` isn't accessible inside the iframe, the [url] parameter will have the current value of the `iframe.src` attribute."), + WindowsPlatform( + apiName: 'ICoreWebView2.add_NavigationStarting', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationstarting', + ), ]) final void Function(T controller, WebUri? url)? onLoadStart; @@ -86,11 +106,32 @@ class PlatformWebViewCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onLoadStop.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onPageFinished', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview',), - WebPlatform( apiName: 'Window.onload', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event', note: "If `window.location.href` isn't accessible inside the iframe, the [url] parameter will have the current value of the `iframe.src` attribute."), - WindowsPlatform( apiName: 'ICoreWebView2.add_NavigationCompleted', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted',), + AndroidPlatform( + apiName: 'WebViewClient.onPageFinished', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview', + ), + WebPlatform( + apiName: 'Window.onload', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event', + note: + "If `window.location.href` isn't accessible inside the iframe, the [url] parameter will have the current value of the `iframe.src` attribute."), + WindowsPlatform( + apiName: 'ICoreWebView2.add_NavigationCompleted', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted', + ), ]) final void Function(T controller, WebUri? url)? onLoadStop; @@ -114,10 +155,26 @@ class PlatformWebViewCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onReceivedError.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedError', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview',), - WindowsPlatform( apiName: 'ICoreWebView2.add_NavigationCompleted', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted',), + AndroidPlatform( + apiName: 'WebViewClient.onReceivedError', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_NavigationCompleted', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted', + ), ]) final void Function( T controller, WebResourceRequest request, WebResourceError error)? @@ -148,10 +205,26 @@ class PlatformWebViewCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onReceivedHttpError.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedHttpError', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse)', available: '23'), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview',), - WindowsPlatform( apiName: 'ICoreWebView2.add_NavigationCompleted', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted',), + AndroidPlatform( + apiName: 'WebViewClient.onReceivedHttpError', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse)', + available: '23'), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_NavigationCompleted', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/iwebview2webview?view=webview2-0.8.355#add_navigationcompleted', + ), ]) final void Function(T controller, WebResourceRequest request, WebResourceResponse errorResponse)? onReceivedHttpError; @@ -162,7 +235,11 @@ class PlatformWebViewCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onProgressChanged.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onProgressChanged', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int)',), + AndroidPlatform( + apiName: 'WebChromeClient.onProgressChanged', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int)', + ), IOSPlatform(), MacOSPlatform(), WindowsPlatform(), @@ -175,9 +252,17 @@ class PlatformWebViewCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onConsoleMessage.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onConsoleMessage', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)',), - IOSPlatform( note: 'This event is implemented using JavaScript.',), - MacOSPlatform( note: 'This event is implemented using JavaScript.',), + AndroidPlatform( + apiName: 'WebChromeClient.onConsoleMessage', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)', + ), + IOSPlatform( + note: 'This event is implemented using JavaScript.', + ), + MacOSPlatform( + note: 'This event is implemented using JavaScript.', + ), WebPlatform(), WindowsPlatform(), ]) @@ -194,8 +279,12 @@ class PlatformWebViewCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.shouldOverrideUrlLoading.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.shouldOverrideUrlLoading', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)', - note: """There isn't any way to load an URL for a frame that is not the main frame, so if the request is not for the main frame, the navigation is allowed by default. + AndroidPlatform( + apiName: 'WebViewClient.shouldOverrideUrlLoading', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)', + note: + """There isn't any way to load an URL for a frame that is not the main frame, so if the request is not for the main frame, the navigation is allowed by default. However, if you want to cancel requests for subframes, you can use the [InAppWebViewSettings.regexToCancelSubFramesLoading] setting to write a Regular Expression that, if the url request of a subframe matches, then the request of that subframe is canceled. Instead, the [InAppWebViewSettings.regexToAllowSyncUrlLoading] setting could @@ -203,8 +292,16 @@ be used to allow navigation requests synchronously, as this event is synchronous and the current plugin implementation will always cancel the current request and load a new request if this event returns [NavigationActionPolicy.ALLOW] because Flutter method channels work only asynchronously. Also, this event is not called for POST requests and is not called on the first page load."""), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview',), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview', + ), WindowsPlatform(), ]) final FutureOr Function( @@ -219,9 +316,15 @@ Also, this event is not called for POST requests and is not called on the first /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onLoadResource.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( note: 'This event is implemented using JavaScript.',), - IOSPlatform( note: 'This event is implemented using JavaScript.',), - MacOSPlatform( note: 'This event is implemented using JavaScript.',), + AndroidPlatform( + note: 'This event is implemented using JavaScript.', + ), + IOSPlatform( + note: 'This event is implemented using JavaScript.', + ), + MacOSPlatform( + note: 'This event is implemented using JavaScript.', + ), ]) final void Function(T controller, LoadedResource resource)? onLoadResource; @@ -235,10 +338,24 @@ Also, this event is not called for POST requests and is not called on the first /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onScrollChanged.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.onScrollChanged', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int)',), - IOSPlatform( apiName: 'UIScrollViewDelegate.scrollViewDidScroll', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll',), - MacOSPlatform( note: 'This event is implemented using JavaScript.',), - WebPlatform( apiName: 'Window.onscroll', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onscroll',), + AndroidPlatform( + apiName: 'WebView.onScrollChanged', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int)', + ), + IOSPlatform( + apiName: 'UIScrollViewDelegate.scrollViewDidScroll', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll', + ), + MacOSPlatform( + note: 'This event is implemented using JavaScript.', + ), + WebPlatform( + apiName: 'Window.onscroll', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onscroll', + ), ]) final void Function(T controller, int x, int y)? onScrollChanged; @@ -279,10 +396,18 @@ Also, this event is not called for POST requests and is not called on the first /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onDownloadStarting.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.setDownloadListener', apiUrl: '(https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)',), + AndroidPlatform( + apiName: 'WebView.setDownloadListener', + apiUrl: + '(https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)', + ), IOSPlatform(), MacOSPlatform(), - WindowsPlatform( apiName: 'ICoreWebView2_4.add_DownloadStarting', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_4?view=webview2-1.0.2849.39#add_downloadstarting',), + WindowsPlatform( + apiName: 'ICoreWebView2_4.add_DownloadStarting', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_4?view=webview2-1.0.2849.39#add_downloadstarting', + ), ]) final FutureOr Function( T controller, DownloadStartRequest downloadStartRequest)? @@ -310,8 +435,16 @@ Also, this event is not called for POST requests and is not called on the first ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onLoadResourceWithCustomScheme.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform( apiName: 'WKURLSchemeHandler', apiUrl: 'https://developer.apple.com/documentation/webkit/wkurlschemehandler',), - MacOSPlatform( apiName: 'WKURLSchemeHandler', apiUrl: 'https://developer.apple.com/documentation/webkit/wkurlschemehandler',), + IOSPlatform( + apiName: 'WKURLSchemeHandler', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkurlschemehandler', + ), + MacOSPlatform( + apiName: 'WKURLSchemeHandler', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkurlschemehandler', + ), WindowsPlatform(), ]) final FutureOr Function( @@ -331,10 +464,18 @@ Also, this event is not called for POST requests and is not called on the first /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onCreateWindow.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onCreateWindow', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)', - note: 'You need to set [InAppWebViewSettings.supportMultipleWindows] setting to `true`. Also, if the request has been created using JavaScript (`window.open()`), then there are some limitation: check the [NavigationAction] class.'), - IOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview', - note: """Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], + AndroidPlatform( + apiName: 'WebChromeClient.onCreateWindow', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)', + note: + 'You need to set [InAppWebViewSettings.supportMultipleWindows] setting to `true`. Also, if the request has been created using JavaScript (`window.open()`), then there are some limitation: check the [NavigationAction] class.'), + IOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview', + note: + """Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], [InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically], [InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito], [InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture], @@ -349,8 +490,12 @@ with a different `WKWebViewConfiguration` instance (see https://developer.apple. So, these options will be inherited from the caller WebView. Also, note that calling [InAppWebViewController.setSettings] method using the controller of the new created WebView, it will update also the WebView options of the caller WebView."""), - MacOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview', - note: """Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], + MacOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview', + note: + """Setting these initial settings [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest], [InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically], [InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito], [InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture], @@ -365,8 +510,14 @@ with a different `WKWebViewConfiguration` instance (see https://developer.apple. So, these options will be inherited from the caller WebView. Also, note that calling [InAppWebViewController.setSettings] method using the controller of the new created WebView, it will update also the WebView options of the caller WebView."""), - WebPlatform( note: 'It works only for `window.open()` javascript calls. Also, there is no way to block the opening the window in a synchronous way, so returning `true` will just close it quickly.'), - WindowsPlatform( apiName: 'ICoreWebView2.add_NewWindowRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_newwindowrequested',), + WebPlatform( + note: + 'It works only for `window.open()` javascript calls. Also, there is no way to block the opening the window in a synchronous way, so returning `true` will just close it quickly.'), + WindowsPlatform( + apiName: 'ICoreWebView2.add_NewWindowRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_newwindowrequested', + ), ]) final FutureOr Function( T controller, CreateWindowAction createWindowAction)? onCreateWindow; @@ -378,11 +529,27 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onCloseWindow.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onCloseWindow', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onCloseWindow(android.webkit.WebView)',), - IOSPlatform( apiName: 'WKUIDelegate.webViewDidClose', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose',), - MacOSPlatform( apiName: 'WKUIDelegate.webViewDidClose', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose',), + AndroidPlatform( + apiName: 'WebChromeClient.onCloseWindow', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onCloseWindow(android.webkit.WebView)', + ), + IOSPlatform( + apiName: 'WKUIDelegate.webViewDidClose', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose', + ), + MacOSPlatform( + apiName: 'WKUIDelegate.webViewDidClose', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose', + ), WebPlatform(), - WindowsPlatform( apiName: 'ICoreWebView2.add_WindowCloseRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_windowcloserequested',), + WindowsPlatform( + apiName: 'ICoreWebView2.add_WindowCloseRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_windowcloserequested', + ), ]) final void Function(T controller)? onCloseWindow; @@ -396,7 +563,11 @@ it will update also the WebView options of the caller WebView."""), AndroidPlatform(), IOSPlatform(), MacOSPlatform(), - WebPlatform( apiName: 'Window.onfocus', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/focus_event',), + WebPlatform( + apiName: 'Window.onfocus', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Window/focus_event', + ), ]) final void Function(T controller)? onWindowFocus; @@ -410,7 +581,11 @@ it will update also the WebView options of the caller WebView."""), AndroidPlatform(), IOSPlatform(), MacOSPlatform(), - WebPlatform( apiName: 'Window.onblur', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Window/blur_event',), + WebPlatform( + apiName: 'Window.onblur', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Window/blur_event', + ), ]) final void Function(T controller)? onWindowBlur; @@ -423,9 +598,21 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onJsAlert.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onJsAlert', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)',), - IOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview',), - MacOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview',), + AndroidPlatform( + apiName: 'WebChromeClient.onJsAlert', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)', + ), + IOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview', + ), + MacOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview', + ), ]) final FutureOr Function( T controller, JsAlertRequest jsAlertRequest)? onJsAlert; @@ -439,9 +626,21 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onJsConfirm.onJsConfirm} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onJsConfirm', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsConfirm(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)',), - IOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview',), - MacOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview',), + AndroidPlatform( + apiName: 'WebChromeClient.onJsConfirm', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsConfirm(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)', + ), + IOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview', + ), + MacOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview', + ), ]) final FutureOr Function( T controller, JsConfirmRequest jsConfirmRequest)? onJsConfirm; @@ -455,9 +654,21 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onJsPrompt.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onJsPrompt', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult)',), - IOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview',), - MacOSPlatform( apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview',), + AndroidPlatform( + apiName: 'WebChromeClient.onJsPrompt', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult)', + ), + IOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview', + ), + MacOSPlatform( + apiName: 'WKUIDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview', + ), ]) final FutureOr Function( T controller, JsPromptRequest jsPromptRequest)? onJsPrompt; @@ -470,10 +681,26 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onReceivedHttpAuthRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedHttpAuthRequest', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview',), - WindowsPlatform( apiName: 'ICoreWebView2_10.add_BasicAuthenticationRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_10?view=webview2-1.0.2849.39#add_basicauthenticationrequested',), + AndroidPlatform( + apiName: 'WebViewClient.onReceivedHttpAuthRequest', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + ), + WindowsPlatform( + apiName: 'ICoreWebView2_10.add_BasicAuthenticationRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_10?view=webview2-1.0.2849.39#add_basicauthenticationrequested', + ), ]) final FutureOr Function( T controller, HttpAuthenticationChallenge challenge)? @@ -488,14 +715,30 @@ it will update also the WebView options of the caller WebView."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onReceivedServerTrustAuthRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedSslError', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', - note: """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. + AndroidPlatform( + apiName: 'WebViewClient.onReceivedSslError', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedSslError(android.webkit.WebView,%20android.webkit.SslErrorHandler,%20android.net.http.SslError)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + note: + """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. See `NSAppTransportSecurity` in the [Information Property List Key Reference](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1) for details."""), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', - note: """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + note: + """To override the certificate verification logic, you have to provide ATS (App Transport Security) exceptions in your iOS/macOS `Info.plist`. See `NSAppTransportSecurity` in the [Information Property List Key Reference](https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW1) for details."""), - WindowsPlatform( apiName: 'ICoreWebView2_14.add_ServerCertificateErrorDetected', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_14?view=webview2-1.0.2792.45#add_servercertificateerrordetected',), + WindowsPlatform( + apiName: 'ICoreWebView2_14.add_ServerCertificateErrorDetected', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_14?view=webview2-1.0.2792.45#add_servercertificateerrordetected', + ), ]) final FutureOr Function( T controller, ServerTrustChallenge challenge)? @@ -512,10 +755,26 @@ See `NSAppTransportSecurity` in the [Information Property List Key Reference](ht /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onReceivedClientCertRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedClientCertRequest', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedClientCertRequest(android.webkit.WebView,%20android.webkit.ClientCertRequest)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview',), - WindowsPlatform( apiName: 'ICoreWebView2_5.add_ClientCertificateRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_5?view=webview2-1.0.2849.39#add_clientcertificaterequested',), + AndroidPlatform( + apiName: 'WebViewClient.onReceivedClientCertRequest', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedClientCertRequest(android.webkit.WebView,%20android.webkit.ClientCertRequest)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview', + ), + WindowsPlatform( + apiName: 'ICoreWebView2_5.add_ClientCertificateRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2_5?view=webview2-1.0.2849.39#add_clientcertificaterequested', + ), ]) final FutureOr Function( T controller, ClientCertChallenge challenge)? onReceivedClientCertRequest; @@ -549,7 +808,9 @@ See `NSAppTransportSecurity` in the [Information Property List Key Reference](ht /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.shouldInterceptAjaxRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting documentation. + AndroidPlatform( + note: + """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] setting documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. @@ -575,7 +836,9 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onAjaxReadyStateChange.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxReadyStateChange] settings documentation. + AndroidPlatform( + note: + """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxReadyStateChange] settings documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. @@ -596,7 +859,9 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onAjaxProgress.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxProgress] settings documentation. + AndroidPlatform( + note: + """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptAjaxRequest] and [InAppWebViewSettings.useOnAjaxProgress] settings documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. @@ -617,7 +882,9 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.shouldInterceptFetchRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptFetchRequest] setting documentation. + AndroidPlatform( + note: + """In order to be able to listen this event, check the [InAppWebViewSettings.useShouldInterceptFetchRequest] setting documentation. Also, on Android that doesn't support the [WebViewFeature.DOCUMENT_START_SCRIPT], unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS. @@ -641,11 +908,19 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onUpdateVisitedHistory.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.doUpdateVisitedHistory', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean)',), + AndroidPlatform( + apiName: 'WebViewClient.doUpdateVisitedHistory', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean)', + ), IOSPlatform(), MacOSPlatform(), WebPlatform(), - WindowsPlatform( apiName: 'ICoreWebView2.add_HistoryChanged', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_historychanged',), + WindowsPlatform( + apiName: 'ICoreWebView2.add_HistoryChanged', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_historychanged', + ), ], parameterPlatforms: { 'isReload': [AndroidPlatform()], }) @@ -684,7 +959,7 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea 'printJobController': [AndroidPlatform(), IOSPlatform(), MacOSPlatform()], }) final FutureOr Function(T controller, WebUri? url, - PlatformPrintJobController? printJobController)? onPrintRequest; + PlatformPrintJobController? printJobController)? onPrintRequest; ///{@template flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onLongPressHitTestResult} ///Event fired when an HTML element of the webview has been clicked and held. @@ -694,8 +969,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onLongPressHitTestResult.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'View.setOnLongClickListener', apiUrl: 'https://developer.android.com/reference/android/view/View#setOnLongClickListener(android.view.View.OnLongClickListener)',), - IOSPlatform( apiName: 'UILongPressGestureRecognizer', apiUrl: 'https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer',), + AndroidPlatform( + apiName: 'View.setOnLongClickListener', + apiUrl: + 'https://developer.android.com/reference/android/view/View#setOnLongClickListener(android.view.View.OnLongClickListener)', + ), + IOSPlatform( + apiName: 'UILongPressGestureRecognizer', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer', + ), ]) final void Function(T controller, InAppWebViewHitTestResult hitTestResult)? onLongPressHitTestResult; @@ -706,10 +989,26 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onEnterFullscreen.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onShowCustomView', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)',), - IOSPlatform( apiName: 'UIWindow.didBecomeVisibleNotification', apiUrl: 'https://developer.apple.com/documentation/uikit/uiwindow/1621621-didbecomevisiblenotification',), - MacOSPlatform( apiName: 'NSWindow.didEnterFullScreenNotification', apiUrl: 'https://developer.apple.com/documentation/appkit/nswindow/1419651-didenterfullscreennotification',), - WebPlatform( apiName: 'Document.onfullscreenchange', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event',), + AndroidPlatform( + apiName: 'WebChromeClient.onShowCustomView', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)', + ), + IOSPlatform( + apiName: 'UIWindow.didBecomeVisibleNotification', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiwindow/1621621-didbecomevisiblenotification', + ), + MacOSPlatform( + apiName: 'NSWindow.didEnterFullScreenNotification', + apiUrl: + 'https://developer.apple.com/documentation/appkit/nswindow/1419651-didenterfullscreennotification', + ), + WebPlatform( + apiName: 'Document.onfullscreenchange', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event', + ), ]) final void Function(T controller)? onEnterFullscreen; @@ -719,10 +1018,26 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onExitFullscreen.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onHideCustomView', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()',), - IOSPlatform( apiName: 'UIWindow.didBecomeHiddenNotification', apiUrl: 'https://developer.apple.com/documentation/uikit/uiwindow/1621617-didbecomehiddennotification',), - MacOSPlatform( apiName: 'NSWindow.didExitFullScreenNotification', apiUrl: 'https://developer.apple.com/documentation/appkit/nswindow/1419177-didexitfullscreennotification',), - WebPlatform( apiName: 'Document.onfullscreenchange', apiUrl: 'https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event',), + AndroidPlatform( + apiName: 'WebChromeClient.onHideCustomView', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()', + ), + IOSPlatform( + apiName: 'UIWindow.didBecomeHiddenNotification', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiwindow/1621617-didbecomehiddennotification', + ), + MacOSPlatform( + apiName: 'NSWindow.didExitFullScreenNotification', + apiUrl: + 'https://developer.apple.com/documentation/appkit/nswindow/1419177-didexitfullscreennotification', + ), + WebPlatform( + apiName: 'Document.onfullscreenchange', + apiUrl: + 'https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event', + ), ]) final void Function(T controller)? onExitFullscreen; @@ -737,9 +1052,21 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onPageCommitVisible.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onPageCommitVisible', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String)',), - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview',), + AndroidPlatform( + apiName: 'WebViewClient.onPageCommitVisible', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String)', + ), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview', + ), ]) final void Function(T controller, WebUri? url)? onPageCommitVisible; @@ -751,11 +1078,19 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onTitleChanged.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onReceivedTitle', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)',), + AndroidPlatform( + apiName: 'WebChromeClient.onReceivedTitle', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)', + ), IOSPlatform(), MacOSPlatform(), WebPlatform(), - WindowsPlatform( apiName: 'ICoreWebView2.add_DocumentTitleChanged', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_documenttitlechanged',), + WindowsPlatform( + apiName: 'ICoreWebView2.add_DocumentTitleChanged', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_documenttitlechanged', + ), ]) final void Function(T controller, String? title)? onTitleChanged; @@ -773,7 +1108,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onOverScrolled.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebView.onOverScrolled', apiUrl: 'https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean)',), + AndroidPlatform( + apiName: 'WebView.onOverScrolled', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean)', + ), IOSPlatform(), ]) final void Function(T controller, int x, int y, bool clampedX, bool clampedY)? @@ -789,10 +1128,22 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onZoomScaleChanged.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onScaleChanged', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onScaleChanged(android.webkit.WebView,%20float,%20float)',), - IOSPlatform( apiName: 'UIScrollViewDelegate.scrollViewDidZoom', apiUrl: 'https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619409-scrollviewdidzoom',), + AndroidPlatform( + apiName: 'WebViewClient.onScaleChanged', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onScaleChanged(android.webkit.WebView,%20float,%20float)', + ), + IOSPlatform( + apiName: 'UIScrollViewDelegate.scrollViewDidZoom', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619409-scrollviewdidzoom', + ), WebPlatform(), - WindowsPlatform( apiName: 'ICoreWebView2Controller.add_ZoomFactorChanged', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.2849.39#add_zoomfactorchanged',), + WindowsPlatform( + apiName: 'ICoreWebView2Controller.add_ZoomFactorChanged', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.2849.39#add_zoomfactorchanged', + ), ]) final void Function(T controller, double oldScale, double newScale)? onZoomScaleChanged; @@ -821,7 +1172,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onSafeBrowsingHit.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onSafeBrowsingHit', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse)', available: '27'), + AndroidPlatform( + apiName: 'WebViewClient.onSafeBrowsingHit', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse)', + available: '27'), ]) final FutureOr Function( T controller, WebUri url, SafeBrowsingThreat? threatType)? @@ -849,10 +1204,26 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onPermissionRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onPermissionRequest', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)', available: '21'), - IOSPlatform( available: '15.0', note: 'The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].',), - MacOSPlatform( available: '12.0', note: 'The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].',), - WindowsPlatform( apiName: 'ICoreWebView2.add_PermissionRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_permissionrequested',), + AndroidPlatform( + apiName: 'WebChromeClient.onPermissionRequest', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)', + available: '21'), + IOSPlatform( + available: '15.0', + note: + 'The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].', + ), + MacOSPlatform( + available: '12.0', + note: + 'The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_PermissionRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2210.55#add_permissionrequested', + ), ]) final FutureOr Function( T controller, PermissionRequest permissionRequest)? onPermissionRequest; @@ -879,7 +1250,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onGeolocationPermissionsShowPrompt.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onGeolocationPermissionsShowPrompt', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)',), + AndroidPlatform( + apiName: 'WebChromeClient.onGeolocationPermissionsShowPrompt', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)', + ), ]) final FutureOr Function( T controller, String origin)? onGeolocationPermissionsShowPrompt; @@ -902,7 +1277,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onGeolocationPermissionsHidePrompt.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onGeolocationPermissionsHidePrompt', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt()',), + AndroidPlatform( + apiName: 'WebChromeClient.onGeolocationPermissionsHidePrompt', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt()', + ), ]) final void Function(T controller)? onGeolocationPermissionsHidePrompt; @@ -936,8 +1315,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.shouldInterceptRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.shouldInterceptRequest', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest)',), - WindowsPlatform( apiName: 'ICoreWebView2.add_WebResourceRequested', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2478.35#add_webresourcerequested',), + AndroidPlatform( + apiName: 'WebViewClient.shouldInterceptRequest', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest)', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_WebResourceRequested', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2478.35#add_webresourcerequested', + ), ]) final FutureOr Function( T controller, WebResourceRequest request)? shouldInterceptRequest; @@ -973,8 +1360,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onRenderProcessUnresponsive.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewRenderProcessClient.onRenderProcessUnresponsive', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)', available: '29'), - WindowsPlatform( apiName: 'ICoreWebView2.add_ProcessFailed', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed',), + AndroidPlatform( + apiName: 'WebViewRenderProcessClient.onRenderProcessUnresponsive', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)', + available: '29'), + WindowsPlatform( + apiName: 'ICoreWebView2.add_ProcessFailed', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed', + ), ]) final FutureOr Function( T controller, WebUri? url)? onRenderProcessUnresponsive; @@ -1003,7 +1398,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onRenderProcessResponsive.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewRenderProcessClient.onRenderProcessResponsive', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)', available: '29'), + AndroidPlatform( + apiName: 'WebViewRenderProcessClient.onRenderProcessResponsive', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)', + available: '29'), ]) final FutureOr Function( T controller, WebUri? url)? onRenderProcessResponsive; @@ -1033,8 +1432,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onRenderProcessGone.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onRenderProcessGone', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail)', available: '26'), - WindowsPlatform( apiName: 'ICoreWebView2.add_ProcessFailed', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed',), + AndroidPlatform( + apiName: 'WebViewClient.onRenderProcessGone', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail)', + available: '26'), + WindowsPlatform( + apiName: 'ICoreWebView2.add_ProcessFailed', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed', + ), ]) final void Function(T controller, RenderProcessGoneDetail detail)? onRenderProcessGone; @@ -1057,7 +1464,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onFormResubmission.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onFormResubmission', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message)',), + AndroidPlatform( + apiName: 'WebViewClient.onFormResubmission', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message)', + ), ]) final FutureOr Function(T controller, WebUri? url)? onFormResubmission; @@ -1093,7 +1504,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onReceivedIcon.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onReceivedIcon', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap)',), + AndroidPlatform( + apiName: 'WebChromeClient.onReceivedIcon', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap)', + ), ]) final void Function(T controller, Uint8List icon)? onReceivedIcon; @@ -1119,7 +1534,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onReceivedTouchIconUrl.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onReceivedTouchIconUrl', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)',), + AndroidPlatform( + apiName: 'WebChromeClient.onReceivedTouchIconUrl', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)', + ), ]) final void Function(T controller, WebUri url, bool precomposed)? onReceivedTouchIconUrl; @@ -1151,7 +1570,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onJsBeforeUnload.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onJsBeforeUnload', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsBeforeUnload(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)',), + AndroidPlatform( + apiName: 'WebChromeClient.onJsBeforeUnload', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsBeforeUnload(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)', + ), ]) final FutureOr Function( T controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)? @@ -1177,7 +1600,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onReceivedLoginRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebViewClient.onReceivedLoginRequest', apiUrl: 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String)',), + AndroidPlatform( + apiName: 'WebViewClient.onReceivedLoginRequest', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String)', + ), ]) final void Function(T controller, LoginRequest loginRequest)? onReceivedLoginRequest; @@ -1192,7 +1619,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onPermissionRequestCanceled.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onPermissionRequestCanceled', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequestCanceled(android.webkit.PermissionRequest)', available: '21'), + AndroidPlatform( + apiName: 'WebChromeClient.onPermissionRequestCanceled', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequestCanceled(android.webkit.PermissionRequest)', + available: '21'), ]) final void Function(T controller, PermissionRequest permissionRequest)? onPermissionRequestCanceled; @@ -1207,7 +1638,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onRequestFocus.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onRequestFocus', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onRequestFocus(android.webkit.WebView)',), + AndroidPlatform( + apiName: 'WebChromeClient.onRequestFocus', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onRequestFocus(android.webkit.WebView)', + ), ]) final void Function(T controller)? onRequestFocus; @@ -1229,9 +1664,21 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onWebContentProcessDidTerminate.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKNavigationDelegate.webViewWebContentProcessDidTerminate', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webViewWebContentProcessDidTerminate', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi',), - WindowsPlatform( apiName: 'ICoreWebView2.add_ProcessFailed', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed',), + IOSPlatform( + apiName: 'WKNavigationDelegate.webViewWebContentProcessDidTerminate', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webViewWebContentProcessDidTerminate', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi', + ), + WindowsPlatform( + apiName: 'ICoreWebView2.add_ProcessFailed', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed', + ), ]) final void Function(T controller)? onWebContentProcessDidTerminate; @@ -1253,8 +1700,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onDidReceiveServerRedirectForProvisionalNavigation.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview',), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview', + ), ]) final void Function(T controller)? onDidReceiveServerRedirectForProvisionalNavigation; @@ -1282,8 +1737,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onNavigationResponse.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview',), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview',), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview', + ), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview', + ), ]) final FutureOr Function( T controller, NavigationResponse navigationResponse)? @@ -1310,8 +1773,16 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.shouldAllowDeprecatedTLS.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview', available: '14.0'), - MacOSPlatform( apiName: 'WKNavigationDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview', available: '11.0'), + IOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview', + available: '14.0'), + MacOSPlatform( + apiName: 'WKNavigationDelegate.webView', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview', + available: '11.0'), ]) final FutureOr Function( T controller, URLAuthenticationChallenge challenge)? @@ -1323,8 +1794,12 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onCameraCaptureStateChanged.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( available: '15.0',), - MacOSPlatform( available: '12.0',), + IOSPlatform( + available: '15.0', + ), + MacOSPlatform( + available: '12.0', + ), ]) final FutureOr Function( T controller, @@ -1338,8 +1813,12 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onMicrophoneCaptureStateChanged.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( available: '15.0',), - MacOSPlatform( available: '12.0',), + IOSPlatform( + available: '15.0', + ), + MacOSPlatform( + available: '12.0', + ), ]) final FutureOr Function( T controller, @@ -1372,7 +1851,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onProcessFailed.supported_platforms} @SupportedPlatforms(platforms: [ - WindowsPlatform( apiName: 'ICoreWebView2.add_ProcessFailed', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed',), + WindowsPlatform( + apiName: 'ICoreWebView2.add_ProcessFailed', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2?view=webview2-1.0.2849.39#add_processfailed', + ), ]) final void Function(T controller, ProcessFailedDetail detail)? onProcessFailed; @@ -1395,7 +1878,11 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onAcceleratorKeyPressed.supported_platforms} @SupportedPlatforms(platforms: [ - WindowsPlatform( apiName: 'ICoreWebView2Controller.add_AcceleratorKeyPressed', apiUrl: 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.2849.39#add_acceleratorkeypressed',), + WindowsPlatform( + apiName: 'ICoreWebView2Controller.add_AcceleratorKeyPressed', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2controller?view=webview2-1.0.2849.39#add_acceleratorkeypressed', + ), ]) final void Function(T controller, AcceleratorKeyPressedDetail detail)? onAcceleratorKeyPressed; @@ -1415,9 +1902,14 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.onShowFileChooser.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'WebChromeClient.onShowFileChooser', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onShowFileChooser(android.webkit.WebView,%20android.webkit.ValueCallback%3Candroid.net.Uri[]%3E,%20android.webkit.WebChromeClient.FileChooserParams)',), + AndroidPlatform( + apiName: 'WebChromeClient.onShowFileChooser', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebChromeClient#onShowFileChooser(android.webkit.WebView,%20android.webkit.ValueCallback%3Candroid.net.Uri[]%3E,%20android.webkit.WebChromeClient.FileChooserParams)', + ), ]) - final FutureOr Function(T controller, ShowFileChooserRequest request)? onShowFileChooser; + final FutureOr Function( + T controller, ShowFileChooserRequest request)? onShowFileChooser; ///{@template flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.initialUrlRequest} ///Initial url request that will be loaded. @@ -1425,7 +1917,9 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.initialUrlRequest.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: 'When loading an URL Request using "POST" method, headers are ignored.'), + AndroidPlatform( + note: + 'When loading an URL Request using "POST" method, headers are ignored.'), IOSPlatform(), MacOSPlatform(), WebPlatform(requiresSameOrigin: false), @@ -1507,10 +2001,14 @@ In that case, after the `window.addEventListener("flutterInAppWebViewPlatformRea ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.initialUserScripts.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(note: """This property will be ignored if the [PlatformWebViewCreationParams.windowId] has been set. + IOSPlatform( + note: + """This property will be ignored if the [PlatformWebViewCreationParams.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 WebKit APIs."""), - MacOSPlatform(note: """This property will be ignored if the [PlatformWebViewCreationParams.windowId] has been set. + MacOSPlatform( + note: + """This property will be ignored if the [PlatformWebViewCreationParams.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 WebKit APIs."""), WebPlatform(), @@ -1524,7 +2022,9 @@ This is a limitation of the native WebKit APIs."""), /// ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewCreationParams.pullToRefreshController.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: 'To be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`.'), + AndroidPlatform( + note: + 'To be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`.'), IOSPlatform(), ]) final PlatformPullToRefreshController? pullToRefreshController; @@ -1671,7 +2171,7 @@ This is a limitation of the native WebKit APIs."""), ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isPropertySupported(PlatformWebViewCreationParamsProperty property, - {TargetPlatform? platform}) => + {TargetPlatform? platform}) => _PlatformWebViewCreationParamsPropertySupported.isPropertySupported( property, platform: platform); diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index a63bd5f3a..b05cb5765 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -125,7 +125,8 @@ abstract class InAppWebViewPlatform extends PlatformInterface { /// /// This function should only be called by the app-facing package. /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. - PlatformFindInteractionController createPlatformFindInteractionControllerStatic() { + PlatformFindInteractionController + createPlatformFindInteractionControllerStatic() { throw UnimplementedError( 'createPlatformFindInteractionControllerStatic is not implemented on the current platform.'); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart index ec14fe887..5eaca7bde 100755 --- a/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.dart @@ -53,9 +53,11 @@ class PlatformCookieManagerCreationParams { ///{@template flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isPropertySupported} ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} - bool isPropertySupported(PlatformCookieManagerCreationParamsProperty property, {TargetPlatform? platform}) => - _PlatformCookieManagerCreationParamsPropertySupported - .isPropertySupported(property, platform: platform); + bool isPropertySupported(PlatformCookieManagerCreationParamsProperty property, + {TargetPlatform? platform}) => + _PlatformCookieManagerCreationParamsPropertySupported.isPropertySupported( + property, + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager} @@ -64,14 +66,24 @@ class PlatformCookieManagerCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: 'It is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager).',), - IOSPlatform(note: """It is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore). + AndroidPlatform( + note: + 'It is implemented using [CookieManager](https://developer.android.com/reference/android/webkit/CookieManager).', + ), + IOSPlatform( + note: + """It is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore). On iOS below 11.0, it is implemented using JavaScript. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. - """,), - MacOSPlatform(note: 'It is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore).'), - WebPlatform(note: """It is implemented using JavaScript. + """, + ), + MacOSPlatform( + note: + 'It is implemented using [WKHTTPCookieStore](https://developer.apple.com/documentation/webkit/wkhttpcookiestore).'), + WebPlatform( + note: """It is implemented using JavaScript. See https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies for JavaScript restrictions. - """,), + """, + ), WindowsPlatform(), ]) abstract class PlatformCookieManager extends PlatformInterface { @@ -93,14 +105,14 @@ abstract class PlatformCookieManager extends PlatformInterface { /// Creates a new [PlatformCookieManager] to access static methods. factory PlatformCookieManager.static() { assert( - InAppWebViewPlatform.instance != null, - 'A platform implementation for `flutter_inappwebview` has not been set. Please ' - 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' - '`InAppWebViewPlatform.instance` before use. For unit testing, ' - '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', ); final PlatformCookieManager cookieManagerStatic = - InAppWebViewPlatform.instance!.createPlatformCookieManagerStatic(); + InAppWebViewPlatform.instance!.createPlatformCookieManagerStatic(); PlatformInterface.verify(cookieManagerStatic, _token); return cookieManagerStatic; } @@ -129,28 +141,46 @@ abstract class PlatformCookieManager extends PlatformInterface { /// ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.setCookie.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'CookieManager.setCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)'), - IOSPlatform( apiName: 'WKHTTPCookieStore.setCookie', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie', - note: """On iOS below 11.0, the [webViewController] could be used if you need to set a session-only cookie using JavaScript + AndroidPlatform( + apiName: 'CookieManager.setCookie', + apiUrl: + 'https://developer.android.com/reference/android/webkit/CookieManager#setCookie(java.lang.String,%20java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)'), + IOSPlatform( + apiName: 'WKHTTPCookieStore.setCookie', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie', + note: + """On iOS below 11.0, the [webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) on the current URL of the `WebView` managed by that controller. JavaScript must be enabled in order to work. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). -In this case, this method will return always `true`.""",), - MacOSPlatform( apiName: 'WKHTTPCookieStore.setCookie', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie', - note: """On macOS below 10.13, the [webViewController] could be used if you need to set a session-only cookie using JavaScript +In this case, this method will return always `true`.""", + ), + MacOSPlatform( + apiName: 'WKHTTPCookieStore.setCookie', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882007-setcookie', + note: + """On macOS below 10.13, the [webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) on the current URL of the `WebView` managed by that controller. JavaScript must be enabled in order to work. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). -In this case, this method will return always `true`.""",), - WebPlatform(note: """The [webViewController] could be used if you need to set a session-only cookie using JavaScript +In this case, this method will return always `true`.""", + ), + WebPlatform( + note: + """The [webViewController] could be used if you need to set a session-only cookie using JavaScript (so [isHttpOnly] cannot be set, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) on the current URL of the `WebView` managed by that controller. JavaScript must be enabled in order to work. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to set the cookie (session-only cookie won't work! In that case, you should set also [expiresDate] or [maxAge]). -In this case, this method will return always `true`.""",), - WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), +In this case, this method will return always `true`.""", + ), + WindowsPlatform( + note: + 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), ]) Future setCookie( {required WebUri url, @@ -165,7 +195,12 @@ In this case, this method will return always `true`.""",), HTTPCookieSameSitePolicy? sameSite, @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, - @SupportedPlatforms(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) + @SupportedPlatforms(platforms: [ + MacOSPlatform(), + IOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) PlatformInAppWebViewController? webViewController}) { throw UnimplementedError( 'setCookie is not implemented on the current platform'); @@ -177,36 +212,59 @@ In this case, this method will return always `true`.""",), /// ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getCookies.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'CookieManager.getCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), - IOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', - note: """On iOS below 11.0, the [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript + AndroidPlatform( + apiName: 'CookieManager.getCookie', + apiUrl: + 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), + IOSPlatform( + apiName: 'WKHTTPCookieStore.getAllCookies', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + note: + """On iOS below 11.0, the [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] -to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!).""",), - MacOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', - note: """On macOS below 10.13, the [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript +to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!).""", + ), + MacOSPlatform( + apiName: 'WKHTTPCookieStore.getAllCookies', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + note: + """On macOS below 10.13, the [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] -to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!).""",), - WebPlatform(note: """The [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript +to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!).""", + ), + WebPlatform( + note: + """The [webViewController] is used for getting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] -to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!).""",), - WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), +to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be found!).""", + ), + WindowsPlatform( + note: + 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), ]) Future> getCookies( {required WebUri url, @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, - @SupportedPlatforms(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) + @SupportedPlatforms(platforms: [ + MacOSPlatform(), + IOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) PlatformInAppWebViewController? webViewController}) { throw UnimplementedError( 'getCookies is not implemented on the current platform'); @@ -218,37 +276,60 @@ to get the cookies (session-only cookies and cookies with `isHttpOnly` enabled w /// ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getCookie.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'CookieManager.getCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), - IOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', - note: """On iOS below 11.0, the [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript + AndroidPlatform( + apiName: 'CookieManager.getCookie', + apiUrl: + 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), + IOSPlatform( + apiName: 'WKHTTPCookieStore.getAllCookies', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + note: + """On iOS below 11.0, the [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] -to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!).""",), - MacOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', - note: """On macOS below 10.13, the [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript +to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!).""", + ), + MacOSPlatform( + apiName: 'WKHTTPCookieStore.getAllCookies', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + note: + """On macOS below 10.13, the [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. All the cookies returned this way will have all the properties to `null` except for [Cookie.name] and [Cookie.value]. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] -to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!).""",), - WebPlatform(note: """The [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript +to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!).""", + ), + WebPlatform( + note: + """The [webViewController] is used for getting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be found, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] -to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!).""",), - WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), +to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be found!).""", + ), + WindowsPlatform( + note: + 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), ]) Future getCookie( {required WebUri url, required String name, @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, - @SupportedPlatforms(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) + @SupportedPlatforms(platforms: [ + MacOSPlatform(), + IOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) PlatformInAppWebViewController? webViewController}) { throw UnimplementedError( 'getCookie is not implemented on the current platform'); @@ -264,31 +345,49 @@ to get the cookie (session-only cookie and cookie with `isHttpOnly` enabled won' /// ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteCookie.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'CookieManager.getCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), - IOSPlatform( apiName: 'WKHTTPCookieStore.delete', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', - note: """On iOS below 11.0, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript + AndroidPlatform( + apiName: 'CookieManager.getCookie', + apiUrl: + 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), + IOSPlatform( + apiName: 'WKHTTPCookieStore.delete', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', + note: + """On iOS below 11.0, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). -In this case, this method will return always `true`.""",), - MacOSPlatform( apiName: 'WKHTTPCookieStore.delete', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', - note: """On macOS below 10.13, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript +In this case, this method will return always `true`.""", + ), + MacOSPlatform( + apiName: 'WKHTTPCookieStore.delete', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', + note: + """On macOS below 10.13, the [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). -In this case, this method will return always `true`.""",), - WebPlatform(note: """The [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript +In this case, this method will return always `true`.""", + ), + WebPlatform( + note: + """The [webViewController] is used for deleting the cookie (also session-only cookie) using JavaScript (cookie with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookie (session-only cookie and cookie with `isHttpOnly` enabled won't be deleted!). -In this case, this method will return always `true`.""",), - WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), +In this case, this method will return always `true`.""", + ), + WindowsPlatform( + note: + 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), ]) Future deleteCookie( {required WebUri url, @@ -297,7 +396,12 @@ In this case, this method will return always `true`.""",), String? domain, @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, - @SupportedPlatforms(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) + @SupportedPlatforms(platforms: [ + MacOSPlatform(), + IOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) PlatformInAppWebViewController? webViewController}) { throw UnimplementedError( 'deleteCookie is not implemented on the current platform'); @@ -313,31 +417,49 @@ In this case, this method will return always `true`.""",), /// ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteCookies.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'CookieManager.getCookie', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), - IOSPlatform( apiName: 'WKHTTPCookieStore.delete', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', - note: """On iOS below 11.0, the [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript + AndroidPlatform( + apiName: 'CookieManager.getCookie', + apiUrl: + 'https://developer.android.com/reference/android/webkit/CookieManager#getCookie(java.lang.String)'), + IOSPlatform( + apiName: 'WKHTTPCookieStore.delete', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', + note: + """On iOS below 11.0, the [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). -In this case, this method will return always `true`.""",), - MacOSPlatform( apiName: 'WKHTTPCookieStore.delete', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', - note: """On macOS below 10.13, the [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript +In this case, this method will return always `true`.""", + ), + MacOSPlatform( + apiName: 'WKHTTPCookieStore.delete', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882009-delete', + note: + """On macOS below 10.13, the [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). -In this case, this method will return always `true`.""",), - WebPlatform(note: """The [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript +In this case, this method will return always `true`.""", + ), + WebPlatform( + note: + """The [webViewController] is used for deleting the cookies (also session-only cookies) using JavaScript (cookies with `isHttpOnly` enabled cannot be deleted, see: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#restrict_access_to_cookies) from the current context of the `WebView` managed by that controller. JavaScript must be enabled in order to work. In this case the [url] parameter is ignored. If [webViewController] is `null` or JavaScript is disabled for it, it will try to use a [PlatformHeadlessInAppWebView] to delete the cookies (session-only cookies and cookies with `isHttpOnly` enabled won't be deleted!). -In this case, this method will return always `true`.""",), - WindowsPlatform(note: 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), +In this case, this method will return always `true`.""", + ), + WindowsPlatform( + note: + 'The [webViewController] could be used to access cookies accessible only on the WebView managed by that controller, such as cookie with partition key.'), ]) Future deleteCookies( {required WebUri url, @@ -345,7 +467,12 @@ In this case, this method will return always `true`.""",), String? domain, @Deprecated("Use webViewController instead") PlatformInAppWebViewController? iosBelow11WebViewController, - @SupportedPlatforms(platforms: [MacOSPlatform(), IOSPlatform(), WebPlatform(), WindowsPlatform()]) + @SupportedPlatforms(platforms: [ + MacOSPlatform(), + IOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) PlatformInAppWebViewController? webViewController}) { throw UnimplementedError( 'deleteCookies is not implemented on the current platform'); @@ -359,13 +486,24 @@ In this case, this method will return always `true`.""",), /// ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.deleteAllCookies.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'CookieManager.removeAllCookies', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)'), - IOSPlatform( apiName: 'WKWebsiteDataStore.removeData', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata', + AndroidPlatform( + apiName: 'CookieManager.removeAllCookies', + apiUrl: + 'https://developer.android.com/reference/android/webkit/CookieManager#removeAllCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)'), + IOSPlatform( + apiName: 'WKWebsiteDataStore.removeData', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata', available: '11.0', - note: """It will return always `true`.""",), - MacOSPlatform( apiName: 'WKWebsiteDataStore.removeData', apiUrl: 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata', + note: """It will return always `true`.""", + ), + MacOSPlatform( + apiName: 'WKWebsiteDataStore.removeData', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata', available: '10.13', - note: """It will return always `true`.""",), + note: """It will return always `true`.""", + ), WindowsPlatform(), ]) Future deleteAllCookies() { @@ -379,10 +517,18 @@ In this case, this method will return always `true`.""",), /// ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.getAllCookies.supported_platforms} @SupportedPlatforms(platforms: [ - IOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', - available: '11.0',), - MacOSPlatform( apiName: 'WKHTTPCookieStore.getAllCookies', apiUrl: 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', - available: '10.13',), + IOSPlatform( + apiName: 'WKHTTPCookieStore.getAllCookies', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + available: '11.0', + ), + MacOSPlatform( + apiName: 'WKHTTPCookieStore.getAllCookies', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkhttpcookiestore/2882005-getallcookies', + available: '10.13', + ), ]) Future> getAllCookies() { throw UnimplementedError( @@ -397,7 +543,11 @@ In this case, this method will return always `true`.""",), /// ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.removeSessionCookies.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'CookieManager.removeSessionCookies', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#removeSessionCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)',), + AndroidPlatform( + apiName: 'CookieManager.removeSessionCookies', + apiUrl: + 'https://developer.android.com/reference/android/webkit/CookieManager#removeSessionCookies(android.webkit.ValueCallback%3Cjava.lang.Boolean%3E)', + ), ]) Future removeSessionCookies() { throw UnimplementedError( @@ -411,7 +561,11 @@ In this case, this method will return always `true`.""",), /// ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManager.flush.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform( apiName: 'CookieManager.flush', apiUrl: 'https://developer.android.com/reference/android/webkit/CookieManager#flush()',), + AndroidPlatform( + apiName: 'CookieManager.flush', + apiUrl: + 'https://developer.android.com/reference/android/webkit/CookieManager#flush()', + ), ]) Future flush() { throw UnimplementedError( @@ -423,15 +577,15 @@ In this case, this method will return always `true`.""",), params.isClassSupported(platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformCookieManagerCreationParams.isPropertySupported} - bool isPropertySupported(PlatformCookieManagerCreationParamsProperty property, {TargetPlatform? platform}) => + bool isPropertySupported(PlatformCookieManagerCreationParamsProperty property, + {TargetPlatform? platform}) => params.isPropertySupported(property, platform: platform); ///{@template flutter_inappwebview_platform_interface.PlatformCookieManager.isMethodSupported} ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isMethodSupported(PlatformCookieManagerMethod method, - {TargetPlatform? platform}) => - _PlatformCookieManagerMethodSupported.isMethodSupported( - method, + {TargetPlatform? platform}) => + _PlatformCookieManagerMethodSupported.isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart index 695be35eb..8b1e61cc4 100755 --- a/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.dart @@ -30,8 +30,8 @@ class PlatformHttpAuthCredentialDatabaseCreationParams { ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isClassSupported({TargetPlatform? platform}) => - _PlatformHttpAuthCredentialDatabaseCreationParamsClassSupported.isClassSupported( - platform: platform); + _PlatformHttpAuthCredentialDatabaseCreationParamsClassSupported + .isClassSupported(platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase} @@ -40,9 +40,15 @@ class PlatformHttpAuthCredentialDatabaseCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(note: 'It has a custom implementation using `android.database.sqlite.SQLiteDatabase` because [WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase) doesn\'t offer the same functionalities as iOS/macOS `URLCredentialStorage`.'), - IOSPlatform(note: 'It is implemented using the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.'), - MacOSPlatform(note: 'It is implemented using the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.'), + AndroidPlatform( + note: + 'It has a custom implementation using `android.database.sqlite.SQLiteDatabase` because [WebViewDatabase](https://developer.android.com/reference/android/webkit/WebViewDatabase) doesn\'t offer the same functionalities as iOS/macOS `URLCredentialStorage`.'), + IOSPlatform( + note: + 'It is implemented using the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.'), + MacOSPlatform( + note: + 'It is implemented using the [URLCredentialStorage](https://developer.apple.com/documentation/foundation/urlcredentialstorage) class.'), ]) abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { /// Creates a new [PlatformHttpAuthCredentialDatabase] @@ -65,14 +71,15 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { /// Creates a new [PlatformHttpAuthCredentialDatabase] to access static methods. factory PlatformHttpAuthCredentialDatabase.static() { assert( - InAppWebViewPlatform.instance != null, - 'A platform implementation for `flutter_inappwebview` has not been set. Please ' - 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' - '`InAppWebViewPlatform.instance` before use. For unit testing, ' - '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', ); final PlatformHttpAuthCredentialDatabase httpAuthCredentialDatabaseStatic = - InAppWebViewPlatform.instance!.createPlatformHttpAuthCredentialDatabaseStatic(); + InAppWebViewPlatform.instance! + .createPlatformHttpAuthCredentialDatabaseStatic(); PlatformInterface.verify(httpAuthCredentialDatabaseStatic, _token); return httpAuthCredentialDatabaseStatic; } @@ -100,8 +107,16 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.getAllAuthCredentials.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(apiName: 'URLCredentialStorage.allCredentials', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials',), - MacOSPlatform(apiName: 'URLCredentialStorage.allCredentials', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials',), + IOSPlatform( + apiName: 'URLCredentialStorage.allCredentials', + apiUrl: + 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials', + ), + MacOSPlatform( + apiName: 'URLCredentialStorage.allCredentials', + apiUrl: + 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1413859-allcredentials', + ), ]) Future> getAllAuthCredentials() { throw UnimplementedError( @@ -131,8 +146,16 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.setHttpAuthCredential.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(apiName: 'URLCredentialStorage.set', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set',), - MacOSPlatform(apiName: 'URLCredentialStorage.set', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set',), + IOSPlatform( + apiName: 'URLCredentialStorage.set', + apiUrl: + 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set', + ), + MacOSPlatform( + apiName: 'URLCredentialStorage.set', + apiUrl: + 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1407227-set', + ), ]) Future setHttpAuthCredential( {required URLProtectionSpace protectionSpace, @@ -148,8 +171,16 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { ///{@macro flutter_inappwebview_platform_interface.PlatformHttpAuthCredentialDatabase.removeHttpAuthCredential.supported_platforms} @SupportedPlatforms(platforms: [ AndroidPlatform(), - IOSPlatform(apiName: 'URLCredentialStorage.remove', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove',), - MacOSPlatform(apiName: 'URLCredentialStorage.remove', apiUrl: 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove',), + IOSPlatform( + apiName: 'URLCredentialStorage.remove', + apiUrl: + 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove', + ), + MacOSPlatform( + apiName: 'URLCredentialStorage.remove', + apiUrl: + 'https://developer.apple.com/documentation/foundation/urlcredentialstorage/1408664-remove', + ), ]) Future removeHttpAuthCredential( {required URLProtectionSpace protectionSpace, @@ -197,7 +228,7 @@ abstract class PlatformHttpAuthCredentialDatabase extends PlatformInterface { ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isMethodSupported(PlatformHttpAuthCredentialDatabaseMethod method, - {TargetPlatform? platform}) => + {TargetPlatform? platform}) => _PlatformHttpAuthCredentialDatabaseMethodSupported.isMethodSupported( method, platform: platform); diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart index 3e843900a..0115e7fc7 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.dart @@ -43,7 +43,10 @@ class PlatformTracingControllerCreationParams { /// ///{@macro flutter_inappwebview_platform_interface.PlatformTracingController.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'TracingController', apiUrl: 'https://developer.android.com/reference/androidx/webkit/TracingController'), + AndroidPlatform( + apiName: 'TracingController', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/TracingController'), ]) abstract class PlatformTracingController extends PlatformInterface { /// Creates a new [PlatformTracingController] @@ -65,15 +68,14 @@ abstract class PlatformTracingController extends PlatformInterface { /// Creates a new [PlatformTracingController] factory PlatformTracingController.static() { assert( - InAppWebViewPlatform.instance != null, - 'A platform implementation for `flutter_inappwebview` has not been set. Please ' - 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' - '`WebViewPlatform.instance` before use. For unit testing, ' - '`WebViewPlatform.instance` can be set with your own test implementation.', + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', ); final PlatformTracingController tracingControllerStatic = - InAppWebViewPlatform.instance! - .createPlatformTracingControllerStatic(); + InAppWebViewPlatform.instance!.createPlatformTracingControllerStatic(); PlatformInterface.verify(tracingControllerStatic, _token); return tracingControllerStatic; } @@ -101,7 +103,10 @@ abstract class PlatformTracingController extends PlatformInterface { /// ///{@macro flutter_inappwebview_platform_interface.PlatformTracingController.start.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'TracingController.start', apiUrl: 'https://developer.android.com/reference/android/webkit/TracingController#start(android.webkit.TracingConfig)'), + AndroidPlatform( + apiName: 'TracingController.start', + apiUrl: + 'https://developer.android.com/reference/android/webkit/TracingController#start(android.webkit.TracingConfig)'), ]) Future start({required TracingSettings settings}) { throw UnimplementedError( @@ -119,7 +124,10 @@ abstract class PlatformTracingController extends PlatformInterface { /// ///{@macro flutter_inappwebview_platform_interface.PlatformTracingController.stop.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'TracingController.stop', apiUrl: 'https://developer.android.com/reference/android/webkit/TracingController#stop(java.io.OutputStream,%20java.util.concurrent.Executor)'), + AndroidPlatform( + apiName: 'TracingController.stop', + apiUrl: + 'https://developer.android.com/reference/android/webkit/TracingController#stop(java.io.OutputStream,%20java.util.concurrent.Executor)'), ]) Future stop({String? filePath}) { throw UnimplementedError('stop is not implemented on the current platform'); @@ -131,7 +139,10 @@ abstract class PlatformTracingController extends PlatformInterface { /// ///{@macro flutter_inappwebview_platform_interface.PlatformTracingController.isTracing.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'TracingController.isTracing', apiUrl: 'https://developer.android.com/reference/android/webkit/TracingController#isTracing()'), + AndroidPlatform( + apiName: 'TracingController.isTracing', + apiUrl: + 'https://developer.android.com/reference/android/webkit/TracingController#isTracing()'), ]) Future isTracing() { throw UnimplementedError( @@ -146,7 +157,7 @@ abstract class PlatformTracingController extends PlatformInterface { ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isMethodSupported(PlatformTracingControllerMethod method, - {TargetPlatform? platform}) => + {TargetPlatform? platform}) => _PlatformTracingControllerMethodSupported.isMethodSupported(method, platform: platform); } @@ -194,7 +205,10 @@ List _serializeCategories(List categories, /// ///{@macro flutter_inappwebview_platform_interface.TracingSettings.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'TracingConfig', apiUrl: 'https://developer.android.com/reference/androidx/webkit/TracingConfig'), + AndroidPlatform( + apiName: 'TracingConfig', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/TracingConfig'), ]) @ExchangeableObject(copyMethod: true) class TracingSettings_ { @@ -234,15 +248,13 @@ class TracingSettings_ { ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) => - _TracingSettingsClassSupported.isClassSupported( - platform: platform); + _TracingSettingsClassSupported.isClassSupported(platform: platform); ///{@template flutter_inappwebview_platform_interface.TracingSettings.isPropertySupported} ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} static bool isPropertySupported(TracingSettingsProperty property, - {TargetPlatform? platform}) => - _TracingSettingsPropertySupported.isPropertySupported( - property, + {TargetPlatform? platform}) => + _TracingSettingsPropertySupported.isPropertySupported(property, platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart index 14244d85b..b3e6df816 100644 --- a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.dart @@ -26,8 +26,7 @@ part 'platform_print_job_controller.g.dart'; @immutable class PlatformPrintJobControllerCreationParams { /// Used by the platform implementation to create a new [PlatformPrintJobController]. - const PlatformPrintJobControllerCreationParams( - {required this.id}); + const PlatformPrintJobControllerCreationParams({required this.id}); ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobControllerCreationParams.id} ///Print job ID. @@ -52,8 +51,8 @@ class PlatformPrintJobControllerCreationParams { ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isPropertySupported( - PlatformPrintJobControllerCreationParamsProperty property, - {TargetPlatform? platform}) => + PlatformPrintJobControllerCreationParamsProperty property, + {TargetPlatform? platform}) => _PlatformPrintJobControllerCreationParamsPropertySupported .isPropertySupported(property, platform: platform); } @@ -100,8 +99,7 @@ abstract class PlatformPrintJobController extends PlatformInterface '`WebViewPlatform.instance` can be set with your own test implementation.', ); final PlatformPrintJobController printJobControllerStatic = - InAppWebViewPlatform.instance! - .createPlatformPrintJobControllerStatic(); + InAppWebViewPlatform.instance!.createPlatformPrintJobControllerStatic(); PlatformInterface.verify(printJobControllerStatic, _token); return printJobControllerStatic; } @@ -125,15 +123,23 @@ abstract class PlatformPrintJobController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.onComplete} ///A completion handler used to handle the conclusion of the print job (for instance, to reset state) and to handle any errors encountered in printing. - /// - ///NOTE for Android: `completed` is always `true` and `error` is always `null`. ///{@endtemplate} /// ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.onComplete.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'PrintDocumentAdapter.onFinish', apiUrl: 'https://developer.android.com/reference/android/print/PrintDocumentAdapter#onFinish()'), - IOSPlatform(apiName: 'UIPrintInteractionController.CompletionHandler', apiUrl: 'https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/completionhandler'), - MacOSPlatform(apiName: 'NSPrintOperation.runModal', apiUrl: 'https://developer.apple.com/documentation/appkit/nsprintoperation/1532065-runmodal'), + AndroidPlatform( + apiName: 'PrintDocumentAdapter.onFinish', + apiUrl: + 'https://developer.android.com/reference/android/print/PrintDocumentAdapter#onFinish()', + note: '`completed` is always `true` and `error` is always `null`.'), + IOSPlatform( + apiName: 'UIPrintInteractionController.CompletionHandler', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/completionhandler'), + MacOSPlatform( + apiName: 'NSPrintOperation.runModal', + apiUrl: + 'https://developer.apple.com/documentation/appkit/nsprintoperation/1532065-runmodal'), ]) PrintJobCompletionHandler? onComplete; @@ -144,7 +150,10 @@ abstract class PlatformPrintJobController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.cancel.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'PrintJob.cancel', apiUrl: 'https://developer.android.com/reference/android/print/PrintJob#cancel()'), + AndroidPlatform( + apiName: 'PrintJob.cancel', + apiUrl: + 'https://developer.android.com/reference/android/print/PrintJob#cancel()'), ]) Future cancel() { throw UnimplementedError( @@ -158,7 +167,10 @@ abstract class PlatformPrintJobController extends PlatformInterface /// ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.restart.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'PrintJob.restart', apiUrl: 'https://developer.android.com/reference/android/print/PrintJob#restart()'), + AndroidPlatform( + apiName: 'PrintJob.restart', + apiUrl: + 'https://developer.android.com/reference/android/print/PrintJob#restart()'), ]) Future restart() { throw UnimplementedError( @@ -186,14 +198,17 @@ abstract class PlatformPrintJobController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.getInfo} ///Gets the [PrintJobInfo] that describes this job. /// - ///NOTE: The returned info object is a snapshot of the + ///**NOTE**: The returned info object is a snapshot of the ///current print job state. Every call to this method returns a fresh ///info object that reflects the current print job state. ///{@endtemplate} /// ///{@macro flutter_inappwebview_platform_interface.PlatformPrintJobController.getInfo.supported_platforms} @SupportedPlatforms(platforms: [ - AndroidPlatform(apiName: 'PrintJob.getInfo', apiUrl: 'https://developer.android.com/reference/android/print/PrintJob#getInfo()'), + AndroidPlatform( + apiName: 'PrintJob.getInfo', + apiUrl: + 'https://developer.android.com/reference/android/print/PrintJob#getInfo()'), IOSPlatform(), MacOSPlatform(), ]) @@ -230,13 +245,14 @@ abstract class PlatformPrintJobController extends PlatformInterface property is PlatformPrintJobControllerCreationParamsProperty ? params.isPropertySupported(property, platform: platform) : _PlatformPrintJobControllerPropertySupported.isPropertySupported( - property, platform: platform); + property, + platform: platform); ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.isMethodSupported} ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. ///{@endtemplate} bool isMethodSupported(PlatformPrintJobControllerMethod method, - {TargetPlatform? platform}) => + {TargetPlatform? platform}) => _PlatformPrintJobControllerMethodSupported.isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart index b134e87c0..b7b197bdd 100644 --- a/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart @@ -63,10 +63,8 @@ class PrintJobSettings_ { int? numberOfPages; ///Force rendering quality. - /// - ///**NOTE for iOS**: available only on iOS 14.5+. @SupportedPlatforms(platforms: [ - IOSPlatform(), + IOSPlatform(available: '14.5'), ]) PrintJobRenderingQuality_? forceRenderingQuality; @@ -130,10 +128,8 @@ class PrintJobSettings_ { ///A Boolean value that determines whether the printing options include the paper orientation control when available. ///The default value is `true`. - /// - ///**NOTE for iOS**: available only on iOS 15.0+. @SupportedPlatforms(platforms: [ - IOSPlatform(), + IOSPlatform(available: '15.0'), MacOSPlatform(), ]) bool? showsPaperOrientation; diff --git a/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request.dart b/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request.dart index 4cad89af7..b9629036c 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request.dart @@ -36,4 +36,4 @@ class ShowFileChooserRequest_ { this.title, this.filenameHint, }); -} \ No newline at end of file +} diff --git a/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request_mode.dart b/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request_mode.dart index dff40f408..e51f67d19 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request_mode.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_request_mode.dart @@ -14,28 +14,20 @@ class ShowFileChooserRequestMode_ { const ShowFileChooserRequestMode_._internal(this._value); ///Open single file. Requires that the file exists before allowing the user to pick it. - @EnumSupportedPlatforms(platforms: [ - EnumAndroidPlatform(value: 0) - ]) + @EnumSupportedPlatforms(platforms: [EnumAndroidPlatform(value: 0)]) static const OPEN = const ShowFileChooserRequestMode_._internal(0); ///Like Open but allows multiple files to be selected. - @EnumSupportedPlatforms(platforms: [ - EnumAndroidPlatform(value: 1) - ]) + @EnumSupportedPlatforms(platforms: [EnumAndroidPlatform(value: 1)]) static const OPEN_MULTIPLE = const ShowFileChooserRequestMode_._internal(1); ///Like Open but allows a folder to be selected. ///The implementation should enumerate all files selected by this operation. ///This feature is not supported at the moment. - @EnumSupportedPlatforms(platforms: [ - EnumAndroidPlatform(value: 2) - ]) + @EnumSupportedPlatforms(platforms: [EnumAndroidPlatform(value: 2)]) static const OPEN_FOLDER = const ShowFileChooserRequestMode_._internal(2); ///Allows picking a nonexistent file and saving it. - @EnumSupportedPlatforms(platforms: [ - EnumAndroidPlatform(value: 3) - ]) + @EnumSupportedPlatforms(platforms: [EnumAndroidPlatform(value: 3)]) static const SAVE = const ShowFileChooserRequestMode_._internal(3); } diff --git a/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_response.dart b/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_response.dart index 88fc3ee7c..638c23d77 100644 --- a/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_response.dart +++ b/flutter_inappwebview_platform_interface/lib/src/types/show_file_chooser_response.dart @@ -19,4 +19,4 @@ class ShowFileChooserResponse_ { required this.handledByClient, this.filePaths, }); -} \ No newline at end of file +} diff --git a/flutter_inappwebview_web/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview_web/lib/src/in_app_webview/headless_in_app_webview.dart index c323adb6e..c25de0408 100644 --- a/flutter_inappwebview_web/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/flutter_inappwebview_web/lib/src/in_app_webview/headless_in_app_webview.dart @@ -269,8 +269,8 @@ class WebPlatformHeadlessInAppWebView extends PlatformHeadlessInAppWebView } static final WebPlatformHeadlessInAppWebView _staticValue = - WebPlatformHeadlessInAppWebView( - WebPlatformHeadlessInAppWebViewCreationParams()); + WebPlatformHeadlessInAppWebView( + WebPlatformHeadlessInAppWebViewCreationParams()); factory WebPlatformHeadlessInAppWebView.static() { return _staticValue; diff --git a/flutter_inappwebview_web/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_web/lib/src/in_app_webview/in_app_webview.dart index 653185b13..2cc001260 100755 --- a/flutter_inappwebview_web/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_web/lib/src/in_app_webview/in_app_webview.dart @@ -273,8 +273,8 @@ class WebPlatformInAppWebViewWidget extends PlatformInAppWebViewWidget { _webPlatformParams.headlessWebView as WebPlatformHeadlessInAppWebView?; static final WebPlatformInAppWebViewWidget _staticValue = - WebPlatformInAppWebViewWidget( - WebPlatformInAppWebViewWidgetCreationParams()); + WebPlatformInAppWebViewWidget( + WebPlatformInAppWebViewWidgetCreationParams()); factory WebPlatformInAppWebViewWidget.static() { return _staticValue; diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index dced0b00b..b8f670167 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -148,7 +148,8 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. @override - PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { + PlatformServiceWorkerController + createPlatformServiceWorkerControllerStatic() { return _PlatformServiceWorkerController.static(); } @@ -166,7 +167,8 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. @override - PlatformFindInteractionController createPlatformFindInteractionControllerStatic() { + PlatformFindInteractionController + createPlatformFindInteractionControllerStatic() { return _PlatformFindInteractionController.static(); } @@ -231,11 +233,12 @@ class _PlatformProxyController extends PlatformProxyController { } class _PlatformServiceWorkerController extends PlatformServiceWorkerController { - _PlatformServiceWorkerController(PlatformServiceWorkerControllerCreationParams params) + _PlatformServiceWorkerController( + PlatformServiceWorkerControllerCreationParams params) : super.implementation(params); static final _PlatformServiceWorkerController _staticValue = - _PlatformServiceWorkerController( - const PlatformServiceWorkerControllerCreationParams()); + _PlatformServiceWorkerController( + const PlatformServiceWorkerControllerCreationParams()); factory _PlatformServiceWorkerController.static() => _staticValue; @@ -247,18 +250,20 @@ class _PlatformTracingController extends PlatformTracingController { _PlatformTracingController(PlatformTracingControllerCreationParams params) : super.implementation(params); static final _PlatformTracingController _staticValue = - _PlatformTracingController( - const PlatformTracingControllerCreationParams()); + _PlatformTracingController( + const PlatformTracingControllerCreationParams()); factory _PlatformTracingController.static() => _staticValue; } -class _PlatformFindInteractionController extends PlatformFindInteractionController { - _PlatformFindInteractionController(PlatformFindInteractionControllerCreationParams params) +class _PlatformFindInteractionController + extends PlatformFindInteractionController { + _PlatformFindInteractionController( + PlatformFindInteractionControllerCreationParams params) : super.implementation(params); static final _PlatformFindInteractionController _staticValue = - _PlatformFindInteractionController( - const PlatformFindInteractionControllerCreationParams()); + _PlatformFindInteractionController( + const PlatformFindInteractionControllerCreationParams()); factory _PlatformFindInteractionController.static() => _staticValue; } diff --git a/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart b/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart index caa3b3ae0..1bd5ed254 100644 --- a/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart +++ b/flutter_inappwebview_web/lib/web/in_app_web_view_web_element.dart @@ -298,8 +298,7 @@ class InAppWebViewWebElement implements Disposable { void makeInitialLoad() async { if (windowId != null) { if (InAppWebViewManager.windowActions.containsKey(windowId!)) { - final createWindowAction = - InAppWebViewManager.windowActions[windowId!]; + final createWindowAction = InAppWebViewManager.windowActions[windowId!]; loadUrl(urlRequest: createWindowAction!.request); } } else if (initialUrlRequest != null) { diff --git a/flutter_inappwebview_web/lib/web/js_bridge.dart b/flutter_inappwebview_web/lib/web/js_bridge.dart index c9eecf9e6..ed94ae114 100644 --- a/flutter_inappwebview_web/lib/web/js_bridge.dart +++ b/flutter_inappwebview_web/lib/web/js_bridge.dart @@ -45,7 +45,10 @@ external FlutterInAppWebViewBridge? get flutterInAppWebView; extension type FlutterInAppWebViewBridge._(JSObject _) implements JSObject { external JSWebView createFlutterInAppWebView( - JSAny viewId, HTMLIFrameElement iframe, HTMLDivElement iframeContainer, String bridgeSecret); + JSAny viewId, + HTMLIFrameElement iframe, + HTMLDivElement iframeContainer, + String bridgeSecret); external JSString getCookieExpirationDate(num timestamp); external JSFunction nativeAsyncCommunication; @@ -56,4 +59,4 @@ extension type FlutterInAppWebViewBridge._(JSObject _) implements JSObject { external JSObject Object_freeze(JSObject obj); @JS('Object.isFrozen') -external JSBoolean Object_isFrozen(JSObject obj); \ No newline at end of file +external JSBoolean Object_isFrozen(JSObject obj); diff --git a/flutter_inappwebview_windows/lib/src/in_app_webview/headless_in_app_webview.dart b/flutter_inappwebview_windows/lib/src/in_app_webview/headless_in_app_webview.dart index 4dd946476..e0f3f29d1 100644 --- a/flutter_inappwebview_windows/lib/src/in_app_webview/headless_in_app_webview.dart +++ b/flutter_inappwebview_windows/lib/src/in_app_webview/headless_in_app_webview.dart @@ -280,8 +280,7 @@ class WindowsHeadlessInAppWebView extends PlatformHeadlessInAppWebView } static final WindowsHeadlessInAppWebView _staticValue = - WindowsHeadlessInAppWebView( - WindowsHeadlessInAppWebViewCreationParams()); + WindowsHeadlessInAppWebView(WindowsHeadlessInAppWebViewCreationParams()); factory WindowsHeadlessInAppWebView.static() { return _staticValue; diff --git a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview.dart b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview.dart index d0998b74f..ff93cc9c6 100644 --- a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview.dart +++ b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview.dart @@ -286,8 +286,7 @@ class WindowsInAppWebViewWidget extends PlatformInAppWebViewWidget { params.headlessWebView as WindowsHeadlessInAppWebView?; static final WindowsInAppWebViewWidget _staticValue = - WindowsInAppWebViewWidget( - WindowsInAppWebViewWidgetCreationParams()); + WindowsInAppWebViewWidget(WindowsInAppWebViewWidgetCreationParams()); factory WindowsInAppWebViewWidget.static() { return _staticValue; diff --git a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart index 03e5dc040..8ffb0b3b3 100644 --- a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart @@ -1559,9 +1559,9 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController _controllerFromPlatform, request)) ?.toNativeValue()); else - return jsonEncode((await _inAppBrowserEventHandler! - .onAjaxProgress(request)) - ?.toNativeValue()); + return jsonEncode( + (await _inAppBrowserEventHandler!.onAjaxProgress(request)) + ?.toNativeValue()); } return null; case "shouldInterceptFetchRequest": diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index 8cff08e2d..948f4095b 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -216,7 +216,8 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [ServiceWorkerController] in `flutter_inappwebview` instead. @override - PlatformServiceWorkerController createPlatformServiceWorkerControllerStatic() { + PlatformServiceWorkerController + createPlatformServiceWorkerControllerStatic() { return _PlatformServiceWorkerController.static(); } @@ -234,7 +235,8 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { /// This function should only be called by the app-facing package. /// Look at using [FindInteractionController] in `flutter_inappwebview` instead. @override - PlatformFindInteractionController createPlatformFindInteractionControllerStatic() { + PlatformFindInteractionController + createPlatformFindInteractionControllerStatic() { return _PlatformFindInteractionController.static(); } @@ -290,11 +292,12 @@ class _PlatformProxyController extends PlatformProxyController { } class _PlatformServiceWorkerController extends PlatformServiceWorkerController { - _PlatformServiceWorkerController(PlatformServiceWorkerControllerCreationParams params) + _PlatformServiceWorkerController( + PlatformServiceWorkerControllerCreationParams params) : super.implementation(params); static final _PlatformServiceWorkerController _staticValue = - _PlatformServiceWorkerController( - const PlatformServiceWorkerControllerCreationParams()); + _PlatformServiceWorkerController( + const PlatformServiceWorkerControllerCreationParams()); factory _PlatformServiceWorkerController.static() => _staticValue; @@ -306,18 +309,20 @@ class _PlatformTracingController extends PlatformTracingController { _PlatformTracingController(PlatformTracingControllerCreationParams params) : super.implementation(params); static final _PlatformTracingController _staticValue = - _PlatformTracingController( - const PlatformTracingControllerCreationParams()); + _PlatformTracingController( + const PlatformTracingControllerCreationParams()); factory _PlatformTracingController.static() => _staticValue; } -class _PlatformFindInteractionController extends PlatformFindInteractionController { - _PlatformFindInteractionController(PlatformFindInteractionControllerCreationParams params) +class _PlatformFindInteractionController + extends PlatformFindInteractionController { + _PlatformFindInteractionController( + PlatformFindInteractionControllerCreationParams params) : super.implementation(params); static final _PlatformFindInteractionController _staticValue = - _PlatformFindInteractionController( - const PlatformFindInteractionControllerCreationParams()); + _PlatformFindInteractionController( + const PlatformFindInteractionControllerCreationParams()); factory _PlatformFindInteractionController.static() => _staticValue; } diff --git a/flutter_inappwebview_windows/lib/src/print_job/print_job_controller.dart b/flutter_inappwebview_windows/lib/src/print_job/print_job_controller.dart index c32e48735..b2b6e430e 100644 --- a/flutter_inappwebview_windows/lib/src/print_job/print_job_controller.dart +++ b/flutter_inappwebview_windows/lib/src/print_job/print_job_controller.dart @@ -11,16 +11,14 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla class WindowsPrintJobControllerCreationParams extends PlatformPrintJobControllerCreationParams { /// Creates a new [WindowsPrintJobControllerCreationParams] instance. - const WindowsPrintJobControllerCreationParams( - {required super.id}); + const WindowsPrintJobControllerCreationParams({required super.id}); /// Creates a [WindowsPrintJobControllerCreationParams] instance based on [PlatformPrintJobControllerCreationParams]. factory WindowsPrintJobControllerCreationParams.fromPlatformPrintJobControllerCreationParams( // Recommended placeholder to prevent being broken by platform interface. // ignore: avoid_unused_constructor_parameters PlatformPrintJobControllerCreationParams params) { - return WindowsPrintJobControllerCreationParams( - id: params.id); + return WindowsPrintJobControllerCreationParams(id: params.id); } } From bb38b6aaadcb09b9b9c84b0d1688ddc522edc2d9 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Thu, 2 Oct 2025 16:12:39 +0200 Subject: [PATCH 156/181] added support methods for PullToRefreshController class --- .../pull_to_refresh_controller.dart | 18 + .../lib/src/inappwebview_platform.dart | 9 + .../pull_to_refresh_controller.dart | 9 + .../lib/src/inappwebview_platform.dart | 9 + .../pull_to_refresh_controller.dart | 8 + .../lib/src/inappwebview_platform.dart | 22 + .../lib/src/inappwebview_platform.dart | 10 + .../lib/src/print_job/main.dart | 3 +- .../platform_print_job_controller.g.dart | 3 +- .../lib/src/print_job/print_job_settings.dart | 12 + .../src/print_job/print_job_settings.g.dart | 721 +++++++++++++++++- .../lib/src/pull_to_refresh/main.dart | 5 +- .../platform_pull_to_refresh_controller.dart | 323 ++++++-- ...platform_pull_to_refresh_controller.g.dart | 379 +++++++++ .../pull_to_refresh_settings.dart | 62 +- .../pull_to_refresh_settings.g.dart | 159 +++- .../lib/src/inappwebview_platform.dart | 22 + .../lib/src/inappwebview_platform.dart | 22 + 18 files changed, 1687 insertions(+), 109 deletions(-) create mode 100644 flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.g.dart diff --git a/flutter_inappwebview/lib/src/pull_to_refresh/pull_to_refresh_controller.dart b/flutter_inappwebview/lib/src/pull_to_refresh/pull_to_refresh_controller.dart index fbe5a5cb5..fe2deecdd 100644 --- a/flutter_inappwebview/lib/src/pull_to_refresh/pull_to_refresh_controller.dart +++ b/flutter_inappwebview/lib/src/pull_to_refresh/pull_to_refresh_controller.dart @@ -92,4 +92,22 @@ class PullToRefreshController { ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.dispose} void dispose({bool isKeepAlive = false}) => platform.dispose(isKeepAlive: isKeepAlive); + + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformPullToRefreshController.static() + .isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isPropertySupported} + static bool isPropertySupported( + PlatformPullToRefreshControllerCreationParamsProperty property, + {TargetPlatform? platform}) => + PlatformPullToRefreshController.static() + .isPropertySupported(property, platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isMethodSupported} + static bool isMethodSupported(PlatformPullToRefreshControllerMethod method, + {TargetPlatform? platform}) => + PlatformPullToRefreshController.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index c60d6403e..c2120bfa6 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -136,6 +136,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidPullToRefreshController(params); } + /// Creates a new empty [AndroidPullToRefreshController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PullToRefreshController] in `flutter_inappwebview` instead. + @override + AndroidPullToRefreshController createPlatformPullToRefreshControllerStatic() { + return AndroidPullToRefreshController.static(); + } + /// Creates a new [AndroidWebMessageChannel]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_android/lib/src/pull_to_refresh/pull_to_refresh_controller.dart b/flutter_inappwebview_android/lib/src/pull_to_refresh/pull_to_refresh_controller.dart index 693c98a1b..cf802bd06 100644 --- a/flutter_inappwebview_android/lib/src/pull_to_refresh/pull_to_refresh_controller.dart +++ b/flutter_inappwebview_android/lib/src/pull_to_refresh/pull_to_refresh_controller.dart @@ -39,6 +39,15 @@ class AndroidPullToRefreshController extends PlatformPullToRefreshController .fromPlatformPullToRefreshControllerCreationParams(params), ); + static final AndroidPullToRefreshController _staticValue = + AndroidPullToRefreshController( + AndroidPullToRefreshControllerCreationParams()); + + /// Provide static access. + factory AndroidPullToRefreshController.static() { + return _staticValue; + } + _debugLog(String method, dynamic args) { debugLog( className: this.runtimeType.toString(), diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index a8009ec9d..b22222367 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -131,6 +131,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSPullToRefreshController(params); } + /// Creates a new empty [IOSPullToRefreshController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PullToRefreshController] in `flutter_inappwebview` instead. + @override + IOSPullToRefreshController createPlatformPullToRefreshControllerStatic() { + return IOSPullToRefreshController.static(); + } + /// Creates a new [IOSWebMessageChannel]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_ios/lib/src/pull_to_refresh/pull_to_refresh_controller.dart b/flutter_inappwebview_ios/lib/src/pull_to_refresh/pull_to_refresh_controller.dart index fae128c50..39b24daee 100644 --- a/flutter_inappwebview_ios/lib/src/pull_to_refresh/pull_to_refresh_controller.dart +++ b/flutter_inappwebview_ios/lib/src/pull_to_refresh/pull_to_refresh_controller.dart @@ -39,6 +39,14 @@ class IOSPullToRefreshController extends PlatformPullToRefreshController .fromPlatformPullToRefreshControllerCreationParams(params), ); + static final IOSPullToRefreshController _staticValue = + IOSPullToRefreshController(IOSPullToRefreshControllerCreationParams()); + + /// Provide static access. + factory IOSPullToRefreshController.static() { + return _staticValue; + } + _debugLog(String method, dynamic args) { debugLog( className: this.runtimeType.toString(), diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index b32634c06..37f5a4186 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -119,6 +119,16 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSPrintJobController.static(); } + /// Creates a new empty [PlatformPullToRefreshController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PullToRefreshController] in `flutter_inappwebview` instead. + @override + PlatformPullToRefreshController + createPlatformPullToRefreshControllerStatic() { + return _PlatformPullToRefreshController.static(); + } + /// Creates a new [MacOSWebMessageChannel]. /// /// This function should only be called by the app-facing package. @@ -401,3 +411,15 @@ class _PlatformTracingController extends PlatformTracingController { factory _PlatformTracingController.static() => _staticValue; } + +class _PlatformPullToRefreshController extends PlatformPullToRefreshController { + _PlatformPullToRefreshController( + PlatformPullToRefreshControllerCreationParams params) + : super.implementation(params); + + static final _PlatformPullToRefreshController _staticValue = + _PlatformPullToRefreshController( + PlatformPullToRefreshControllerCreationParams()); + + factory _PlatformPullToRefreshController.static() => _staticValue; +} diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index b05cb5765..719d859e1 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -162,6 +162,16 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformPullToRefreshController is not implemented on the current platform.'); } + /// Creates a new empty [PlatformPullToRefreshController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PullToRefreshController] in `flutter_inappwebview` instead. + PlatformPullToRefreshController + createPlatformPullToRefreshControllerStatic() { + throw UnimplementedError( + 'createPlatformPullToRefreshControllerStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformWebAuthenticationSession]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/main.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/main.dart index 2c3638911..e4516d9c4 100644 --- a/flutter_inappwebview_platform_interface/lib/src/print_job/main.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/main.dart @@ -1,2 +1,3 @@ export 'platform_print_job_controller.dart'; -export 'print_job_settings.dart' show PrintJobSettings; +export 'print_job_settings.dart' + show PrintJobSettings, PrintJobSettingsProperty; diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart index e8db52d6f..e04212827 100644 --- a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart @@ -79,7 +79,8 @@ enum PlatformPrintJobControllerProperty { ///{@template flutter_inappwebview_platform_interface.PlatformPrintJobController.onComplete.supported_platforms} /// ///**Officially Supported Platforms/Implementations**: - ///- Android WebView ([Official API - PrintDocumentAdapter.onFinish](https://developer.android.com/reference/android/print/PrintDocumentAdapter#onFinish())) + ///- Android WebView ([Official API - PrintDocumentAdapter.onFinish](https://developer.android.com/reference/android/print/PrintDocumentAdapter#onFinish())): + /// - `completed` is always `true` and `error` is always `null`. ///- iOS WKWebView ([Official API - UIPrintInteractionController.CompletionHandler](https://developer.apple.com/documentation/uikit/uiprintinteractioncontroller/completionhandler)) ///- macOS WKWebView ([Official API - NSPrintOperation.runModal](https://developer.apple.com/documentation/appkit/nsprintoperation/1532065-runmodal)) /// diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart index b7b197bdd..adc8bd769 100644 --- a/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.dart @@ -1,4 +1,5 @@ import 'package:flutter/cupertino.dart'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import '../types/main.dart'; @@ -20,6 +21,11 @@ part 'print_job_settings.g.dart'; ///Class that represents the settings of a [PlatformPrintJobController]. @ExchangeableObject(copyMethod: true) +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), +]) class PrintJobSettings_ { ///Set this to `true` to handle the [PlatformPrintJobController]. ///Otherwise, it will be handled and disposed automatically by the system. @@ -411,4 +417,10 @@ class PrintJobSettings_ { this.pagesAcross, this.pagesDown, this.time}); + + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported(PrintJobSettingsProperty property, + {TargetPlatform? platform}) => + _PrintJobSettingsPropertySupported.isPropertySupported(property, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart index 7a995ca7e..ddddf9a00 100644 --- a/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart @@ -7,6 +7,11 @@ part of 'print_job_settings.dart'; // ************************************************************************** ///Class that represents the settings of a [PlatformPrintJobController]. +/// +///**Officially Supported Platforms/Implementations**: +///- Android WebView +///- iOS WKWebView +///- macOS WKWebView class PrintJobSettings { ///`true` to animate the display of the sheet, `false` to display the sheet immediately. /// @@ -72,10 +77,8 @@ class PrintJobSettings { ///Force rendering quality. /// - ///**NOTE for iOS**: available only on iOS 14.5+. - /// ///**Officially Supported Platforms/Implementations**: - ///- iOS WKWebView + ///- iOS WKWebView 14.5+ PrintJobRenderingQuality? forceRenderingQuality; ///Set this to `true` to handle the [PlatformPrintJobController]. @@ -276,10 +279,8 @@ class PrintJobSettings { ///A Boolean value that determines whether the printing options include the paper orientation control when available. ///The default value is `true`. /// - ///**NOTE for iOS**: available only on iOS 15.0+. - /// ///**Officially Supported Platforms/Implementations**: - ///- iOS WKWebView + ///- iOS WKWebView 15.0+ ///- macOS WKWebView bool? showsPaperOrientation; @@ -353,6 +354,12 @@ class PrintJobSettings { ///**Officially Supported Platforms/Implementations**: ///- macOS WKWebView PrintJobPaginationMode? verticalPagination; + + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView PrintJobSettings( {this.animated = true, this.canSpawnSeparateThread = true, @@ -518,6 +525,12 @@ class PrintJobSettings { return instance; } + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported(PrintJobSettingsProperty property, + {TargetPlatform? platform}) => + _PrintJobSettingsPropertySupported.isPropertySupported(property, + platform: platform); + ///Converts instance to a map. Map toMap({EnumMethod? enumMethod}) { return { @@ -622,3 +635,699 @@ class PrintJobSettings { return 'PrintJobSettings{animated: $animated, canSpawnSeparateThread: $canSpawnSeparateThread, colorMode: $colorMode, copies: $copies, detailedErrorReporting: $detailedErrorReporting, duplexMode: $duplexMode, faxNumber: $faxNumber, firstPage: $firstPage, footerHeight: $footerHeight, forceRenderingQuality: $forceRenderingQuality, handledByClient: $handledByClient, headerAndFooter: $headerAndFooter, headerHeight: $headerHeight, horizontalPagination: $horizontalPagination, isHorizontallyCentered: $isHorizontallyCentered, isVerticallyCentered: $isVerticallyCentered, jobDisposition: $jobDisposition, jobName: $jobName, jobSavingURL: $jobSavingURL, lastPage: $lastPage, margins: $margins, maximumContentHeight: $maximumContentHeight, maximumContentWidth: $maximumContentWidth, mediaSize: $mediaSize, mustCollate: $mustCollate, numberOfPages: $numberOfPages, orientation: $orientation, outputType: $outputType, pageOrder: $pageOrder, pagesAcross: $pagesAcross, pagesDown: $pagesDown, paperName: $paperName, resolution: $resolution, scalingFactor: $scalingFactor, showsNumberOfCopies: $showsNumberOfCopies, showsPageRange: $showsPageRange, showsPageSetupAccessory: $showsPageSetupAccessory, showsPaperOrientation: $showsPaperOrientation, showsPaperSelectionForLoadedPapers: $showsPaperSelectionForLoadedPapers, showsPaperSize: $showsPaperSize, showsPreview: $showsPreview, showsPrintPanel: $showsPrintPanel, showsPrintSelection: $showsPrintSelection, showsProgressPanel: $showsProgressPanel, showsScaling: $showsScaling, time: $time, verticalPagination: $verticalPagination}'; } } + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +///List of [PrintJobSettings]'s properties that can be used to check i they are supported or not by the current platform. +enum PrintJobSettingsProperty { + ///Can be used to check if the [PrintJobSettings.animated] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.animated.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + animated, + + ///Can be used to check if the [PrintJobSettings.canSpawnSeparateThread] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.canSpawnSeparateThread.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + canSpawnSeparateThread, + + ///Can be used to check if the [PrintJobSettings.colorMode] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.colorMode.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + colorMode, + + ///Can be used to check if the [PrintJobSettings.copies] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.copies.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + copies, + + ///Can be used to check if the [PrintJobSettings.detailedErrorReporting] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.detailedErrorReporting.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + detailedErrorReporting, + + ///Can be used to check if the [PrintJobSettings.duplexMode] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.duplexMode.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView 23+ + ///- iOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + duplexMode, + + ///Can be used to check if the [PrintJobSettings.faxNumber] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.faxNumber.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + faxNumber, + + ///Can be used to check if the [PrintJobSettings.firstPage] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.firstPage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + firstPage, + + ///Can be used to check if the [PrintJobSettings.footerHeight] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.footerHeight.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + footerHeight, + + ///Can be used to check if the [PrintJobSettings.forceRenderingQuality] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.forceRenderingQuality.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 14.5+ + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + forceRenderingQuality, + + ///Can be used to check if the [PrintJobSettings.handledByClient] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.handledByClient.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + handledByClient, + + ///Can be used to check if the [PrintJobSettings.headerAndFooter] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.headerAndFooter.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + headerAndFooter, + + ///Can be used to check if the [PrintJobSettings.headerHeight] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.headerHeight.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + headerHeight, + + ///Can be used to check if the [PrintJobSettings.horizontalPagination] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.horizontalPagination.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + horizontalPagination, + + ///Can be used to check if the [PrintJobSettings.isHorizontallyCentered] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.isHorizontallyCentered.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + isHorizontallyCentered, + + ///Can be used to check if the [PrintJobSettings.isVerticallyCentered] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.isVerticallyCentered.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + isVerticallyCentered, + + ///Can be used to check if the [PrintJobSettings.jobDisposition] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.jobDisposition.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + jobDisposition, + + ///Can be used to check if the [PrintJobSettings.jobName] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.jobName.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + jobName, + + ///Can be used to check if the [PrintJobSettings.jobSavingURL] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.jobSavingURL.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + jobSavingURL, + + ///Can be used to check if the [PrintJobSettings.lastPage] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.lastPage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + lastPage, + + ///Can be used to check if the [PrintJobSettings.margins] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.margins.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + margins, + + ///Can be used to check if the [PrintJobSettings.maximumContentHeight] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.maximumContentHeight.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + maximumContentHeight, + + ///Can be used to check if the [PrintJobSettings.maximumContentWidth] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.maximumContentWidth.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + maximumContentWidth, + + ///Can be used to check if the [PrintJobSettings.mediaSize] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.mediaSize.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + mediaSize, + + ///Can be used to check if the [PrintJobSettings.mustCollate] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.mustCollate.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + mustCollate, + + ///Can be used to check if the [PrintJobSettings.numberOfPages] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.numberOfPages.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + numberOfPages, + + ///Can be used to check if the [PrintJobSettings.orientation] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.orientation.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + orientation, + + ///Can be used to check if the [PrintJobSettings.outputType] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.outputType.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + outputType, + + ///Can be used to check if the [PrintJobSettings.pageOrder] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.pageOrder.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + pageOrder, + + ///Can be used to check if the [PrintJobSettings.pagesAcross] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.pagesAcross.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + pagesAcross, + + ///Can be used to check if the [PrintJobSettings.pagesDown] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.pagesDown.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + pagesDown, + + ///Can be used to check if the [PrintJobSettings.paperName] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.paperName.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + paperName, + + ///Can be used to check if the [PrintJobSettings.resolution] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.resolution.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + resolution, + + ///Can be used to check if the [PrintJobSettings.scalingFactor] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.scalingFactor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + scalingFactor, + + ///Can be used to check if the [PrintJobSettings.showsNumberOfCopies] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsNumberOfCopies.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsNumberOfCopies, + + ///Can be used to check if the [PrintJobSettings.showsPageRange] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsPageRange.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsPageRange, + + ///Can be used to check if the [PrintJobSettings.showsPageSetupAccessory] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsPageSetupAccessory.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsPageSetupAccessory, + + ///Can be used to check if the [PrintJobSettings.showsPaperOrientation] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsPaperOrientation.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 15.0+ + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsPaperOrientation, + + ///Can be used to check if the [PrintJobSettings.showsPaperSelectionForLoadedPapers] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsPaperSelectionForLoadedPapers.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsPaperSelectionForLoadedPapers, + + ///Can be used to check if the [PrintJobSettings.showsPaperSize] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsPaperSize.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsPaperSize, + + ///Can be used to check if the [PrintJobSettings.showsPreview] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsPreview.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsPreview, + + ///Can be used to check if the [PrintJobSettings.showsPrintPanel] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsPrintPanel.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsPrintPanel, + + ///Can be used to check if the [PrintJobSettings.showsPrintSelection] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsPrintSelection.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsPrintSelection, + + ///Can be used to check if the [PrintJobSettings.showsProgressPanel] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsProgressPanel.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsProgressPanel, + + ///Can be used to check if the [PrintJobSettings.showsScaling] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.showsScaling.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + showsScaling, + + ///Can be used to check if the [PrintJobSettings.time] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.time.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + time, + + ///Can be used to check if the [PrintJobSettings.verticalPagination] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PrintJobSettings.verticalPagination.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- macOS WKWebView + /// + ///Use the [PrintJobSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + verticalPagination, +} + +extension _PrintJobSettingsPropertySupported on PrintJobSettings { + static bool isPropertySupported(PrintJobSettingsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PrintJobSettingsProperty.animated: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.canSpawnSeparateThread: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.colorMode: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.copies: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.detailedErrorReporting: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.duplexMode: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.faxNumber: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.firstPage: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.footerHeight: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.forceRenderingQuality: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.handledByClient: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.headerAndFooter: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.headerHeight: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.horizontalPagination: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.isHorizontallyCentered: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.isVerticallyCentered: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.jobDisposition: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.jobName: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.jobSavingURL: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.lastPage: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.margins: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.maximumContentHeight: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.maximumContentWidth: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.mediaSize: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.mustCollate: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.numberOfPages: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.orientation: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.outputType: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.pageOrder: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.pagesAcross: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.pagesDown: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.paperName: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.resolution: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.scalingFactor: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsNumberOfCopies: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsPageRange: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsPageSetupAccessory: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsPaperOrientation: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsPaperSelectionForLoadedPapers: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsPaperSize: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsPreview: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsPrintPanel: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsPrintSelection: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsProgressPanel: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.showsScaling: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.time: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + case PrintJobSettingsProperty.verticalPagination: + return !kIsWeb && + [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/main.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/main.dart index b3bf2b8ff..17b2971c0 100644 --- a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/main.dart +++ b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/main.dart @@ -1,3 +1,6 @@ export 'platform_pull_to_refresh_controller.dart'; export 'pull_to_refresh_settings.dart' - show PullToRefreshSettings, PullToRefreshOptions; + show + PullToRefreshSettings, + PullToRefreshOptions, + PullToRefreshSettingsProperty; diff --git a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.dart index 8bb0a9a7f..d295b0ff6 100644 --- a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.dart +++ b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.dart @@ -1,19 +1,32 @@ import 'dart:ui'; import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; -import '../in_app_webview/in_app_webview_settings.dart'; + import '../debug_logging_settings.dart'; +import '../in_app_browser/platform_in_app_browser.dart'; +import '../in_app_webview/in_app_webview_settings.dart'; +import '../in_app_webview/platform_webview.dart'; import '../inappwebview_platform.dart'; import '../types/main.dart'; import 'pull_to_refresh_settings.dart'; -import '../in_app_webview/platform_webview.dart'; -import '../in_app_browser/platform_in_app_browser.dart'; +// ignore: uri_has_not_been_generated +part 'platform_pull_to_refresh_controller.g.dart'; + +///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams} /// Object specifying creation parameters for creating a [PlatformPullToRefreshController]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), +]) class PlatformPullToRefreshControllerCreationParams { /// Used by the platform implementation to create a new [PlatformPullToRefreshController]. PlatformPullToRefreshControllerCreationParams( @@ -23,15 +36,55 @@ class PlatformPullToRefreshControllerCreationParams { : this.options = options ?? PullToRefreshOptions(), this.settings = settings ?? PullToRefreshSettings(); - ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.options} + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.options} + /// Use [settings] instead. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.options.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) @Deprecated("Use settings instead") late PullToRefreshOptions options; - ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.settings} + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.settings} + /// Initial settings. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.settings.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) late PullToRefreshSettings settings; - ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.onRefresh} + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.onRefresh} + ///Event called when a swipe gesture triggers a refresh. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.onRefresh.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) final void Function()? onRefresh; + + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformPullToRefreshControllerCreationParamsClassSupported + .isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported( + PlatformPullToRefreshControllerCreationParamsProperty property, + {TargetPlatform? platform}) => + _PlatformPullToRefreshControllerCreationParamsPropertySupported + .isPropertySupported(property, platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController} @@ -40,13 +93,15 @@ class PlatformPullToRefreshControllerCreationParams { /// ///All the methods should be called only when the WebView has been created or is already running ///(for example [PlatformWebViewCreationParams.onWebViewCreated] or [PlatformInAppBrowserEvents.onBrowserCreated]). -/// -///**NOTE for Android**: to be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView -///- iOS ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform( + note: + '**NOTE**: to be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`.'), + IOSPlatform(), +]) abstract class PlatformPullToRefreshController extends PlatformInterface implements Disposable { ///Debug settings. @@ -69,6 +124,22 @@ abstract class PlatformPullToRefreshController extends PlatformInterface return webViewControllerDelegate; } + /// Creates a new empty [PlatformPullToRefreshController] to access static methods. + factory PlatformPullToRefreshController.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `flutter_inappwebview` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformPullToRefreshController controllerStatic = + InAppWebViewPlatform.instance! + .createPlatformPullToRefreshControllerStatic(); + PlatformInterface.verify(controllerStatic, _token); + return controllerStatic; + } + /// Used by the platform implementation to create a new [PlatformPullToRefreshController]. /// /// Should only be used by platform implementations because they can't extend @@ -82,29 +153,37 @@ abstract class PlatformPullToRefreshController extends PlatformInterface /// The parameters used to initialize the [PlatformPullToRefreshController]. final PlatformPullToRefreshControllerCreationParams params; - ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.options} - /// Use [settings] instead. - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.options} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.options.supported_platforms} @Deprecated("Use settings instead") PullToRefreshOptions get options => params.options; - ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.settings} - /// Initial settings. - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.settings} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.settings.supported_platforms} PullToRefreshSettings get settings => params.settings; - ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.onRefresh} - ///Event called when a swipe gesture triggers a refresh. - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.onRefresh} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.onRefresh.supported_platforms} void Function()? get onRefresh => params.onRefresh; ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setEnabled} ///Sets whether the pull-to-refresh feature is enabled or not. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setEnabled](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setEnabled(boolean))) - ///- iOS ([Official API - UIScrollView.refreshControl](https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setEnabled.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.setEnabled', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setEnabled(boolean)'), + IOSPlatform( + apiName: 'UIScrollView.refreshControl', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol'), + ]) Future setEnabled(bool enabled) { throw UnimplementedError( 'setEnabled is not implemented on the current platform'); @@ -112,11 +191,19 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isEnabled} ///Returns `true` is pull-to-refresh feature is enabled, otherwise `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - View.isEnabled](https://developer.android.com/reference/android/view/View#isEnabled())) - ///- iOS ([Official API - UIScrollView.refreshControl](https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isEnabled.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'View.isEnabled', + apiUrl: + 'https://developer.android.com/reference/android/view/View#isEnabled()'), + IOSPlatform( + apiName: 'UIScrollView.refreshControl', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol'), + ]) Future isEnabled() { throw UnimplementedError( 'isEnabled is not implemented on the current platform'); @@ -128,11 +215,19 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///Call this method when an external event source triggers a programmatic refresh of your scrolling view. ///This method updates the state of the refresh control to reflect the in-progress refresh operation. ///When the refresh operation ends, be sure to call the [endRefreshing] method to return the controller to its default state. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.beginRefreshing.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.setRefreshing', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setRefreshing(boolean)'), + IOSPlatform( + apiName: 'UIRefreshControl.beginRefreshing', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624842-beginrefreshing'), + ]) Future beginRefreshing() { throw UnimplementedError( 'beginRefreshing is not implemented on the current platform'); @@ -145,11 +240,19 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///to return the refresh control to its default state. ///If the refresh control is at least partially visible, calling this method also hides it. ///If animations are also enabled, the control is hidden using an animation. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.endRefreshing.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.setRefreshing', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setRefreshing(boolean)'), + IOSPlatform( + apiName: 'UIRefreshControl.endRefreshing', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624846-endrefreshing'), + ]) Future endRefreshing() { throw UnimplementedError( 'endRefreshing is not implemented on the current platform'); @@ -157,11 +260,19 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isRefreshing} ///Returns whether a refresh operation has been triggered and is in progress. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.isRefreshing](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#isRefreshing())) - ///- iOS ([Official API - UIRefreshControl.isRefreshing](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624844-isrefreshing)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isRefreshing.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.isRefreshing', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#isRefreshing()'), + IOSPlatform( + apiName: 'UIRefreshControl.isRefreshing', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624844-isrefreshing'), + ]) Future isRefreshing() { throw UnimplementedError( 'isRefreshing is not implemented on the current platform'); @@ -169,11 +280,19 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setColor} ///Sets the color of the refresh control. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setColorSchemeColors](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setColorSchemeColors(int...))) - ///- iOS ([Official API - UIRefreshControl.tintColor](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624847-tintcolor)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setColor.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.setColorSchemeColors', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setColorSchemeColors(int...)'), + IOSPlatform( + apiName: 'UIRefreshControl.tintColor', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624847-tintcolor'), + ]) Future setColor(Color color) { throw UnimplementedError( 'setColor is not implemented on the current platform'); @@ -181,11 +300,19 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setBackgroundColor} ///Sets the background color of the refresh control. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setProgressBackgroundColorSchemeColor](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setProgressBackgroundColorSchemeColor(int))) - ///- iOS ([Official API - UIView.backgroundColor](https://developer.apple.com/documentation/uikit/uiview/1622591-backgroundcolor)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setBackgroundColor.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.setProgressBackgroundColorSchemeColor', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setProgressBackgroundColorSchemeColor(int)'), + IOSPlatform( + apiName: 'UIView.backgroundColor', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uiview/1622591-backgroundcolor'), + ]) Future setBackgroundColor(Color color) { throw UnimplementedError( 'setBackgroundColor is not implemented on the current platform'); @@ -193,10 +320,15 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setDistanceToTriggerSync} ///Set the distance to trigger a sync in dips. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setDistanceToTriggerSync](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setDistanceToTriggerSync(int))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setDistanceToTriggerSync.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.setDistanceToTriggerSync', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setDistanceToTriggerSync(int)'), + ]) Future setDistanceToTriggerSync(int distanceToTriggerSync) { throw UnimplementedError( 'setDistanceToTriggerSync is not implemented on the current platform'); @@ -204,10 +336,15 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setSlingshotDistance} ///Sets the distance that the refresh indicator can be pulled beyond its resting position during a swipe gesture. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setSlingshotDistance](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSlingshotDistance(int))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setSlingshotDistance.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.setSlingshotDistance', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSlingshotDistance(int)'), + ]) Future setSlingshotDistance(int slingshotDistance) { throw UnimplementedError( 'setSlingshotDistance is not implemented on the current platform'); @@ -215,10 +352,15 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.getDefaultSlingshotDistance} ///Gets the default distance that the refresh indicator can be pulled beyond its resting position during a swipe gesture. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.DEFAULT_SLINGSHOT_DISTANCE](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#DEFAULT_SLINGSHOT_DISTANCE())) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.getDefaultSlingshotDistance.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.DEFAULT_SLINGSHOT_DISTANCE', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#DEFAULT_SLINGSHOT_DISTANCE()'), + ]) Future getDefaultSlingshotDistance() { throw UnimplementedError( 'getDefaultSlingshotDistance is not implemented on the current platform'); @@ -227,6 +369,14 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setSize} ///Use [setIndicatorSize] instead. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setSize.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.setSize', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSize(int)'), + ]) @Deprecated("Use setIndicatorSize instead") Future setSize(AndroidPullToRefreshSize size) { throw UnimplementedError( @@ -235,10 +385,15 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setIndicatorSize} ///Sets the size of the refresh indicator. One of [PullToRefreshSize.DEFAULT], or [PullToRefreshSize.LARGE]. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - SwipeRefreshLayout.setSize](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSize(int))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setIndicatorSize.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'SwipeRefreshLayout.setSize', + apiUrl: + 'https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSize(int)'), + ]) Future setIndicatorSize(PullToRefreshSize size) { throw UnimplementedError( 'setIndicatorSize is not implemented on the current platform'); @@ -247,6 +402,14 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setAttributedTitle} ///Use [setStyledTitle] instead. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setAttributedTitle.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + apiName: 'UIRefreshControl.attributedTitle', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624845-attributedtitle'), + ]) @Deprecated("Use setStyledTitle instead") Future setAttributedTitle(IOSNSAttributedString attributedTitle) { throw UnimplementedError( @@ -255,10 +418,15 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setStyledTitle} ///Sets the styled title text to display in the refresh control. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - UIRefreshControl.attributedTitle](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624845-attributedtitle)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setStyledTitle.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + apiName: 'UIRefreshControl.attributedTitle', + apiUrl: + 'https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624845-attributedtitle'), + ]) Future setStyledTitle(AttributedString attributedTitle) { throw UnimplementedError( 'setStyledTitle is not implemented on the current platform'); @@ -267,9 +435,36 @@ abstract class PlatformPullToRefreshController extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.dispose} ///Disposes the controller. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshController.dispose.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) @override void dispose({bool isKeepAlive = false}) { throw UnimplementedError( 'dispose is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformPullToRefreshControllerClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported( + PlatformPullToRefreshControllerCreationParamsProperty property, + {TargetPlatform? platform}) => + params.isPropertySupported(property, platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformPullToRefreshControllerMethod method, + {TargetPlatform? platform}) => + _PlatformPullToRefreshControllerMethodSupported.isMethodSupported(method, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.g.dart new file mode 100644 index 000000000..2997edffd --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.g.dart @@ -0,0 +1,379 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_pull_to_refresh_controller.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformPullToRefreshControllerCreationParamsClassSupported + on PlatformPullToRefreshControllerCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + /// + ///Use the [PlatformPullToRefreshControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformPullToRefreshControllerCreationParams]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformPullToRefreshControllerCreationParamsProperty { + ///Can be used to check if the [PlatformPullToRefreshControllerCreationParams.onRefresh] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.onRefresh.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + /// + ///Use the [PlatformPullToRefreshControllerCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + onRefresh, + + ///Can be used to check if the [PlatformPullToRefreshControllerCreationParams.options] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.options.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + /// + ///Use the [PlatformPullToRefreshControllerCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + @Deprecated('Use settings instead') + options, + + ///Can be used to check if the [PlatformPullToRefreshControllerCreationParams.settings] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshControllerCreationParams.settings.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + /// + ///Use the [PlatformPullToRefreshControllerCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + settings, +} + +extension _PlatformPullToRefreshControllerCreationParamsPropertySupported + on PlatformPullToRefreshControllerCreationParams { + static bool isPropertySupported( + PlatformPullToRefreshControllerCreationParamsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformPullToRefreshControllerCreationParamsProperty.onRefresh: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerCreationParamsProperty.options: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerCreationParamsProperty.settings: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformPullToRefreshControllerClassSupported + on PlatformPullToRefreshController { + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView: + /// - **NOTE**: to be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`. + ///- iOS WKWebView + /// + ///Use the [PlatformPullToRefreshController.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformPullToRefreshController]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformPullToRefreshControllerMethod { + ///Can be used to check if the [PlatformPullToRefreshController.beginRefreshing] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.beginRefreshing.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.setRefreshing](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setRefreshing(boolean))) + ///- iOS WKWebView ([Official API - UIRefreshControl.beginRefreshing](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624842-beginrefreshing)) + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + beginRefreshing, + + ///Can be used to check if the [PlatformPullToRefreshController.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [isKeepAlive]: all platforms + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, + + ///Can be used to check if the [PlatformPullToRefreshController.endRefreshing] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.endRefreshing.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.setRefreshing](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setRefreshing(boolean))) + ///- iOS WKWebView ([Official API - UIRefreshControl.endRefreshing](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624846-endrefreshing)) + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + endRefreshing, + + ///Can be used to check if the [PlatformPullToRefreshController.getDefaultSlingshotDistance] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.getDefaultSlingshotDistance.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.DEFAULT_SLINGSHOT_DISTANCE](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#DEFAULT_SLINGSHOT_DISTANCE())) + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getDefaultSlingshotDistance, + + ///Can be used to check if the [PlatformPullToRefreshController.isEnabled] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isEnabled.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - View.isEnabled](https://developer.android.com/reference/android/view/View#isEnabled())) + ///- iOS WKWebView ([Official API - UIScrollView.refreshControl](https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol)) + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + isEnabled, + + ///Can be used to check if the [PlatformPullToRefreshController.isRefreshing] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.isRefreshing.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.isRefreshing](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#isRefreshing())) + ///- iOS WKWebView ([Official API - UIRefreshControl.isRefreshing](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624844-isrefreshing)) + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + isRefreshing, + + ///Can be used to check if the [PlatformPullToRefreshController.setAttributedTitle] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setAttributedTitle.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView ([Official API - UIRefreshControl.attributedTitle](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624845-attributedtitle)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [attributedTitle]: all platforms + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + @Deprecated('Use setStyledTitle instead') + setAttributedTitle, + + ///Can be used to check if the [PlatformPullToRefreshController.setBackgroundColor] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setBackgroundColor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.setProgressBackgroundColorSchemeColor](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setProgressBackgroundColorSchemeColor(int))) + ///- iOS WKWebView ([Official API - UIView.backgroundColor](https://developer.apple.com/documentation/uikit/uiview/1622591-backgroundcolor)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [color]: all platforms + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setBackgroundColor, + + ///Can be used to check if the [PlatformPullToRefreshController.setColor] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setColor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.setColorSchemeColors](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setColorSchemeColors(int...))) + ///- iOS WKWebView ([Official API - UIRefreshControl.tintColor](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624847-tintcolor)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [color]: all platforms + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setColor, + + ///Can be used to check if the [PlatformPullToRefreshController.setDistanceToTriggerSync] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setDistanceToTriggerSync.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.setDistanceToTriggerSync](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setDistanceToTriggerSync(int))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [distanceToTriggerSync]: all platforms + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setDistanceToTriggerSync, + + ///Can be used to check if the [PlatformPullToRefreshController.setEnabled] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setEnabled.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.setEnabled](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setEnabled(boolean))) + ///- iOS WKWebView ([Official API - UIScrollView.refreshControl](https://developer.apple.com/documentation/uikit/uiscrollview/2127691-refreshcontrol)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [enabled]: all platforms + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setEnabled, + + ///Can be used to check if the [PlatformPullToRefreshController.setIndicatorSize] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setIndicatorSize.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.setSize](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSize(int))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [size]: all platforms + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setIndicatorSize, + + ///Can be used to check if the [PlatformPullToRefreshController.setSize] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setSize.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.setSize](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSize(int))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [size]: all platforms + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + @Deprecated('Use setIndicatorSize instead') + setSize, + + ///Can be used to check if the [PlatformPullToRefreshController.setSlingshotDistance] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setSlingshotDistance.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - SwipeRefreshLayout.setSlingshotDistance](https://developer.android.com/reference/androidx/swiperefreshlayout/widget/SwipeRefreshLayout#setSlingshotDistance(int))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [slingshotDistance]: all platforms + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setSlingshotDistance, + + ///Can be used to check if the [PlatformPullToRefreshController.setStyledTitle] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformPullToRefreshController.setStyledTitle.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView ([Official API - UIRefreshControl.attributedTitle](https://developer.apple.com/documentation/uikit/uirefreshcontrol/1624845-attributedtitle)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [attributedTitle]: all platforms + /// + ///Use the [PlatformPullToRefreshController.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setStyledTitle, +} + +extension _PlatformPullToRefreshControllerMethodSupported + on PlatformPullToRefreshController { + static bool isMethodSupported(PlatformPullToRefreshControllerMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformPullToRefreshControllerMethod.beginRefreshing: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.dispose: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.endRefreshing: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.getDefaultSlingshotDistance: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.isEnabled: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.isRefreshing: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.setAttributedTitle: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.setBackgroundColor: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.setColor: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.setDistanceToTriggerSync: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.setEnabled: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.setIndicatorSize: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.setSize: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.setSlingshotDistance: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformPullToRefreshControllerMethod.setStyledTitle: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.dart index 807f2c3e5..8860ee231 100644 --- a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.dart @@ -1,60 +1,66 @@ import 'dart:ui'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import '../types/attributed_string.dart'; import '../types/pull_to_refresh_size.dart'; import '../util.dart'; import '../types/main.dart'; +import 'platform_pull_to_refresh_controller.dart'; part 'pull_to_refresh_settings.g.dart'; -///Pull-To-Refresh Settings +///Pull-To-Refresh Settings for [PlatformPullToRefreshController]. +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), +]) @ExchangeableObject(copyMethod: true) class PullToRefreshSettings_ { ///Sets whether the pull-to-refresh feature is enabled or not. ///The default value is `true`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) bool? enabled; ///The color of the refresh control. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) Color_? color; ///The background color of the refresh control. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + ]) Color_? backgroundColor; ///The distance to trigger a sync in dips. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) int? distanceToTriggerSync; ///The distance in pixels that the refresh indicator can be pulled beyond its resting position. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) int? slingshotDistance; ///The size of the refresh indicator. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + ]) PullToRefreshSize_? size; ///The title text to display in the refresh control. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS + @SupportedPlatforms(platforms: [ + IOSPlatform(), + ]) AttributedString_? attributedTitle; PullToRefreshSettings_( @@ -65,6 +71,12 @@ class PullToRefreshSettings_ { this.slingshotDistance, this.size, this.attributedTitle}); + + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported(PullToRefreshSettingsProperty property, + {TargetPlatform? platform}) => + _PullToRefreshSettingsPropertySupported.isPropertySupported(property, + platform: platform); } ///Use [PullToRefreshSettings] instead. diff --git a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart index 3614aa791..89d90bdb2 100644 --- a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart @@ -6,53 +6,62 @@ part of 'pull_to_refresh_settings.dart'; // ExchangeableObjectGenerator // ************************************************************************** -///Pull-To-Refresh Settings +///Pull-To-Refresh Settings for [PlatformPullToRefreshController]. +/// +///**Officially Supported Platforms/Implementations**: +///- Android WebView +///- iOS WKWebView class PullToRefreshSettings { ///The title text to display in the refresh control. /// ///**Officially Supported Platforms/Implementations**: - ///- iOS + ///- iOS WKWebView AttributedString? attributedTitle; ///The background color of the refresh control. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + ///- Android WebView + ///- iOS WKWebView Color? backgroundColor; ///The color of the refresh control. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + ///- Android WebView + ///- iOS WKWebView Color? color; ///The distance to trigger a sync in dips. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView int? distanceToTriggerSync; ///Sets whether the pull-to-refresh feature is enabled or not. ///The default value is `true`. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS + ///- Android WebView + ///- iOS WKWebView bool? enabled; ///The size of the refresh indicator. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView PullToRefreshSize? size; ///The distance in pixels that the refresh indicator can be pulled beyond its resting position. /// ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView + ///- Android WebView int? slingshotDistance; + + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView PullToRefreshSettings( {this.attributedTitle, this.backgroundColor, @@ -91,6 +100,12 @@ class PullToRefreshSettings { return instance; } + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported(PullToRefreshSettingsProperty property, + {TargetPlatform? platform}) => + _PullToRefreshSettingsPropertySupported.isPropertySupported(property, + platform: platform); + ///Converts instance to a map. Map toMap({EnumMethod? enumMethod}) { return { @@ -123,3 +138,125 @@ class PullToRefreshSettings { return 'PullToRefreshSettings{attributedTitle: $attributedTitle, backgroundColor: $backgroundColor, color: $color, distanceToTriggerSync: $distanceToTriggerSync, enabled: $enabled, size: $size, slingshotDistance: $slingshotDistance}'; } } + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +///List of [PullToRefreshSettings]'s properties that can be used to check i they are supported or not by the current platform. +enum PullToRefreshSettingsProperty { + ///Can be used to check if the [PullToRefreshSettings.attributedTitle] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PullToRefreshSettings.attributedTitle.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + /// + ///Use the [PullToRefreshSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + attributedTitle, + + ///Can be used to check if the [PullToRefreshSettings.backgroundColor] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PullToRefreshSettings.backgroundColor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + /// + ///Use the [PullToRefreshSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + backgroundColor, + + ///Can be used to check if the [PullToRefreshSettings.color] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PullToRefreshSettings.color.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + /// + ///Use the [PullToRefreshSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + color, + + ///Can be used to check if the [PullToRefreshSettings.distanceToTriggerSync] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PullToRefreshSettings.distanceToTriggerSync.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [PullToRefreshSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + distanceToTriggerSync, + + ///Can be used to check if the [PullToRefreshSettings.enabled] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PullToRefreshSettings.enabled.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + /// + ///Use the [PullToRefreshSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + enabled, + + ///Can be used to check if the [PullToRefreshSettings.size] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PullToRefreshSettings.size.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [PullToRefreshSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + size, + + ///Can be used to check if the [PullToRefreshSettings.slingshotDistance] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PullToRefreshSettings.slingshotDistance.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + /// + ///Use the [PullToRefreshSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + slingshotDistance, +} + +extension _PullToRefreshSettingsPropertySupported on PullToRefreshSettings { + static bool isPropertySupported(PullToRefreshSettingsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PullToRefreshSettingsProperty.attributedTitle: + return !kIsWeb && + [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); + case PullToRefreshSettingsProperty.backgroundColor: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PullToRefreshSettingsProperty.color: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PullToRefreshSettingsProperty.distanceToTriggerSync: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PullToRefreshSettingsProperty.enabled: + return !kIsWeb && + [TargetPlatform.android, TargetPlatform.iOS] + .contains(platform ?? defaultTargetPlatform); + case PullToRefreshSettingsProperty.size: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PullToRefreshSettingsProperty.slingshotDistance: + return !kIsWeb && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index b8f670167..25ff312db 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -180,6 +180,16 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { PlatformPrintJobController createPlatformPrintJobControllerStatic() { return _PlatformPrintJobController.static(); } + + /// Creates a new empty [PlatformPullToRefreshController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PullToRefreshController] in `flutter_inappwebview` instead. + @override + PlatformPullToRefreshController + createPlatformPullToRefreshControllerStatic() { + return _PlatformPullToRefreshController.static(); + } } class _PlatformInAppBrowser extends PlatformInAppBrowser { @@ -278,3 +288,15 @@ class _PlatformPrintJobController extends PlatformPrintJobController { factory _PlatformPrintJobController.static() => _staticValue; } + +class _PlatformPullToRefreshController extends PlatformPullToRefreshController { + _PlatformPullToRefreshController( + PlatformPullToRefreshControllerCreationParams params) + : super.implementation(params); + + static final _PlatformPullToRefreshController _staticValue = + _PlatformPullToRefreshController( + PlatformPullToRefreshControllerCreationParams()); + + factory _PlatformPullToRefreshController.static() => _staticValue; +} diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index 948f4095b..c71a451fe 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -248,6 +248,16 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { PlatformPrintJobController createPlatformPrintJobControllerStatic() { return _PlatformPrintJobController.static(); } + + /// Creates a new empty [PlatformPullToRefreshController] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PullToRefreshController] in `flutter_inappwebview` instead. + @override + PlatformPullToRefreshController + createPlatformPullToRefreshControllerStatic() { + return _PlatformPullToRefreshController.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -337,3 +347,15 @@ class _PlatformPrintJobController extends PlatformPrintJobController { factory _PlatformPrintJobController.static() => _staticValue; } + +class _PlatformPullToRefreshController extends PlatformPullToRefreshController { + _PlatformPullToRefreshController( + PlatformPullToRefreshControllerCreationParams params) + : super.implementation(params); + + static final _PlatformPullToRefreshController _staticValue = + _PlatformPullToRefreshController( + PlatformPullToRefreshControllerCreationParams()); + + factory _PlatformPullToRefreshController.static() => _staticValue; +} From b744adc3e4c2c4a282663a9930fa9d3543fdfe67 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 3 Oct 2025 18:13:27 +0200 Subject: [PATCH 157/181] added support methods for PlatformWebAuthenticationSession class --- .../web_authenticate_session.dart | 25 ++ .../lib/src/inappwebview_platform.dart | 30 +++ .../src/web_authentication_session/main.dart | 4 +- .../platform_web_authenticate_session.dart | 165 +++++++++--- .../platform_web_authenticate_session.g.dart | 252 ++++++++++++++++++ .../web_authenticate_session_settings.dart | 29 +- .../web_authenticate_session_settings.g.dart | 64 ++++- .../lib/src/inappwebview_platform.dart | 23 ++ .../lib/src/inappwebview_platform.dart | 23 ++ 9 files changed, 562 insertions(+), 53 deletions(-) create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.g.dart diff --git a/flutter_inappwebview/lib/src/web_authentication_session/web_authenticate_session.dart b/flutter_inappwebview/lib/src/web_authentication_session/web_authenticate_session.dart index f167748d2..64eaa6d95 100755 --- a/flutter_inappwebview/lib/src/web_authentication_session/web_authenticate_session.dart +++ b/flutter_inappwebview/lib/src/web_authentication_session/web_authenticate_session.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession} @@ -69,4 +70,28 @@ class WebAuthenticationSession { ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.isAvailable} static Future isAvailable() => PlatformWebAuthenticationSession.static().isAvailable(); + + ///{@template flutter_inappwebview.WebAuthenticationSession.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformWebAuthenticationSession.static() + .isClassSupported(platform: platform); + + ///{@template flutter_inappwebview.WebAuthenticationSession.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///The property should be one of the [PlatformWebAuthenticationSessionProperty] or [PlatformWebAuthenticationSessionCreationParamsProperty] values. + ///{@endtemplate} + static bool isPropertySupported(dynamic property, + {TargetPlatform? platform}) => + PlatformWebAuthenticationSession.static() + .isPropertySupported(property, platform: platform); + + ///{@template flutter_inappwebview.WebAuthenticationSession.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + static bool isMethodSupported(PlatformWebAuthenticationSessionMethod method, + {TargetPlatform? platform}) => + PlatformWebAuthenticationSession.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index c2120bfa6..e8e66124b 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -465,4 +465,34 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { PlatformWebStorageManagerCreationParams params) { return AndroidWebStorageManager(params); } + + // ************************************************************************ // + // Create static instances of unsupported classes to be able to call // + // isClassSupported, isMethodSupported, isPropertySupported, etc. // + // static methods without throwing a missing platform implementation // + // exception. // + // ************************************************************************ // + + /// Creates a new empty [PlatformWebAuthenticationSession] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebAuthenticationSession] in `flutter_inappwebview` instead. + @override + PlatformWebAuthenticationSession + createPlatformWebAuthenticationSessionStatic() { + return _PlatformWebAuthenticationSession.static(); + } +} + +class _PlatformWebAuthenticationSession + extends PlatformWebAuthenticationSession { + _PlatformWebAuthenticationSession( + PlatformWebAuthenticationSessionCreationParams params) + : super.implementation(params); + + static final _PlatformWebAuthenticationSession _staticValue = + _PlatformWebAuthenticationSession( + const PlatformWebAuthenticationSessionCreationParams()); + + factory _PlatformWebAuthenticationSession.static() => _staticValue; } diff --git a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/main.dart b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/main.dart index fda76b888..5d91c1ee2 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/main.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/main.dart @@ -1,3 +1,5 @@ export 'platform_web_authenticate_session.dart'; export 'web_authenticate_session_settings.dart' - show WebAuthenticationSessionSettings; + show + WebAuthenticationSessionSettings, + WebAuthenticationSessionSettingsProperty; diff --git a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart index 3bb6f3c17..396f5b093 100755 --- a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart @@ -1,6 +1,7 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import '../debug_logging_settings.dart'; import '../inappwebview_platform.dart'; @@ -8,17 +9,36 @@ import '../types/main.dart'; import '../web_uri.dart'; import 'web_authenticate_session_settings.dart'; +// ignore: uri_has_not_been_generated +part 'platform_web_authenticate_session.g.dart'; + ///A completion handler for the [PlatformWebAuthenticationSession]. typedef WebAuthenticationSessionCompletionHandler = Future Function( WebUri? url, WebAuthenticationSessionError? error)?; +///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSessionCreationParams} /// Object specifying creation parameters for creating a [PlatformWebAuthenticationSession]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSessionCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + IOSPlatform(available: '11.0'), + MacOSPlatform(available: '10.15'), +]) +@immutable class PlatformWebAuthenticationSessionCreationParams { /// Used by the platform implementation to create a new [PlatformWebAuthenticationSession]. const PlatformWebAuthenticationSessionCreationParams(); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSessionCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebAuthenticationSessionCreationParamsClassSupported + .isClassSupported(platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession} @@ -31,21 +51,19 @@ class PlatformWebAuthenticationSessionCreationParams { ///Initialize the session with a URL that points to the authentication webpage. ///A browser loads and displays the page, from which the user can authenticate. ///In iOS, the browser is a secure, embedded web view. -///In macOS, the system opens the user’s default browser if it supports web authentication sessions, or Safari otherwise. +///In macOS, the system opens the user's default browser if it supports web authentication sessions, or Safari otherwise. /// ///On completion, the service sends a callback URL to the session with an authentication token, and the session passes this URL back to the app through a completion handler. -///[PlatformWebAuthenticationSession] ensures that only the calling app’s session receives the authentication callback, even when more than one app registers the same callback URL scheme. +///[PlatformWebAuthenticationSession] ensures that only the calling app's session receives the authentication callback, even when more than one app registers the same callback URL scheme. /// ///**NOTE**: Remember to dispose it when you don't need it anymore. -/// -///**NOTE for iOS**: Available only on iOS 11.0+. -/// -///**NOTE for MacOS**: Available only on MacOS 10.15+. -/// -///**Officially Supported Platforms/Implementations**: -///- iOS -///- MacOS ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.supported_platforms} +@SupportedPlatforms(platforms: [ + IOSPlatform(available: '11.0'), + MacOSPlatform(available: '10.15'), +]) abstract class PlatformWebAuthenticationSession extends PlatformInterface implements Disposable { ///Debug settings. @@ -100,24 +118,48 @@ abstract class PlatformWebAuthenticationSession extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.id} ///ID used internally. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.id.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(), + MacOSPlatform(), + ]) String get id => throw UnimplementedError('id is not implemented on the current platform'); ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.url} ///A URL with the `http` or `https` scheme pointing to the authentication webpage. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.url.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(), + MacOSPlatform(), + ]) WebUri get url => throw UnimplementedError( 'url is not implemented on the current platform'); ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.callbackURLScheme} ///The custom URL scheme that the app expects in the callback URL. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.callbackURLScheme.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(), + MacOSPlatform(), + ]) String? get callbackURLScheme => throw UnimplementedError( 'callbackURLScheme is not implemented on the current platform'); ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.initialSettings} ///Initial settings. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.initialSettings.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(), + MacOSPlatform(), + ]) WebAuthenticationSessionSettings? get initialSettings => throw UnimplementedError( 'initialSettings is not implemented on the current platform'); @@ -125,6 +167,12 @@ abstract class PlatformWebAuthenticationSession extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.onComplete} ///A completion handler the session calls when it completes successfully, or when the user cancels the session. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.onComplete.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(), + MacOSPlatform(), + ]) WebAuthenticationSessionCompletionHandler get onComplete => throw UnimplementedError( 'onComplete is not implemented on the current platform'); @@ -140,6 +188,12 @@ abstract class PlatformWebAuthenticationSession extends PlatformInterface /// ///[initialSettings] represents initial settings. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.create.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(), + MacOSPlatform(), + ]) Future create( {required WebUri url, String? callbackURLScheme, @@ -151,11 +205,19 @@ abstract class PlatformWebAuthenticationSession extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.canStart} ///Indicates whether the session can begin. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - ASWebAuthenticationSession.canStart](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/3516277-canstart)) - ///- MacOS ([Official API - ASWebAuthenticationSession.canStart](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/3516277-canstart)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.canStart.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + apiName: 'ASWebAuthenticationSession.canStart', + apiUrl: + 'https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/3516277-canstart'), + MacOSPlatform( + apiName: 'ASWebAuthenticationSession.canStart', + apiUrl: + 'https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/3516277-canstart'), + ]) Future canStart() { throw UnimplementedError( 'canStart is not implemented on the current platform'); @@ -168,11 +230,19 @@ abstract class PlatformWebAuthenticationSession extends PlatformInterface /// ///Only call this method once for a given [PlatformWebAuthenticationSession] instance after initialization. ///Calling the [start] method on a canceled session results in a failure. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - ASWebAuthenticationSession.start](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990953-start)) - ///- MacOS ([Official API - ASWebAuthenticationSession.start](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990953-start)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.start.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + apiName: 'ASWebAuthenticationSession.start', + apiUrl: + 'https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990953-start'), + MacOSPlatform( + apiName: 'ASWebAuthenticationSession.start', + apiUrl: + 'https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990953-start'), + ]) Future start() { throw UnimplementedError( 'start is not implemented on the current platform'); @@ -183,11 +253,19 @@ abstract class PlatformWebAuthenticationSession extends PlatformInterface /// ///If the session has already presented a view with the authentication webpage, calling this method dismisses that view. ///Calling [cancel] on an already canceled session has no effect. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - ASWebAuthenticationSession.cancel](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990951-cancel)) - ///- MacOS ([Official API - ASWebAuthenticationSession.cancel](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990951-cancel)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.cancel.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + apiName: 'ASWebAuthenticationSession.cancel', + apiUrl: + 'https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990951-cancel'), + MacOSPlatform( + apiName: 'ASWebAuthenticationSession.cancel', + apiUrl: + 'https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990951-cancel'), + ]) Future cancel() { throw UnimplementedError( 'cancel is not implemented on the current platform'); @@ -195,28 +273,53 @@ abstract class PlatformWebAuthenticationSession extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.dispose} ///Disposes the web authentication session. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.dispose.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(), + MacOSPlatform(), + ]) @override Future dispose() { throw UnimplementedError( - 'cancel is not implemented on the current platform'); + 'dispose is not implemented on the current platform'); } ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.isAvailable} ///Returns `true` if [ASWebAuthenticationSession](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession) ///or [SFAuthenticationSession](https://developer.apple.com/documentation/safariservices/sfauthenticationsession) is available. ///Otherwise returns `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.isAvailable.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform(), + MacOSPlatform(), + ]) Future isAvailable() { throw UnimplementedError( 'isAvailable is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSessionCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + params.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported(PlatformWebAuthenticationSessionProperty property, + {TargetPlatform? platform}) => + _PlatformWebAuthenticationSessionPropertySupported.isPropertySupported( + property, + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformWebAuthenticationSessionMethod method, + {TargetPlatform? platform}) => + _PlatformWebAuthenticationSessionMethodSupported.isMethodSupported(method, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.g.dart b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.g.dart new file mode 100644 index 000000000..a8cd9aa93 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.g.dart @@ -0,0 +1,252 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_web_authenticate_session.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformWebAuthenticationSessionCreationParamsClassSupported + on PlatformWebAuthenticationSessionCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSessionCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 11.0+ + ///- macOS WKWebView 10.15+ + /// + ///Use the [PlatformWebAuthenticationSessionCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +extension _PlatformWebAuthenticationSessionClassSupported + on PlatformWebAuthenticationSession { + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 11.0+ + ///- macOS WKWebView 10.15+ + /// + ///Use the [PlatformWebAuthenticationSession.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformWebAuthenticationSession]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformWebAuthenticationSessionProperty { + ///Can be used to check if the [PlatformWebAuthenticationSession.callbackURLScheme] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.callbackURLScheme.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebAuthenticationSession.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + callbackURLScheme, + + ///Can be used to check if the [PlatformWebAuthenticationSession.id] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.id.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebAuthenticationSession.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + id, + + ///Can be used to check if the [PlatformWebAuthenticationSession.initialSettings] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.initialSettings.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebAuthenticationSession.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + initialSettings, + + ///Can be used to check if the [PlatformWebAuthenticationSession.onComplete] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.onComplete.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + ///- [error]: all platforms + /// + ///Use the [PlatformWebAuthenticationSession.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + onComplete, + + ///Can be used to check if the [PlatformWebAuthenticationSession.url] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.url.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebAuthenticationSession.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + url, +} + +extension _PlatformWebAuthenticationSessionPropertySupported + on PlatformWebAuthenticationSession { + static bool isPropertySupported( + PlatformWebAuthenticationSessionProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformWebAuthenticationSessionProperty.callbackURLScheme: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebAuthenticationSessionProperty.id: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebAuthenticationSessionProperty.initialSettings: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebAuthenticationSessionProperty.onComplete: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebAuthenticationSessionProperty.url: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +///List of [PlatformWebAuthenticationSession]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformWebAuthenticationSessionMethod { + ///Can be used to check if the [PlatformWebAuthenticationSession.canStart] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.canStart.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView ([Official API - ASWebAuthenticationSession.canStart](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/3516277-canstart)) + ///- macOS WKWebView ([Official API - ASWebAuthenticationSession.canStart](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/3516277-canstart)) + /// + ///Use the [PlatformWebAuthenticationSession.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + canStart, + + ///Can be used to check if the [PlatformWebAuthenticationSession.cancel] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.cancel.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView ([Official API - ASWebAuthenticationSession.cancel](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990951-cancel)) + ///- macOS WKWebView ([Official API - ASWebAuthenticationSession.cancel](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990951-cancel)) + /// + ///Use the [PlatformWebAuthenticationSession.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + cancel, + + ///Can be used to check if the [PlatformWebAuthenticationSession.create] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.create.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [url]: all platforms + ///- [callbackURLScheme]: all platforms + ///- [onComplete]: all platforms + ///- [initialSettings]: all platforms + /// + ///Use the [PlatformWebAuthenticationSession.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + create, + + ///Can be used to check if the [PlatformWebAuthenticationSession.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebAuthenticationSession.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, + + ///Can be used to check if the [PlatformWebAuthenticationSession.isAvailable] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.isAvailable.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebAuthenticationSession.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + isAvailable, + + ///Can be used to check if the [PlatformWebAuthenticationSession.start] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.start.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView ([Official API - ASWebAuthenticationSession.start](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990953-start)) + ///- macOS WKWebView ([Official API - ASWebAuthenticationSession.start](https://developer.apple.com/documentation/authenticationservices/aswebauthenticationsession/2990953-start)) + /// + ///Use the [PlatformWebAuthenticationSession.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + start, +} + +extension _PlatformWebAuthenticationSessionMethodSupported + on PlatformWebAuthenticationSession { + static bool isMethodSupported(PlatformWebAuthenticationSessionMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformWebAuthenticationSessionMethod.canStart: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebAuthenticationSessionMethod.cancel: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebAuthenticationSessionMethod.create: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebAuthenticationSessionMethod.dispose: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebAuthenticationSessionMethod.isAvailable: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebAuthenticationSessionMethod.start: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.dart b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.dart index 226c6bd17..037f3b4c0 100755 --- a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'platform_web_authenticate_session.dart'; @@ -7,6 +8,10 @@ part 'web_authenticate_session_settings.g.dart'; ///Class that represents the settings that can be used for a [PlatformWebAuthenticationSession]. @ExchangeableObject(copyMethod: true) +@SupportedPlatforms(platforms: [ + IOSPlatform(available: '13.0'), + MacOSPlatform(available: '10.15'), +]) class WebAuthenticationSessionSettings_ { ///A Boolean value that indicates whether the session should ask the browser for a private authentication session. /// @@ -18,22 +23,20 @@ class WebAuthenticationSessionSettings_ { ///The value of this property is `false` by default. /// ///Set this property before you call [PlatformWebAuthenticationSession.start]. Otherwise it has no effect. - /// - ///**NOTE for iOS**: Available only on iOS 13.0+. - /// - ///**NOTE for MacOS**: Available only on iOS 10.15+. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + @SupportedPlatforms(platforms: [ + IOSPlatform(available: '13.0'), + MacOSPlatform(available: '10.15'), + ]) bool? prefersEphemeralWebBrowserSession; WebAuthenticationSessionSettings_( {this.prefersEphemeralWebBrowserSession = false}); - Map toMap() { - return { - "prefersEphemeralWebBrowserSession": prefersEphemeralWebBrowserSession - }; - } + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported( + WebAuthenticationSessionSettingsProperty property, + {TargetPlatform? platform}) => + _WebAuthenticationSessionSettingsPropertySupported.isPropertySupported( + property, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart index 4b0d77613..42d5bd294 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart @@ -7,6 +7,10 @@ part of 'web_authenticate_session_settings.dart'; // ************************************************************************** ///Class that represents the settings that can be used for a [PlatformWebAuthenticationSession]. +/// +///**Officially Supported Platforms/Implementations**: +///- iOS WKWebView 13.0+ +///- macOS WKWebView 10.15+ class WebAuthenticationSessionSettings { ///A Boolean value that indicates whether the session should ask the browser for a private authentication session. /// @@ -19,14 +23,15 @@ class WebAuthenticationSessionSettings { /// ///Set this property before you call [PlatformWebAuthenticationSession.start]. Otherwise it has no effect. /// - ///**NOTE for iOS**: Available only on iOS 13.0+. - /// - ///**NOTE for MacOS**: Available only on iOS 10.15+. - /// ///**Officially Supported Platforms/Implementations**: - ///- iOS - ///- MacOS + ///- iOS WKWebView 13.0+ + ///- macOS WKWebView 10.15+ bool? prefersEphemeralWebBrowserSession; + + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 13.0+ + ///- macOS WKWebView 10.15+ WebAuthenticationSessionSettings( {this.prefersEphemeralWebBrowserSession = false}); @@ -42,9 +47,18 @@ class WebAuthenticationSessionSettings { return instance; } - Map toMap() { + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported( + WebAuthenticationSessionSettingsProperty property, + {TargetPlatform? platform}) => + _WebAuthenticationSessionSettingsPropertySupported.isPropertySupported( + property, + platform: platform); + + ///Converts instance to a map. + Map toMap({EnumMethod? enumMethod}) { return { - "prefersEphemeralWebBrowserSession": prefersEphemeralWebBrowserSession + "prefersEphemeralWebBrowserSession": prefersEphemeralWebBrowserSession, }; } @@ -64,3 +78,37 @@ class WebAuthenticationSessionSettings { return 'WebAuthenticationSessionSettings{prefersEphemeralWebBrowserSession: $prefersEphemeralWebBrowserSession}'; } } + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +///List of [WebAuthenticationSessionSettings]'s properties that can be used to check i they are supported or not by the current platform. +enum WebAuthenticationSessionSettingsProperty { + ///Can be used to check if the [WebAuthenticationSessionSettings.prefersEphemeralWebBrowserSession] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.WebAuthenticationSessionSettings.prefersEphemeralWebBrowserSession.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 13.0+ + ///- macOS WKWebView 10.15+ + /// + ///Use the [WebAuthenticationSessionSettings.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + prefersEphemeralWebBrowserSession, +} + +extension _WebAuthenticationSessionSettingsPropertySupported + on WebAuthenticationSessionSettings { + static bool isPropertySupported( + WebAuthenticationSessionSettingsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case WebAuthenticationSessionSettingsProperty + .prefersEphemeralWebBrowserSession: + return !kIsWeb && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index 25ff312db..c0f0a2cba 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -190,6 +190,16 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { createPlatformPullToRefreshControllerStatic() { return _PlatformPullToRefreshController.static(); } + + /// Creates a new empty [PlatformWebAuthenticationSession] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebAuthenticationSession] in `flutter_inappwebview` instead. + @override + PlatformWebAuthenticationSession + createPlatformWebAuthenticationSessionStatic() { + return _PlatformWebAuthenticationSession.static(); + } } class _PlatformInAppBrowser extends PlatformInAppBrowser { @@ -300,3 +310,16 @@ class _PlatformPullToRefreshController extends PlatformPullToRefreshController { factory _PlatformPullToRefreshController.static() => _staticValue; } + +class _PlatformWebAuthenticationSession + extends PlatformWebAuthenticationSession { + _PlatformWebAuthenticationSession( + PlatformWebAuthenticationSessionCreationParams params) + : super.implementation(params); + + static final _PlatformWebAuthenticationSession _staticValue = + _PlatformWebAuthenticationSession( + const PlatformWebAuthenticationSessionCreationParams()); + + factory _PlatformWebAuthenticationSession.static() => _staticValue; +} diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index c71a451fe..00591b905 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -258,6 +258,16 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { createPlatformPullToRefreshControllerStatic() { return _PlatformPullToRefreshController.static(); } + + /// Creates a new empty [PlatformWebAuthenticationSession] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebAuthenticationSession] in `flutter_inappwebview` instead. + @override + PlatformWebAuthenticationSession + createPlatformWebAuthenticationSessionStatic() { + return _PlatformWebAuthenticationSession.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -359,3 +369,16 @@ class _PlatformPullToRefreshController extends PlatformPullToRefreshController { factory _PlatformPullToRefreshController.static() => _staticValue; } + +class _PlatformWebAuthenticationSession + extends PlatformWebAuthenticationSession { + _PlatformWebAuthenticationSession( + PlatformWebAuthenticationSessionCreationParams params) + : super.implementation(params); + + static final _PlatformWebAuthenticationSession _staticValue = + _PlatformWebAuthenticationSession( + const PlatformWebAuthenticationSessionCreationParams()); + + factory _PlatformWebAuthenticationSession.static() => _staticValue; +} From 873825ce697be5c27328810d386bd0dcb42f5a70 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 3 Oct 2025 18:18:59 +0200 Subject: [PATCH 158/181] added support methods for PlatformWebAuthenticationSession class --- .../platform_web_authenticate_session.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart index 396f5b093..2355eacf5 100755 --- a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart @@ -304,7 +304,7 @@ abstract class PlatformWebAuthenticationSession extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSessionCreationParams.isClassSupported} bool isClassSupported({TargetPlatform? platform}) => - params.isClassSupported(platform: platform); + _PlatformWebAuthenticationSessionClassSupported.isClassSupported(platform: platform); ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.isPropertySupported} ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. From 3ec8487f9b7a1d2340f2039345fea04167fbea73 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Sat, 4 Oct 2025 00:22:34 +0200 Subject: [PATCH 159/181] fixed supported platform methods generator for web platform --- .../src/supported_platforms_generator.dart | 12 +- .../chrome_safari_browser_settings.g.dart | 56 +-- .../platform_chrome_safari_browser.g.dart | 72 ++-- ...latform_find_interaction_controller.g.dart | 28 +- .../in_app_browser_settings.g.dart | 58 +-- .../platform_in_app_browser.g.dart | 232 +++++----- .../in_app_webview_settings.g.dart | 368 ++++++++-------- .../platform_headless_in_app_webview.g.dart | 34 +- .../platform_inappwebview_controller.g.dart | 395 +++++++++--------- .../platform_inappwebview_widget.g.dart | 14 +- .../in_app_webview/platform_webview.g.dart | 236 +++++------ .../lib/src/platform_cookie_manager.g.dart | 38 +- ...form_http_auth_credentials_database.g.dart | 16 +- .../src/platform_process_global_config.g.dart | 12 +- .../lib/src/platform_proxy_controller.g.dart | 22 +- .../platform_service_worker_controller.g.dart | 26 +- .../src/platform_tracing_controller.g.dart | 14 +- .../platform_print_job_controller.g.dart | 18 +- .../src/print_job/print_job_settings.g.dart | 94 ++--- ...platform_pull_to_refresh_controller.g.dart | 40 +- .../pull_to_refresh_settings.g.dart | 14 +- .../platform_web_authenticate_session.dart | 3 +- .../platform_web_authenticate_session.g.dart | 26 +- .../web_authenticate_session_settings.g.dart | 2 +- 24 files changed, 920 insertions(+), 910 deletions(-) diff --git a/dev_packages/generators/lib/src/supported_platforms_generator.dart b/dev_packages/generators/lib/src/supported_platforms_generator.dart index c6d8cd81d..7f2be8c9c 100644 --- a/dev_packages/generators/lib/src/supported_platforms_generator.dart +++ b/dev_packages/generators/lib/src/supported_platforms_generator.dart @@ -118,10 +118,10 @@ class SupportedPlatformsGenerator classBuffer.writeln("return "); if (hasWebSupport) { - classBuffer.writeln("kIsWeb ? true :"); + classBuffer.writeln("kIsWeb && platform == null ? true :"); } classBuffer.writeln( - "!kIsWeb && [${targetPlatforms.where((e) => e != 'web').map((e) => "TargetPlatform.$e").join(', ')}].contains(platform ?? defaultTargetPlatform)"); + "((kIsWeb && platform != null) || !kIsWeb) && [${targetPlatforms.where((e) => e != 'web').map((e) => "TargetPlatform.$e").join(', ')}].contains(platform ?? defaultTargetPlatform)"); classBuffer.writeln(";"); } classBuffer.writeln(""" @@ -215,10 +215,10 @@ class SupportedPlatformsGenerator classBuffer.writeln("case $enumClassName.$fieldName:"); classBuffer.writeln("return "); if (hasWebSupport) { - classBuffer.writeln("kIsWeb ? true :"); + classBuffer.writeln("kIsWeb && platform == null ? true :"); } classBuffer.writeln( - "!kIsWeb && [${targetPlatforms.where((e) => e != 'web').map((e) => "TargetPlatform.$e").join(', ')}].contains(platform ?? defaultTargetPlatform)"); + "((kIsWeb && platform != null) || !kIsWeb) && [${targetPlatforms.where((e) => e != 'web').map((e) => "TargetPlatform.$e").join(', ')}].contains(platform ?? defaultTargetPlatform)"); classBuffer.writeln(";"); } classBuffer.writeln(""" @@ -297,10 +297,10 @@ class SupportedPlatformsGenerator classBuffer.writeln("case $enumClassName.$methodName:"); classBuffer.writeln("return "); if (hasWebSupport) { - classBuffer.writeln("kIsWeb ? true :"); + classBuffer.writeln("kIsWeb && platform == null ? true :"); } classBuffer.writeln( - "!kIsWeb && [${targetPlatforms.where((e) => e != 'web').map((e) => "TargetPlatform.$e").join(', ')}].contains(platform ?? defaultTargetPlatform)"); + "((kIsWeb && platform != null) || !kIsWeb) && [${targetPlatforms.where((e) => e != 'web').map((e) => "TargetPlatform.$e").join(', ')}].contains(platform ?? defaultTargetPlatform)"); classBuffer.writeln(";"); } classBuffer.writeln(""" diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart index 0af9272a3..9d98b92c0 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/chrome_safari_browser_settings.g.dart @@ -753,107 +753,107 @@ extension _ChromeSafariBrowserSettingsPropertySupported {TargetPlatform? platform}) { switch (property) { case ChromeSafariBrowserSettingsProperty.activityButton: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.additionalTrustedOrigins: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.alwaysUseBrowserUI: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.barCollapsingEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.dismissButtonStyle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.displayMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.enableUrlBarHiding: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.entersReaderIfAvailable: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.eventAttribution: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.exitAnimations: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.instantAppsEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.isSingleInstance: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.isTrustedWebActivity: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.keepAliveEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.navigationBarColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.navigationBarDividerColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.noHistory: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.packageName: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.preferredBarTintColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.preferredControlTintColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.presentationStyle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.screenOrientation: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.secondaryToolbarColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.shareState: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.showTitle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.startAnimations: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.toolbarBackgroundColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ChromeSafariBrowserSettingsProperty.transitionStyle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); } } diff --git a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.g.dart b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.g.dart index 0fcdd6a56..2950e1cf4 100644 --- a/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/chrome_safari_browser/platform_chrome_safari_browser.g.dart @@ -19,7 +19,7 @@ extension _PlatformChromeSafariBrowserClassSupported ///Use the [PlatformChromeSafariBrowser.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); } @@ -349,88 +349,88 @@ extension _PlatformChromeSafariBrowserMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformChromeSafariBrowserMethod.addMenuItem: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.addMenuItems: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.clearWebsiteData: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.close: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.dispose: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.getMaxToolbarItems: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.getPackageName: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.invalidatePrewarmingToken: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.isAvailable: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.isEngagementSignalsApiAvailable: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.isOpened: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.launchUrl: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.mayLaunchUrl: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.open: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.postMessage: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.prewarmConnections: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.requestPostMessageChannel: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.setActionButton: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.setSecondaryToolbar: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.updateActionButton: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.updateSecondaryToolbar: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserMethod.validateRelationship: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } @@ -619,56 +619,56 @@ extension _PlatformChromeSafariBrowserEventsMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformChromeSafariBrowserEventsMethod.onClosed: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod.onCompletedInitialLoad: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod .onGreatestScrollPercentageIncreased: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod.onInitialLoadDidRedirect: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod.onMessageChannelReady: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod.onNavigationEvent: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod.onOpened: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod.onPostMessage: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod .onRelationshipValidationResult: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod.onServiceConnected: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod.onSessionEnded: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod.onVerticalScrollEvent: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformChromeSafariBrowserEventsMethod.onWillOpenInBrowser: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); } } diff --git a/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.g.dart index 33caae367..f7ba008ea 100644 --- a/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/find_interaction/platform_find_interaction_controller.g.dart @@ -18,7 +18,7 @@ extension _PlatformFindInteractionControllerCreationParamsClassSupported ///Use the [PlatformFindInteractionControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -55,7 +55,7 @@ extension _PlatformFindInteractionControllerCreationParamsPropertySupported switch (property) { case PlatformFindInteractionControllerCreationParamsProperty .onFindResultReceived: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -74,7 +74,7 @@ extension _PlatformFindInteractionControllerClassSupported ///Use the [PlatformFindInteractionController.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -246,44 +246,44 @@ extension _PlatformFindInteractionControllerMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformFindInteractionControllerMethod.clearMatches: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformFindInteractionControllerMethod.dismissFindNavigator: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformFindInteractionControllerMethod.dispose: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformFindInteractionControllerMethod.findAll: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformFindInteractionControllerMethod.findNext: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformFindInteractionControllerMethod.getActiveFindSession: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformFindInteractionControllerMethod.getSearchText: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformFindInteractionControllerMethod.isFindNavigatorVisible: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformFindInteractionControllerMethod.presentFindNavigator: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformFindInteractionControllerMethod.setSearchText: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformFindInteractionControllerMethod.updateResultCount: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); } } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart index fda6d7716..17ab4f9a1 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/in_app_browser_settings.g.dart @@ -763,21 +763,21 @@ extension _InAppBrowserSettingsPropertySupported on InAppBrowserSettings { {TargetPlatform? platform}) { switch (property) { case InAppBrowserSettingsProperty.allowGoBackWithBackButton: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.closeButtonCaption: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.closeButtonColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.closeOnCannotGoBack: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.hidden: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -785,89 +785,89 @@ extension _InAppBrowserSettingsPropertySupported on InAppBrowserSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.hideCloseButton: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.hideDefaultMenuItems: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.hideProgressBar: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.hideTitleBar: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.hideToolbarBottom: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.hideToolbarTop: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.hideUrlBar: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.menuButtonColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.presentationStyle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.shouldCloseOnBackButtonPressed: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.toolbarBottomBackgroundColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.toolbarBottomTintColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.toolbarBottomTranslucent: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.toolbarTopBackgroundColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.toolbarTopBarTintColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.toolbarTopFixedTitle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.macOS, TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.toolbarTopTintColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.toolbarTopTranslucent: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.transitionStyle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.windowAlphaValue: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.windowFrame: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.windowStyleMask: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.windowTitlebarSeparatorStyle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case InAppBrowserSettingsProperty.windowType: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart index 7028adf0d..4d408d338 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_browser/platform_in_app_browser.g.dart @@ -18,7 +18,7 @@ extension _PlatformInAppBrowserClassSupported on PlatformInAppBrowser { ///Use the [PlatformInAppBrowser.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -128,15 +128,15 @@ extension _PlatformInAppBrowserPropertySupported on PlatformInAppBrowser { {TargetPlatform? platform}) { switch (property) { case PlatformInAppBrowserProperty.contextMenu: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserProperty.findInteractionController: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserProperty.id: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -144,7 +144,7 @@ extension _PlatformInAppBrowserPropertySupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserProperty.initialUserScripts: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -152,15 +152,15 @@ extension _PlatformInAppBrowserPropertySupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserProperty.pullToRefreshController: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserProperty.webViewEnvironment: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserProperty.windowId: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -491,15 +491,15 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { {TargetPlatform? platform}) { switch (method) { case PlatformInAppBrowserMethod.addMenuItem: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.addMenuItems: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.close: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -507,7 +507,7 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.dispose: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -515,11 +515,11 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.getOptions: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.getSettings: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -527,11 +527,11 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.hasMenuItem: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.hide: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -539,7 +539,7 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.isHidden: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -547,7 +547,7 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.isOpened: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -555,7 +555,7 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.openData: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -563,7 +563,7 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.openFile: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -571,7 +571,7 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.openUrlRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -579,7 +579,7 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.openWithSystemBrowser: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -587,23 +587,23 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.removeAllMenuItem: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.removeMenuItem: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.removeMenuItems: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.setOptions: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.setSettings: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -611,7 +611,7 @@ extension _PlatformInAppBrowserMethodSupported on PlatformInAppBrowser { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserMethod.show: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1974,90 +1974,90 @@ extension _PlatformInAppBrowserEventsMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformInAppBrowserEventsMethod.androidOnFormResubmission: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod .androidOnGeolocationPermissionsHidePrompt: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod .androidOnGeolocationPermissionsShowPrompt: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidOnJsBeforeUnload: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidOnPermissionRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidOnReceivedIcon: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidOnReceivedLoginRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidOnReceivedTouchIconUrl: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidOnRenderProcessGone: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidOnRenderProcessResponsive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidOnRenderProcessUnresponsive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidOnSafeBrowsingHit: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidOnScaleChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.androidShouldInterceptRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod .iosOnDidReceiveServerRedirectForProvisionalNavigation: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.iosOnNavigationResponse: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.iosOnWebContentProcessDidTerminate: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.iosShouldAllowDeprecatedTLS: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onAcceleratorKeyPressed: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onAjaxProgress: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onAjaxReadyStateChange: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onBrowserCreated: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2065,13 +2065,13 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onCameraCaptureStateChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onCloseWindow: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2079,9 +2079,9 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onConsoleMessage: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2089,10 +2089,10 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onContentSizeChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onCreateWindow: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2101,19 +2101,19 @@ extension _PlatformInAppBrowserEventsMethodSupported ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod .onDidReceiveServerRedirectForProvisionalNavigation: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onDownloadStart: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onDownloadStartRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onDownloadStarting: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2121,11 +2121,11 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onEnterFullscreen: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onExit: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2133,55 +2133,55 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onExitFullscreen: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onFindResultReceived: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onFormResubmission: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onGeolocationPermissionsHidePrompt: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onGeolocationPermissionsShowPrompt: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onJsAlert: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onJsConfirm: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onJsPrompt: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onLoadError: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onLoadHttpError: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onLoadResource: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onLoadResourceCustomScheme: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onLoadResourceWithCustomScheme: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2189,7 +2189,7 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onLoadStart: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2197,7 +2197,7 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onLoadStop: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2205,30 +2205,30 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onLongPressHitTestResult: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onMainWindowWillClose: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onMicrophoneCaptureStateChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onNavigationResponse: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onOverScrolled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onPageCommitVisible: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onPermissionRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2236,23 +2236,23 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onPermissionRequestCanceled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onPrint: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onPrintRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onProcessFailed: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onProgressChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2260,7 +2260,7 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onReceivedClientCertRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2268,7 +2268,7 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onReceivedError: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2276,7 +2276,7 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onReceivedHttpAuthRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2284,7 +2284,7 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onReceivedHttpError: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2292,15 +2292,15 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onReceivedIcon: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onReceivedLoginRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onReceivedServerTrustAuthRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2308,39 +2308,39 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onReceivedTouchIconUrl: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onRenderProcessGone: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onRenderProcessResponsive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onRenderProcessUnresponsive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onRequestFocus: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onSafeBrowsingHit: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onScrollChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onShowFileChooser: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onTitleChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2348,7 +2348,7 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onUpdateVisitedHistory: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2356,39 +2356,39 @@ extension _PlatformInAppBrowserEventsMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onWebContentProcessDidTerminate: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onWindowBlur: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onWindowFocus: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.onZoomScaleChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.shouldAllowDeprecatedTLS: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.shouldInterceptAjaxRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.shouldInterceptFetchRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.shouldInterceptRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppBrowserEventsMethod.shouldOverrideUrlLoading: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart index bf448a58c..ca4e13546 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/in_app_webview_settings.g.dart @@ -4338,291 +4338,299 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { {TargetPlatform? platform}) { switch (property) { case InAppWebViewSettingsProperty.accessibilityIgnoresInvertColors: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.algorithmicDarkeningAllowed: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowBackgroundAudioPlaying: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowContentAccess: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowFileAccess: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowFileAccessFromFileURLs: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowUniversalAccessFromFileURLs: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowingReadAccessTo: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowsAirPlayForMediaPlayback: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowsBackForwardNavigationGestures: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowsInlineMediaPlayback: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowsLinkPreview: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.allowsPictureInPictureMediaPlayback: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.alpha: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.alwaysBounceHorizontal: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.alwaysBounceVertical: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.appCachePath: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.applePayAPIEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.applicationNameForUserAgent: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty .automaticallyAdjustsScrollIndicatorInsets: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.blockNetworkImage: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.blockNetworkLoads: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.browserAcceleratorKeysEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.builtInZoomControls: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.cacheEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.cacheMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.clearCache: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.clearSessionCache: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.contentBlockers: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.contentInsetAdjustmentBehavior: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.cursiveFontFamily: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.dataDetectorTypes: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.databaseEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.decelerationRate: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.defaultFixedFontSize: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.defaultFontSize: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.defaultTextEncodingName: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.defaultVideoPoster: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.disableContextMenu: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.disableDefaultErrorPage: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.disableHorizontalScroll: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.disableInputAccessoryView: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.disableLongPressContextMenuOnLinks: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.disableVerticalScroll: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.disabledActionModeMenuItems: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.disallowOverScroll: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.displayZoomControls: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.domStorageEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.enableViewportScale: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty .enterpriseAuthenticationAppLinkPolicyEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.fantasyFontFamily: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.fixedFontFamily: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.forceDark: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.forceDarkStrategy: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.generalAutofillEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.geolocationEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.handleAcceleratorKeyPressed: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.hardwareAcceleration: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.hiddenPdfToolbarItems: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.horizontalScrollBarEnabled: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.horizontalScrollbarThumbColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.horizontalScrollbarTrackColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.iframeAllow: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && [].contains(platform ?? defaultTargetPlatform); + : ((kIsWeb && platform != null) || !kIsWeb) && + [].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.iframeAllowFullscreen: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && [].contains(platform ?? defaultTargetPlatform); + : ((kIsWeb && platform != null) || !kIsWeb) && + [].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.iframeAriaHidden: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && [].contains(platform ?? defaultTargetPlatform); + : ((kIsWeb && platform != null) || !kIsWeb) && + [].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.iframeCsp: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && [].contains(platform ?? defaultTargetPlatform); + : ((kIsWeb && platform != null) || !kIsWeb) && + [].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.iframeName: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && [].contains(platform ?? defaultTargetPlatform); + : ((kIsWeb && platform != null) || !kIsWeb) && + [].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.iframeReferrerPolicy: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && [].contains(platform ?? defaultTargetPlatform); + : ((kIsWeb && platform != null) || !kIsWeb) && + [].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.iframeRole: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && [].contains(platform ?? defaultTargetPlatform); + : ((kIsWeb && platform != null) || !kIsWeb) && + [].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.iframeSandbox: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && [].contains(platform ?? defaultTargetPlatform); + : ((kIsWeb && platform != null) || !kIsWeb) && + [].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.ignoresViewportScaleLimits: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.incognito: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4630,50 +4638,50 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.initialScale: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.interceptOnlyAsyncAjaxRequests: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.isDirectionalLockEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.isElementFullscreenEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.isFindInteractionEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.isFraudulentWebsiteWarningEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.isInspectable: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.isPagingEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.isSiteSpecificQuirksModeEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.isTextInteractionEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.isUserInteractionEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.javaScriptBridgeEnabled: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4681,7 +4689,7 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.javaScriptBridgeForMainFrameOnly: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4689,9 +4697,9 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.javaScriptBridgeOriginAllowList: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4699,18 +4707,18 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.javaScriptCanOpenWindowsAutomatically: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.javaScriptEnabled: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4718,7 +4726,7 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.javaScriptHandlersForMainFrameOnly: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4726,9 +4734,9 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.javaScriptHandlersOriginAllowList: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4736,87 +4744,87 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.layoutAlgorithm: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.limitsNavigationsToAppBoundDomains: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.loadWithOverviewMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.loadsImagesAutomatically: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.maximumViewportInset: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.maximumZoomScale: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.mediaPlaybackRequiresUserGesture: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.mediaType: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.minimumFontSize: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.minimumLogicalFontSize: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.minimumViewportInset: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.minimumZoomScale: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.mixedContentMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.needInitialFocus: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.networkAvailable: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.nonClientRegionSupportEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.offscreenPreRaster: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.overScrollMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.pageZoom: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.passwordAutosaveEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.pinchZoomEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.pluginScriptsForMainFrameOnly: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4824,7 +4832,7 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.pluginScriptsOriginAllowList: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4832,97 +4840,97 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.preferredContentMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.regexToAllowSyncUrlLoading: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.regexToCancelSubFramesLoading: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.rendererPriorityPolicy: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.reputationCheckingRequired: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.requestedWithHeaderOriginAllowList: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.resourceCustomSchemes: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.safeBrowsingEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.sansSerifFontFamily: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.saveFormData: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.scrollBarDefaultDelayBeforeFade: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.scrollBarFadeDuration: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.scrollBarStyle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.scrollMultiplier: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.scrollbarFadingEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.scrollsToTop: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.selectionGranularity: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.serifFontFamily: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.sharedCookiesEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.shouldPrintBackgrounds: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.standardFontFamily: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.statusBarEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.supportMultipleWindows: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.supportZoom: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4930,19 +4938,19 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.suppressesIncrementalRendering: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.textZoom: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.thirdPartyCookiesEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.transparentBackground: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -4950,59 +4958,59 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.underPageBackgroundColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.upgradeKnownHostsToHTTPS: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useHybridComposition: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useOnAjaxProgress: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useOnAjaxReadyStateChange: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useOnDownloadStart: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useOnLoadResource: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useOnNavigationResponse: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useOnRenderProcessGone: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useOnShowFileChooser: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useShouldInterceptAjaxRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useShouldInterceptFetchRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useShouldInterceptRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useShouldOverrideUrlLoading: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -5010,11 +5018,11 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.useWideViewPort: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.userAgent: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -5022,25 +5030,25 @@ extension _InAppWebViewSettingsPropertySupported on InAppWebViewSettings { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.verticalScrollBarEnabled: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.verticalScrollbarPosition: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.verticalScrollbarThumbColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.verticalScrollbarTrackColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case InAppWebViewSettingsProperty.webViewAssetLoader: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.g.dart index d8447bdd1..c2e1a4e6f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_headless_in_app_webview.g.dart @@ -20,9 +20,9 @@ extension _PlatformHeadlessInAppWebViewCreationParamsClassSupported ///Use the [PlatformHeadlessInAppWebViewCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -69,9 +69,9 @@ extension _PlatformHeadlessInAppWebViewCreationParamsPropertySupported {TargetPlatform? platform}) { switch (property) { case PlatformHeadlessInAppWebViewCreationParamsProperty.initialSize: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -80,7 +80,7 @@ extension _PlatformHeadlessInAppWebViewCreationParamsPropertySupported ].contains(platform ?? defaultTargetPlatform); case PlatformHeadlessInAppWebViewCreationParamsProperty .webViewEnvironment: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); } @@ -101,9 +101,9 @@ extension _PlatformHeadlessInAppWebViewClassSupported ///Use the [PlatformHeadlessInAppWebView.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -200,9 +200,9 @@ extension _PlatformHeadlessInAppWebViewMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformHeadlessInAppWebViewMethod.dispose: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -210,18 +210,18 @@ extension _PlatformHeadlessInAppWebViewMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformHeadlessInAppWebViewMethod.getSize: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformHeadlessInAppWebViewMethod.isRunning: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -229,9 +229,9 @@ extension _PlatformHeadlessInAppWebViewMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformHeadlessInAppWebViewMethod.run: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -239,9 +239,9 @@ extension _PlatformHeadlessInAppWebViewMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformHeadlessInAppWebViewMethod.setSize: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.g.dart index b9013903a..f8db925e3 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_controller.g.dart @@ -20,9 +20,9 @@ extension _PlatformInAppWebViewControllerClassSupported ///Use the [PlatformInAppWebViewController.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -87,9 +87,9 @@ extension _PlatformInAppWebViewControllerPropertySupported {TargetPlatform? platform}) { switch (property) { case PlatformInAppWebViewControllerProperty.tRexRunnerCss: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -97,9 +97,9 @@ extension _PlatformInAppWebViewControllerPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerProperty.tRexRunnerHtml: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -107,9 +107,9 @@ extension _PlatformInAppWebViewControllerPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerProperty.webStorage: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2190,13 +2190,13 @@ extension _PlatformInAppWebViewControllerMethodSupported switch (method) { case PlatformInAppWebViewControllerMethod .addDevToolsProtocolEventListener: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.addJavaScriptHandler: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2204,9 +2204,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.addUserScript: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2214,9 +2214,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.addUserScripts: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2224,11 +2224,11 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.addWebMessageListener: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.callAsyncJavaScript: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2236,11 +2236,11 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.callDevToolsProtocolMethod: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.canGoBack: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2248,7 +2248,7 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.canGoBackOrForward: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2256,7 +2256,7 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.canGoForward: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2264,79 +2264,79 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.canScrollHorizontally: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.canScrollVertically: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.clearAllCache: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.clearCache: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.clearClientCertPreferences: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.clearFocus: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.clearFormData: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.clearHistory: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.clearMatches: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.clearSslPreferences: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.closeAllMediaPresentations: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.createPdf: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.createWebArchiveData: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.createWebMessageChannel: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.disableWebView: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.dispose: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2344,7 +2344,7 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.disposeKeepAlive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2352,13 +2352,13 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.enableSlowWholeDocumentDraw: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.evaluateJavascript: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2366,19 +2366,19 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.findAllAsync: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.findNext: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getCameraCaptureState: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getCertificate: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2386,25 +2386,25 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getContentHeight: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getContentWidth: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getCopyBackForwardList: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2412,22 +2412,22 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getCurrentWebViewPackage: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getDefaultUserAgent: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getFavicons: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2435,13 +2435,13 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getHitTestResult: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getHtml: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2449,13 +2449,14 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getIFrameId: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && [].contains(platform ?? defaultTargetPlatform); + : ((kIsWeb && platform != null) || !kIsWeb) && + [].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getJavaScriptBridgeName: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2463,9 +2464,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getMetaTags: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2473,9 +2474,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getMetaThemeColor: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2483,13 +2484,13 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getMicrophoneCaptureState: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getOptions: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2497,57 +2498,57 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getOriginalUrl: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getProgress: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getSafeBrowsingPrivacyPolicyUrl: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getScale: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getScrollX: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getScrollY: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getSelectedText: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getSettings: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2555,9 +2556,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getTRexRunnerCss: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2565,9 +2566,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getTRexRunnerHtml: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2575,9 +2576,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getTitle: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2585,9 +2586,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getUrl: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2595,13 +2596,13 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getVariationsHeader: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getViewId: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2609,13 +2610,13 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.getZoomScale: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.goBack: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2623,9 +2624,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.goBackOrForward: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2633,9 +2634,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.goForward: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2643,9 +2644,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.goTo: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2653,13 +2654,13 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.handlesURLScheme: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.hasJavaScriptHandler: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2667,13 +2668,13 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.hasOnlySecureContent: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.hasUserScript: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2681,44 +2682,44 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.hasWebMessageListener: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.hideInputMethod: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.injectCSSCode: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.injectCSSFileFromAsset: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.injectCSSFileFromUrl: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.injectJavascriptFileFromAsset: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2726,26 +2727,26 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.injectJavascriptFileFromUrl: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.isInFullscreen: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.isInterfaceSupported: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.isLoading: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2753,22 +2754,22 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.isMultiProcessEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.isSecureContext: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.loadData: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2776,9 +2777,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.loadFile: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2786,13 +2787,13 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.loadSimulatedRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.loadUrl: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2800,33 +2801,33 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.openDevTools: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.pageDown: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.pageUp: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.pause: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.pauseAllMediaPlayback: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.pauseTimers: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.postUrl: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2834,22 +2835,22 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.postWebMessage: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.printCurrentPage: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.reload: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2857,13 +2858,13 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.reloadFromOrigin: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.removeAllUserScripts: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2872,13 +2873,13 @@ extension _PlatformInAppWebViewControllerMethodSupported ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod .removeDevToolsProtocolEventListener: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.removeJavaScriptHandler: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2886,9 +2887,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.removeUserScript: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2896,9 +2897,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.removeUserScripts: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2906,9 +2907,9 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.removeUserScriptsByGroupName: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2916,78 +2917,78 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.requestFocus: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.requestFocusNodeHref: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.requestImageRef: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.requestMediaPlaybackState: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.restoreState: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.resume: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.resumeTimers: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.saveState: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.saveWebArchive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.scrollBy: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.scrollTo: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setAllMediaPlaybackSuspended: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setCameraCaptureState: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setContextMenu: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setInputMethodEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setJavaScriptBridgeName: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2995,13 +2996,13 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setMicrophoneCaptureState: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setOptions: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -3009,17 +3010,17 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setSafeBrowsingAllowlist: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setSafeBrowsingWhitelist: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setSettings: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -3027,21 +3028,21 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.setWebContentsDebuggingEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.showInputMethod: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.startSafeBrowsing: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.stopLoading: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -3049,7 +3050,7 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.takeScreenshot: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -3057,15 +3058,15 @@ extension _PlatformInAppWebViewControllerMethodSupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.zoomBy: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.zoomIn: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewControllerMethod.zoomOut: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.g.dart index 691a2207b..711482280 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_inappwebview_widget.g.dart @@ -20,9 +20,9 @@ extension _PlatformInAppWebViewWidgetCreationParamsClassSupported ///Use the [PlatformInAppWebViewWidgetCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -93,9 +93,9 @@ extension _PlatformInAppWebViewWidgetCreationParamsPropertySupported {TargetPlatform? platform}) { switch (property) { case PlatformInAppWebViewWidgetCreationParamsProperty.headlessWebView: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -103,7 +103,7 @@ extension _PlatformInAppWebViewWidgetCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewWidgetCreationParamsProperty.keepAlive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -111,10 +111,10 @@ extension _PlatformInAppWebViewWidgetCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewWidgetCreationParamsProperty.preventGestureDelay: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformInAppWebViewWidgetCreationParamsProperty.webViewEnvironment: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.g.dart b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.g.dart index 58c6d50ac..18cdc1cf2 100644 --- a/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/in_app_webview/platform_webview.g.dart @@ -20,9 +20,9 @@ extension _PlatformWebViewCreationParamsClassSupported ///Use the [PlatformWebViewCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1536,77 +1536,77 @@ extension _PlatformWebViewCreationParamsPropertySupported {TargetPlatform? platform}) { switch (property) { case PlatformWebViewCreationParamsProperty.androidOnFormResubmission: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .androidOnGeolocationPermissionsHidePrompt: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .androidOnGeolocationPermissionsShowPrompt: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.androidOnJsBeforeUnload: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.androidOnPermissionRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.androidOnReceivedIcon: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.androidOnReceivedLoginRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.androidOnReceivedTouchIconUrl: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.androidOnRenderProcessGone: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .androidOnRenderProcessResponsive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .androidOnRenderProcessUnresponsive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.androidOnSafeBrowsingHit: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.androidOnScaleChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.androidShouldInterceptRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.contextMenu: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.findInteractionController: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.initialData: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1614,9 +1614,9 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.initialFile: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1624,13 +1624,13 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.initialOptions: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.initialSettings: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1638,9 +1638,9 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.initialUrlRequest: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1648,9 +1648,9 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.initialUserScripts: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1659,38 +1659,38 @@ extension _PlatformWebViewCreationParamsPropertySupported ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .iosOnDidReceiveServerRedirectForProvisionalNavigation: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.iosOnNavigationResponse: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .iosOnWebContentProcessDidTerminate: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.iosShouldAllowDeprecatedTLS: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onAcceleratorKeyPressed: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onAjaxProgress: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onAjaxReadyStateChange: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onCameraCaptureStateChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onCloseWindow: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1698,9 +1698,9 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onConsoleMessage: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1708,12 +1708,12 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onContentSizeChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onCreateWindow: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1722,19 +1722,19 @@ extension _PlatformWebViewCreationParamsPropertySupported ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .onDidReceiveServerRedirectForProvisionalNavigation: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onDownloadStart: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onDownloadStartRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onDownloadStarting: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1742,75 +1742,75 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onEnterFullscreen: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onExitFullscreen: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onFindResultReceived: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onFormResubmission: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .onGeolocationPermissionsHidePrompt: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .onGeolocationPermissionsShowPrompt: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onJsAlert: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onJsBeforeUnload: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onJsConfirm: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onJsPrompt: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onLoadError: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onLoadHttpError: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onLoadResource: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onLoadResourceCustomScheme: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onLoadResourceWithCustomScheme: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1818,9 +1818,9 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onLoadStart: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1828,9 +1828,9 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onLoadStop: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1838,28 +1838,28 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onLongPressHitTestResult: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .onMicrophoneCaptureStateChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onNavigationResponse: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onOverScrolled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onPageCommitVisible: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onPermissionRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1867,28 +1867,28 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onPermissionRequestCanceled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onPrint: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onPrintRequest: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onProcessFailed: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onProgressChanged: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1896,7 +1896,7 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onReceivedClientCertRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1904,7 +1904,7 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onReceivedError: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1912,7 +1912,7 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onReceivedHttpAuthRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1920,7 +1920,7 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onReceivedHttpError: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1928,16 +1928,16 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onReceivedIcon: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onReceivedLoginRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .onReceivedServerTrustAuthRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1945,46 +1945,46 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onReceivedTouchIconUrl: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onRenderProcessGone: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onRenderProcessResponsive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onRenderProcessUnresponsive: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onRequestFocus: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onSafeBrowsingHit: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onScrollChanged: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onShowFileChooser: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onTitleChanged: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -1992,9 +1992,9 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onUpdateVisitedHistory: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2003,13 +2003,13 @@ extension _PlatformWebViewCreationParamsPropertySupported ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty .onWebContentProcessDidTerminate: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onWebViewCreated: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2017,54 +2017,54 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onWindowBlur: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onWindowFocus: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.onZoomScaleChanged: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.pullToRefreshController: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.shouldAllowDeprecatedTLS: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.shouldInterceptAjaxRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.shouldInterceptFetchRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.shouldInterceptRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.shouldOverrideUrlLoading: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -2072,9 +2072,9 @@ extension _PlatformWebViewCreationParamsPropertySupported TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformWebViewCreationParamsProperty.windowId: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.g.dart index f1930a6e4..21ad7afa6 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_cookie_manager.g.dart @@ -20,9 +20,9 @@ extension _PlatformCookieManagerCreationParamsClassSupported ///Use the [PlatformCookieManagerCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -53,7 +53,7 @@ extension _PlatformCookieManagerCreationParamsPropertySupported {TargetPlatform? platform}) { switch (property) { case PlatformCookieManagerCreationParamsProperty.webViewEnvironment: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.windows] .contains(platform ?? defaultTargetPlatform); } @@ -77,9 +77,9 @@ extension _PlatformCookieManagerClassSupported on PlatformCookieManager { ///Use the [PlatformCookieManager.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -297,7 +297,7 @@ extension _PlatformCookieManagerMethodSupported on PlatformCookieManager { {TargetPlatform? platform}) { switch (method) { case PlatformCookieManagerMethod.deleteAllCookies: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -305,9 +305,9 @@ extension _PlatformCookieManagerMethodSupported on PlatformCookieManager { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformCookieManagerMethod.deleteCookie: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -315,9 +315,9 @@ extension _PlatformCookieManagerMethodSupported on PlatformCookieManager { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformCookieManagerMethod.deleteCookies: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -325,17 +325,17 @@ extension _PlatformCookieManagerMethodSupported on PlatformCookieManager { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformCookieManagerMethod.flush: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformCookieManagerMethod.getAllCookies: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformCookieManagerMethod.getCookie: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -343,9 +343,9 @@ extension _PlatformCookieManagerMethodSupported on PlatformCookieManager { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformCookieManagerMethod.getCookies: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, @@ -353,13 +353,13 @@ extension _PlatformCookieManagerMethodSupported on PlatformCookieManager { TargetPlatform.windows ].contains(platform ?? defaultTargetPlatform); case PlatformCookieManagerMethod.removeSessionCookies: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformCookieManagerMethod.setCookie: - return kIsWeb + return kIsWeb && platform == null ? true - : !kIsWeb && + : ((kIsWeb && platform != null) || !kIsWeb) && [ TargetPlatform.android, TargetPlatform.iOS, diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.g.dart index 7d81a8e5e..e0c330774 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_http_auth_credentials_database.g.dart @@ -18,7 +18,7 @@ extension _PlatformHttpAuthCredentialDatabaseCreationParamsClassSupported ///Use the [PlatformHttpAuthCredentialDatabaseCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -39,7 +39,7 @@ extension _PlatformHttpAuthCredentialDatabaseClassSupported ///Use the [PlatformHttpAuthCredentialDatabase.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -146,27 +146,27 @@ extension _PlatformHttpAuthCredentialDatabaseMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformHttpAuthCredentialDatabaseMethod.clearAllAuthCredentials: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformHttpAuthCredentialDatabaseMethod.getAllAuthCredentials: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformHttpAuthCredentialDatabaseMethod.getHttpAuthCredentials: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformHttpAuthCredentialDatabaseMethod.removeHttpAuthCredential: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformHttpAuthCredentialDatabaseMethod.removeHttpAuthCredentials: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformHttpAuthCredentialDatabaseMethod.setHttpAuthCredential: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart index 3b730203e..a3ed41b93 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_process_global_config.g.dart @@ -190,7 +190,7 @@ extension _PlatformProcessGlobalConfigCreationParamsClassSupported ///Use the [PlatformProcessGlobalConfigCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); } } @@ -205,7 +205,7 @@ extension _PlatformProcessGlobalConfigClassSupported ///Use the [PlatformProcessGlobalConfig.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); } } @@ -233,7 +233,7 @@ extension _PlatformProcessGlobalConfigMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformProcessGlobalConfigMethod.apply: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } @@ -250,7 +250,7 @@ extension _ProcessGlobalConfigSettingsClassSupported ///Use the [ProcessGlobalConfigSettings.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); } } @@ -288,11 +288,11 @@ extension _ProcessGlobalConfigSettingsPropertySupported {TargetPlatform? platform}) { switch (property) { case ProcessGlobalConfigSettingsProperty.dataDirectorySuffix: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ProcessGlobalConfigSettingsProperty.directoryBasePaths: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart index 189f7ba89..e3fc33dc9 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_proxy_controller.g.dart @@ -186,7 +186,7 @@ extension _PlatformProxyControllerCreationParamsClassSupported ///Use the [PlatformProxyControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -203,7 +203,7 @@ extension _PlatformProxyControllerClassSupported on PlatformProxyController { ///Use the [PlatformProxyController.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -246,11 +246,11 @@ extension _PlatformProxyControllerMethodSupported on PlatformProxyController { {TargetPlatform? platform}) { switch (method) { case PlatformProxyControllerMethod.clearProxyOverride: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformProxyControllerMethod.setProxyOverride: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -268,7 +268,7 @@ extension _ProxySettingsClassSupported on ProxySettings { ///Use the [ProxySettings.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -350,27 +350,27 @@ extension _ProxySettingsPropertySupported on ProxySettings { {TargetPlatform? platform}) { switch (property) { case ProxySettingsProperty.bypassRules: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ProxySettingsProperty.bypassSimpleHostnames: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ProxySettingsProperty.directs: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ProxySettingsProperty.proxyRules: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case ProxySettingsProperty.removeImplicitRules: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case ProxySettingsProperty.reverseBypassEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.g.dart index 23f4f64cc..c77b0cc2f 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_service_worker_controller.g.dart @@ -16,7 +16,7 @@ extension _PlatformServiceWorkerControllerCreationParamsClassSupported ///Use the [PlatformServiceWorkerControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); } } @@ -31,7 +31,7 @@ extension _PlatformServiceWorkerControllerClassSupported ///Use the [PlatformServiceWorkerController.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); } } @@ -159,39 +159,39 @@ extension _PlatformServiceWorkerControllerMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformServiceWorkerControllerMethod.getAllowContentAccess: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformServiceWorkerControllerMethod.getAllowFileAccess: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformServiceWorkerControllerMethod.getBlockNetworkLoads: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformServiceWorkerControllerMethod.getCacheMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformServiceWorkerControllerMethod.setAllowContentAccess: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformServiceWorkerControllerMethod.setAllowFileAccess: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformServiceWorkerControllerMethod.setBlockNetworkLoads: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformServiceWorkerControllerMethod.setCacheMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformServiceWorkerControllerMethod.setServiceWorkerClient: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } @@ -207,7 +207,7 @@ extension _ServiceWorkerClientClassSupported on ServiceWorkerClient { ///Use the [ServiceWorkerClient.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); } } @@ -234,7 +234,7 @@ extension _ServiceWorkerClientPropertySupported on ServiceWorkerClient { {TargetPlatform? platform}) { switch (property) { case ServiceWorkerClientProperty.shouldInterceptRequest: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart index d4f6c20fd..3d427f972 100644 --- a/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/platform_tracing_controller.g.dart @@ -124,7 +124,7 @@ extension _PlatformTracingControllerCreationParamsClassSupported ///Use the [PlatformTracingControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); } } @@ -139,7 +139,7 @@ extension _PlatformTracingControllerClassSupported ///Use the [PlatformTracingController.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); } } @@ -192,15 +192,15 @@ extension _PlatformTracingControllerMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformTracingControllerMethod.isTracing: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformTracingControllerMethod.start: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformTracingControllerMethod.stop: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } @@ -216,7 +216,7 @@ extension _TracingSettingsClassSupported on TracingSettings { ///Use the [TracingSettings.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android].contains(platform ?? defaultTargetPlatform); } } @@ -240,7 +240,7 @@ extension _TracingSettingsPropertySupported on TracingSettings { {TargetPlatform? platform}) { switch (property) { case TracingSettingsProperty.tracingMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart index e04212827..90b9c361b 100644 --- a/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/platform_print_job_controller.g.dart @@ -18,7 +18,7 @@ extension _PlatformPrintJobControllerCreationParamsClassSupported ///Use the [PlatformPrintJobControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -47,7 +47,7 @@ extension _PlatformPrintJobControllerCreationParamsPropertySupported {TargetPlatform? platform}) { switch (property) { case PlatformPrintJobControllerCreationParamsProperty.id: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -66,7 +66,7 @@ extension _PlatformPrintJobControllerClassSupported ///Use the [PlatformPrintJobController.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -99,7 +99,7 @@ extension _PlatformPrintJobControllerPropertySupported {TargetPlatform? platform}) { switch (property) { case PlatformPrintJobControllerProperty.onComplete: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -177,22 +177,22 @@ extension _PlatformPrintJobControllerMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformPrintJobControllerMethod.cancel: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformPrintJobControllerMethod.dismiss: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformPrintJobControllerMethod.dispose: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformPrintJobControllerMethod.getInfo: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformPrintJobControllerMethod.restart: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart index ddddf9a00..17c10b0b7 100644 --- a/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/print_job/print_job_settings.g.dart @@ -1177,156 +1177,156 @@ extension _PrintJobSettingsPropertySupported on PrintJobSettings { {TargetPlatform? platform}) { switch (property) { case PrintJobSettingsProperty.animated: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.canSpawnSeparateThread: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.colorMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.copies: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.detailedErrorReporting: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.duplexMode: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.faxNumber: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.firstPage: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.footerHeight: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.forceRenderingQuality: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.handledByClient: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.headerAndFooter: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.headerHeight: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.horizontalPagination: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.isHorizontallyCentered: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.isVerticallyCentered: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.jobDisposition: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.jobName: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.jobSavingURL: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.lastPage: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.margins: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.maximumContentHeight: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.maximumContentWidth: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.mediaSize: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.mustCollate: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.numberOfPages: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.orientation: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.outputType: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.pageOrder: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.pagesAcross: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.pagesDown: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.paperName: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.resolution: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.scalingFactor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsNumberOfCopies: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsPageRange: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsPageSetupAccessory: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsPaperOrientation: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsPaperSelectionForLoadedPapers: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsPaperSize: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsPreview: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsPrintPanel: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsPrintSelection: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsProgressPanel: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.showsScaling: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.time: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); case PrintJobSettingsProperty.verticalPagination: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.macOS].contains(platform ?? defaultTargetPlatform); } } diff --git a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.g.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.g.dart index 2997edffd..358d51628 100644 --- a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/platform_pull_to_refresh_controller.g.dart @@ -17,7 +17,7 @@ extension _PlatformPullToRefreshControllerCreationParamsClassSupported ///Use the [PlatformPullToRefreshControllerCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); } @@ -70,15 +70,15 @@ extension _PlatformPullToRefreshControllerCreationParamsPropertySupported {TargetPlatform? platform}) { switch (property) { case PlatformPullToRefreshControllerCreationParamsProperty.onRefresh: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerCreationParamsProperty.options: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerCreationParamsProperty.settings: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); } @@ -97,7 +97,7 @@ extension _PlatformPullToRefreshControllerClassSupported ///Use the [PlatformPullToRefreshController.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); } @@ -317,62 +317,62 @@ extension _PlatformPullToRefreshControllerMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformPullToRefreshControllerMethod.beginRefreshing: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.dispose: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.endRefreshing: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.getDefaultSlingshotDistance: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.isEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.isRefreshing: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.setAttributedTitle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.setBackgroundColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.setColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.setDistanceToTriggerSync: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.setEnabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.setIndicatorSize: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.setSize: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.setSlingshotDistance: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PlatformPullToRefreshControllerMethod.setStyledTitle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); } } diff --git a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart index 89d90bdb2..c1857c8e5 100644 --- a/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/pull_to_refresh/pull_to_refresh_settings.g.dart @@ -231,30 +231,30 @@ extension _PullToRefreshSettingsPropertySupported on PullToRefreshSettings { {TargetPlatform? platform}) { switch (property) { case PullToRefreshSettingsProperty.attributedTitle: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS].contains(platform ?? defaultTargetPlatform); case PullToRefreshSettingsProperty.backgroundColor: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PullToRefreshSettingsProperty.color: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PullToRefreshSettingsProperty.distanceToTriggerSync: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PullToRefreshSettingsProperty.enabled: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android, TargetPlatform.iOS] .contains(platform ?? defaultTargetPlatform); case PullToRefreshSettingsProperty.size: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); case PullToRefreshSettingsProperty.slingshotDistance: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.android] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart index 2355eacf5..71a240d4e 100755 --- a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.dart @@ -304,7 +304,8 @@ abstract class PlatformWebAuthenticationSession extends PlatformInterface ///{@macro flutter_inappwebview_platform_interface.PlatformWebAuthenticationSessionCreationParams.isClassSupported} bool isClassSupported({TargetPlatform? platform}) => - _PlatformWebAuthenticationSessionClassSupported.isClassSupported(platform: platform); + _PlatformWebAuthenticationSessionClassSupported.isClassSupported( + platform: platform); ///{@template flutter_inappwebview_platform_interface.PlatformWebAuthenticationSession.isPropertySupported} ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. diff --git a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.g.dart b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.g.dart index a8cd9aa93..d631f1b92 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/platform_web_authenticate_session.g.dart @@ -17,7 +17,7 @@ extension _PlatformWebAuthenticationSessionCreationParamsClassSupported ///Use the [PlatformWebAuthenticationSessionCreationParams.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -34,7 +34,7 @@ extension _PlatformWebAuthenticationSessionClassSupported ///Use the [PlatformWebAuthenticationSession.isClassSupported] method to check if this class is supported at runtime. ///{@endtemplate} static bool isClassSupported({TargetPlatform? platform}) { - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -114,23 +114,23 @@ extension _PlatformWebAuthenticationSessionPropertySupported {TargetPlatform? platform}) { switch (property) { case PlatformWebAuthenticationSessionProperty.callbackURLScheme: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebAuthenticationSessionProperty.id: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebAuthenticationSessionProperty.initialSettings: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebAuthenticationSessionProperty.onComplete: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebAuthenticationSessionProperty.url: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } @@ -224,27 +224,27 @@ extension _PlatformWebAuthenticationSessionMethodSupported {TargetPlatform? platform}) { switch (method) { case PlatformWebAuthenticationSessionMethod.canStart: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebAuthenticationSessionMethod.cancel: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebAuthenticationSessionMethod.create: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebAuthenticationSessionMethod.dispose: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebAuthenticationSessionMethod.isAvailable: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); case PlatformWebAuthenticationSessionMethod.start: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart index 42d5bd294..24ac29ac2 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_authentication_session/web_authenticate_session_settings.g.dart @@ -106,7 +106,7 @@ extension _WebAuthenticationSessionSettingsPropertySupported switch (property) { case WebAuthenticationSessionSettingsProperty .prefersEphemeralWebBrowserSession: - return !kIsWeb && + return ((kIsWeb && platform != null) || !kIsWeb) && [TargetPlatform.iOS, TargetPlatform.macOS] .contains(platform ?? defaultTargetPlatform); } From 971e89560e26c8effaab2895612c0ee7d64c514e Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Sun, 5 Oct 2025 12:36:55 +0200 Subject: [PATCH 160/181] added support methods for PlatformWebMessageChannel and PlatformWebMessageListener classes --- .../src/web_message/web_message_channel.dart | 24 +++ .../src/web_message/web_message_listener.dart | 24 +++ .../lib/src/inappwebview_platform.dart | 9 + .../src/web_message/web_message_listener.dart | 9 + .../lib/src/inappwebview_platform.dart | 9 + .../src/web_message/web_message_listener.dart | 9 + .../lib/src/inappwebview_platform.dart | 9 + .../src/web_message/web_message_listener.dart | 9 + .../lib/src/inappwebview_platform.dart | 9 + .../platform_web_message_channel.dart | 122 +++++++++++-- .../platform_web_message_channel.g.dart | 136 +++++++++++++++ .../platform_web_message_listener.dart | 152 +++++++++++++--- .../platform_web_message_listener.g.dart | 142 +++++++++++++++ .../lib/src/inappwebview_platform.dart | 79 +++++++++ .../in_app_webview_controller.dart | 66 ------- .../lib/src/inappwebview_platform.dart | 79 +++++++++ .../lib/src/main.dart | 1 - .../lib/src/web_message/main.dart | 3 - .../src/web_message/web_message_channel.dart | 120 ------------- .../src/web_message/web_message_listener.dart | 164 ------------------ .../lib/src/web_message/web_message_port.dart | 95 ---------- 21 files changed, 778 insertions(+), 492 deletions(-) create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_channel.g.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_listener.g.dart delete mode 100644 flutter_inappwebview_windows/lib/src/web_message/main.dart delete mode 100644 flutter_inappwebview_windows/lib/src/web_message/web_message_channel.dart delete mode 100644 flutter_inappwebview_windows/lib/src/web_message/web_message_listener.dart delete mode 100644 flutter_inappwebview_windows/lib/src/web_message/web_message_port.dart diff --git a/flutter_inappwebview/lib/src/web_message/web_message_channel.dart b/flutter_inappwebview/lib/src/web_message/web_message_channel.dart index 16ea7dbdd..b666cc89e 100644 --- a/flutter_inappwebview/lib/src/web_message/web_message_channel.dart +++ b/flutter_inappwebview/lib/src/web_message/web_message_channel.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; import 'web_message_port.dart'; @@ -26,6 +27,29 @@ class WebMessageChannel { /// Implementation of [PlatformWebMessageChannel] for the current platform. final PlatformWebMessageChannel platform; + /// Provide static access. + static WebMessageChannel static() { + return WebMessageChannel.fromPlatform( + platform: PlatformWebMessageChannel.static()); + } + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformWebMessageChannel.static().isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannel.isPropertySupported} + static bool isPropertySupported( + PlatformWebMessageChannelCreationParamsProperty property, + {TargetPlatform? platform}) => + PlatformWebMessageChannel.static() + .isPropertySupported(property, platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannel.isMethodSupported} + static bool isMethodSupported(PlatformWebMessageChannelMethod method, + {TargetPlatform? platform}) => + PlatformWebMessageChannel.static() + .isMethodSupported(method, platform: platform); + static WebMessageChannel? fromMap(Map? map) { PlatformWebMessageChannel? platform = PlatformWebMessageChannel.static().fromMap(map); diff --git a/flutter_inappwebview/lib/src/web_message/web_message_listener.dart b/flutter_inappwebview/lib/src/web_message/web_message_listener.dart index 18d039add..f9d561144 100644 --- a/flutter_inappwebview/lib/src/web_message/web_message_listener.dart +++ b/flutter_inappwebview/lib/src/web_message/web_message_listener.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener} @@ -27,6 +28,29 @@ class WebMessageListener { /// Implementation of [PlatformWebMessageListener] for the current platform. final PlatformWebMessageListener platform; + /// Provide static access. + static WebMessageListener static() { + return WebMessageListener.fromPlatform( + platform: PlatformWebMessageListener.static()); + } + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformWebMessageListener.static().isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener.isPropertySupported} + static bool isPropertySupported( + PlatformWebMessageListenerCreationParamsProperty property, + {TargetPlatform? platform}) => + PlatformWebMessageListener.static() + .isPropertySupported(property, platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener.isMethodSupported} + static bool isMethodSupported(PlatformWebMessageListenerMethod method, + {TargetPlatform? platform}) => + PlatformWebMessageListener.static() + .isMethodSupported(method, platform: platform); + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener.jsObjectName} String get jsObjectName => platform.jsObjectName; diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index e8e66124b..03ff3ad04 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -176,6 +176,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidWebMessageListener(params); } + /// Creates a new empty [AndroidWebMessageListener] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageListener] in `flutter_inappwebview` instead. + @override + AndroidWebMessageListener createPlatformWebMessageListenerStatic() { + return AndroidWebMessageListener.static(); + } + /// Creates a new [AndroidJavaScriptReplyProxy]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart b/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart index 00307c9a2..c90196e2d 100644 --- a/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart +++ b/flutter_inappwebview_android/lib/src/web_message/web_message_listener.dart @@ -55,6 +55,15 @@ class AndroidWebMessageListener extends PlatformWebMessageListener initMethodCallHandler(); } + static final AndroidWebMessageListener _staticValue = + AndroidWebMessageListener(AndroidWebMessageListenerCreationParams( + jsObjectName: '', allowedOriginRules: Set.from(["*"]))); + + /// Provide static access. + factory AndroidWebMessageListener.static() { + return _staticValue; + } + ///Message Listener ID used internally. final String _id = IdGenerator.generate(); diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index b22222367..3ce86ba32 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -171,6 +171,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSWebMessageListener(params); } + /// Creates a new empty [IOSWebMessageListener] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageListener] in `flutter_inappwebview` instead. + @override + IOSWebMessageListener createPlatformWebMessageListenerStatic() { + return IOSWebMessageListener.static(); + } + /// Creates a new [IOSJavaScriptReplyProxy]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_ios/lib/src/web_message/web_message_listener.dart b/flutter_inappwebview_ios/lib/src/web_message/web_message_listener.dart index 38a278806..94390438a 100644 --- a/flutter_inappwebview_ios/lib/src/web_message/web_message_listener.dart +++ b/flutter_inappwebview_ios/lib/src/web_message/web_message_listener.dart @@ -55,6 +55,15 @@ class IOSWebMessageListener extends PlatformWebMessageListener initMethodCallHandler(); } + static final IOSWebMessageListener _staticValue = IOSWebMessageListener( + IOSWebMessageListenerCreationParams( + jsObjectName: '', allowedOriginRules: Set.from(["*"]))); + + /// Provide static access. + factory IOSWebMessageListener.static() { + return _staticValue; + } + ///Message Listener ID used internally. final String _id = IdGenerator.generate(); diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index 37f5a4186..c4e4ab6af 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -160,6 +160,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSWebMessageListener(params); } + /// Creates a new empty [MacOSWebMessageListener] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageListener] in `flutter_inappwebview` instead. + @override + MacOSWebMessageListener createPlatformWebMessageListenerStatic() { + return MacOSWebMessageListener.static(); + } + /// Creates a new [MacOSJavaScriptReplyProxy]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_macos/lib/src/web_message/web_message_listener.dart b/flutter_inappwebview_macos/lib/src/web_message/web_message_listener.dart index b2791eba0..1b7fd8b02 100644 --- a/flutter_inappwebview_macos/lib/src/web_message/web_message_listener.dart +++ b/flutter_inappwebview_macos/lib/src/web_message/web_message_listener.dart @@ -55,6 +55,15 @@ class MacOSWebMessageListener extends PlatformWebMessageListener initMethodCallHandler(); } + static final MacOSWebMessageListener _staticValue = MacOSWebMessageListener( + MacOSWebMessageListenerCreationParams( + jsObjectName: '', allowedOriginRules: Set.from(["*"]))); + + /// Provide static access. + factory MacOSWebMessageListener.static() { + return _staticValue; + } + ///Message Listener ID used internally. final String _id = IdGenerator.generate(); diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index 719d859e1..c1ed36a55 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -224,6 +224,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformWebMessageListener is not implemented on the current platform.'); } + /// Creates a new empty [PlatformWebMessageListener] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageListener] in `flutter_inappwebview` instead. + PlatformWebMessageListener createPlatformWebMessageListenerStatic() { + throw UnimplementedError( + 'createPlatformWebMessageListenerStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformJavaScriptReplyProxy]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_channel.dart b/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_channel.dart index 75767a3b7..c8c66af13 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_channel.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_channel.dart @@ -1,28 +1,84 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_platform_interface/src/types/disposable.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import '../inappwebview_platform.dart'; import 'platform_web_message_port.dart'; +// ignore: uri_has_not_been_generated +part 'platform_web_message_channel.g.dart'; + +///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams} /// Object specifying creation parameters for creating a [PlatformWebMessageChannel]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), +]) @immutable class PlatformWebMessageChannelCreationParams { /// Used by the platform implementation to create a new [PlatformWebMessageChannel]. const PlatformWebMessageChannelCreationParams( {required this.id, required this.port1, required this.port2}); - ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannel.id} + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.id} + ///Message Channel ID used internally. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.id.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) final String id; - ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannel.port1} + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.port1} + ///The first [PlatformWebMessagePort] object of the channel. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.port1.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) final PlatformWebMessagePort port1; - ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannel.port2} + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.port2} + ///The second [PlatformWebMessagePort] object of the channel. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.port2.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) final PlatformWebMessagePort port2; + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebMessageChannelCreationParamsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported( + PlatformWebMessageChannelCreationParamsProperty property, + {TargetPlatform? platform}) => + _PlatformWebMessageChannelCreationParamsPropertySupported + .isPropertySupported(property, platform: platform); + @override String toString() { return 'PlatformWebMessageChannelCreationParams{id: $id, port1: $port1, port2: $port2}'; @@ -31,12 +87,14 @@ class PlatformWebMessageChannelCreationParams { ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannel} ///The representation of the [HTML5 message channels](https://html.spec.whatwg.org/multipage/web-messaging.html#message-channels). -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannel.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), +]) abstract class PlatformWebMessageChannel extends PlatformInterface implements Disposable { /// Creates a new [PlatformWebMessageChannel] @@ -82,19 +140,19 @@ abstract class PlatformWebMessageChannel extends PlatformInterface /// The parameters used to initialize the [PlatformWebMessageChannel]. final PlatformWebMessageChannelCreationParams params; - ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannel.id} - ///Message Channel ID used internally. - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.id} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.id.supported_platforms} String get id => params.id; - ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannel.port1} - ///The first [PlatformWebMessagePort] object of the channel. - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.port1} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.port1.supported_platforms} PlatformWebMessagePort get port1 => params.port1; - ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannel.port2} - ///The second [PlatformWebMessagePort] object of the channel. - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.port2} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.port2.supported_platforms} PlatformWebMessagePort get port2 => params.port2; PlatformWebMessageChannel? fromMap(Map? map) { @@ -102,15 +160,43 @@ abstract class PlatformWebMessageChannel extends PlatformInterface 'fromMap is not implemented on the current platform'); } - ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannel} + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannel.dispose} ///Disposes the web message channel. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannel.dispose.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) @override void dispose() { throw UnimplementedError( 'dispose is not implemented on the current platform'); } + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebMessageChannelClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannel.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported( + PlatformWebMessageChannelCreationParamsProperty property, + {TargetPlatform? platform}) => + params.isPropertySupported(property, platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannel.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformWebMessageChannelMethod method, + {TargetPlatform? platform}) => + _PlatformWebMessageChannelMethodSupported.isMethodSupported(method, + platform: platform); + @override String toString() { return 'PlatformWebMessageChannel{id: $id, port1: $port1, port2: $port2}'; diff --git a/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_channel.g.dart b/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_channel.g.dart new file mode 100644 index 000000000..3fa50511c --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_channel.g.dart @@ -0,0 +1,136 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_web_message_channel.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformWebMessageChannelCreationParamsClassSupported + on PlatformWebMessageChannelCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageChannelCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformWebMessageChannelCreationParams]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformWebMessageChannelCreationParamsProperty { + ///Can be used to check if the [PlatformWebMessageChannelCreationParams.id] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.id.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageChannelCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + id, + + ///Can be used to check if the [PlatformWebMessageChannelCreationParams.port1] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.port1.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageChannelCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + port1, + + ///Can be used to check if the [PlatformWebMessageChannelCreationParams.port2] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannelCreationParams.port2.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageChannelCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + port2, +} + +extension _PlatformWebMessageChannelCreationParamsPropertySupported + on PlatformWebMessageChannelCreationParams { + static bool isPropertySupported( + PlatformWebMessageChannelCreationParamsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformWebMessageChannelCreationParamsProperty.id: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebMessageChannelCreationParamsProperty.port1: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebMessageChannelCreationParamsProperty.port2: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformWebMessageChannelClassSupported + on PlatformWebMessageChannel { + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannel.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageChannel.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformWebMessageChannel]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformWebMessageChannelMethod { + ///Can be used to check if the [PlatformWebMessageChannel.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageChannel.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageChannel.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, +} + +extension _PlatformWebMessageChannelMethodSupported + on PlatformWebMessageChannel { + static bool isMethodSupported(PlatformWebMessageChannelMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformWebMessageChannelMethod.dispose: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_listener.dart b/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_listener.dart index 5cca28c6e..bf6f31143 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_listener.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_listener.dart @@ -1,4 +1,5 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_platform_interface/src/types/disposable.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import '../in_app_webview/platform_inappwebview_controller.dart'; @@ -6,10 +7,22 @@ import '../inappwebview_platform.dart'; import '../types/main.dart'; import 'web_message.dart'; +// ignore: uri_has_not_been_generated +part 'platform_web_message_listener.g.dart'; + +///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams} /// Object specifying creation parameters for creating a [PlatformWebMessageListener]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), +]) @immutable class PlatformWebMessageListenerCreationParams { /// Used by the platform implementation to create a new [PlatformWebMessageListener]. @@ -18,15 +31,68 @@ class PlatformWebMessageListenerCreationParams { this.allowedOriginRules, this.onPostMessage}); - ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener.jsObjectName} + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.jsObjectName} + ///The name for the injected JavaScript object. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.jsObjectName.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) final String jsObjectName; - ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener.allowedOriginRules} + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.allowedOriginRules} + ///A set of matching rules for the allowed origins. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.allowedOriginRules.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) final Set? allowedOriginRules; - ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener.onPostMessage} + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.onPostMessage} + ///Event that receives a message sent by a `postMessage()` on the injected JavaScript object. + /// + ///Note that when the frame is `file:` or `content:` origin, the value of [sourceOrigin] is `null`. + /// + ///- [message] represents the message from JavaScript. + ///- [sourceOrigin] represents the origin of the frame that the message is from. + ///- [isMainFrame] is `true` if the message is from the main frame. + ///- [replyProxy] is used to reply back to the JavaScript object. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.onPostMessage.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'WebViewCompat.WebMessageListener.onPostMessage', + apiUrl: + 'https://developer.android.com/reference/androidx/webkit/WebViewCompat.WebMessageListener#onPostMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri,%20boolean,%20androidx.webkit.JavaScriptReplyProxy)'), + IOSPlatform(), + MacOSPlatform(), + ]) final OnPostMessageCallback? onPostMessage; + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebMessageListenerCreationParamsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported( + PlatformWebMessageListenerCreationParamsProperty property, + {TargetPlatform? platform}) => + _PlatformWebMessageListenerCreationParamsPropertySupported + .isPropertySupported(property, platform: platform); + @override String toString() { return 'PlatformWebMessageListenerCreationParams{jsObjectName: $jsObjectName, allowedOriginRules: $allowedOriginRules, onPostMessage: $onPostMessage}'; @@ -35,12 +101,14 @@ class PlatformWebMessageListenerCreationParams { ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListener} ///This listener receives messages sent on the JavaScript object which was injected by [PlatformInAppWebViewController.addWebMessageListener]. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), +]) abstract class PlatformWebMessageListener extends PlatformInterface implements Disposable { /// Creates a new [PlatformWebMessageListener] @@ -59,6 +127,21 @@ abstract class PlatformWebMessageListener extends PlatformInterface return webMessageListener; } + /// Creates a new [PlatformWebMessageListener] to access static methods. + factory PlatformWebMessageListener.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformWebMessageListener webMessageListenerStatic = + InAppWebViewPlatform.instance!.createPlatformWebMessageListenerStatic(); + PlatformInterface.verify(webMessageListenerStatic, _token); + return webMessageListenerStatic; + } + /// Used by the platform implementation to create a new [PlatformWebMessageListener]. /// /// Should only be used by platform implementations because they can't extend @@ -71,28 +154,19 @@ abstract class PlatformWebMessageListener extends PlatformInterface /// The parameters used to initialize the [PlatformWebMessageListener]. final PlatformWebMessageListenerCreationParams params; - ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListener.jsObjectName} - ///The name for the injected JavaScript object. - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.jsObjectName} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.jsObjectName.supported_platforms} String get jsObjectName => params.jsObjectName; - ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListener.allowedOriginRules} - ///A set of matching rules for the allowed origins. - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.allowedOriginRules} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.allowedOriginRules.supported_platforms} Set? get allowedOriginRules => params.allowedOriginRules; - ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListener.onPostMessage} - ///Event that receives a message sent by a `postMessage()` on the injected JavaScript object. + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.onPostMessage} /// - ///Note that when the frame is `file:` or `content:` origin, the value of [sourceOrigin] is `null`. - /// - ///- [message] represents the message from JavaScript. - ///- [sourceOrigin] represents the origin of the frame that the message is from. - ///- [isMainFrame] is `true` if the message is from the main frame. - ///- [replyProxy] is used to reply back to the JavaScript object. - /// - ///**Official Android API**: https://developer.android.com/reference/androidx/webkit/WebViewCompat.WebMessageListener#onPostMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri,%20boolean,%20androidx.webkit.JavaScriptReplyProxy) - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.onPostMessage.supported_platforms} OnPostMessageCallback? get onPostMessage => params.onPostMessage; Map toMap() { @@ -108,12 +182,40 @@ abstract class PlatformWebMessageListener extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListener.dispose} ///Disposes the channel. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener.dispose.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + ]) @override void dispose() { throw UnimplementedError( 'dispose is not implemented on the current platform.'); } + ///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebMessageListenerClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListener.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported( + PlatformWebMessageListenerCreationParamsProperty property, + {TargetPlatform? platform}) => + params.isPropertySupported(property, platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListener.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformWebMessageListenerMethod method, + {TargetPlatform? platform}) => + _PlatformWebMessageListenerMethodSupported.isMethodSupported(method, + platform: platform); + @override String toString() { return 'PlatformWebMessageListener{jsObjectName: $jsObjectName, allowedOriginRules: $allowedOriginRules, onPostMessage: $onPostMessage}'; diff --git a/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_listener.g.dart b/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_listener.g.dart new file mode 100644 index 000000000..5f0da9a32 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/web_message/platform_web_message_listener.g.dart @@ -0,0 +1,142 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_web_message_listener.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformWebMessageListenerCreationParamsClassSupported + on PlatformWebMessageListenerCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageListenerCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformWebMessageListenerCreationParams]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformWebMessageListenerCreationParamsProperty { + ///Can be used to check if the [PlatformWebMessageListenerCreationParams.allowedOriginRules] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.allowedOriginRules.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageListenerCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + allowedOriginRules, + + ///Can be used to check if the [PlatformWebMessageListenerCreationParams.jsObjectName] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.jsObjectName.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageListenerCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + jsObjectName, + + ///Can be used to check if the [PlatformWebMessageListenerCreationParams.onPostMessage] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListenerCreationParams.onPostMessage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebViewCompat.WebMessageListener.onPostMessage](https://developer.android.com/reference/androidx/webkit/WebViewCompat.WebMessageListener#onPostMessage(android.webkit.WebView,%20androidx.webkit.WebMessageCompat,%20android.net.Uri,%20boolean,%20androidx.webkit.JavaScriptReplyProxy))) + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [message]: all platforms + ///- [sourceOrigin]: all platforms + ///- [isMainFrame]: all platforms + ///- [replyProxy]: all platforms + /// + ///Use the [PlatformWebMessageListenerCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + onPostMessage, +} + +extension _PlatformWebMessageListenerCreationParamsPropertySupported + on PlatformWebMessageListenerCreationParams { + static bool isPropertySupported( + PlatformWebMessageListenerCreationParamsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformWebMessageListenerCreationParamsProperty.allowedOriginRules: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebMessageListenerCreationParamsProperty.jsObjectName: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebMessageListenerCreationParamsProperty.onPostMessage: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformWebMessageListenerClassSupported + on PlatformWebMessageListener { + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListener.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageListener.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformWebMessageListener]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformWebMessageListenerMethod { + ///Can be used to check if the [PlatformWebMessageListener.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebMessageListener.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + /// + ///Use the [PlatformWebMessageListener.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, +} + +extension _PlatformWebMessageListenerMethodSupported + on PlatformWebMessageListener { + static bool isMethodSupported(PlatformWebMessageListenerMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformWebMessageListenerMethod.dispose: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index c0f0a2cba..e16e54fee 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -200,6 +200,24 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { createPlatformWebAuthenticationSessionStatic() { return _PlatformWebAuthenticationSession.static(); } + + /// Creates a new empty [PlatformWebMessageChannel] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageChannel] in `flutter_inappwebview` instead. + @override + PlatformWebMessageChannel createPlatformWebMessageChannelStatic() { + return _PlatformWebMessageChannel.static(); + } + + /// Creates a new empty [PlatformWebMessageListener] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageListener] in `flutter_inappwebview` instead. + @override + PlatformWebMessageListener createPlatformWebMessageListenerStatic() { + return _PlatformWebMessageListener.static(); + } } class _PlatformInAppBrowser extends PlatformInAppBrowser { @@ -323,3 +341,64 @@ class _PlatformWebAuthenticationSession factory _PlatformWebAuthenticationSession.static() => _staticValue; } + +class _PlatformWebMessageChannel extends PlatformWebMessageChannel { + _PlatformWebMessageChannel(PlatformWebMessageChannelCreationParams params) + : super.implementation(params); + + static final _PlatformWebMessageChannel _staticValue = + _PlatformWebMessageChannel(PlatformWebMessageChannelCreationParams( + id: '', + port1: _PlatformWebMessagePort( + const PlatformWebMessagePortCreationParams(index: 0)), + port2: _PlatformWebMessagePort( + const PlatformWebMessagePortCreationParams(index: 1)))); + + factory _PlatformWebMessageChannel.static() => _staticValue; +} + +class _PlatformWebMessageListener extends PlatformWebMessageListener { + _PlatformWebMessageListener(PlatformWebMessageListenerCreationParams params) + : super.implementation(params); + + static final _PlatformWebMessageListener _staticValue = + _PlatformWebMessageListener( + const PlatformWebMessageListenerCreationParams(jsObjectName: '')); + + factory _PlatformWebMessageListener.static() => _staticValue; +} + +class _PlatformWebMessagePort extends PlatformWebMessagePort { + _PlatformWebMessagePort(PlatformWebMessagePortCreationParams params) + : super.implementation(params); + + static final _PlatformWebMessagePort _staticValue = _PlatformWebMessagePort( + const PlatformWebMessagePortCreationParams(index: 0)); + + factory _PlatformWebMessagePort.static() => _staticValue; + + @override + Future close() { + throw UnimplementedError(); + } + + @override + Future postMessage(WebMessage message) { + throw UnimplementedError(); + } + + @override + Future setWebMessageCallback(WebMessageCallback? onMessage) { + throw UnimplementedError(); + } + + @override + Map toJson() { + throw UnimplementedError(); + } + + @override + Map toMap({EnumMethod? enumMethod}) { + throw UnimplementedError(); + } +} diff --git a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart index 8ffb0b3b3..ce4b9d7ee 100644 --- a/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart +++ b/flutter_inappwebview_windows/lib/src/in_app_webview/in_app_webview_controller.dart @@ -10,7 +10,6 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla import '../in_app_browser/in_app_browser.dart'; import '../print_job/main.dart'; -import '../web_message/main.dart'; import '../web_storage/web_storage.dart'; import '_static_channel.dart'; import 'headless_in_app_webview.dart'; @@ -53,8 +52,6 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController }; Set _webMessageListenerObjNames = Set(); Map _injectedScriptsFromURL = {}; - Set _webMessageChannels = Set(); - Set _webMessageListeners = Set(); Map _devToolsProtocolEventListenerMap = HashMap(); @@ -162,8 +159,6 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController javaScriptHandlersMap: _javaScriptHandlersMap, userScripts: _userScripts, webMessageListenerObjNames: _webMessageListenerObjNames, - webMessageChannels: _webMessageChannels, - webMessageListeners: _webMessageListeners, devToolsProtocolEventListenerMap: _devToolsProtocolEventListenerMap); } else { @@ -172,10 +167,6 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController _javaScriptHandlersMap = props.javaScriptHandlersMap; _userScripts = props.userScripts; _webMessageListenerObjNames = props.webMessageListenerObjNames; - _webMessageChannels = - props.webMessageChannels as Set; - _webMessageListeners = - props.webMessageListeners as Set; _devToolsProtocolEventListenerMap = props.devToolsProtocolEventListenerMap; } @@ -2554,55 +2545,6 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController return await channel?.invokeMethod('isSecureContext', args) ?? false; } - @override - Future createWebMessageChannel() async { - Map args = {}; - Map? result = - (await channel?.invokeMethod('createWebMessageChannel', args)) - ?.cast(); - final webMessageChannel = WindowsWebMessageChannel.static().fromMap(result); - if (webMessageChannel != null) { - _webMessageChannels.add(webMessageChannel); - } - return webMessageChannel; - } - - @override - Future postWebMessage( - {required WebMessage message, WebUri? targetOrigin}) async { - if (targetOrigin == null) { - targetOrigin = WebUri(''); - } - Map args = {}; - args.putIfAbsent('message', () => message.toMap()); - args.putIfAbsent('targetOrigin', () => targetOrigin.toString()); - await channel?.invokeMethod('postWebMessage', args); - } - - @override - Future addWebMessageListener( - PlatformWebMessageListener webMessageListener) async { - assert(!_webMessageListeners.contains(webMessageListener), - "${webMessageListener} was already added."); - assert( - !_webMessageListenerObjNames - .contains(webMessageListener.params.jsObjectName), - "jsObjectName ${webMessageListener.params.jsObjectName} was already added."); - _webMessageListeners.add(webMessageListener as WindowsWebMessageListener); - _webMessageListenerObjNames.add(webMessageListener.params.jsObjectName); - - Map args = {}; - args.putIfAbsent('webMessageListener', () => webMessageListener.toMap()); - await channel?.invokeMethod('addWebMessageListener', args); - } - - @override - bool hasWebMessageListener(PlatformWebMessageListener webMessageListener) { - return _webMessageListeners.contains(webMessageListener) || - _webMessageListenerObjNames - .contains(webMessageListener.params.jsObjectName); - } - @override Future canScrollVertically() async { Map args = {}; @@ -2858,14 +2800,6 @@ class WindowsInAppWebViewController extends PlatformInAppWebViewController _userScripts.clear(); _webMessageListenerObjNames.clear(); _injectedScriptsFromURL.clear(); - for (final webMessageChannel in _webMessageChannels) { - webMessageChannel.dispose(); - } - _webMessageChannels.clear(); - for (final webMessageListener in _webMessageListeners) { - webMessageListener.dispose(); - } - _webMessageListeners.clear(); _devToolsProtocolEventListenerMap.clear(); } } diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index 00591b905..6971050ab 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -268,6 +268,24 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { createPlatformWebAuthenticationSessionStatic() { return _PlatformWebAuthenticationSession.static(); } + + /// Creates a new empty [PlatformWebMessageChannel] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageChannel] in `flutter_inappwebview` instead. + @override + PlatformWebMessageChannel createPlatformWebMessageChannelStatic() { + return _PlatformWebMessageChannel.static(); + } + + /// Creates a new empty [PlatformWebMessageListener] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebMessageListener] in `flutter_inappwebview` instead. + @override + PlatformWebMessageListener createPlatformWebMessageListenerStatic() { + return _PlatformWebMessageListener.static(); + } } class _PlatformChromeSafariBrowser extends PlatformChromeSafariBrowser { @@ -382,3 +400,64 @@ class _PlatformWebAuthenticationSession factory _PlatformWebAuthenticationSession.static() => _staticValue; } + +class _PlatformWebMessageChannel extends PlatformWebMessageChannel { + _PlatformWebMessageChannel(PlatformWebMessageChannelCreationParams params) + : super.implementation(params); + + static final _PlatformWebMessageChannel _staticValue = + _PlatformWebMessageChannel(PlatformWebMessageChannelCreationParams( + id: '', + port1: _PlatformWebMessagePort( + const PlatformWebMessagePortCreationParams(index: 0)), + port2: _PlatformWebMessagePort( + const PlatformWebMessagePortCreationParams(index: 1)))); + + factory _PlatformWebMessageChannel.static() => _staticValue; +} + +class _PlatformWebMessageListener extends PlatformWebMessageListener { + _PlatformWebMessageListener(PlatformWebMessageListenerCreationParams params) + : super.implementation(params); + + static final _PlatformWebMessageListener _staticValue = + _PlatformWebMessageListener( + const PlatformWebMessageListenerCreationParams(jsObjectName: '')); + + factory _PlatformWebMessageListener.static() => _staticValue; +} + +class _PlatformWebMessagePort extends PlatformWebMessagePort { + _PlatformWebMessagePort(PlatformWebMessagePortCreationParams params) + : super.implementation(params); + + static final _PlatformWebMessagePort _staticValue = _PlatformWebMessagePort( + const PlatformWebMessagePortCreationParams(index: 0)); + + factory _PlatformWebMessagePort.static() => _staticValue; + + @override + Future close() { + throw UnimplementedError(); + } + + @override + Future postMessage(WebMessage message) { + throw UnimplementedError(); + } + + @override + Future setWebMessageCallback(WebMessageCallback? onMessage) { + throw UnimplementedError(); + } + + @override + Map toJson() { + throw UnimplementedError(); + } + + @override + Map toMap({EnumMethod? enumMethod}) { + throw UnimplementedError(); + } +} diff --git a/flutter_inappwebview_windows/lib/src/main.dart b/flutter_inappwebview_windows/lib/src/main.dart index 4fce8f8c0..e93d1dee6 100644 --- a/flutter_inappwebview_windows/lib/src/main.dart +++ b/flutter_inappwebview_windows/lib/src/main.dart @@ -5,7 +5,6 @@ export 'web_storage/main.dart'; export 'cookie_manager.dart' hide InternalCookieManager; export 'http_auth_credentials_database.dart' hide InternalHttpAuthCredentialDatabase; -export 'web_message/main.dart'; export 'print_job/main.dart'; export 'find_interaction/main.dart'; export 'webview_environment/main.dart'; diff --git a/flutter_inappwebview_windows/lib/src/web_message/main.dart b/flutter_inappwebview_windows/lib/src/web_message/main.dart deleted file mode 100644 index d41e30c75..000000000 --- a/flutter_inappwebview_windows/lib/src/web_message/main.dart +++ /dev/null @@ -1,3 +0,0 @@ -export 'web_message_port.dart' hide InternalWebMessagePort; -export 'web_message_channel.dart' hide InternalWebMessageChannel; -export 'web_message_listener.dart'; diff --git a/flutter_inappwebview_windows/lib/src/web_message/web_message_channel.dart b/flutter_inappwebview_windows/lib/src/web_message/web_message_channel.dart deleted file mode 100644 index 19c99b315..000000000 --- a/flutter_inappwebview_windows/lib/src/web_message/web_message_channel.dart +++ /dev/null @@ -1,120 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; -import 'web_message_port.dart'; - -/// Object specifying creation parameters for creating a [WindowsWebMessageChannel]. -/// -/// When adding additional fields make sure they can be null or have a default -/// value to avoid breaking changes. See [PlatformWebMessageChannelCreationParams] for -/// more information. -@immutable -class WindowsWebMessageChannelCreationParams - extends PlatformWebMessageChannelCreationParams { - /// Creates a new [WindowsWebMessageChannelCreationParams] instance. - const WindowsWebMessageChannelCreationParams( - {required super.id, required super.port1, required super.port2}); - - /// Creates a [WindowsWebMessageChannelCreationParams] instance based on [PlatformWebMessageChannelCreationParams]. - factory WindowsWebMessageChannelCreationParams.fromPlatformWebMessageChannelCreationParams( - // Recommended placeholder to prevent being broken by platform interface. - // ignore: avoid_unused_constructor_parameters - PlatformWebMessageChannelCreationParams params) { - return WindowsWebMessageChannelCreationParams( - id: params.id, port1: params.port1, port2: params.port2); - } - - @override - String toString() { - return 'MacOSWebMessageChannelCreationParams{id: $id, port1: $port1, port2: $port2}'; - } -} - -///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageChannel} -class WindowsWebMessageChannel extends PlatformWebMessageChannel - with ChannelController { - /// Constructs a [WindowsWebMessageChannel]. - WindowsWebMessageChannel(PlatformWebMessageChannelCreationParams params) - : super.implementation( - params is WindowsWebMessageChannelCreationParams - ? params - : WindowsWebMessageChannelCreationParams - .fromPlatformWebMessageChannelCreationParams(params), - ) { - channel = MethodChannel( - 'com.pichillilorenzo/flutter_inappwebview_web_message_channel_${params.id}'); - handler = _handleMethod; - initMethodCallHandler(); - } - - static final WindowsWebMessageChannel _staticValue = WindowsWebMessageChannel( - WindowsWebMessageChannelCreationParams( - id: '', - port1: WindowsWebMessagePort( - WindowsWebMessagePortCreationParams(index: 0)), - port2: WindowsWebMessagePort( - WindowsWebMessagePortCreationParams(index: 1)))); - - /// Provide static access. - factory WindowsWebMessageChannel.static() { - return _staticValue; - } - - WindowsWebMessagePort get _macosPort1 => port1 as WindowsWebMessagePort; - - WindowsWebMessagePort get _macosPort2 => port2 as WindowsWebMessagePort; - - static WindowsWebMessageChannel? _fromMap(Map? map) { - if (map == null) { - return null; - } - var webMessageChannel = WindowsWebMessageChannel( - WindowsWebMessageChannelCreationParams( - id: map["id"], - port1: WindowsWebMessagePort( - WindowsWebMessagePortCreationParams(index: 0)), - port2: WindowsWebMessagePort( - WindowsWebMessagePortCreationParams(index: 1)))); - webMessageChannel._macosPort1.webMessageChannel = webMessageChannel; - webMessageChannel._macosPort2.webMessageChannel = webMessageChannel; - return webMessageChannel; - } - - Future _handleMethod(MethodCall call) async { - switch (call.method) { - case "onMessage": - int index = call.arguments["index"]; - var port = index == 0 ? _macosPort1 : _macosPort2; - if (port.onMessage != null) { - WebMessage? message = call.arguments["message"] != null - ? WebMessage.fromMap( - call.arguments["message"].cast()) - : null; - port.onMessage!(message); - } - break; - default: - throw UnimplementedError("Unimplemented ${call.method} method"); - } - return null; - } - - @override - WindowsWebMessageChannel? fromMap(Map? map) { - return _fromMap(map); - } - - @override - void dispose() { - disposeChannel(); - } - - @override - String toString() { - return 'MacOSWebMessageChannel{id: $id, port1: $port1, port2: $port2}'; - } -} - -extension InternalWebMessageChannel on WindowsWebMessageChannel { - MethodChannel? get internalChannel => channel; -} diff --git a/flutter_inappwebview_windows/lib/src/web_message/web_message_listener.dart b/flutter_inappwebview_windows/lib/src/web_message/web_message_listener.dart deleted file mode 100644 index 22a9cd768..000000000 --- a/flutter_inappwebview_windows/lib/src/web_message/web_message_listener.dart +++ /dev/null @@ -1,164 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter/services.dart'; -import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; - -/// Object specifying creation parameters for creating a [WindowsWebMessageListener]. -/// -/// When adding additional fields make sure they can be null or have a default -/// value to avoid breaking changes. See [PlatformWebMessageListenerCreationParams] for -/// more information. -@immutable -class WindowsWebMessageListenerCreationParams - extends PlatformWebMessageListenerCreationParams { - /// Creates a new [WindowsWebMessageListenerCreationParams] instance. - const WindowsWebMessageListenerCreationParams( - {required this.allowedOriginRules, - required super.jsObjectName, - super.onPostMessage}); - - /// Creates a [WindowsWebMessageListenerCreationParams] instance based on [PlatformWebMessageListenerCreationParams]. - factory WindowsWebMessageListenerCreationParams.fromPlatformWebMessageListenerCreationParams( - // Recommended placeholder to prevent being broken by platform interface. - // ignore: avoid_unused_constructor_parameters - PlatformWebMessageListenerCreationParams params) { - return WindowsWebMessageListenerCreationParams( - allowedOriginRules: params.allowedOriginRules ?? Set.from(["*"]), - jsObjectName: params.jsObjectName, - onPostMessage: params.onPostMessage); - } - - @override - final Set allowedOriginRules; - - @override - String toString() { - return 'MacOSWebMessageListenerCreationParams{jsObjectName: $jsObjectName, allowedOriginRules: $allowedOriginRules, onPostMessage: $onPostMessage}'; - } -} - -///{@macro flutter_inappwebview_platform_interface.PlatformWebMessageListener} -class WindowsWebMessageListener extends PlatformWebMessageListener - with ChannelController { - /// Constructs a [WindowsWebMessageListener]. - WindowsWebMessageListener(PlatformWebMessageListenerCreationParams params) - : super.implementation( - params is WindowsWebMessageListenerCreationParams - ? params - : WindowsWebMessageListenerCreationParams - .fromPlatformWebMessageListenerCreationParams(params), - ) { - assert(!this._macosParams.allowedOriginRules.contains(""), - "allowedOriginRules cannot contain empty strings"); - channel = MethodChannel( - 'com.pichillilorenzo/flutter_inappwebview_web_message_listener_${_id}_${params.jsObjectName}'); - handler = _handleMethod; - initMethodCallHandler(); - } - - ///Message Listener ID used internally. - final String _id = IdGenerator.generate(); - - MacOSJavaScriptReplyProxy? _replyProxy; - - WindowsWebMessageListenerCreationParams get _macosParams => - params as WindowsWebMessageListenerCreationParams; - - Future _handleMethod(MethodCall call) async { - switch (call.method) { - case "onPostMessage": - if (_replyProxy == null) { - _replyProxy = MacOSJavaScriptReplyProxy( - PlatformJavaScriptReplyProxyCreationParams( - webMessageListener: this)); - } - if (onPostMessage != null) { - WebMessage? message = call.arguments["message"] != null - ? WebMessage.fromMap( - call.arguments["message"].cast()) - : null; - WebUri? sourceOrigin = call.arguments["sourceOrigin"] != null - ? WebUri(call.arguments["sourceOrigin"]) - : null; - bool isMainFrame = call.arguments["isMainFrame"]; - onPostMessage!(message, sourceOrigin, isMainFrame, _replyProxy!); - } - break; - default: - throw UnimplementedError("Unimplemented ${call.method} method"); - } - return null; - } - - @override - void dispose() { - disposeChannel(); - } - - @override - Map toMap() { - return { - "id": _id, - "jsObjectName": params.jsObjectName, - "allowedOriginRules": _macosParams.allowedOriginRules.toList(), - }; - } - - @override - Map toJson() { - return this.toMap(); - } - - @override - String toString() { - return 'MacOSWebMessageListener{id: ${_id}, jsObjectName: ${params.jsObjectName}, allowedOriginRules: ${params.allowedOriginRules}, replyProxy: $_replyProxy}'; - } -} - -/// Object specifying creation parameters for creating a [MacOSJavaScriptReplyProxy]. -/// -/// When adding additional fields make sure they can be null or have a default -/// value to avoid breaking changes. See [PlatformJavaScriptReplyProxyCreationParams] for -/// more information. -@immutable -class MacOSJavaScriptReplyProxyCreationParams - extends PlatformJavaScriptReplyProxyCreationParams { - /// Creates a new [MacOSJavaScriptReplyProxyCreationParams] instance. - const MacOSJavaScriptReplyProxyCreationParams( - {required super.webMessageListener}); - - /// Creates a [MacOSJavaScriptReplyProxyCreationParams] instance based on [PlatformJavaScriptReplyProxyCreationParams]. - factory MacOSJavaScriptReplyProxyCreationParams.fromPlatformJavaScriptReplyProxyCreationParams( - // Recommended placeholder to prevent being broken by platform interface. - // ignore: avoid_unused_constructor_parameters - PlatformJavaScriptReplyProxyCreationParams params) { - return MacOSJavaScriptReplyProxyCreationParams( - webMessageListener: params.webMessageListener); - } -} - -///{@macro flutter_inappwebview_platform_interface.JavaScriptReplyProxy} -class MacOSJavaScriptReplyProxy extends PlatformJavaScriptReplyProxy { - /// Constructs a [WindowsWebMessageListener]. - MacOSJavaScriptReplyProxy(PlatformJavaScriptReplyProxyCreationParams params) - : super.implementation( - params is MacOSJavaScriptReplyProxyCreationParams - ? params - : MacOSJavaScriptReplyProxyCreationParams - .fromPlatformJavaScriptReplyProxyCreationParams(params), - ); - - WindowsWebMessageListener get _macosWebMessageListener => - params.webMessageListener as WindowsWebMessageListener; - - @override - Future postMessage(WebMessage message) async { - Map args = {}; - args.putIfAbsent('message', () => message.toMap()); - await _macosWebMessageListener.channel?.invokeMethod('postMessage', args); - } - - @override - String toString() { - return 'MacOSJavaScriptReplyProxy{}'; - } -} diff --git a/flutter_inappwebview_windows/lib/src/web_message/web_message_port.dart b/flutter_inappwebview_windows/lib/src/web_message/web_message_port.dart deleted file mode 100644 index 5a910bc01..000000000 --- a/flutter_inappwebview_windows/lib/src/web_message/web_message_port.dart +++ /dev/null @@ -1,95 +0,0 @@ -import 'package:flutter/foundation.dart'; -import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; - -import 'web_message_channel.dart'; - -/// Object specifying creation parameters for creating a [WindowsWebMessagePort]. -/// -/// When adding additional fields make sure they can be null or have a default -/// value to avoid breaking changes. See [PlatformWebMessagePortCreationParams] for -/// more information. -@immutable -class WindowsWebMessagePortCreationParams - extends PlatformWebMessagePortCreationParams { - /// Creates a new [WindowsWebMessagePortCreationParams] instance. - const WindowsWebMessagePortCreationParams({required super.index}); - - /// Creates a [WindowsWebMessagePortCreationParams] instance based on [PlatformWebMessagePortCreationParams]. - factory WindowsWebMessagePortCreationParams.fromPlatformWebMessagePortCreationParams( - // Recommended placeholder to prevent being broken by platform interface. - // ignore: avoid_unused_constructor_parameters - PlatformWebMessagePortCreationParams params) { - return WindowsWebMessagePortCreationParams(index: params.index); - } - - @override - String toString() { - return 'MacOSWebMessagePortCreationParams{index: $index}'; - } -} - -///{@macro flutter_inappwebview_platform_interface.PlatformWebMessagePort} -class WindowsWebMessagePort extends PlatformWebMessagePort { - WebMessageCallback? _onMessage; - late WindowsWebMessageChannel _webMessageChannel; - - /// Constructs a [WindowsWebMessagePort]. - WindowsWebMessagePort(PlatformWebMessagePortCreationParams params) - : super.implementation( - params is WindowsWebMessagePortCreationParams - ? params - : WindowsWebMessagePortCreationParams - .fromPlatformWebMessagePortCreationParams(params), - ); - - @override - Future setWebMessageCallback(WebMessageCallback? onMessage) async { - Map args = {}; - args.putIfAbsent('index', () => params.index); - await _webMessageChannel.internalChannel - ?.invokeMethod('setWebMessageCallback', args); - this._onMessage = onMessage; - } - - @override - Future postMessage(WebMessage message) async { - Map args = {}; - args.putIfAbsent('index', () => params.index); - args.putIfAbsent('message', () => message.toMap()); - await _webMessageChannel.internalChannel?.invokeMethod('postMessage', args); - } - - @override - Future close() async { - Map args = {}; - args.putIfAbsent('index', () => params.index); - await _webMessageChannel.internalChannel?.invokeMethod('close', args); - } - - @override - Map toMap({EnumMethod? enumMethod}) { - return { - "index": params.index, - "webMessageChannelId": this._webMessageChannel.params.id - }; - } - - @override - Map toJson() { - return toMap(); - } - - @override - String toString() { - return 'MacOSWebMessagePort{index: ${params.index}}'; - } -} - -extension InternalWebMessagePort on WindowsWebMessagePort { - WebMessageCallback? get onMessage => _onMessage; - void set onMessage(WebMessageCallback? value) => _onMessage = value; - - WindowsWebMessageChannel get webMessageChannel => _webMessageChannel; - void set webMessageChannel(WindowsWebMessageChannel value) => - _webMessageChannel = value; -} From 62d68d911c4ffa5e8e6c7bac5e21ad2ff5642c98 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Sat, 22 Nov 2025 16:52:54 +0100 Subject: [PATCH 161/181] created initial copilot instructions --- .github/copilot-instructions.md | 70 +++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 .github/copilot-instructions.md diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md new file mode 100644 index 000000000..778f61558 --- /dev/null +++ b/.github/copilot-instructions.md @@ -0,0 +1,70 @@ +# GitHub Copilot Instructions — flutter_inappwebview + +You are an expert Flutter and Dart plugin developer, specializing in the `flutter_inappwebview` plugin architecture. +Use these notes whenever you propose code for this repository. + +## Architecture Overview + +This repository follows the **Federated Plugin** architecture: + +- **`flutter_inappwebview/`**: The **app-facing package**. This is the public API that developers depend on. + - Files here usually wrap platform implementations via `Platform*` classes (e.g., `PlatformInAppWebViewWidget`). + - It delegates logic to the platform interface or specific platform implementations. +- **`flutter_inappwebview_platform_interface/`**: The **platform interface package**. + - Contains pure Dart contracts, typedefs, enums, and shared utilities. + - Defines the `PlatformInterface` that all platform packages must implement. + - **Crucial**: Anything added to the public API (`flutter_inappwebview`) MUST rely on or extend these definitions. DO NOT duplicate platform logic in the public package. +- **`flutter_inappwebview_/`**: The **platform implementation packages** (Android, iOS, macOS, Windows, Web). + - These packages implement the abstract classes defined in `flutter_inappwebview_platform_interface`. + - They contain platform-specific code (Dart and native: Java/Kotlin, Obj-C/Swift, C++, JavaScript). + - Keep their APIs strictly aligned with the `platform_interface` layer. +- **`dev_packages/` and `scripts/`**: Internal tooling, generators, and maintenance scripts. + +## Coding Guidelines + +### General +- **Stay Dart-side unless explicitly working inside a platform package.** Never touch native (`.java`, `.kt`, `.mm`, `.swift`, `.cpp`, `.cs`) code when an issue only concerns the shared Dart API. +- **Null Safety**: Strictly adhere to null safety. Do not introduce nullable APIs unless absolutely necessary. Prefer optional named parameters with sensible defaults. +- **Avoid Breaking Changes**: In the public package (`flutter_inappwebview`), avoid breaking changes. Any API change requires updating the `platform_interface`, all federated implementations, and changelog entries. +- **Code Generation**: Use `@ExchangeableObject`, `@ExchangeableEnum`, and other annotations from `flutter_inappwebview_internal_annotations` to generate boilerplate code (e.g., `toMap`, `fromMap`, `copy`). Run `dart run build_runner build` to regenerate files. +- **Generated Files**: Never hand-edit generated artifacts (for example `*.g.dart`). Update the annotated source instead, rerun `dart run build_runner build`, and include only the regenerated outputs relevant to your change. + +### Platform Interface & Public API +- **Constructor Helpers**: When exposing new public classes in `flutter_inappwebview`, prefer constructor helpers like `fromPlatformCreationParams` and `fromPlatform`. This allows downstream packages to inject platform overrides. +- **Documentation Macros**: Respect documentation macros (`{@macro ...}`) and keep comments synchronized with definitions in the `platform_interface` package. +- **`@SupportedPlatforms`**: Add `@SupportedPlatforms` annotations that mirror the contract comments in `platform_interface`. Only mark a platform supported when the corresponding federated implementation actually exists. + - **Parameters**: + - `platforms`: List of `Platform` objects (e.g., `AndroidPlatform`, `IOSPlatform`). + - **Platform Object Parameters**: + - `available`: Version string when the feature became available (e.g., "21"). + - `apiName`: Name of the underlying native API (e.g., "View.setAlpha"). + - `apiUrl`: URL to the official native documentation. + - `note`: Special notes or restrictions. +- **Support Checks**: Implement support-check helpers (`isClassSupported`, `isPropertySupported`, `isMethodSupported`) by deferring to the `platform_interface` static singleton (`PlatformX.static()`). +- **Enums & Types**: Keep enums for methods/properties in the `platform_interface` package. The public package should use simple passthrough helpers. +- **Propagation Order**: Add or change APIs in `flutter_inappwebview_platform_interface` first, then update every `flutter_inappwebview_` implementation, and finally wire the public `flutter_inappwebview` wrapper. Each touched package needs an aligned changelog entry. + +### Platform Implementations +- **`inappwebview_platform.dart`**: This file in each platform package implements `InAppWebViewPlatform` and handles the creation of platform-specific classes (e.g., `createPlatformInAppWebViewController`). +- **Unsupported Features**: If a feature is NOT supported on a specific platform, you must still implement the creation method in `inappwebview_platform.dart`. Return an instance of a private empty class (e.g., `class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig`) that extends the platform interface class. This ensures `isClassSupported`, `isPropertySupported`, `isMethodSupported` static methods works correctly via the `@SupportedPlatforms` annotation. +- **Extending Params**: Platform implementations should extend `Platform*CreationParams` (e.g., `AndroidInAppWebViewWidgetCreationParams` extends `PlatformInAppWebViewWidgetCreationParams`) to add platform-specific fields. +- **Platform Views**: + - **Android**: Uses `PlatformViewLink` and `AndroidViewSurface` (or `AndroidView` for simple cases) to render native views. + - **iOS**: Uses `UiKitView`. +- **Method Channels**: Use `MethodChannel` for communication between Dart and native code, but ensure it's encapsulated within the platform implementation classes. + +## Testing & Validation +- **Run Tests**: Run `flutter test` inside the relevant package before suggesting changes. +- **Analyze**: For analyzer-only updates, run `dart analyze` and ensure `analysis_options.yaml` lints stay satisfied. +- **Contract Updates**: When touching `platform_interface` contracts, explicitly explain how downstream packages must be updated and list the follow-up steps. + +## Documentation & Examples +- **Update Docs**: Update `README.md`, `doc/`, or example apps when you expose new public APIs. +- **Snippets**: Show simple snippets that exercise the new API on supported platforms only. +- **Changelog**: Keep changelog entries scoped under the correct package (e.g., `flutter_inappwebview/CHANGELOG.md`). + +## Pull Request Tips +- **Title**: Reference the federated package you changed in the PR title (e.g., `[flutter_inappwebview] Add PrintJobController helpers`). +- **Testing Instructions**: Call out any manual steps required for testers (running example app, enabling permissions, etc.). +- **Platform Parity**: Mention unsupported platforms explicitly instead of assuming parity. + From 13b78b0a330964e0f3eeeca259a2bd28f5180b4f Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 5 Dec 2025 00:29:48 +0100 Subject: [PATCH 162/181] added supported platform for webview environment and storage APIs --- .github/copilot-instructions.md | 96 ++ .../lib/src/web_storage/web_storage.dart | 49 + .../src/web_storage/web_storage_manager.dart | 11 + .../webview_environment.dart | 17 + .../lib/src/inappwebview_platform.dart | 57 ++ .../lib/src/web_storage/main.dart | 2 +- .../src/web_storage/web_storage_manager.dart | 15 +- .../lib/src/inappwebview_platform.dart | 57 ++ .../lib/src/web_storage/main.dart | 2 +- .../src/web_storage/web_storage_manager.dart | 15 +- .../lib/src/inappwebview_platform.dart | 57 ++ .../lib/src/web_storage/main.dart | 2 +- .../src/web_storage/web_storage_manager.dart | 15 +- .../lib/src/inappwebview_platform.dart | 38 +- .../src/web_storage/platform_web_storage.dart | 606 +++++++++++-- .../web_storage/platform_web_storage.g.dart | 857 ++++++++++++++++++ .../platform_web_storage_manager.dart | 189 +++- .../platform_web_storage_manager.g.dart | 198 ++++ .../platform_webview_environment.dart | 165 +++- .../platform_webview_environment.g.dart | 273 ++++++ .../lib/src/inappwebview_platform.dart | 102 +++ .../lib/src/inappwebview_platform.dart | 49 + .../lib/src/web_storage/main.dart | 2 +- .../src/web_storage/web_storage_manager.dart | 15 +- 24 files changed, 2726 insertions(+), 163 deletions(-) create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.g.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage_manager.g.dart create mode 100644 flutter_inappwebview_platform_interface/lib/src/webview_environment/platform_webview_environment.g.dart diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 778f61558..2aa555d3b 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -41,9 +41,84 @@ This repository follows the **Federated Plugin** architecture: - `apiUrl`: URL to the official native documentation. - `note`: Special notes or restrictions. - **Support Checks**: Implement support-check helpers (`isClassSupported`, `isPropertySupported`, `isMethodSupported`) by deferring to the `platform_interface` static singleton (`PlatformX.static()`). +- **Static-only Helpers**: If a class only exposes static helpers (no instance properties/methods), you can skip overriding `isPropertySupported`/`isMethodSupported` altogether; make sure the public wrapper still calls the static singleton when exposing support checks. - **Enums & Types**: Keep enums for methods/properties in the `platform_interface` package. The public package should use simple passthrough helpers. - **Propagation Order**: Add or change APIs in `flutter_inappwebview_platform_interface` first, then update every `flutter_inappwebview_` implementation, and finally wire the public `flutter_inappwebview` wrapper. Each touched package needs an aligned changelog entry. +### Supported Platforms Pattern +When implementing a new platform interface class (e.g., `PlatformWebViewEnvironment`), follow this strict pattern to ensure correct documentation generation and runtime support checks: + +1. **Creation Params Class (`Platform*CreationParams`)**: + - Define the property documentation using `{@template ...}`. + - Apply the `@SupportedPlatforms` annotation to the property here. + - Implement `isClassSupported`, implement `isPropertySupported` if the class has properties, and `isMethodSupported` if the class has methods. + - **Crucial**: `isPropertySupported` must accept `dynamic property` and check if the property name exists in the `CreationParams` class first. + + ```dart + @SupportedPlatforms(platforms: [WindowsPlatform()]) + @immutable + class PlatformWebViewEnvironmentCreationParams { + const PlatformWebViewEnvironmentCreationParams({this.settings}); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.settings} + /// WebView Environment settings. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.settings.supported_platforms} + @SupportedPlatforms(platforms: [WindowsPlatform()]) + final WebViewEnvironmentSettings? settings; + + bool isClassSupported({TargetPlatform? platform}) => + PlatformWebViewEnvironment.isClassSupported(platform: platform); + + bool isPropertySupported(dynamic property, {TargetPlatform? platform}) => + PlatformWebViewEnvironment.isPropertySupported(property, platform: platform); + } + ``` + +2. **Main Interface Class (`Platform*`)**: + - Use `{@macro ...}` to reuse the documentation from `CreationParams`. + - **Do NOT** repeat `@SupportedPlatforms` on the getters/properties in this class. The macro will pull the supported platforms documentation. + - Implement `isClassSupported`, `isPropertySupported`, and `isMethodSupported` instance methods (which are called by the static singleton). + - **Crucial**: `isPropertySupported` and `isMethodSupported` should ONLY be implemented if the class actually has properties or methods to check. If the class has no properties, do not implement `isPropertySupported`. If it has no methods, do not implement `isMethodSupported`. + - **Crucial**: `isPropertySupported` must handle both `CreationParams` properties and the class's own properties (using the generated `*CreationParamsProperty` and `*PropertySupported` classes). + - **Crucial**: `isMethodSupported` delegates to the generated `_Platform*MethodSupported` class. + - **Reference Implementations**: `PlatformPrintJobController` shows the full property+method pattern, `PlatformFindInteractionController` shows params-only property forwarding, and `PlatformCookieManager` mixes environment-specific params with method support. + + ```dart + @SupportedPlatforms(platforms: [WindowsPlatform()]) + abstract class PlatformWebViewEnvironment extends PlatformInterface implements Disposable { + // ... factory constructors ... + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.settings} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.settings.supported_platforms} + WebViewEnvironmentSettings? get settings => params.settings; + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + params.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported(dynamic property, {TargetPlatform? platform}) => + property is PlatformWebViewEnvironmentCreationParamsProperty + ? params.isPropertySupported(property, platform: platform) + : _PlatformWebViewEnvironmentPropertySupported.isPropertySupported( + property, + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformWebViewEnvironmentMethod method, + {TargetPlatform? platform}) => + _PlatformWebViewEnvironmentMethodSupported.isMethodSupported(method, + platform: platform); + } + ``` + ### Platform Implementations - **`inappwebview_platform.dart`**: This file in each platform package implements `InAppWebViewPlatform` and handles the creation of platform-specific classes (e.g., `createPlatformInAppWebViewController`). - **Unsupported Features**: If a feature is NOT supported on a specific platform, you must still implement the creation method in `inappwebview_platform.dart`. Return an instance of a private empty class (e.g., `class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig`) that extends the platform interface class. This ensures `isClassSupported`, `isPropertySupported`, `isMethodSupported` static methods works correctly via the `@SupportedPlatforms` annotation. @@ -53,6 +128,15 @@ This repository follows the **Federated Plugin** architecture: - **iOS**: Uses `UiKitView`. - **Method Channels**: Use `MethodChannel` for communication between Dart and native code, but ensure it's encapsulated within the platform implementation classes. +### Feature Update Checklist +1. Update or add the contract inside `flutter_inappwebview_platform_interface`. +2. Run `npm run build` (or the equivalent `build_runner` command) to regenerate annotated files. +3. Mirror the new contract in every federated implementation under `flutter_inappwebview_/lib/src/inappwebview_platform.dart` (returning stub implementations for unsupported platforms). +4. Wire the public API in `flutter_inappwebview/` (controllers, widgets, helpers) and update the example app if the feature is user-facing. +5. Add or update tests/analyzer coverage where possible. +6. Update documentation (README, docs site) and add changelog entries for every package you touched (interface, each platform, public plugin, etc.). +7. Re-run `dart analyze`/`flutter test` in the affected packages before sending the PR. + ## Testing & Validation - **Run Tests**: Run `flutter test` inside the relevant package before suggesting changes. - **Analyze**: For analyzer-only updates, run `dart analyze` and ensure `analysis_options.yaml` lints stay satisfied. @@ -62,9 +146,21 @@ This repository follows the **Federated Plugin** architecture: - **Update Docs**: Update `README.md`, `doc/`, or example apps when you expose new public APIs. - **Snippets**: Show simple snippets that exercise the new API on supported platforms only. - **Changelog**: Keep changelog entries scoped under the correct package (e.g., `flutter_inappwebview/CHANGELOG.md`). + - If a change spans multiple packages, add a short entry to each relevant `CHANGELOG.md` so consumers of standalone packages understand what changed. ## Pull Request Tips - **Title**: Reference the federated package you changed in the PR title (e.g., `[flutter_inappwebview] Add PrintJobController helpers`). - **Testing Instructions**: Call out any manual steps required for testers (running example app, enabling permissions, etc.). - **Platform Parity**: Mention unsupported platforms explicitly instead of assuming parity. +## NPM Scripts + +The root `package.json` contains useful scripts for development and maintenance: + +- **`npm run build`**: Runs `build_runner build` in `flutter_inappwebview_platform_interface`. Use this when you change code that requires generation (e.g., `*.g.dart` files). +- **`npm run watch`**: Runs `build_runner watch` in `flutter_inappwebview_platform_interface`. +- **`npm run format`**: Formats code in all packages using `dart format`. +- **`npm run docs:gen`**: Generates API documentation. +- **`npm run docs:serve`**: Serves the generated API documentation locally. +- **`npm run publish:dry`**: Runs a dry-run publish check. + diff --git a/flutter_inappwebview/lib/src/web_storage/web_storage.dart b/flutter_inappwebview/lib/src/web_storage/web_storage.dart index 72a02e2ec..ede545a99 100644 --- a/flutter_inappwebview/lib/src/web_storage/web_storage.dart +++ b/flutter_inappwebview/lib/src/web_storage/web_storage.dart @@ -1,3 +1,4 @@ +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; import '../in_app_webview/in_app_webview_controller.dart'; @@ -26,6 +27,22 @@ class WebStorage { /// Implementation of [PlatformWebStorage] for the current platform. final PlatformWebStorage platform; + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isClassSupported({TargetPlatform? platform}) => + PlatformWebStorage.static().isClassSupported(platform: platform); + + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported(dynamic property, + {TargetPlatform? platform}) => + PlatformWebStorage.static() + .isPropertySupported(property, platform: platform); + + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isMethodSupported(PlatformWebStorageMethod method, + {TargetPlatform? platform}) => + PlatformWebStorage.static() + .isMethodSupported(method, platform: platform); + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage.localStorage} LocalStorage get localStorage => LocalStorage.fromPlatform(platform: platform.localStorage); @@ -103,6 +120,22 @@ class LocalStorage extends Storage { /// Implementation of [PlatformLocalStorage] for the current platform. final PlatformLocalStorage platform; + + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isClassSupported({TargetPlatform? platform}) => + PlatformLocalStorage.static().isClassSupported(platform: platform); + + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported(PlatformStorageCreationParamsProperty property, + {TargetPlatform? platform}) => + PlatformLocalStorage.static() + .isPropertySupported(property, platform: platform); + + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isMethodSupported(PlatformLocalStorageMethod method, + {TargetPlatform? platform}) => + PlatformLocalStorage.static() + .isMethodSupported(method, platform: platform); } ///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage} @@ -129,4 +162,20 @@ class SessionStorage extends Storage { /// Implementation of [PlatformSessionStorage] for the current platform. final PlatformSessionStorage platform; + + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isClassSupported({TargetPlatform? platform}) => + PlatformSessionStorage.static().isClassSupported(platform: platform); + + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isPropertySupported(PlatformStorageCreationParamsProperty property, + {TargetPlatform? platform}) => + PlatformSessionStorage.static() + .isPropertySupported(property, platform: platform); + + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isMethodSupported(PlatformSessionStorageMethod method, + {TargetPlatform? platform}) => + PlatformSessionStorage.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview/lib/src/web_storage/web_storage_manager.dart b/flutter_inappwebview/lib/src/web_storage/web_storage_manager.dart index 1f33de95a..3d80dee8f 100755 --- a/flutter_inappwebview/lib/src/web_storage/web_storage_manager.dart +++ b/flutter_inappwebview/lib/src/web_storage/web_storage_manager.dart @@ -1,5 +1,6 @@ import 'dart:async'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; import 'android/web_storage_manager.dart'; @@ -28,6 +29,16 @@ class WebStorageManager { static WebStorageManager? _instance; + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isClassSupported({TargetPlatform? platform}) => + PlatformWebStorageManager.static().isClassSupported(platform: platform); + + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + static bool isMethodSupported(PlatformWebStorageManagerMethod method, + {TargetPlatform? platform}) => + PlatformWebStorageManager.static() + .isMethodSupported(method, platform: platform); + ///Use [WebStorageManager] instead. @Deprecated("Use WebStorageManager instead") AndroidWebStorageManager android = AndroidWebStorageManager(); diff --git a/flutter_inappwebview/lib/src/webview_environment/webview_environment.dart b/flutter_inappwebview/lib/src/webview_environment/webview_environment.dart index 141804c37..eae6b50b6 100644 --- a/flutter_inappwebview/lib/src/webview_environment/webview_environment.dart +++ b/flutter_inappwebview/lib/src/webview_environment/webview_environment.dart @@ -1,5 +1,6 @@ import 'dart:core'; +import 'package:flutter/foundation.dart'; import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_platform_interface.dart'; ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment} @@ -78,4 +79,20 @@ class WebViewEnvironment { ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose} Future dispose() => platform.dispose(); + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.isClassSupported} + static bool isClassSupported({TargetPlatform? platform}) => + PlatformWebViewEnvironment.static().isClassSupported(platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.isPropertySupported} + static bool isPropertySupported(dynamic property, + {TargetPlatform? platform}) => + PlatformWebViewEnvironment.static() + .isPropertySupported(property, platform: platform); + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.isMethodSupported} + static bool isMethodSupported(PlatformWebViewEnvironmentMethod method, + {TargetPlatform? platform}) => + PlatformWebViewEnvironment.static() + .isMethodSupported(method, platform: platform); } diff --git a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart index 03ff3ad04..b818f607f 100644 --- a/flutter_inappwebview_android/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_android/lib/src/inappwebview_platform.dart @@ -218,6 +218,17 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidWebStorage(params); } + /// Creates a new empty [AndroidWebStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorage] in `flutter_inappwebview` instead. + @override + AndroidWebStorage createPlatformWebStorageStatic() { + return AndroidWebStorage(AndroidWebStorageCreationParams( + localStorage: createPlatformLocalStorageStatic(), + sessionStorage: createPlatformSessionStorageStatic())); + } + /// Creates a new [AndroidLocalStorage]. /// /// This function should only be called by the app-facing package. @@ -229,6 +240,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidLocalStorage(params); } + /// Creates a new empty [AndroidLocalStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [LocalStorage] in `flutter_inappwebview` instead. + @override + AndroidLocalStorage createPlatformLocalStorageStatic() { + return AndroidLocalStorage.defaultStorage(controller: null); + } + /// Creates a new [AndroidSessionStorage]. /// /// This function should only be called by the app-facing package. @@ -240,6 +260,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidSessionStorage(params); } + /// Creates a new empty [AndroidSessionStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [SessionStorage] in `flutter_inappwebview` instead. + @override + AndroidSessionStorage createPlatformSessionStorageStatic() { + return AndroidSessionStorage.defaultStorage(controller: null); + } + /// Creates a new [AndroidHeadlessInAppWebView]. /// /// This function should only be called by the app-facing package. @@ -475,6 +504,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { return AndroidWebStorageManager(params); } + /// Creates a new empty [AndroidWebStorageManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorageManager] in `flutter_inappwebview` instead. + @override + AndroidWebStorageManager createPlatformWebStorageManagerStatic() { + return AndroidWebStorageManager.static(); + } + // ************************************************************************ // // Create static instances of unsupported classes to be able to call // // isClassSupported, isMethodSupported, isPropertySupported, etc. // @@ -482,6 +520,15 @@ class AndroidInAppWebViewPlatform extends InAppWebViewPlatform { // exception. // // ************************************************************************ // + /// Creates a new empty [PlatformWebViewEnvironment] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewEnvironment] in `flutter_inappwebview` instead. + @override + PlatformWebViewEnvironment createPlatformWebViewEnvironmentStatic() { + return _PlatformWebViewEnvironment.static(); + } + /// Creates a new empty [PlatformWebAuthenticationSession] to access static methods. /// /// This function should only be called by the app-facing package. @@ -505,3 +552,13 @@ class _PlatformWebAuthenticationSession factory _PlatformWebAuthenticationSession.static() => _staticValue; } + +class _PlatformWebViewEnvironment extends PlatformWebViewEnvironment { + _PlatformWebViewEnvironment(PlatformWebViewEnvironmentCreationParams params) + : super.implementation(params); + static final _PlatformWebViewEnvironment _staticValue = + _PlatformWebViewEnvironment( + const PlatformWebViewEnvironmentCreationParams()); + + factory _PlatformWebViewEnvironment.static() => _staticValue; +} diff --git a/flutter_inappwebview_android/lib/src/web_storage/main.dart b/flutter_inappwebview_android/lib/src/web_storage/main.dart index 7265ae52c..dab327ba6 100644 --- a/flutter_inappwebview_android/lib/src/web_storage/main.dart +++ b/flutter_inappwebview_android/lib/src/web_storage/main.dart @@ -1,2 +1,2 @@ export 'web_storage.dart'; -export 'web_storage_manager.dart' hide InternalWebStorageManager; +export 'web_storage_manager.dart'; diff --git a/flutter_inappwebview_android/lib/src/web_storage/web_storage_manager.dart b/flutter_inappwebview_android/lib/src/web_storage/web_storage_manager.dart index d5fc4562d..e3723e6c1 100755 --- a/flutter_inappwebview_android/lib/src/web_storage/web_storage_manager.dart +++ b/flutter_inappwebview_android/lib/src/web_storage/web_storage_manager.dart @@ -39,7 +39,7 @@ class AndroidWebStorageManager extends PlatformWebStorageManager ) { channel = const MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_webstoragemanager'); - handler = handleMethod; + handler = _handleMethod; initMethodCallHandler(); } @@ -56,6 +56,15 @@ class AndroidWebStorageManager extends PlatformWebStorageManager return _instance!; } + static AndroidWebStorageManager? _static; + + /// Provide static access. + factory AndroidWebStorageManager.static() { + _static ??= AndroidWebStorageManager(AndroidWebStorageManagerCreationParams( + const PlatformWebStorageManagerCreationParams())); + return _static!; + } + Future _handleMethod(MethodCall call) async {} @override @@ -110,7 +119,3 @@ class AndroidWebStorageManager extends PlatformWebStorageManager // empty } } - -extension InternalWebStorageManager on AndroidWebStorageManager { - get handleMethod => _handleMethod; -} diff --git a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart index 3ce86ba32..bb71d9e51 100644 --- a/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_ios/lib/src/inappwebview_platform.dart @@ -213,6 +213,17 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSWebStorage(params); } + /// Creates a new empty [IOSWebStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorage] in `flutter_inappwebview` instead. + @override + IOSWebStorage createPlatformWebStorageStatic() { + return IOSWebStorage(IOSWebStorageCreationParams( + localStorage: createPlatformLocalStorageStatic(), + sessionStorage: createPlatformSessionStorageStatic())); + } + /// Creates a new [IOSLocalStorage]. /// /// This function should only be called by the app-facing package. @@ -224,6 +235,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSLocalStorage(params); } + /// Creates a new empty [IOSLocalStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [LocalStorage] in `flutter_inappwebview` instead. + @override + IOSLocalStorage createPlatformLocalStorageStatic() { + return IOSLocalStorage.defaultStorage(controller: null); + } + /// Creates a new [IOSSessionStorage]. /// /// This function should only be called by the app-facing package. @@ -235,6 +255,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSSessionStorage(params); } + /// Creates a new empty [IOSSessionStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [SessionStorage] in `flutter_inappwebview` instead. + @override + IOSSessionStorage createPlatformSessionStorageStatic() { + return IOSSessionStorage.defaultStorage(controller: null); + } + /// Creates a new [IOSHeadlessInAppWebView]. /// /// This function should only be called by the app-facing package. @@ -326,6 +355,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { return IOSWebStorageManager(params); } + /// Creates a new empty [IOSWebStorageManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorageManager] in `flutter_inappwebview` instead. + @override + IOSWebStorageManager createPlatformWebStorageManagerStatic() { + return IOSWebStorageManager.static(); + } + /// Creates a new [IOSWebAuthenticationSession]. /// /// This function should only be called by the app-facing package. @@ -371,6 +409,15 @@ class IOSInAppWebViewPlatform extends InAppWebViewPlatform { // exception. // // ************************************************************************ // + /// Creates a new empty [PlatformWebViewEnvironment] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewEnvironment] in `flutter_inappwebview` instead. + @override + PlatformWebViewEnvironment createPlatformWebViewEnvironmentStatic() { + return _PlatformWebViewEnvironment.static(); + } + /// Creates a new empty [PlatformProcessGlobalConfig] to access static methods. /// /// This function should only be called by the app-facing package. @@ -433,3 +480,13 @@ class _PlatformTracingController extends PlatformTracingController { factory _PlatformTracingController.static() => _staticValue; } + +class _PlatformWebViewEnvironment extends PlatformWebViewEnvironment { + _PlatformWebViewEnvironment(PlatformWebViewEnvironmentCreationParams params) + : super.implementation(params); + static final _PlatformWebViewEnvironment _staticValue = + _PlatformWebViewEnvironment( + const PlatformWebViewEnvironmentCreationParams()); + + factory _PlatformWebViewEnvironment.static() => _staticValue; +} diff --git a/flutter_inappwebview_ios/lib/src/web_storage/main.dart b/flutter_inappwebview_ios/lib/src/web_storage/main.dart index 7265ae52c..dab327ba6 100644 --- a/flutter_inappwebview_ios/lib/src/web_storage/main.dart +++ b/flutter_inappwebview_ios/lib/src/web_storage/main.dart @@ -1,2 +1,2 @@ export 'web_storage.dart'; -export 'web_storage_manager.dart' hide InternalWebStorageManager; +export 'web_storage_manager.dart'; diff --git a/flutter_inappwebview_ios/lib/src/web_storage/web_storage_manager.dart b/flutter_inappwebview_ios/lib/src/web_storage/web_storage_manager.dart index bb259cc3f..7bc9d9700 100755 --- a/flutter_inappwebview_ios/lib/src/web_storage/web_storage_manager.dart +++ b/flutter_inappwebview_ios/lib/src/web_storage/web_storage_manager.dart @@ -39,7 +39,7 @@ class IOSWebStorageManager extends PlatformWebStorageManager ) { channel = const MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_webstoragemanager'); - handler = handleMethod; + handler = _handleMethod; initMethodCallHandler(); } @@ -56,6 +56,15 @@ class IOSWebStorageManager extends PlatformWebStorageManager return _instance!; } + static IOSWebStorageManager? _static; + + /// Provide static access. + factory IOSWebStorageManager.static() { + _static ??= IOSWebStorageManager(IOSWebStorageManagerCreationParams( + const PlatformWebStorageManagerCreationParams())); + return _static!; + } + Future _handleMethod(MethodCall call) async {} @override @@ -128,7 +137,3 @@ class IOSWebStorageManager extends PlatformWebStorageManager // empty } } - -extension InternalWebStorageManager on IOSWebStorageManager { - get handleMethod => _handleMethod; -} diff --git a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart index c4e4ab6af..fd15d5dd0 100644 --- a/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_macos/lib/src/inappwebview_platform.dart @@ -202,6 +202,17 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSWebStorage(params); } + /// Creates a new empty [MacOSWebStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorage] in `flutter_inappwebview` instead. + @override + MacOSWebStorage createPlatformWebStorageStatic() { + return MacOSWebStorage(MacOSWebStorageCreationParams( + localStorage: createPlatformLocalStorageStatic(), + sessionStorage: createPlatformSessionStorageStatic())); + } + /// Creates a new [MacOSLocalStorage]. /// /// This function should only be called by the app-facing package. @@ -213,6 +224,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSLocalStorage(params); } + /// Creates a new empty [MacOSLocalStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [LocalStorage] in `flutter_inappwebview` instead. + @override + MacOSLocalStorage createPlatformLocalStorageStatic() { + return MacOSLocalStorage.defaultStorage(controller: null); + } + /// Creates a new [MacOSSessionStorage]. /// /// This function should only be called by the app-facing package. @@ -224,6 +244,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSSessionStorage(params); } + /// Creates a new empty [MacOSSessionStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [SessionStorage] in `flutter_inappwebview` instead. + @override + MacOSSessionStorage createPlatformSessionStorageStatic() { + return MacOSSessionStorage.defaultStorage(controller: null); + } + /// Creates a new [MacOSHeadlessInAppWebView]. /// /// This function should only be called by the app-facing package. @@ -295,6 +324,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { return MacOSWebStorageManager(params); } + /// Creates a new empty [MacOSWebStorageManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorageManager] in `flutter_inappwebview` instead. + @override + MacOSWebStorageManager createPlatformWebStorageManagerStatic() { + return MacOSWebStorageManager.static(); + } + /// Creates a new [MacOSWebAuthenticationSession]. /// /// This function should only be called by the app-facing package. @@ -340,6 +378,15 @@ class MacOSInAppWebViewPlatform extends InAppWebViewPlatform { // exception. // // ************************************************************************ // + /// Creates a new empty [PlatformWebViewEnvironment] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewEnvironment] in `flutter_inappwebview` instead. + @override + PlatformWebViewEnvironment createPlatformWebViewEnvironmentStatic() { + return _PlatformWebViewEnvironment.static(); + } + /// Creates a new empty [PlatformChromeSafariBrowser] to access static methods. /// /// This function should only be called by the app-facing package. @@ -432,3 +479,13 @@ class _PlatformPullToRefreshController extends PlatformPullToRefreshController { factory _PlatformPullToRefreshController.static() => _staticValue; } + +class _PlatformWebViewEnvironment extends PlatformWebViewEnvironment { + _PlatformWebViewEnvironment(PlatformWebViewEnvironmentCreationParams params) + : super.implementation(params); + static final _PlatformWebViewEnvironment _staticValue = + _PlatformWebViewEnvironment( + const PlatformWebViewEnvironmentCreationParams()); + + factory _PlatformWebViewEnvironment.static() => _staticValue; +} diff --git a/flutter_inappwebview_macos/lib/src/web_storage/main.dart b/flutter_inappwebview_macos/lib/src/web_storage/main.dart index 7265ae52c..dab327ba6 100644 --- a/flutter_inappwebview_macos/lib/src/web_storage/main.dart +++ b/flutter_inappwebview_macos/lib/src/web_storage/main.dart @@ -1,2 +1,2 @@ export 'web_storage.dart'; -export 'web_storage_manager.dart' hide InternalWebStorageManager; +export 'web_storage_manager.dart'; diff --git a/flutter_inappwebview_macos/lib/src/web_storage/web_storage_manager.dart b/flutter_inappwebview_macos/lib/src/web_storage/web_storage_manager.dart index b281f0d76..342f8fc43 100755 --- a/flutter_inappwebview_macos/lib/src/web_storage/web_storage_manager.dart +++ b/flutter_inappwebview_macos/lib/src/web_storage/web_storage_manager.dart @@ -39,7 +39,7 @@ class MacOSWebStorageManager extends PlatformWebStorageManager ) { channel = const MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_webstoragemanager'); - handler = handleMethod; + handler = _handleMethod; initMethodCallHandler(); } @@ -56,6 +56,15 @@ class MacOSWebStorageManager extends PlatformWebStorageManager return _instance!; } + static MacOSWebStorageManager? _static; + + /// Provide static access. + factory MacOSWebStorageManager.static() { + _static ??= MacOSWebStorageManager(MacOSWebStorageManagerCreationParams( + const PlatformWebStorageManagerCreationParams())); + return _static!; + } + Future _handleMethod(MethodCall call) async {} @override @@ -128,7 +137,3 @@ class MacOSWebStorageManager extends PlatformWebStorageManager // empty } } - -extension InternalWebStorageManager on MacOSWebStorageManager { - get handleMethod => _handleMethod; -} diff --git a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart index c1ed36a55..30bda1efa 100644 --- a/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_platform_interface/lib/src/inappwebview_platform.dart @@ -266,6 +266,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformWebStorage is not implemented on the current platform.'); } + /// Creates a new empty [PlatformWebStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorage] in `flutter_inappwebview` instead. + PlatformWebStorage createPlatformWebStorageStatic() { + throw UnimplementedError( + 'createPlatformWebStorageStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformLocalStorage]. /// /// This function should only be called by the app-facing package. @@ -277,6 +286,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformLocalStorage is not implemented on the current platform.'); } + /// Creates a new empty [PlatformLocalStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [LocalStorage] in `flutter_inappwebview` instead. + PlatformLocalStorage createPlatformLocalStorageStatic() { + throw UnimplementedError( + 'createPlatformLocalStorageStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformSessionStorage]. /// /// This function should only be called by the app-facing package. @@ -288,6 +306,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformSessionStorage is not implemented on the current platform.'); } + /// Creates a new empty [PlatformSessionStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [PlatformSessionStorage] in `flutter_inappwebview` instead. + PlatformSessionStorage createPlatformSessionStorageStatic() { + throw UnimplementedError( + 'createPlatformSessionStorageStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformHeadlessInAppWebView]. /// /// This function should only be called by the app-facing package. @@ -311,7 +338,7 @@ abstract class InAppWebViewPlatform extends PlatformInterface { /// Creates a new [PlatformWebStorageManager]. /// /// This function should only be called by the app-facing package. - /// Look at using [CookieManager] in `flutter_inappwebview` instead. + /// Look at using [WebStorageManager] in `flutter_inappwebview` instead. PlatformWebStorageManager createPlatformWebStorageManager( PlatformWebStorageManagerCreationParams params, ) { @@ -319,6 +346,15 @@ abstract class InAppWebViewPlatform extends PlatformInterface { 'createPlatformWebStorageManager is not implemented on the current platform.'); } + /// Creates a new empty [PlatformWebStorageManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorageManager] in `flutter_inappwebview` instead. + PlatformWebStorageManager createPlatformWebStorageManagerStatic() { + throw UnimplementedError( + 'createPlatformWebStorageManagerStatic is not implemented on the current platform.'); + } + /// Creates a new [PlatformHttpAuthCredentialDatabase]. /// /// This function should only be called by the app-facing package. diff --git a/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.dart b/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.dart index dcd40e254..067e80f46 100644 --- a/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.dart @@ -1,4 +1,5 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:flutter_inappwebview_platform_interface/src/types/disposable.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; @@ -7,10 +8,27 @@ import '../inappwebview_platform.dart'; import '../types/main.dart'; import 'web_storage_item.dart'; +part 'platform_web_storage.g.dart'; + +/// Object specifying creation parameters for creating a [PlatformWebStorage]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +///{@template flutter_inappwebview_platform_interface.PlatformWebStorageCreationParams} /// Object specifying creation parameters for creating a [PlatformWebStorage]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() +]) @immutable class PlatformWebStorageCreationParams { /// Used by the platform implementation to create a new [PlatformWebStorage]. @@ -18,23 +36,58 @@ class PlatformWebStorageCreationParams { {required this.localStorage, required this.sessionStorage}); ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage.localStorage} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage.localStorage.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) final PlatformLocalStorage localStorage; ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage.sessionStorage} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage.sessionStorage.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) final PlatformSessionStorage sessionStorage; + + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebStorageCreationParamsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageCreationParams.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported(PlatformWebStorageCreationParamsProperty property, + {TargetPlatform? platform}) => + _PlatformWebStorageCreationParamsPropertySupported.isPropertySupported( + property, + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformWebStorage} ///Class that provides access to the JavaScript [Web Storage API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API): `window.sessionStorage` and `window.localStorage`. ///It used by [PlatformInAppWebViewController.webStorage]. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS -///- Web -///- Windows ///{@endtemplate} +///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() +]) abstract class PlatformWebStorage extends PlatformInterface implements Disposable { /// Creates a new [PlatformWebStorage] @@ -52,6 +105,21 @@ abstract class PlatformWebStorage extends PlatformInterface return webStorage; } + /// Creates a new empty [PlatformWebStorage] to access static methods. + factory PlatformWebStorage.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`InAppWebViewPlatform.instance` before use. For unit testing, ' + '`InAppWebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformWebStorage webStorageStatic = + InAppWebViewPlatform.instance!.createPlatformWebStorageStatic(); + PlatformInterface.verify(webStorageStatic, _token); + return webStorageStatic; + } + /// Used by the platform implementation to create a new [PlatformWebStorage]. /// /// Should only be used by platform implementations because they can't extend @@ -67,26 +135,89 @@ abstract class PlatformWebStorage extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformWebStorage.localStorage} ///Represents `window.localStorage`. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage.localStorage.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) PlatformLocalStorage get localStorage => params.localStorage; ///{@template flutter_inappwebview_platform_interface.PlatformWebStorage.sessionStorage} ///Represents `window.sessionStorage`. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage.sessionStorage.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) PlatformSessionStorage get sessionStorage => params.sessionStorage; ///{@template flutter_inappwebview_platform_interface.PlatformWebStorage.dispose} ///Disposes the web storage. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage.dispose.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) void dispose() { throw UnimplementedError( 'dispose is not implemented on the current platform'); } + + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageCreationParams.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebStorageClassSupported.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorage.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported(dynamic property, {TargetPlatform? platform}) => + property is PlatformWebStorageCreationParamsProperty + ? params.isPropertySupported(property, platform: platform) + : _PlatformWebStoragePropertySupported.isPropertySupported(property, + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorage.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformWebStorageMethod method, + {TargetPlatform? platform}) => + _PlatformWebStorageMethodSupported.isMethodSupported(method, + platform: platform); } /// Object specifying creation parameters for creating a [PlatformStorage]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@template flutter_inappwebview_platform_interface.PlatformStorageCreationParams} +/// Object specifying creation parameters for creating a [PlatformStorage]. +/// +/// Platform specific implementations can add additional fields by extending +/// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformStorageCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() +]) @immutable class PlatformStorageCreationParams { /// Used by the platform implementation to create a new [PlatformStorage]. @@ -94,25 +225,81 @@ class PlatformStorageCreationParams { {required this.controller, required this.webStorageType}); ///{@macro flutter_inappwebview_platform_interface.PlatformStorage.controller} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformStorage.controller.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) final PlatformInAppWebViewController? controller; ///{@macro flutter_inappwebview_platform_interface.PlatformStorage.webStorageType} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformStorage.webStorageType.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) final WebStorageType webStorageType; + + ///{@template flutter_inappwebview_platform_interface.PlatformStorageCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformStorageCreationParamsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformStorageCreationParams.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported(PlatformStorageCreationParamsProperty property, + {TargetPlatform? platform}) => + _PlatformStorageCreationParamsPropertySupported.isPropertySupported( + property, + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformStorage} ///Class that provides methods to manage the JavaScript [Storage](https://developer.mozilla.org/en-US/docs/Web/API/Storage) object. ///It is used by [PlatformLocalStorage] and [PlatformSessionStorage]. ///{@endtemplate} +///{@macro flutter_inappwebview_platform_interface.PlatformStorage.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() +]) abstract mixin class PlatformStorage implements Disposable { ///{@template flutter_inappwebview_platform_interface.PlatformStorage.controller} ///Controller used to interact with storage. ///{@endtemplate} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) PlatformInAppWebViewController? get controller; ///{@template flutter_inappwebview_platform_interface.PlatformStorage.webStorageType} ///The web storage type: `window.sessionStorage` or `window.localStorage`. ///{@endtemplate} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) WebStorageType get webStorageType { throw UnimplementedError( 'webStorageType is not implemented on the current platform'); @@ -120,15 +307,16 @@ abstract mixin class PlatformStorage implements Disposable { ///{@template flutter_inappwebview_platform_interface.PlatformStorage.length} ///Returns an integer representing the number of data items stored in the Storage object. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web ///{@endtemplate} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform( + note: + 'This method has an effect only if the iframe has the same origin.'), + WindowsPlatform() + ]) Future length() { throw UnimplementedError( 'length is not implemented on the current platform'); @@ -136,15 +324,16 @@ abstract mixin class PlatformStorage implements Disposable { ///{@template flutter_inappwebview_platform_interface.PlatformStorage.setItem} ///When passed a [key] name and [value], will add that key to the storage, or update that key's value if it already exists. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web ///{@endtemplate} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform( + note: + 'This method has an effect only if the iframe has the same origin.'), + WindowsPlatform() + ]) Future setItem({required String key, required dynamic value}) { throw UnimplementedError( 'setItem is not implemented on the current platform'); @@ -152,15 +341,16 @@ abstract mixin class PlatformStorage implements Disposable { ///{@template flutter_inappwebview_platform_interface.PlatformStorage.getItem} ///When passed a [key] name, will return that key's value, or `null` if the key does not exist, in the given Storage object. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web ///{@endtemplate} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform( + note: + 'This method has an effect only if the iframe has the same origin.'), + WindowsPlatform() + ]) Future getItem({required String key}) { throw UnimplementedError( 'getItem is not implemented on the current platform'); @@ -168,15 +358,16 @@ abstract mixin class PlatformStorage implements Disposable { ///{@template flutter_inappwebview_platform_interface.PlatformStorage.removeItem} ///When passed a [key] name, will remove that key from the given Storage object if it exists. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web ///{@endtemplate} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform( + note: + 'This method has an effect only if the iframe has the same origin.'), + WindowsPlatform() + ]) Future removeItem({required String key}) { throw UnimplementedError( 'removeItem is not implemented on the current platform'); @@ -184,15 +375,16 @@ abstract mixin class PlatformStorage implements Disposable { ///{@template flutter_inappwebview_platform_interface.PlatformStorage.getItems} ///Returns the list of all items from the given Storage object. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web ///{@endtemplate} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform( + note: + 'This method has an effect only if the iframe has the same origin.'), + WindowsPlatform() + ]) Future> getItems() { throw UnimplementedError( 'getItems is not implemented on the current platform'); @@ -200,15 +392,16 @@ abstract mixin class PlatformStorage implements Disposable { ///{@template flutter_inappwebview_platform_interface.PlatformStorage.clear} ///Clears all keys stored in a given Storage object. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web ///{@endtemplate} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform( + note: + 'This method has an effect only if the iframe has the same origin.'), + WindowsPlatform() + ]) Future clear() { throw UnimplementedError( 'clear is not implemented on the current platform'); @@ -217,20 +410,28 @@ abstract mixin class PlatformStorage implements Disposable { ///{@template flutter_inappwebview_platform_interface.PlatformStorage.key} ///When passed a number [index], returns the name of the nth key in a given Storage object. ///The order of keys is user-agent defined, so you should not rely on it. - /// - ///**NOTE for Web**: this method will have effect only if the iframe has the same origin. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView - ///- iOS - ///- MacOS - ///- Web ///{@endtemplate} + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform( + note: + 'This method has an effect only if the iframe has the same origin.'), + WindowsPlatform() + ]) Future key({required int index}) { throw UnimplementedError('key is not implemented on the current platform'); } @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) void dispose() { throw UnimplementedError( 'dispose is not implemented on the current platform'); @@ -242,6 +443,13 @@ abstract mixin class PlatformStorage implements Disposable { /// Platform specific implementations can add additional fields by extending /// this class. @immutable +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() +]) class PlatformLocalStorageCreationParams extends PlatformStorageCreationParams { /// Used by the platform implementation to create a new [PlatformLocalStorage]. PlatformLocalStorageCreationParams( @@ -252,17 +460,32 @@ class PlatformLocalStorageCreationParams extends PlatformStorageCreationParams { controller: params.controller, webStorageType: WebStorageType.LOCAL_STORAGE); - /// Creates a [AndroidCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams]. + /// Creates a [PlatformLocalStorageCreationParams] instance based on [PlatformLocalStorageCreationParams]. factory PlatformLocalStorageCreationParams.fromPlatformStorageCreationParams( PlatformStorageCreationParams params) { return PlatformLocalStorageCreationParams(params); } + + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorageCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformLocalStorageCreationParamsClassSupported.isClassSupported( + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage} ///Class that provides methods to manage the JavaScript `window.localStorage` object. ///It used by [PlatformWebStorage]. ///{@endtemplate} +///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() +]) abstract class PlatformLocalStorage extends PlatformInterface with PlatformStorage { /// Creates a new [PlatformLocalStorage] @@ -280,6 +503,21 @@ abstract class PlatformLocalStorage extends PlatformInterface return localStorage; } + /// Creates a new empty [PlatformLocalStorage] to access static methods. + factory PlatformLocalStorage.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformLocalStorage localStorageStatic = + InAppWebViewPlatform.instance!.createPlatformLocalStorageStatic(); + PlatformInterface.verify(localStorageStatic, _token); + return localStorageStatic; + } + /// Used by the platform implementation to create a new [PlatformLocalStorage]. /// /// Should only be used by platform implementations because they can't extend @@ -294,6 +532,106 @@ abstract class PlatformLocalStorage extends PlatformInterface @override WebStorageType get webStorageType => params.webStorageType; + + ///{@macro flutter_inappwebview_platform_interface.PlatformLocalStorage.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformLocalStorageClassSupported.isClassSupported(platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported(PlatformStorageCreationParamsProperty property, + {TargetPlatform? platform}) => + params.isPropertySupported(property, platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformLocalStorageMethod method, + {TargetPlatform? platform}) => + _PlatformLocalStorageMethodSupported.isMethodSupported(method, + platform: platform); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future length() => super.length(); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future setItem({required String key, required dynamic value}) => + super.setItem(key: key, value: value); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future getItem({required String key}) => super.getItem(key: key); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future removeItem({required String key}) => super.removeItem(key: key); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future> getItems() => super.getItems(); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future clear() => super.clear(); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future key({required int index}) => super.key(index: index); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + void dispose() => super.dispose(); } /// Object specifying creation parameters for creating a [PlatformSessionStorage]. @@ -301,6 +639,13 @@ abstract class PlatformLocalStorage extends PlatformInterface /// Platform specific implementations can add additional fields by extending /// this class. @immutable +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() +]) class PlatformSessionStorageCreationParams extends PlatformStorageCreationParams { /// Used by the platform implementation to create a new [PlatformSessionStorage]. @@ -312,17 +657,32 @@ class PlatformSessionStorageCreationParams controller: params.controller, webStorageType: WebStorageType.SESSION_STORAGE); - /// Creates a [AndroidCookieManagerCreationParams] instance based on [PlatformCookieManagerCreationParams]. + /// Creates a [PlatformSessionStorageCreationParams] instance based on [PlatformStorageCreationParams]. factory PlatformSessionStorageCreationParams.fromPlatformStorageCreationParams( PlatformStorageCreationParams params) { return PlatformSessionStorageCreationParams(params); } + + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorageCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformSessionStorageCreationParamsClassSupported.isClassSupported( + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage} ///Class that provides methods to manage the JavaScript `window.sessionStorage` object. ///It used by [PlatformWebStorage]. ///{@endtemplate} +///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() +]) abstract class PlatformSessionStorage extends PlatformInterface with PlatformStorage { /// Creates a new [PlatformSessionStorage] @@ -340,6 +700,21 @@ abstract class PlatformSessionStorage extends PlatformInterface return sessionStorage; } + /// Creates a new empty [PlatformSessionStorage] to access static methods. + factory PlatformSessionStorage.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformSessionStorage sessionStorageStatic = + InAppWebViewPlatform.instance!.createPlatformSessionStorageStatic(); + PlatformInterface.verify(sessionStorageStatic, _token); + return sessionStorageStatic; + } + /// Used by the platform implementation to create a new [PlatformSessionStorage]. /// /// Should only be used by platform implementations because they can't extend @@ -354,4 +729,105 @@ abstract class PlatformSessionStorage extends PlatformInterface @override WebStorageType get webStorageType => params.webStorageType; + + ///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage.isClassSupported} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformSessionStorageClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported(PlatformStorageCreationParamsProperty property, + {TargetPlatform? platform}) => + params.isPropertySupported(property, platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformSessionStorageMethod method, + {TargetPlatform? platform}) => + _PlatformSessionStorageMethodSupported.isMethodSupported(method, + platform: platform); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future length() => super.length(); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future setItem({required String key, required dynamic value}) => + super.setItem(key: key, value: value); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future getItem({required String key}) => super.getItem(key: key); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future removeItem({required String key}) => super.removeItem(key: key); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future> getItems() => super.getItems(); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future clear() => super.clear(); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + Future key({required int index}) => super.key(index: index); + + @override + @SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(), + MacOSPlatform(), + WebPlatform(), + WindowsPlatform() + ]) + void dispose() => super.dispose(); } diff --git a/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.g.dart b/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.g.dart new file mode 100644 index 000000000..c92dc5893 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage.g.dart @@ -0,0 +1,857 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_web_storage.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformWebStorageCreationParamsClassSupported + on PlatformWebStorageCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformWebStorageCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformWebStorageCreationParams]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformWebStorageCreationParamsProperty { + ///Can be used to check if the [PlatformWebStorageCreationParams.localStorage] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageCreationParams.localStorage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformWebStorageCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + localStorage, + + ///Can be used to check if the [PlatformWebStorageCreationParams.sessionStorage] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageCreationParams.sessionStorage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformWebStorageCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + sessionStorage, +} + +extension _PlatformWebStorageCreationParamsPropertySupported + on PlatformWebStorageCreationParams { + static bool isPropertySupported( + PlatformWebStorageCreationParamsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformWebStorageCreationParamsProperty.localStorage: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformWebStorageCreationParamsProperty.sessionStorage: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformWebStorageClassSupported on PlatformWebStorage { + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformWebStorage.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformWebStorage]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformWebStorageProperty { + ///Can be used to check if the [PlatformWebStorage.localStorage] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorage.localStorage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformWebStorage.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + localStorage, + + ///Can be used to check if the [PlatformWebStorage.sessionStorage] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorage.sessionStorage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformWebStorage.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + sessionStorage, +} + +extension _PlatformWebStoragePropertySupported on PlatformWebStorage { + static bool isPropertySupported(PlatformWebStorageProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformWebStorageProperty.localStorage: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformWebStorageProperty.sessionStorage: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } + } +} + +///List of [PlatformWebStorage]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformWebStorageMethod { + ///Can be used to check if the [PlatformWebStorage.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorage.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformWebStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, +} + +extension _PlatformWebStorageMethodSupported on PlatformWebStorage { + static bool isMethodSupported(PlatformWebStorageMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformWebStorageMethod.dispose: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformStorageCreationParamsClassSupported + on PlatformStorageCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformStorageCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformStorageCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformStorageCreationParams]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformStorageCreationParamsProperty { + ///Can be used to check if the [PlatformStorageCreationParams.controller] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformStorageCreationParams.controller.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformStorageCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + controller, + + ///Can be used to check if the [PlatformStorageCreationParams.webStorageType] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformStorageCreationParams.webStorageType.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformStorageCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + webStorageType, +} + +extension _PlatformStorageCreationParamsPropertySupported + on PlatformStorageCreationParams { + static bool isPropertySupported( + PlatformStorageCreationParamsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformStorageCreationParamsProperty.controller: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformStorageCreationParamsProperty.webStorageType: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformLocalStorageCreationParamsClassSupported + on PlatformLocalStorageCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorageCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformLocalStorageCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } +} + +extension _PlatformLocalStorageClassSupported on PlatformLocalStorage { + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformLocalStorage.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformLocalStorage]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformLocalStorageMethod { + ///Can be used to check if the [PlatformLocalStorage.clear] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.clear.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformLocalStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + clear, + + ///Can be used to check if the [PlatformLocalStorage.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformLocalStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, + + ///Can be used to check if the [PlatformLocalStorage.getItem] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.getItem.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [key]: all platforms + /// + ///Use the [PlatformLocalStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getItem, + + ///Can be used to check if the [PlatformLocalStorage.getItems] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.getItems.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformLocalStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getItems, + + ///Can be used to check if the [PlatformLocalStorage.key] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.key.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [index]: all platforms + /// + ///Use the [PlatformLocalStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + key, + + ///Can be used to check if the [PlatformLocalStorage.length] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.length.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformLocalStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + length, + + ///Can be used to check if the [PlatformLocalStorage.removeItem] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.removeItem.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [key]: all platforms + /// + ///Use the [PlatformLocalStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + removeItem, + + ///Can be used to check if the [PlatformLocalStorage.setItem] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformLocalStorage.setItem.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [key]: all platforms + ///- [value]: all platforms + /// + ///Use the [PlatformLocalStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setItem, +} + +extension _PlatformLocalStorageMethodSupported on PlatformLocalStorage { + static bool isMethodSupported(PlatformLocalStorageMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformLocalStorageMethod.clear: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformLocalStorageMethod.dispose: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformLocalStorageMethod.getItem: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformLocalStorageMethod.getItems: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformLocalStorageMethod.key: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformLocalStorageMethod.length: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformLocalStorageMethod.removeItem: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformLocalStorageMethod.setItem: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformSessionStorageCreationParamsClassSupported + on PlatformSessionStorageCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorageCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformSessionStorageCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } +} + +extension _PlatformSessionStorageClassSupported on PlatformSessionStorage { + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformSessionStorage.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformSessionStorage]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformSessionStorageMethod { + ///Can be used to check if the [PlatformSessionStorage.clear] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.clear.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformSessionStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + clear, + + ///Can be used to check if the [PlatformSessionStorage.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformSessionStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, + + ///Can be used to check if the [PlatformSessionStorage.getItem] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.getItem.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [key]: all platforms + /// + ///Use the [PlatformSessionStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getItem, + + ///Can be used to check if the [PlatformSessionStorage.getItems] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.getItems.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformSessionStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getItems, + + ///Can be used to check if the [PlatformSessionStorage.key] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.key.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [index]: all platforms + /// + ///Use the [PlatformSessionStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + key, + + ///Can be used to check if the [PlatformSessionStorage.length] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.length.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///Use the [PlatformSessionStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + length, + + ///Can be used to check if the [PlatformSessionStorage.removeItem] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.removeItem.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [key]: all platforms + /// + ///Use the [PlatformSessionStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + removeItem, + + ///Can be used to check if the [PlatformSessionStorage.setItem] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformSessionStorage.setItem.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView + ///- macOS WKWebView + ///- Web \ but requires same origin + ///- Windows WebView2 + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [key]: all platforms + ///- [value]: all platforms + /// + ///Use the [PlatformSessionStorage.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + setItem, +} + +extension _PlatformSessionStorageMethodSupported on PlatformSessionStorage { + static bool isMethodSupported(PlatformSessionStorageMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformSessionStorageMethod.clear: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformSessionStorageMethod.dispose: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformSessionStorageMethod.getItem: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformSessionStorageMethod.getItems: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformSessionStorageMethod.key: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformSessionStorageMethod.length: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformSessionStorageMethod.removeItem: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + case PlatformSessionStorageMethod.setItem: + return kIsWeb && platform == null + ? true + : ((kIsWeb && platform != null) || !kIsWeb) && + [ + TargetPlatform.android, + TargetPlatform.iOS, + TargetPlatform.macOS, + TargetPlatform.windows + ].contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage_manager.dart b/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage_manager.dart index 6f2131ed4..fb24cc1cf 100755 --- a/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage_manager.dart +++ b/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage_manager.dart @@ -1,35 +1,62 @@ import 'dart:async'; import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import '../inappwebview_platform.dart'; import '../types/main.dart'; +part 'platform_web_storage_manager.g.dart'; + +///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManagerCreationParams} /// Object specifying creation parameters for creating a [PlatformWebStorageManager]. /// /// Platform specific implementations can add additional fields by extending /// this class. +///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManagerCreationParams.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform(), + IOSPlatform(available: '9.0'), + MacOSPlatform(), +]) @immutable class PlatformWebStorageManagerCreationParams { /// Used by the platform implementation to create a new [PlatformWebStorageManager]. const PlatformWebStorageManagerCreationParams(); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManagerCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebStorageManagerCreationParamsClassSupported.isClassSupported( + platform: platform); } ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager} ///Class that implements a singleton object (shared instance) which manages the web storage used by WebView instances. -///On Android, it is implemented using [WebStorage](https://developer.android.com/reference/android/webkit/WebStorage.html). -///On iOS and MacOS, it is implemented using [WKWebsiteDataStore.default()](https://developer.apple.com/documentation/webkit/wkwebsitedatastore). -/// -///**NOTE for iOS**: available from iOS 9.0+. -/// -///**Officially Supported Platforms/Implementations**: -///- Android native WebView -///- iOS -///- MacOS ///{@endtemplate} +/// +///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager.supported_platforms} +@SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'WebStorage', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebStorage.html'), + IOSPlatform( + apiName: 'WKWebsiteDataStore', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore', + available: '9.0'), + MacOSPlatform( + apiName: 'WKWebsiteDataStore', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore'), +]) abstract class PlatformWebStorageManager extends PlatformInterface { - /// Creates a new [PlatformCookieManager] + /// Creates a new [PlatformWebStorageManager] factory PlatformWebStorageManager( PlatformWebStorageManagerCreationParams params) { assert( @@ -39,10 +66,25 @@ abstract class PlatformWebStorageManager extends PlatformInterface { '`WebViewPlatform.instance` before use. For unit testing, ' '`WebViewPlatform.instance` can be set with your own test implementation.', ); - final PlatformWebStorageManager cookieManager = + final PlatformWebStorageManager webStorageManager = InAppWebViewPlatform.instance!.createPlatformWebStorageManager(params); - PlatformInterface.verify(cookieManager, _token); - return cookieManager; + PlatformInterface.verify(webStorageManager, _token); + return webStorageManager; + } + + /// Creates a new [PlatformWebStorageManager] to access static methods. + factory PlatformWebStorageManager.static() { + assert( + InAppWebViewPlatform.instance != null, + 'A platform implementation for `flutter_inappwebview` has not been set. Please ' + 'ensure that an implementation of `InAppWebViewPlatform` has been set to ' + '`WebViewPlatform.instance` before use. For unit testing, ' + '`WebViewPlatform.instance` can be set with your own test implementation.', + ); + final PlatformWebStorageManager webStorageManagerStatic = + InAppWebViewPlatform.instance!.createPlatformWebStorageManagerStatic(); + PlatformInterface.verify(webStorageManagerStatic, _token); + return webStorageManagerStatic; } /// Used by the platform implementation to create a new @@ -60,10 +102,15 @@ abstract class PlatformWebStorageManager extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.getOrigins} ///Gets the origins currently using either the Application Cache or Web SQL Database APIs. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebStorage.getOrigins](https://developer.android.com/reference/android/webkit/WebStorage#getOrigins(android.webkit.ValueCallback%3Cjava.util.Map%3E))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager.getOrigins.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'WebStorage.getOrigins', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebStorage#getOrigins(android.webkit.ValueCallback%3Cjava.util.Map%3E)') + ]) Future> getOrigins() { throw UnimplementedError( 'getOrigins is not implemented on the current platform'); @@ -72,10 +119,15 @@ abstract class PlatformWebStorageManager extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.deleteAllData} ///Clears all storage currently being used by the JavaScript storage APIs. ///This includes the Application Cache, Web SQL Database and the HTML5 Web Storage APIs. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebStorage.deleteAllData](https://developer.android.com/reference/android/webkit/WebStorage#deleteAllData())) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager.deleteAllData.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'WebStorage.deleteAllData', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebStorage#deleteAllData()') + ]) Future deleteAllData() { throw UnimplementedError( 'deleteAllData is not implemented on the current platform'); @@ -84,10 +136,15 @@ abstract class PlatformWebStorageManager extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.deleteOrigin} ///Clears the storage currently being used by both the Application Cache and Web SQL Database APIs by the given [origin]. ///The origin is specified using its string representation. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebStorage.deleteOrigin](https://developer.android.com/reference/android/webkit/WebStorage#deleteOrigin(java.lang.String))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager.deleteOrigin.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'WebStorage.deleteOrigin', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebStorage#deleteOrigin(java.lang.String)') + ]) Future deleteOrigin({required String origin}) { throw UnimplementedError( 'deleteOrigin is not implemented on the current platform'); @@ -97,10 +154,15 @@ abstract class PlatformWebStorageManager extends PlatformInterface { ///Gets the storage quota for the Web SQL Database API for the given [origin]. ///The quota is given in bytes and the origin is specified using its string representation. ///Note that a quota is not enforced on a per-origin basis for the Application Cache API. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebStorage.getQuotaForOrigin](https://developer.android.com/reference/android/webkit/WebStorage#getQuotaForOrigin(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Long%3E))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager.getQuotaForOrigin.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'WebStorage.getQuotaForOrigin', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebStorage#getQuotaForOrigin(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Long%3E)') + ]) Future getQuotaForOrigin({required String origin}) { throw UnimplementedError( 'getQuotaForOrigin is not implemented on the current platform'); @@ -109,10 +171,15 @@ abstract class PlatformWebStorageManager extends PlatformInterface { ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.getUsageForOrigin} ///Gets the amount of storage currently being used by both the Application Cache and Web SQL Database APIs by the given [origin]. ///The amount is given in bytes and the origin is specified using its string representation. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Android native WebView ([Official API - WebStorage.getUsageForOrigin](https://developer.android.com/reference/android/webkit/WebStorage#getUsageForOrigin(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Long%3E))) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager.getUsageForOrigin.supported_platforms} + @SupportedPlatforms(platforms: [ + AndroidPlatform( + apiName: 'WebStorage.getUsageForOrigin', + apiUrl: + 'https://developer.android.com/reference/android/webkit/WebStorage#getUsageForOrigin(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Long%3E)') + ]) Future getUsageForOrigin({required String origin}) { throw UnimplementedError( 'getUsageForOrigin is not implemented on the current platform'); @@ -122,11 +189,20 @@ abstract class PlatformWebStorageManager extends PlatformInterface { ///Fetches data records containing the given website data types. /// ///[dataTypes] represents the website data types to fetch records for. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebsiteDataStore.fetchDataRecords](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords)) - ///- MacOS ([Official API - WKWebsiteDataStore.fetchDataRecords](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager.fetchDataRecords.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + available: '9.0', + apiName: 'WKWebsiteDataStore.fetchDataRecords', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords'), + MacOSPlatform( + apiName: 'WKWebsiteDataStore.fetchDataRecords', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords'), + ]) Future> fetchDataRecords( {required Set dataTypes}) { throw UnimplementedError( @@ -139,11 +215,20 @@ abstract class PlatformWebStorageManager extends PlatformInterface { ///[dataTypes] represents the website data types that should be removed. /// ///[dataRecords] represents the website data records to delete website data for. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata)) - ///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager.removeDataFor.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + available: '9.0', + apiName: 'WKWebsiteDataStore.removeData', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata'), + MacOSPlatform( + apiName: 'WKWebsiteDataStore.removeData', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata'), + ]) Future removeDataFor( {required Set dataTypes, required List dataRecords}) { @@ -157,14 +242,38 @@ abstract class PlatformWebStorageManager extends PlatformInterface { ///[dataTypes] represents the website data types that should be removed. /// ///[date] represents a date. All website data modified after this date will be removed. - /// - ///**Officially Supported Platforms/Implementations**: - ///- iOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) - ///- MacOS ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorageManager.removeDataModifiedSince.supported_platforms} + @SupportedPlatforms(platforms: [ + IOSPlatform( + available: '9.0', + apiName: 'WKWebsiteDataStore.removeData', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata'), + MacOSPlatform( + apiName: 'WKWebsiteDataStore.removeData', + apiUrl: + 'https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata'), + ]) Future removeDataModifiedSince( {required Set dataTypes, required DateTime date}) { throw UnimplementedError( 'removeDataModifiedSince is not implemented on the current platform'); } + + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebStorageManagerClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformWebStorageManagerMethod method, + {TargetPlatform? platform}) => + _PlatformWebStorageManagerMethodSupported.isMethodSupported(method, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage_manager.g.dart b/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage_manager.g.dart new file mode 100644 index 000000000..3c8f47055 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/web_storage/platform_web_storage_manager.g.dart @@ -0,0 +1,198 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_web_storage_manager.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformWebStorageManagerCreationParamsClassSupported + on PlatformWebStorageManagerCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManagerCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView + ///- iOS WKWebView 9.0+ + ///- macOS WKWebView + /// + ///Use the [PlatformWebStorageManagerCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +extension _PlatformWebStorageManagerClassSupported + on PlatformWebStorageManager { + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebStorage](https://developer.android.com/reference/android/webkit/WebStorage.html)) + ///- iOS WKWebView 9.0+ ([Official API - WKWebsiteDataStore](https://developer.apple.com/documentation/webkit/wkwebsitedatastore)) + ///- macOS WKWebView ([Official API - WKWebsiteDataStore](https://developer.apple.com/documentation/webkit/wkwebsitedatastore)) + /// + ///Use the [PlatformWebStorageManager.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android, TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformWebStorageManager]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformWebStorageManagerMethod { + ///Can be used to check if the [PlatformWebStorageManager.deleteAllData] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.deleteAllData.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebStorage.deleteAllData](https://developer.android.com/reference/android/webkit/WebStorage#deleteAllData())) + /// + ///Use the [PlatformWebStorageManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + deleteAllData, + + ///Can be used to check if the [PlatformWebStorageManager.deleteOrigin] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.deleteOrigin.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebStorage.deleteOrigin](https://developer.android.com/reference/android/webkit/WebStorage#deleteOrigin(java.lang.String))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [origin]: all platforms + /// + ///Use the [PlatformWebStorageManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + deleteOrigin, + + ///Can be used to check if the [PlatformWebStorageManager.fetchDataRecords] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.fetchDataRecords.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 9.0+ ([Official API - WKWebsiteDataStore.fetchDataRecords](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords)) + ///- macOS WKWebView ([Official API - WKWebsiteDataStore.fetchDataRecords](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532932-fetchdatarecords)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [dataTypes]: all platforms + /// + ///Use the [PlatformWebStorageManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + fetchDataRecords, + + ///Can be used to check if the [PlatformWebStorageManager.getOrigins] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.getOrigins.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebStorage.getOrigins](https://developer.android.com/reference/android/webkit/WebStorage#getOrigins(android.webkit.ValueCallback%3Cjava.util.Map%3E))) + /// + ///Use the [PlatformWebStorageManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getOrigins, + + ///Can be used to check if the [PlatformWebStorageManager.getQuotaForOrigin] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.getQuotaForOrigin.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebStorage.getQuotaForOrigin](https://developer.android.com/reference/android/webkit/WebStorage#getQuotaForOrigin(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Long%3E))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [origin]: all platforms + /// + ///Use the [PlatformWebStorageManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getQuotaForOrigin, + + ///Can be used to check if the [PlatformWebStorageManager.getUsageForOrigin] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.getUsageForOrigin.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Android WebView ([Official API - WebStorage.getUsageForOrigin](https://developer.android.com/reference/android/webkit/WebStorage#getUsageForOrigin(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.Long%3E))) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [origin]: all platforms + /// + ///Use the [PlatformWebStorageManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getUsageForOrigin, + + ///Can be used to check if the [PlatformWebStorageManager.removeDataFor] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.removeDataFor.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 9.0+ ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata)) + ///- macOS WKWebView ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532936-removedata)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [dataTypes]: all platforms + ///- [dataRecords]: all platforms + /// + ///Use the [PlatformWebStorageManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + removeDataFor, + + ///Can be used to check if the [PlatformWebStorageManager.removeDataModifiedSince] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebStorageManager.removeDataModifiedSince.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- iOS WKWebView 9.0+ ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) + ///- macOS WKWebView ([Official API - WKWebsiteDataStore.removeData](https://developer.apple.com/documentation/webkit/wkwebsitedatastore/1532938-removedata)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [dataTypes]: all platforms + ///- [date]: all platforms + /// + ///Use the [PlatformWebStorageManager.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + removeDataModifiedSince, +} + +extension _PlatformWebStorageManagerMethodSupported + on PlatformWebStorageManager { + static bool isMethodSupported(PlatformWebStorageManagerMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformWebStorageManagerMethod.deleteAllData: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebStorageManagerMethod.deleteOrigin: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebStorageManagerMethod.fetchDataRecords: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebStorageManagerMethod.getOrigins: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebStorageManagerMethod.getQuotaForOrigin: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebStorageManagerMethod.getUsageForOrigin: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.android] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebStorageManagerMethod.removeDataFor: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebStorageManagerMethod.removeDataModifiedSince: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.iOS, TargetPlatform.macOS] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_platform_interface/lib/src/webview_environment/platform_webview_environment.dart b/flutter_inappwebview_platform_interface/lib/src/webview_environment/platform_webview_environment.dart index 6e4d5e482..5521c1766 100644 --- a/flutter_inappwebview_platform_interface/lib/src/webview_environment/platform_webview_environment.dart +++ b/flutter_inappwebview_platform_interface/lib/src/webview_environment/platform_webview_environment.dart @@ -1,4 +1,5 @@ import 'package:flutter/foundation.dart'; +import 'package:flutter_inappwebview_internal_annotations/flutter_inappwebview_internal_annotations.dart'; import 'package:plugin_platform_interface/plugin_platform_interface.dart'; import '../debug_logging_settings.dart'; @@ -11,24 +12,48 @@ import '../types/browser_process_infos_changed_detail.dart'; import '../types/webview_interface.dart'; import 'webview_environment_settings.dart'; +part 'platform_webview_environment.g.dart'; + /// Object specifying creation parameters for creating a [PlatformWebViewEnvironment]. /// /// Platform specific implementations can add additional fields by extending /// this class. +@SupportedPlatforms(platforms: [WindowsPlatform()]) @immutable class PlatformWebViewEnvironmentCreationParams { /// Used by the platform implementation to create a new [PlatformWebViewEnvironment]. const PlatformWebViewEnvironmentCreationParams({this.settings}); - ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.settings} + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.settings} + /// WebView Environment settings. + ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.settings.supported_platforms} + @SupportedPlatforms(platforms: [WindowsPlatform()]) final WebViewEnvironmentSettings? settings; + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebViewEnvironmentCreationParamsClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isPropertySupported( + PlatformWebViewEnvironmentCreationParamsProperty property, + {TargetPlatform? platform}) => + _PlatformWebViewEnvironmentCreationParamsPropertySupported + .isPropertySupported(property, platform: platform); } ///Controls a WebView Environment used by WebView instances. ///Use [dispose] when not needed anymore to release references. /// -///**Officially Supported Platforms/Implementations**: -///- Windows +///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.supported_platforms} +@SupportedPlatforms(platforms: [WindowsPlatform()]) abstract class PlatformWebViewEnvironment extends PlatformInterface implements Disposable { ///Debug settings used by [PlatformWebViewEnvironment]. @@ -81,22 +106,23 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.id} /// WebView Environment ID. ///{@endtemplate} + @SupportedPlatforms(platforms: [WindowsPlatform()]) String get id => throw UnimplementedError('id is not implemented on the current platform'); - ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.settings} - /// WebView Environment settings. - ///{@endtemplate} + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.settings} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.settings.supported_platforms} WebViewEnvironmentSettings? get settings => params.settings; ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.isInterfaceSupported} ///Returns `true` if the WebView Environment supports the specified [interface], otherwise `false`. ///Only the ones related to [WebViewInterface.ICoreWebView2Environment] are valid interfaces to check; ///otherwise, it will always return `false`. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.isInterfaceSupported.supported_platforms} + @SupportedPlatforms(platforms: [WindowsPlatform()]) Future isInterfaceSupported(WebViewInterface interface) async { throw UnimplementedError( 'isInterfaceSupported is not implemented on the current platform'); @@ -104,10 +130,16 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getProcessInfos} ///Returns a list of all process using same user data folder except for crashpad process. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.1108.44+ ([Official API - ICoreWebView2Environment8.GetProcessInfos](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment8?view=webview2-1.0.2849.39#getprocessinfos)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getProcessInfos.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform( + available: '1.0.1108.44+', + apiName: 'ICoreWebView2Environment8.GetProcessInfos', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment8?view=webview2-1.0.2849.39#getprocessinfos') + ]) Future> getProcessInfos() async { throw UnimplementedError( 'getProcessInfos is not implemented on the current platform'); @@ -126,10 +158,16 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface ///If there are multiple process failures at once, multiple minidump files could be generated. ///Thus [getFailureReportFolderPath] could contain old minidump files that are ///not associated with a specific [PlatformWebViewCreationParams.onProcessFailed] event. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.1518.46+ ([Official API - ICoreWebView2Environment11.get_FailureReportFolderPath](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment11?view=webview2-1.0.2849.39#get_failurereportfolderpath)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getFailureReportFolderPath.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform( + available: '1.0.1518.46+', + apiName: 'ICoreWebView2Environment11.get_FailureReportFolderPath', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment11?view=webview2-1.0.2849.39#get_failurereportfolderpath') + ]) Future getFailureReportFolderPath() async { throw UnimplementedError( 'getFailureReportFolderPath is not implemented on the current platform'); @@ -140,10 +178,15 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface /// ///Check https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions ///for more info. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - CreateCoreWebView2EnvironmentWithOptions](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.create.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform( + apiName: 'CreateCoreWebView2EnvironmentWithOptions', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions') + ]) Future create( {WebViewEnvironmentSettings? settings}) { throw UnimplementedError( @@ -157,10 +200,15 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface ///If an override exists for the browserExecutableFolder or the channel preference, the override is used. ///If an override is not specified, then the parameter value passed to [getAvailableVersion] is used. ///Returns `null` if it fails to find an installed WebView2 runtime or non-stable Microsoft Edge installation. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - GetAvailableCoreWebView2BrowserVersionString](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#comparebrowserversions)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform( + apiName: 'GetAvailableCoreWebView2BrowserVersionString', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#getavailablecorewebview2browserversionstring') + ]) Future getAvailableVersion({String? browserExecutableFolder}) { throw UnimplementedError( 'getAvailableVersion is not implemented on the current platform'); @@ -173,10 +221,15 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface ///Sets the value of result to `-1`, `0` or `1` if version1 is less than, equal or greater than version2 respectively. ///Returns `null` if it fails to parse any of the version strings. ///Directly use the version info obtained from [getAvailableVersion] with input, channel information is ignored. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - CompareBrowserVersions](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#comparebrowserversions)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.compareBrowserVersions.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform( + apiName: 'CompareBrowserVersions', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#comparebrowserversions') + ]) Future compareBrowserVersions( {required String version1, required String version2}) { throw UnimplementedError( @@ -194,10 +247,15 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface ///if you want to use the same user data folder in the WebView using the new version of the browser, ///you must close the environment and instance of WebView that are using the older version of the browser first. ///Or simply prompt the user to restart the app. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows ([Official API - ICoreWebView2Environment.add_NewBrowserVersionAvailable](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment?view=webview2-1.0.2849.39#add_newbrowserversionavailable)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.onNewBrowserVersionAvailable.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform( + apiName: 'ICoreWebView2Environment.add_NewBrowserVersionAvailable', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment?view=webview2-1.0.2849.39#add_newbrowserversionavailable') + ]) void Function()? onNewBrowserVersionAvailable; ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.onBrowserProcessExited} @@ -234,25 +292,66 @@ abstract class PlatformWebViewEnvironment extends PlatformInterface ///It is up to the app to coordinate the handlers so they do not try to perform ///reliability recovery while also trying to move to a new WebView2 Runtime version ///or remove the user data folder. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.992.28+ ([Official API - ICoreWebView2Environment5.add_BrowserProcessExited](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment5?view=webview2-1.0.2849.39#add_browserprocessexited)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.onBrowserProcessExited.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform( + available: '1.0.992.28+', + apiName: 'ICoreWebView2Environment5.add_BrowserProcessExited', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment5?view=webview2-1.0.2849.39#add_browserprocessexited') + ]) void Function(BrowserProcessExitedDetail detail)? onBrowserProcessExited; ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.onProcessInfosChanged} ///Event fired with a list of all process using same user data folder except for crashpad process. - /// - ///**Officially Supported Platforms/Implementations**: - ///- Windows 1.0.1108.44+ ([Official API - ICoreWebView2Environment8.add_ProcessInfosChanged](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment8?view=webview2-1.0.2849.39#add_processinfoschanged)) ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.onProcessInfosChanged.supported_platforms} + @SupportedPlatforms(platforms: [ + WindowsPlatform( + available: '1.0.1108.44+', + apiName: 'ICoreWebView2Environment8.add_ProcessInfosChanged', + apiUrl: + 'https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment8?view=webview2-1.0.2849.39#add_processinfoschanged') + ]) void Function(BrowserProcessInfosChangedDetail detail)? onProcessInfosChanged; ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose} ///Disposes the WebView Environment reference. ///{@endtemplate} + /// + ///{@macro flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose.supported_platforms} + @SupportedPlatforms(platforms: [WindowsPlatform()]) Future dispose() { throw UnimplementedError( 'dispose is not implemented on the current platform'); } + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.isClassSupported} + ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isClassSupported({TargetPlatform? platform}) => + _PlatformWebViewEnvironmentClassSupported.isClassSupported( + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.isPropertySupported} + ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///The property should be one of the [PlatformWebViewEnvironmentProperty] or [PlatformWebViewEnvironmentCreationParamsProperty] values. + ///{@endtemplate} + bool isPropertySupported(dynamic property, {TargetPlatform? platform}) => + property is PlatformWebViewEnvironmentCreationParamsProperty + ? params.isPropertySupported(property, platform: platform) + : _PlatformWebViewEnvironmentPropertySupported.isPropertySupported( + property, + platform: platform); + + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.isMethodSupported} + ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. + ///{@endtemplate} + bool isMethodSupported(PlatformWebViewEnvironmentMethod method, + {TargetPlatform? platform}) => + _PlatformWebViewEnvironmentMethodSupported.isMethodSupported(method, + platform: platform); } diff --git a/flutter_inappwebview_platform_interface/lib/src/webview_environment/platform_webview_environment.g.dart b/flutter_inappwebview_platform_interface/lib/src/webview_environment/platform_webview_environment.g.dart new file mode 100644 index 000000000..3ad81f5a0 --- /dev/null +++ b/flutter_inappwebview_platform_interface/lib/src/webview_environment/platform_webview_environment.g.dart @@ -0,0 +1,273 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'platform_webview_environment.dart'; + +// ************************************************************************** +// SupportedPlatformsGenerator +// ************************************************************************** + +extension _PlatformWebViewEnvironmentCreationParamsClassSupported + on PlatformWebViewEnvironmentCreationParams { + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 + /// + ///Use the [PlatformWebViewEnvironmentCreationParams.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformWebViewEnvironmentCreationParams]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformWebViewEnvironmentCreationParamsProperty { + ///Can be used to check if the [PlatformWebViewEnvironmentCreationParams.settings] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironmentCreationParams.settings.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 + /// + ///Use the [PlatformWebViewEnvironmentCreationParams.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + settings, +} + +extension _PlatformWebViewEnvironmentCreationParamsPropertySupported + on PlatformWebViewEnvironmentCreationParams { + static bool isPropertySupported( + PlatformWebViewEnvironmentCreationParamsProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformWebViewEnvironmentCreationParamsProperty.settings: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +extension _PlatformWebViewEnvironmentClassSupported + on PlatformWebViewEnvironment { + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 + /// + ///Use the [PlatformWebViewEnvironment.isClassSupported] method to check if this class is supported at runtime. + ///{@endtemplate} + static bool isClassSupported({TargetPlatform? platform}) { + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows].contains(platform ?? defaultTargetPlatform); + } +} + +///List of [PlatformWebViewEnvironment]'s properties that can be used to check i they are supported or not by the current platform. +enum PlatformWebViewEnvironmentProperty { + ///Can be used to check if the [PlatformWebViewEnvironment.id] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.id.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 + /// + ///Use the [PlatformWebViewEnvironment.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + id, + + ///Can be used to check if the [PlatformWebViewEnvironment.onBrowserProcessExited] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.onBrowserProcessExited.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 1.0.992.28++ ([Official API - ICoreWebView2Environment5.add_BrowserProcessExited](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment5?view=webview2-1.0.2849.39#add_browserprocessexited)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [detail]: all platforms + /// + ///Use the [PlatformWebViewEnvironment.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + onBrowserProcessExited, + + ///Can be used to check if the [PlatformWebViewEnvironment.onNewBrowserVersionAvailable] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.onNewBrowserVersionAvailable.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 ([Official API - ICoreWebView2Environment.add_NewBrowserVersionAvailable](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment?view=webview2-1.0.2849.39#add_newbrowserversionavailable)) + /// + ///Use the [PlatformWebViewEnvironment.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + onNewBrowserVersionAvailable, + + ///Can be used to check if the [PlatformWebViewEnvironment.onProcessInfosChanged] property is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.onProcessInfosChanged.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 1.0.1108.44++ ([Official API - ICoreWebView2Environment8.add_ProcessInfosChanged](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment8?view=webview2-1.0.2849.39#add_processinfoschanged)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [detail]: all platforms + /// + ///Use the [PlatformWebViewEnvironment.isPropertySupported] method to check if this property is supported at runtime. + ///{@endtemplate} + onProcessInfosChanged, +} + +extension _PlatformWebViewEnvironmentPropertySupported + on PlatformWebViewEnvironment { + static bool isPropertySupported(PlatformWebViewEnvironmentProperty property, + {TargetPlatform? platform}) { + switch (property) { + case PlatformWebViewEnvironmentProperty.id: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebViewEnvironmentProperty.onBrowserProcessExited: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebViewEnvironmentProperty.onNewBrowserVersionAvailable: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebViewEnvironmentProperty.onProcessInfosChanged: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + } + } +} + +///List of [PlatformWebViewEnvironment]'s methods that can be used to check if they are supported or not by the current platform. +enum PlatformWebViewEnvironmentMethod { + ///Can be used to check if the [PlatformWebViewEnvironment.compareBrowserVersions] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.compareBrowserVersions.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 ([Official API - CompareBrowserVersions](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#comparebrowserversions)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [version1]: all platforms + ///- [version2]: all platforms + /// + ///Use the [PlatformWebViewEnvironment.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + compareBrowserVersions, + + ///Can be used to check if the [PlatformWebViewEnvironment.create] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.create.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 ([Official API - CreateCoreWebView2EnvironmentWithOptions](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2210.55#createcorewebview2environmentwithoptions)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [settings]: all platforms + /// + ///Use the [PlatformWebViewEnvironment.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + create, + + ///Can be used to check if the [PlatformWebViewEnvironment.dispose] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.dispose.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 + /// + ///Use the [PlatformWebViewEnvironment.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + dispose, + + ///Can be used to check if the [PlatformWebViewEnvironment.getAvailableVersion] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getAvailableVersion.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 ([Official API - GetAvailableCoreWebView2BrowserVersionString](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/webview2-idl?view=webview2-1.0.2849.39#getavailablecorewebview2browserversionstring)) + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [browserExecutableFolder]: all platforms + /// + ///Use the [PlatformWebViewEnvironment.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getAvailableVersion, + + ///Can be used to check if the [PlatformWebViewEnvironment.getFailureReportFolderPath] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getFailureReportFolderPath.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 1.0.1518.46++ ([Official API - ICoreWebView2Environment11.get_FailureReportFolderPath](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment11?view=webview2-1.0.2849.39#get_failurereportfolderpath)) + /// + ///Use the [PlatformWebViewEnvironment.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getFailureReportFolderPath, + + ///Can be used to check if the [PlatformWebViewEnvironment.getProcessInfos] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.getProcessInfos.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 1.0.1108.44++ ([Official API - ICoreWebView2Environment8.GetProcessInfos](https://learn.microsoft.com/en-us/microsoft-edge/webview2/reference/win32/icorewebview2environment8?view=webview2-1.0.2849.39#getprocessinfos)) + /// + ///Use the [PlatformWebViewEnvironment.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + getProcessInfos, + + ///Can be used to check if the [PlatformWebViewEnvironment.isInterfaceSupported] method is supported at runtime. + /// + ///{@template flutter_inappwebview_platform_interface.PlatformWebViewEnvironment.isInterfaceSupported.supported_platforms} + /// + ///**Officially Supported Platforms/Implementations**: + ///- Windows WebView2 + /// + ///**Parameters - Officially Supported Platforms/Implementations**: + ///- [interface]: all platforms + /// + ///Use the [PlatformWebViewEnvironment.isMethodSupported] method to check if this method is supported at runtime. + ///{@endtemplate} + isInterfaceSupported, +} + +extension _PlatformWebViewEnvironmentMethodSupported + on PlatformWebViewEnvironment { + static bool isMethodSupported(PlatformWebViewEnvironmentMethod method, + {TargetPlatform? platform}) { + switch (method) { + case PlatformWebViewEnvironmentMethod.compareBrowserVersions: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebViewEnvironmentMethod.create: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebViewEnvironmentMethod.dispose: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebViewEnvironmentMethod.getAvailableVersion: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebViewEnvironmentMethod.getFailureReportFolderPath: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebViewEnvironmentMethod.getProcessInfos: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + case PlatformWebViewEnvironmentMethod.isInterfaceSupported: + return ((kIsWeb && platform != null) || !kIsWeb) && + [TargetPlatform.windows] + .contains(platform ?? defaultTargetPlatform); + } + } +} diff --git a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart index e16e54fee..bfe3e6371 100644 --- a/flutter_inappwebview_web/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_web/lib/src/inappwebview_platform.dart @@ -2,6 +2,7 @@ import 'package:flutter_inappwebview_platform_interface/flutter_inappwebview_pla import 'cookie_manager.dart'; import 'in_app_webview/main.dart'; +import 'web_storage/web_storage.dart'; /// Implementation of [InAppWebViewPlatform] using the Web API. class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { @@ -91,6 +92,77 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { return WebPlatformHeadlessInAppWebView.static(); } + /// Creates a new [WebPlatformWebStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorage] in `flutter_inappwebview` instead. + @override + WebPlatformWebStorage createPlatformWebStorage( + PlatformWebStorageCreationParams params, + ) { + return WebPlatformWebStorage(params); + } + + /// Creates a new empty [WebPlatformWebStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorage] in `flutter_inappwebview` instead. + @override + WebPlatformWebStorage createPlatformWebStorageStatic() { + return WebPlatformWebStorage(WebPlatformWebStorageCreationParams( + localStorage: createPlatformLocalStorageStatic(), + sessionStorage: createPlatformSessionStorageStatic())); + } + + /// Creates a new [WebPlatformLocalStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [LocalStorage] in `flutter_inappwebview` instead. + @override + WebPlatformLocalStorage createPlatformLocalStorage( + PlatformLocalStorageCreationParams params, + ) { + return WebPlatformLocalStorage(params); + } + + /// Creates a new empty [WebPlatformLocalStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [LocalStorage] in `flutter_inappwebview` instead. + @override + WebPlatformLocalStorage createPlatformLocalStorageStatic() { + return WebPlatformLocalStorage.defaultStorage(controller: null); + } + + /// Creates a new [WebPlatformSessionStorage]. + /// + /// This function should only be called by the app-facing package. + /// Look at using [SessionStorage] in `flutter_inappwebview` instead. + @override + WebPlatformSessionStorage createPlatformSessionStorage( + PlatformSessionStorageCreationParams params, + ) { + return WebPlatformSessionStorage(params); + } + + /// Creates a new empty [WebPlatformSessionStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [SessionStorage] in `flutter_inappwebview` instead. + @override + WebPlatformSessionStorage createPlatformSessionStorageStatic() { + return WebPlatformSessionStorage.defaultStorage(controller: null); + } + + /// Creates a new empty [PlatformWebStorageManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorageManager] in `flutter_inappwebview` instead. + @override + PlatformWebStorageManager createPlatformWebStorageManagerStatic() { + return _PlatformWebStorageManager.static(); + } + // ************************************************************************ // // Create static instances of unsupported classes to be able to call // // isClassSupported, isMethodSupported, isPropertySupported, etc. // @@ -98,6 +170,15 @@ class WebPlatformInAppWebViewPlatform extends InAppWebViewPlatform { // exception. // // ************************************************************************ // + /// Creates a new empty [PlatformWebViewEnvironment] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebViewEnvironment] in `flutter_inappwebview` instead. + @override + PlatformWebViewEnvironment createPlatformWebViewEnvironmentStatic() { + return _PlatformWebViewEnvironment.static(); + } + /// Creates a new empty [PlatformInAppBrowser] to access static methods. /// /// This function should only be called by the app-facing package. @@ -402,3 +483,24 @@ class _PlatformWebMessagePort extends PlatformWebMessagePort { throw UnimplementedError(); } } + +class _PlatformWebStorageManager extends PlatformWebStorageManager { + _PlatformWebStorageManager(PlatformWebStorageManagerCreationParams params) + : super.implementation(params); + + static final _PlatformWebStorageManager _staticValue = + _PlatformWebStorageManager( + const PlatformWebStorageManagerCreationParams()); + + factory _PlatformWebStorageManager.static() => _staticValue; +} + +class _PlatformWebViewEnvironment extends PlatformWebViewEnvironment { + _PlatformWebViewEnvironment(PlatformWebViewEnvironmentCreationParams params) + : super.implementation(params); + static final _PlatformWebViewEnvironment _staticValue = + _PlatformWebViewEnvironment( + const PlatformWebViewEnvironmentCreationParams()); + + factory _PlatformWebViewEnvironment.static() => _staticValue; +} diff --git a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart index 6971050ab..877576a02 100644 --- a/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart +++ b/flutter_inappwebview_windows/lib/src/inappwebview_platform.dart @@ -146,6 +146,17 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { return WindowsWebStorage(params); } + /// Creates a new empty [WindowsWebStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorage] in `flutter_inappwebview` instead. + @override + WindowsWebStorage createPlatformWebStorageStatic() { + return WindowsWebStorage(WindowsWebStorageCreationParams( + localStorage: createPlatformLocalStorageStatic(), + sessionStorage: createPlatformSessionStorageStatic())); + } + /// Creates a new [WindowsLocalStorage]. /// /// This function should only be called by the app-facing package. @@ -157,6 +168,15 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { return WindowsLocalStorage(params); } + /// Creates a new empty [WindowsLocalStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [LocalStorage] in `flutter_inappwebview` instead. + @override + WindowsLocalStorage createPlatformLocalStorageStatic() { + return WindowsLocalStorage.defaultStorage(controller: null); + } + /// Creates a new [WindowsSessionStorage]. /// /// This function should only be called by the app-facing package. @@ -168,6 +188,24 @@ class WindowsInAppWebViewPlatform extends InAppWebViewPlatform { return WindowsSessionStorage(params); } + /// Creates a new empty [WindowsSessionStorage] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [SessionStorage] in `flutter_inappwebview` instead. + @override + WindowsSessionStorage createPlatformSessionStorageStatic() { + return WindowsSessionStorage.defaultStorage(controller: null); + } + + /// Creates a new empty [PlatformWebStorageManager] to access static methods. + /// + /// This function should only be called by the app-facing package. + /// Look at using [WebStorageManager] in `flutter_inappwebview` instead. + @override + PlatformWebStorageManager createPlatformWebStorageManagerStatic() { + return _PlatformWebStorageManager.static(); + } + // ************************************************************************ // // Create static instances of unsupported classes to be able to call // // isClassSupported, isMethodSupported, isPropertySupported, etc. // @@ -461,3 +499,14 @@ class _PlatformWebMessagePort extends PlatformWebMessagePort { throw UnimplementedError(); } } + +class _PlatformWebStorageManager extends PlatformWebStorageManager { + _PlatformWebStorageManager(PlatformWebStorageManagerCreationParams params) + : super.implementation(params); + + static final _PlatformWebStorageManager _staticValue = + _PlatformWebStorageManager( + const PlatformWebStorageManagerCreationParams()); + + factory _PlatformWebStorageManager.static() => _staticValue; +} diff --git a/flutter_inappwebview_windows/lib/src/web_storage/main.dart b/flutter_inappwebview_windows/lib/src/web_storage/main.dart index 7265ae52c..dab327ba6 100644 --- a/flutter_inappwebview_windows/lib/src/web_storage/main.dart +++ b/flutter_inappwebview_windows/lib/src/web_storage/main.dart @@ -1,2 +1,2 @@ export 'web_storage.dart'; -export 'web_storage_manager.dart' hide InternalWebStorageManager; +export 'web_storage_manager.dart'; diff --git a/flutter_inappwebview_windows/lib/src/web_storage/web_storage_manager.dart b/flutter_inappwebview_windows/lib/src/web_storage/web_storage_manager.dart index cd9c24e61..e4835bc11 100644 --- a/flutter_inappwebview_windows/lib/src/web_storage/web_storage_manager.dart +++ b/flutter_inappwebview_windows/lib/src/web_storage/web_storage_manager.dart @@ -39,7 +39,7 @@ class WindowsWebStorageManager extends PlatformWebStorageManager ) { channel = const MethodChannel( 'com.pichillilorenzo/flutter_inappwebview_webstoragemanager'); - handler = handleMethod; + handler = _handleMethod; initMethodCallHandler(); } @@ -56,6 +56,15 @@ class WindowsWebStorageManager extends PlatformWebStorageManager return _instance!; } + static WindowsWebStorageManager? _static; + + /// Provide static access. + factory WindowsWebStorageManager.static() { + _static ??= WindowsWebStorageManager(WindowsWebStorageManagerCreationParams( + const PlatformWebStorageManagerCreationParams())); + return _static!; + } + Future _handleMethod(MethodCall call) async {} @override @@ -128,7 +137,3 @@ class WindowsWebStorageManager extends PlatformWebStorageManager // empty } } - -extension InternalWebStorageManager on WindowsWebStorageManager { - get handleMethod => _handleMethod; -} From 250c8d4f1cfcbb201022116c78dd4d26fc8d268e Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Fri, 5 Dec 2025 00:30:09 +0100 Subject: [PATCH 163/181] code format --- .../lib/src/web_storage/web_storage.dart | 47 ++++++++++--------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/flutter_inappwebview/lib/src/web_storage/web_storage.dart b/flutter_inappwebview/lib/src/web_storage/web_storage.dart index ede545a99..41dc5c525 100644 --- a/flutter_inappwebview/lib/src/web_storage/web_storage.dart +++ b/flutter_inappwebview/lib/src/web_storage/web_storage.dart @@ -29,19 +29,18 @@ class WebStorage { ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. static bool isClassSupported({TargetPlatform? platform}) => - PlatformWebStorage.static().isClassSupported(platform: platform); + PlatformWebStorage.static().isClassSupported(platform: platform); ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. static bool isPropertySupported(dynamic property, - {TargetPlatform? platform}) => - PlatformWebStorage.static() - .isPropertySupported(property, platform: platform); + {TargetPlatform? platform}) => + PlatformWebStorage.static() + .isPropertySupported(property, platform: platform); ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. static bool isMethodSupported(PlatformWebStorageMethod method, - {TargetPlatform? platform}) => - PlatformWebStorage.static() - .isMethodSupported(method, platform: platform); + {TargetPlatform? platform}) => + PlatformWebStorage.static().isMethodSupported(method, platform: platform); ///{@macro flutter_inappwebview_platform_interface.PlatformWebStorage.localStorage} LocalStorage get localStorage => @@ -123,19 +122,20 @@ class LocalStorage extends Storage { ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. static bool isClassSupported({TargetPlatform? platform}) => - PlatformLocalStorage.static().isClassSupported(platform: platform); + PlatformLocalStorage.static().isClassSupported(platform: platform); ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. - static bool isPropertySupported(PlatformStorageCreationParamsProperty property, - {TargetPlatform? platform}) => - PlatformLocalStorage.static() - .isPropertySupported(property, platform: platform); + static bool isPropertySupported( + PlatformStorageCreationParamsProperty property, + {TargetPlatform? platform}) => + PlatformLocalStorage.static() + .isPropertySupported(property, platform: platform); ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. static bool isMethodSupported(PlatformLocalStorageMethod method, - {TargetPlatform? platform}) => - PlatformLocalStorage.static() - .isMethodSupported(method, platform: platform); + {TargetPlatform? platform}) => + PlatformLocalStorage.static() + .isMethodSupported(method, platform: platform); } ///{@macro flutter_inappwebview_platform_interface.PlatformSessionStorage} @@ -165,17 +165,18 @@ class SessionStorage extends Storage { ///Check if the current class is supported by the [defaultTargetPlatform] or a specific [platform]. static bool isClassSupported({TargetPlatform? platform}) => - PlatformSessionStorage.static().isClassSupported(platform: platform); + PlatformSessionStorage.static().isClassSupported(platform: platform); ///Check if the given [property] is supported by the [defaultTargetPlatform] or a specific [platform]. - static bool isPropertySupported(PlatformStorageCreationParamsProperty property, - {TargetPlatform? platform}) => - PlatformSessionStorage.static() - .isPropertySupported(property, platform: platform); + static bool isPropertySupported( + PlatformStorageCreationParamsProperty property, + {TargetPlatform? platform}) => + PlatformSessionStorage.static() + .isPropertySupported(property, platform: platform); ///Check if the given [method] is supported by the [defaultTargetPlatform] or a specific [platform]. static bool isMethodSupported(PlatformSessionStorageMethod method, - {TargetPlatform? platform}) => - PlatformSessionStorage.static() - .isMethodSupported(method, platform: platform); + {TargetPlatform? platform}) => + PlatformSessionStorage.static() + .isMethodSupported(method, platform: platform); } From 65c870b547b84866a41b702c24aa65f9022fb1d3 Mon Sep 17 00:00:00 2001 From: Lorenzo Pichilli Date: Sun, 7 Dec 2025 19:22:58 +0100 Subject: [PATCH 164/181] added integration_test/support_methods --- .github/copilot-instructions.md | 17 +- .../support_methods/main.dart | 445 ++++++++++++++++++ .../webview_flutter_test.dart | 2 + 3 files changed, 462 insertions(+), 2 deletions(-) create mode 100644 flutter_inappwebview/example/integration_test/support_methods/main.dart diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 2aa555d3b..ddd0a79f9 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -20,6 +20,14 @@ This repository follows the **Federated Plugin** architecture: - Keep their APIs strictly aligned with the `platform_interface` layer. - **`dev_packages/` and `scripts/`**: Internal tooling, generators, and maintenance scripts. +### Main App-Facing Classes (support checks available) +- Web view: `InAppWebView`, `InAppWebViewController`, `HeadlessInAppWebView` +- Browser shells: `InAppBrowser`, `ChromeSafariBrowser`, `WebAuthenticationSession` +- Platform helpers: `WebViewEnvironment`, `ProcessGlobalConfig`, `ProxyController`, `ServiceWorkerController`, `TracingController`, `PrintJobController`, `PullToRefreshController`, `FindInteractionController` +- Storage & messaging: `WebStorage`, `LocalStorage`, `SessionStorage`, `WebStorageManager`, `WebMessageChannel`, `WebMessageListener` +- Cookies: `CookieManager` +- Auth storage: `HttpAuthCredentialDatabase` + ## Coding Guidelines ### General @@ -124,8 +132,12 @@ When implementing a new platform interface class (e.g., `PlatformWebViewEnvironm - **Unsupported Features**: If a feature is NOT supported on a specific platform, you must still implement the creation method in `inappwebview_platform.dart`. Return an instance of a private empty class (e.g., `class _PlatformProcessGlobalConfig extends PlatformProcessGlobalConfig`) that extends the platform interface class. This ensures `isClassSupported`, `isPropertySupported`, `isMethodSupported` static methods works correctly via the `@SupportedPlatforms` annotation. - **Extending Params**: Platform implementations should extend `Platform*CreationParams` (e.g., `AndroidInAppWebViewWidgetCreationParams` extends `PlatformInAppWebViewWidgetCreationParams`) to add platform-specific fields. - **Platform Views**: - - **Android**: Uses `PlatformViewLink` and `AndroidViewSurface` (or `AndroidView` for simple cases) to render native views. - - **iOS**: Uses `UiKitView`. + - **Android**: Uses `PlatformViewLink` and `AndroidViewSurface` (or `AndroidView` for simple cases) to render native views; [android.webkit.WebView](https://developer.android.com/reference/android/webkit/WebView). + - **iOS**: Uses `UiKitView`; [WKWebView](https://developer.apple.com/documentation/webkit/wkwebview). + - **macOS**: Uses `AppKitView`; [WKWebView](https://developer.apple.com/documentation/webkit/wkwebview). + - **Windows**: Uses a custom platform view implementation using textures; [WebView2](https://learn.microsoft.com/en-us/microsoft-edge/webview2/). + - **Web**: Uses an `HtmlElementView` to embed an `