1084 lines
60 KiB
Dart
1084 lines
60 KiB
Dart
import 'dart:collection';
|
|
import 'dart:typed_data';
|
|
|
|
import '../find_interaction/find_interaction_controller.dart';
|
|
import '../pull_to_refresh/pull_to_refresh_controller.dart';
|
|
|
|
import '../context_menu.dart';
|
|
import '../types/main.dart';
|
|
|
|
import 'in_app_webview_controller.dart';
|
|
import 'in_app_webview_settings.dart';
|
|
import 'headless_in_app_webview.dart';
|
|
import 'in_app_webview.dart';
|
|
import '../in_app_browser/in_app_browser.dart';
|
|
import '../print_job/main.dart';
|
|
|
|
import '../debug_logging_settings.dart';
|
|
|
|
///Abstract class that represents a WebView. Used by [InAppWebView], [HeadlessInAppWebView] and the WebView of [InAppBrowser].
|
|
abstract class WebView {
|
|
///Debug settings used by [InAppWebView], [HeadlessInAppWebView] and [InAppBrowser].
|
|
///The default value excludes the [WebView.onScrollChanged], [WebView.onOverScrolled] and [WebView.onReceivedIcon] events.
|
|
static DebugLoggingSettings debugLoggingSettings = DebugLoggingSettings(
|
|
maxLogMessageLength: 1000,
|
|
excludeFilter: [
|
|
RegExp(r"onScrollChanged"),
|
|
RegExp(r"onOverScrolled"),
|
|
RegExp(r"onReceivedIcon")
|
|
]);
|
|
|
|
///The window id of a [CreateWindowAction.windowId].
|
|
final int? windowId;
|
|
|
|
///Event fired when the [WebView] is created.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
///- Web
|
|
final void Function(InAppWebViewController controller)? onWebViewCreated;
|
|
|
|
///Event fired when the [WebView] starts to load an [url].
|
|
///
|
|
///**NOTE for Web**: 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.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onPageStarted](https://developer.android.com/reference/android/webkit/WebViewClient#onPageStarted(android.webkit.WebView,%20java.lang.String,%20android.graphics.Bitmap)))
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455621-webview))
|
|
///- Web
|
|
final void Function(InAppWebViewController controller, Uri? url)? onLoadStart;
|
|
|
|
///Event fired when the [WebView] finishes loading an [url].
|
|
///
|
|
///**NOTE for Web**: If `window.location.href` isn't accessible inside the iframe,
|
|
///the [url] parameter will have the current value of the `iframe.src` attribute.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onPageFinished](https://developer.android.com/reference/android/webkit/WebViewClient#onPageFinished(android.webkit.WebView,%20java.lang.String)))
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455629-webview))
|
|
///- Web ([Official API - Window.onload](https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event))
|
|
final void Function(InAppWebViewController controller, Uri? url)? onLoadStop;
|
|
|
|
///Use [onReceivedError] instead.
|
|
@Deprecated("Use onReceivedError instead")
|
|
final void Function(InAppWebViewController controller, Uri? url, int code,
|
|
String message)? onLoadError;
|
|
|
|
///Event fired when the [WebView] encounters an [error] loading a [request].
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onReceivedError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceError)))
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455623-webview))
|
|
final void Function(InAppWebViewController controller,
|
|
WebResourceRequest request, WebResourceError error)? onReceivedError;
|
|
|
|
///Use [onReceivedHttpError] instead.
|
|
@Deprecated("Use onReceivedHttpError instead")
|
|
final void Function(InAppWebViewController controller, Uri? url,
|
|
int statusCode, String description)? onLoadHttpError;
|
|
|
|
///Event fired when the [WebView] receives an HTTP error.
|
|
///
|
|
///[request] represents the originating request.
|
|
///
|
|
///[errorResponse] represents the information about the error occurred.
|
|
///
|
|
///**NOTE**: available on Android 23+.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onReceivedHttpError](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpError(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20android.webkit.WebResourceResponse)))
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
|
|
final void Function(
|
|
InAppWebViewController controller,
|
|
WebResourceRequest request,
|
|
WebResourceResponse errorResponse)? onReceivedHttpError;
|
|
|
|
///Event fired when the current [progress] of loading a page is changed.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onProgressChanged](https://developer.android.com/reference/android/webkit/WebChromeClient#onProgressChanged(android.webkit.WebView,%20int)))
|
|
///- iOS
|
|
final void Function(InAppWebViewController controller, int progress)?
|
|
onProgressChanged;
|
|
|
|
///Event fired when the [WebView] receives a [ConsoleMessage].
|
|
///
|
|
///**NOTE for Web**: this event will be called only if the iframe has the same origin.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onConsoleMessage](https://developer.android.com/reference/android/webkit/WebChromeClient#onConsoleMessage(android.webkit.ConsoleMessage)))
|
|
///- iOS
|
|
///- Web
|
|
final void Function(
|
|
InAppWebViewController controller, ConsoleMessage consoleMessage)?
|
|
onConsoleMessage;
|
|
|
|
///Give the host application a chance to take control when a URL is about to be loaded in the current WebView. This event is not called on the initial load of the WebView.
|
|
///
|
|
///Note that on Android there isn't any way to load an URL for a frame that is not the main frame, so if the request is not for the main frame, the navigation is allowed by default.
|
|
///However, if you want to cancel requests for subframes, you can use the [InAppWebViewSettings.regexToCancelSubFramesLoading] option
|
|
///to write a Regular Expression that, if the url request of a subframe matches, then the request of that subframe is canceled.
|
|
///
|
|
///Also, on Android, this method is not called for POST requests.
|
|
///
|
|
///[navigationAction] represents an object that contains information about an action that causes navigation to occur.
|
|
///
|
|
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldOverrideUrlLoading] option to `true`.
|
|
///Also, on Android this event is not called on the first page load.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.shouldOverrideUrlLoading](https://developer.android.com/reference/android/webkit/WebViewClient#shouldOverrideUrlLoading(android.webkit.WebView,%20java.lang.String)))
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455641-webview))
|
|
final Future<NavigationActionPolicy?> Function(
|
|
InAppWebViewController controller, NavigationAction navigationAction)?
|
|
shouldOverrideUrlLoading;
|
|
|
|
///Event fired when the [WebView] loads a resource.
|
|
///
|
|
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnLoadResource] and [InAppWebViewSettings.javaScriptEnabled] options to `true`.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
final void Function(
|
|
InAppWebViewController controller, LoadedResource resource)?
|
|
onLoadResource;
|
|
|
|
///Event fired when the [WebView] scrolls.
|
|
///
|
|
///[x] represents the current horizontal scroll origin in pixels.
|
|
///
|
|
///[y] represents the current vertical scroll origin in pixels.
|
|
///
|
|
///**NOTE for Web**: this event will be called only if the iframe has the same origin.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebView.onScrollChanged](https://developer.android.com/reference/android/webkit/WebView#onScrollChanged(int,%20int,%20int,%20int)))
|
|
///- iOS ([Official API - UIScrollViewDelegate.scrollViewDidScroll](https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619392-scrollviewdidscroll))
|
|
///- Web ([Official API - Window.onscroll](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onscroll))
|
|
final void Function(InAppWebViewController controller, int x, int y)?
|
|
onScrollChanged;
|
|
|
|
///Use [onDownloadStartRequest] instead
|
|
@Deprecated('Use onDownloadStartRequest instead')
|
|
final void Function(InAppWebViewController controller, Uri url)?
|
|
onDownloadStart;
|
|
|
|
///Event fired when [WebView] recognizes a downloadable file.
|
|
///To download the file, you can use the [flutter_downloader](https://pub.dev/packages/flutter_downloader) plugin.
|
|
///
|
|
///[downloadStartRequest] represents the request of the file to download.
|
|
///
|
|
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnDownloadStart] option to `true`.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebView.setDownloadListener](https://developer.android.com/reference/android/webkit/WebView#setDownloadListener(android.webkit.DownloadListener)))
|
|
///- iOS
|
|
final void Function(InAppWebViewController controller,
|
|
DownloadStartRequest downloadStartRequest)? onDownloadStartRequest;
|
|
|
|
///Use [onLoadResourceWithCustomScheme] instead.
|
|
@Deprecated('Use onLoadResourceWithCustomScheme instead')
|
|
final Future<CustomSchemeResponse?> Function(
|
|
InAppWebViewController controller, Uri url)? onLoadResourceCustomScheme;
|
|
|
|
///Event fired when the [WebView] finds the `custom-scheme` while loading a resource.
|
|
///Here you can handle the url [request] and return a [CustomSchemeResponse] to load a specific resource encoded to `base64`.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS ([Official API - WKURLSchemeHandler](https://developer.apple.com/documentation/webkit/wkurlschemehandler))
|
|
final Future<CustomSchemeResponse?> Function(
|
|
InAppWebViewController controller, WebResourceRequest request)?
|
|
onLoadResourceWithCustomScheme;
|
|
|
|
///Event fired when the [WebView] requests the host application to create a new window,
|
|
///for example when trying to open a link with `target="_blank"` or when `window.open()` is called by JavaScript side.
|
|
///If the host application chooses to honor this request, it should return `true` from this method, create a new WebView to host the window.
|
|
///If the host application chooses not to honor the request, it should return `false` from this method.
|
|
///The default implementation of this method does nothing and hence returns `false`.
|
|
///
|
|
///- [createWindowAction] represents the request.
|
|
///
|
|
///**NOTE**: to allow JavaScript to open windows, you need to set [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically] option to `true`.
|
|
///
|
|
///**NOTE for Android**: you need to set [InAppWebViewSettings.supportMultipleWindows] option to `true`.
|
|
///Also, if the request has been created using JavaScript (`window.open()`), then there are some limitation: check the [NavigationAction] class.
|
|
///
|
|
///**NOTE for iOS**: setting these initial options: [InAppWebViewSettings.supportZoom], [InAppWebViewSettings.useOnLoadResource], [InAppWebViewSettings.useShouldInterceptAjaxRequest],
|
|
///[InAppWebViewSettings.useShouldInterceptFetchRequest], [InAppWebViewSettings.applicationNameForUserAgent], [InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically],
|
|
///[InAppWebViewSettings.javaScriptEnabled], [InAppWebViewSettings.minimumFontSize], [InAppWebViewSettings.preferredContentMode], [InAppWebViewSettings.incognito],
|
|
///[InAppWebViewSettings.cacheEnabled], [InAppWebViewSettings.mediaPlaybackRequiresUserGesture],
|
|
///[InAppWebViewSettings.resourceCustomSchemes], [InAppWebViewSettings.sharedCookiesEnabled],
|
|
///[InAppWebViewSettings.enableViewportScale], [InAppWebViewSettings.allowsAirPlayForMediaPlayback],
|
|
///[InAppWebViewSettings.allowsPictureInPictureMediaPlayback], [InAppWebViewSettings.isFraudulentWebsiteWarningEnabled],
|
|
///[InAppWebViewSettings.allowsInlineMediaPlayback], [InAppWebViewSettings.suppressesIncrementalRendering], [InAppWebViewSettings.selectionGranularity],
|
|
///[InAppWebViewSettings.ignoresViewportScaleLimits], [InAppWebViewSettings.limitsNavigationsToAppBoundDomains],
|
|
///[InAppWebViewSettings.upgradeKnownHostsToHTTPS],
|
|
///will have no effect due to a `WKWebView` limitation when creating the new window WebView: it's impossible to return the new `WKWebView`
|
|
///with a different `WKWebViewConfiguration` instance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview).
|
|
///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.
|
|
///
|
|
///**NOTE for Web**: this event will be called only if the iframe has the same origin. 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.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onCreateWindow](https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)))
|
|
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview))
|
|
///- Web
|
|
final Future<bool?> Function(InAppWebViewController controller,
|
|
CreateWindowAction createWindowAction)? onCreateWindow;
|
|
|
|
///Event fired when the host application should close the given WebView and remove it from the view system if necessary.
|
|
///At this point, WebCore has stopped any loading in this window and has removed any cross-scripting ability in javascript.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onCloseWindow](https://developer.android.com/reference/android/webkit/WebChromeClient#onCloseWindow(android.webkit.WebView)))
|
|
///- iOS ([Official API - WKUIDelegate.webViewDidClose](https://developer.apple.com/documentation/webkit/wkuidelegate/1537390-webviewdidclose))
|
|
final void Function(InAppWebViewController controller)? onCloseWindow;
|
|
|
|
///Event fired when the JavaScript `window` object of the WebView has received focus.
|
|
///This is the result of the `focus` JavaScript event applied to the `window` object.
|
|
///
|
|
///**NOTE for Web**: this event will be called only if the iframe has the same origin.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
///- Web ([Official API - Window.onfocus](https://developer.mozilla.org/en-US/docs/Web/API/Window/focus_event))
|
|
final void Function(InAppWebViewController controller)? onWindowFocus;
|
|
|
|
///Event fired when the JavaScript `window` object of the WebView has lost focus.
|
|
///This is the result of the `blur` JavaScript event applied to the `window` object.
|
|
///
|
|
///**NOTE for Web**: this event will be called only if the iframe has the same origin.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
///- Web ([Official API - Window.onblur](https://developer.mozilla.org/en-US/docs/Web/API/Window/blur_event))
|
|
final void Function(InAppWebViewController controller)? onWindowBlur;
|
|
|
|
///Event fired when javascript calls the `alert()` method to display an alert dialog.
|
|
///If [JsAlertResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
|
|
///
|
|
///[jsAlertRequest] contains the message to be displayed in the alert dialog and the of the page requesting the dialog.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onJsAlert](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)))
|
|
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview))
|
|
final Future<JsAlertResponse?> Function(
|
|
InAppWebViewController controller, JsAlertRequest jsAlertRequest)?
|
|
onJsAlert;
|
|
|
|
///Event fired when javascript calls the `confirm()` method to display a confirm dialog.
|
|
///If [JsConfirmResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
|
|
///
|
|
///[jsConfirmRequest] contains the message to be displayed in the confirm dialog and the of the page requesting the dialog.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onJsConfirm](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsConfirm(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)))
|
|
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1536489-webview))
|
|
final Future<JsConfirmResponse?> Function(
|
|
InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)?
|
|
onJsConfirm;
|
|
|
|
///Event fired when javascript calls the `prompt()` method to display a prompt dialog.
|
|
///If [JsPromptResponse.handledByClient] is `true`, the webview will assume that the client will handle the dialog.
|
|
///
|
|
///[jsPromptRequest] contains the message to be displayed in the prompt dialog, the default value displayed in the prompt dialog, and the of the page requesting the dialog.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onJsPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsPrompt(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String,%20android.webkit.JsPromptResult)))
|
|
///- iOS ([Official API - WKUIDelegate.webView](https://developer.apple.com/documentation/webkit/wkuidelegate/1538086-webview))
|
|
final Future<JsPromptResponse?> Function(
|
|
InAppWebViewController controller, JsPromptRequest jsPromptRequest)?
|
|
onJsPrompt;
|
|
|
|
///Event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
|
|
///
|
|
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [URLAuthenticationChallenge].
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onReceivedHttpAuthRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedHttpAuthRequest(android.webkit.WebView,%20android.webkit.HttpAuthHandler,%20java.lang.String,%20java.lang.String)))
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
|
|
final Future<HttpAuthResponse?> Function(InAppWebViewController controller,
|
|
HttpAuthenticationChallenge challenge)? onReceivedHttpAuthRequest;
|
|
|
|
///Event fired when the WebView need to perform server trust authentication (certificate validation).
|
|
///The host application must return either [ServerTrustAuthResponse] instance with [ServerTrustAuthResponseAction.CANCEL] or [ServerTrustAuthResponseAction.PROCEED].
|
|
///
|
|
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ServerTrustChallenge].
|
|
///
|
|
///**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))
|
|
final Future<ServerTrustAuthResponse?> Function(
|
|
InAppWebViewController controller, ServerTrustChallenge challenge)?
|
|
onReceivedServerTrustAuthRequest;
|
|
|
|
///Notify the host application to handle an SSL client certificate request.
|
|
///Webview stores the response in memory (for the life of the application) if [ClientCertResponseAction.PROCEED] or [ClientCertResponseAction.CANCEL]
|
|
///is called and does not call [onReceivedClientCertRequest] again for the same host and port pair.
|
|
///Note that, multiple layers in chromium network stack might be caching the responses.
|
|
///
|
|
///[challenge] contains data about host, port, protocol, realm, etc. as specified in the [ClientCertChallenge].
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onReceivedClientCertRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedClientCertRequest(android.webkit.WebView,%20android.webkit.ClientCertRequest)))
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455638-webview))
|
|
final Future<ClientCertResponse?> Function(
|
|
InAppWebViewController controller, ClientCertChallenge challenge)?
|
|
onReceivedClientCertRequest;
|
|
|
|
///Use [FindInteractionController.onFindResultReceived] instead.
|
|
@Deprecated('Use FindInteractionController.onFindResultReceived instead')
|
|
final void Function(InAppWebViewController controller, int activeMatchOrdinal,
|
|
int numberOfMatches, bool isDoneCounting)? onFindResultReceived;
|
|
|
|
///Event fired when an `XMLHttpRequest` is sent to a server.
|
|
///It gives the host application a chance to take control over the request before sending it.
|
|
///
|
|
///[ajaxRequest] represents the `XMLHttpRequest`.
|
|
///
|
|
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option to `true`.
|
|
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
|
|
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
|
|
///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
|
|
///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the ajax requests will be intercept for sure.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
final Future<AjaxRequest?> Function(
|
|
InAppWebViewController controller, AjaxRequest ajaxRequest)?
|
|
shouldInterceptAjaxRequest;
|
|
|
|
///Event fired whenever the `readyState` attribute of an `XMLHttpRequest` changes.
|
|
///It gives the host application a chance to abort the request.
|
|
///
|
|
///[ajaxRequest] represents the [XMLHttpRequest].
|
|
///
|
|
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option to `true`.
|
|
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
|
|
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
|
|
///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
|
|
///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the ajax requests will be intercept for sure.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
final Future<AjaxRequestAction?> Function(
|
|
InAppWebViewController controller, AjaxRequest ajaxRequest)?
|
|
onAjaxReadyStateChange;
|
|
|
|
///Event fired as an `XMLHttpRequest` progress.
|
|
///It gives the host application a chance to abort the request.
|
|
///
|
|
///[ajaxRequest] represents the [XMLHttpRequest].
|
|
///
|
|
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptAjaxRequest] option to `true`.
|
|
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
|
|
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
|
|
///used to intercept ajax requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
|
|
///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the ajax requests will be intercept for sure.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
final Future<AjaxRequestAction?> Function(
|
|
InAppWebViewController controller, AjaxRequest ajaxRequest)?
|
|
onAjaxProgress;
|
|
|
|
///Event fired when a request is sent to a server through [Fetch API](https://developer.mozilla.org/it/docs/Web/API/Fetch_API).
|
|
///It gives the host application a chance to take control over the request before sending it.
|
|
///
|
|
///[fetchRequest] represents a resource request.
|
|
///
|
|
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptFetchRequest] option to `true`.
|
|
///Also, unlike iOS that has [WKUserScript](https://developer.apple.com/documentation/webkit/wkuserscript) that
|
|
///can inject javascript code right after the document element is created but before any other content is loaded, in Android the javascript code
|
|
///used to intercept fetch requests is loaded as soon as possible so it won't be instantaneous as iOS but just after some milliseconds (< ~100ms).
|
|
///Inside the `window.addEventListener("flutterInAppWebViewPlatformReady")` event, the fetch requests will be intercept for sure.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
final Future<FetchRequest?> Function(
|
|
InAppWebViewController controller, FetchRequest fetchRequest)?
|
|
shouldInterceptFetchRequest;
|
|
|
|
///Event fired when the host application updates its visited links database.
|
|
///This event is also fired when the navigation state of the [WebView] changes through the usage of
|
|
///javascript **[History API](https://developer.mozilla.org/en-US/docs/Web/API/History_API)** functions (`pushState()`, `replaceState()`) and `onpopstate` event
|
|
///or, also, when the javascript `window.location` changes without reloading the webview (for example appending or modifying an hash to the url).
|
|
///
|
|
///[url] represents the url being visited.
|
|
///
|
|
///[isReload] indicates if this url is being reloaded. Available only on Android.
|
|
///
|
|
///**NOTE for Web**: this event will be called only if the iframe has the same origin.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.doUpdateVisitedHistory](https://developer.android.com/reference/android/webkit/WebViewClient#doUpdateVisitedHistory(android.webkit.WebView,%20java.lang.String,%20boolean)))
|
|
///- iOS
|
|
///- Web
|
|
final void Function(
|
|
InAppWebViewController controller, Uri? url, bool? isReload)?
|
|
onUpdateVisitedHistory;
|
|
|
|
///Use [onPrintRequest] instead
|
|
@Deprecated("Use onPrintRequest instead")
|
|
final void Function(InAppWebViewController controller, Uri? url)? onPrint;
|
|
|
|
///Event fired when `window.print()` is called from JavaScript side.
|
|
///Return `true` if you want to handle the print job.
|
|
///Otherwise return `false`, so the [PrintJobController] will be handled and disposed automatically by the system.
|
|
///
|
|
///[url] represents the url on which is called.
|
|
///
|
|
///[printJobController] represents the controller of the print job created.
|
|
///**NOTE**: on Web, it is always `null`
|
|
///
|
|
///**NOTE for Web**: this event will be called only if the iframe has the same origin.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
///- Web
|
|
final Future<bool?> Function(InAppWebViewController controller, Uri? url,
|
|
PrintJobController? printJobController)? onPrintRequest;
|
|
|
|
///Event fired when an HTML element of the webview has been clicked and held.
|
|
///
|
|
///[hitTestResult] represents the hit result for hitting an HTML elements.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - View.setOnLongClickListener](https://developer.android.com/reference/android/view/View#setOnLongClickListener(android.view.View.OnLongClickListener)))
|
|
///- iOS ([Official API - UILongPressGestureRecognizer](https://developer.apple.com/documentation/uikit/uilongpressgesturerecognizer))
|
|
final void Function(InAppWebViewController controller,
|
|
InAppWebViewHitTestResult hitTestResult)? onLongPressHitTestResult;
|
|
|
|
///Event fired when the current page has entered full screen mode.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onShowCustomView](https://developer.android.com/reference/android/webkit/WebChromeClient#onShowCustomView(android.view.View,%20android.webkit.WebChromeClient.CustomViewCallback)))
|
|
///- iOS ([Official API - UIWindow.didBecomeVisibleNotification](https://developer.apple.com/documentation/uikit/uiwindow/1621621-didbecomevisiblenotification))
|
|
///- Web ([Official API - Document.onfullscreenchange](https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event))
|
|
final void Function(InAppWebViewController controller)? onEnterFullscreen;
|
|
|
|
///Event fired when the current page has exited full screen mode.
|
|
///
|
|
///**Official Android API**: https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()
|
|
///
|
|
///**Official iOS API**: https://developer.apple.com/documentation/uikit/uiwindow/1621617-didbecomehiddennotification
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onHideCustomView](https://developer.android.com/reference/android/webkit/WebChromeClient#onHideCustomView()))
|
|
///- iOS ([Official API - UIWindow.didBecomeHiddenNotification](https://developer.apple.com/documentation/uikit/uiwindow/1621617-didbecomehiddennotification))
|
|
///- Web ([Official API - Document.onfullscreenchange](https://developer.mozilla.org/en-US/docs/Web/API/Document/fullscreenchange_event))
|
|
final void Function(InAppWebViewController controller)? onExitFullscreen;
|
|
|
|
///Called when the web view begins to receive web content.
|
|
///
|
|
///This event occurs early in the document loading process, and as such
|
|
///you should expect that linked resources (for example, CSS and images) may not be available.
|
|
///
|
|
///[url] represents the URL corresponding to the page navigation that triggered this callback.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onPageCommitVisible](https://developer.android.com/reference/android/webkit/WebViewClient#onPageCommitVisible(android.webkit.WebView,%20java.lang.String)))
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455635-webview))
|
|
final void Function(InAppWebViewController controller, Uri? url)?
|
|
onPageCommitVisible;
|
|
|
|
///Event fired when a change in the document title occurred.
|
|
///
|
|
///[title] represents the string containing the new title of the document.
|
|
///
|
|
///**NOTE for Web**: this event will be called only if the iframe has the same origin.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onReceivedTitle](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTitle(android.webkit.WebView,%20java.lang.String)))
|
|
///- iOS
|
|
///- Web
|
|
final void Function(InAppWebViewController controller, String? title)?
|
|
onTitleChanged;
|
|
|
|
///Event fired to respond to the results of an over-scroll operation.
|
|
///
|
|
///[x] represents the new X scroll value in pixels.
|
|
///
|
|
///[y] represents the new Y scroll value in pixels.
|
|
///
|
|
///[clampedX] is `true` if [x] was clamped to an over-scroll boundary.
|
|
///
|
|
///[clampedY] is `true` if [y] was clamped to an over-scroll boundary.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebView.onOverScrolled](https://developer.android.com/reference/android/webkit/WebView#onOverScrolled(int,%20int,%20boolean,%20boolean)))
|
|
///- iOS
|
|
final void Function(InAppWebViewController controller, int x, int y,
|
|
bool clampedX, bool clampedY)? onOverScrolled;
|
|
|
|
///Event fired when the zoom scale of the WebView has changed.
|
|
///
|
|
///[oldScale] The old zoom scale factor.
|
|
///
|
|
///[newScale] The new zoom scale factor.
|
|
///
|
|
///**NOTE for Web**: this event will be called only if the iframe has the same origin.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onScaleChanged](https://developer.android.com/reference/android/webkit/WebViewClient#onScaleChanged(android.webkit.WebView,%20float,%20float)))
|
|
///- iOS ([Official API - UIScrollViewDelegate.scrollViewDidZoom](https://developer.apple.com/documentation/uikit/uiscrollviewdelegate/1619409-scrollviewdidzoom))
|
|
///- Web
|
|
final void Function(
|
|
InAppWebViewController controller, double oldScale, double newScale)?
|
|
onZoomScaleChanged;
|
|
|
|
///Use [onSafeBrowsingHit] instead.
|
|
@Deprecated("Use onSafeBrowsingHit instead")
|
|
final Future<SafeBrowsingResponse?> Function(
|
|
InAppWebViewController controller,
|
|
Uri url,
|
|
SafeBrowsingThreat? threatType)? androidOnSafeBrowsingHit;
|
|
|
|
///Event fired when the webview notifies that a loading URL has been flagged by Safe Browsing.
|
|
///The default behavior is to show an interstitial to the user, with the reporting checkbox visible.
|
|
///
|
|
///[url] represents the url of the request.
|
|
///
|
|
///[threatType] represents the reason the resource was caught by Safe Browsing, corresponding to a [SafeBrowsingThreat].
|
|
///
|
|
///**NOTE**: available only on Android 27+.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onSafeBrowsingHit](https://developer.android.com/reference/android/webkit/WebViewClient#onSafeBrowsingHit(android.webkit.WebView,%20android.webkit.WebResourceRequest,%20int,%20android.webkit.SafeBrowsingResponse)))
|
|
final Future<SafeBrowsingResponse?> Function(
|
|
InAppWebViewController controller,
|
|
Uri url,
|
|
SafeBrowsingThreat? threatType)? onSafeBrowsingHit;
|
|
|
|
///Use [onPermissionRequest] instead.
|
|
@Deprecated("Use onPermissionRequest instead")
|
|
final Future<PermissionRequestResponse?> Function(
|
|
InAppWebViewController controller,
|
|
String origin,
|
|
List<String> resources)? androidOnPermissionRequest;
|
|
|
|
///Event fired when the WebView is requesting permission to access the specified resources and the permission currently isn't granted or denied.
|
|
///
|
|
///[origin] represents the origin of the web page which is trying to access the restricted resources.
|
|
///
|
|
///[resources] represents the array of resources the web content wants to access.
|
|
///
|
|
///**NOTE for Android**: available only on Android 23+.
|
|
///
|
|
///**NOTE for iOS**: available only on iOS 15.0+. The default [PermissionResponse.action] is [PermissionResponseAction.PROMPT].
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onPermissionRequest](https://developer.android.com/reference/android/webkit/WebChromeClient#onPermissionRequest(android.webkit.PermissionRequest)))
|
|
///- iOS
|
|
final Future<PermissionResponse?> Function(InAppWebViewController controller,
|
|
PermissionRequest permissionRequest)? onPermissionRequest;
|
|
|
|
///Use [onGeolocationPermissionsShowPrompt] instead.
|
|
@Deprecated("Use onGeolocationPermissionsShowPrompt instead")
|
|
final Future<GeolocationPermissionShowPromptResponse?> Function(
|
|
InAppWebViewController controller, String origin)?
|
|
androidOnGeolocationPermissionsShowPrompt;
|
|
|
|
///Event that notifies the host application that web content from the specified origin is attempting to use the Geolocation API, but no permission state is currently set for that origin.
|
|
///Note that for applications targeting Android N and later SDKs (API level > `Build.VERSION_CODES.M`) this method is only called for requests originating from secure origins such as https.
|
|
///On non-secure origins geolocation requests are automatically denied.
|
|
///
|
|
///[origin] represents the origin of the web content attempting to use the Geolocation API.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsShowPrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)))
|
|
final Future<GeolocationPermissionShowPromptResponse?> Function(
|
|
InAppWebViewController controller, String origin)?
|
|
onGeolocationPermissionsShowPrompt;
|
|
|
|
///Use [onGeolocationPermissionsHidePrompt] instead.
|
|
@Deprecated("Use onGeolocationPermissionsHidePrompt instead")
|
|
final void Function(InAppWebViewController controller)?
|
|
androidOnGeolocationPermissionsHidePrompt;
|
|
|
|
///Notify the host application that a request for Geolocation permissions, made with a previous call to [onGeolocationPermissionsShowPrompt] has been canceled.
|
|
///Any related UI should therefore be hidden.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onGeolocationPermissionsHidePrompt](https://developer.android.com/reference/android/webkit/WebChromeClient#onGeolocationPermissionsHidePrompt()))
|
|
final void Function(InAppWebViewController controller)?
|
|
onGeolocationPermissionsHidePrompt;
|
|
|
|
///Use [shouldInterceptRequest] instead.
|
|
@Deprecated("Use shouldInterceptRequest instead")
|
|
final Future<WebResourceResponse?> Function(
|
|
InAppWebViewController controller, WebResourceRequest request)?
|
|
androidShouldInterceptRequest;
|
|
|
|
///Notify the host application of a resource request and allow the application to return the data.
|
|
///If the return value is `null`, the WebView will continue to load the resource as usual.
|
|
///Otherwise, the return response and data will be used.
|
|
///
|
|
///This callback is invoked for a variety of URL schemes (e.g., `http(s):`, `data:`, `file:`, etc.),
|
|
///not only those schemes which send requests over the network.
|
|
///This is not called for `javascript:` URLs, `blob:` URLs, or for assets accessed via `file:///android_asset/` or `file:///android_res/` URLs.
|
|
///
|
|
///In the case of redirects, this is only called for the initial resource URL, not any subsequent redirect URLs.
|
|
///
|
|
///[request] Object containing the details of the request.
|
|
///
|
|
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useShouldInterceptRequest] option to `true`.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.shouldInterceptRequest](https://developer.android.com/reference/android/webkit/WebViewClient#shouldInterceptRequest(android.webkit.WebView,%20android.webkit.WebResourceRequest)))
|
|
final Future<WebResourceResponse?> Function(
|
|
InAppWebViewController controller, WebResourceRequest request)?
|
|
shouldInterceptRequest;
|
|
|
|
///Use [onRenderProcessUnresponsive] instead.
|
|
@Deprecated("Use onRenderProcessUnresponsive instead")
|
|
final Future<WebViewRenderProcessAction?> Function(
|
|
InAppWebViewController controller, Uri? url)?
|
|
androidOnRenderProcessUnresponsive;
|
|
|
|
///Event called when the renderer currently associated with the WebView becomes unresponsive as a result of a long running blocking task such as the execution of JavaScript.
|
|
///
|
|
///If a WebView fails to process an input event, or successfully navigate to a new URL within a reasonable time frame, the renderer is considered to be unresponsive, and this callback will be called.
|
|
///
|
|
///This callback will continue to be called at regular intervals as long as the renderer remains unresponsive.
|
|
///If the renderer becomes responsive again, [onRenderProcessResponsive] will be called once,
|
|
///and this method will not subsequently be called unless another period of unresponsiveness is detected.
|
|
///
|
|
///The minimum interval between successive calls to [onRenderProcessUnresponsive] is 5 seconds.
|
|
///
|
|
///No action is taken by WebView as a result of this method call.
|
|
///Applications may choose to terminate the associated renderer via the object that is passed to this callback,
|
|
///if in multiprocess mode, however this must be accompanied by correctly handling [onRenderProcessGone] for this WebView,
|
|
///and all other WebViews associated with the same renderer. Failure to do so will result in application termination.
|
|
///
|
|
///**NOTE**: available only on Android 29+.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessUnresponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessUnresponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)))
|
|
final Future<WebViewRenderProcessAction?> Function(
|
|
InAppWebViewController controller, Uri? url)? onRenderProcessUnresponsive;
|
|
|
|
///Use [onRenderProcessResponsive] instead.
|
|
@Deprecated("Use onRenderProcessResponsive instead")
|
|
final Future<WebViewRenderProcessAction?> Function(
|
|
InAppWebViewController controller, Uri? url)?
|
|
androidOnRenderProcessResponsive;
|
|
|
|
///Event called once when an unresponsive renderer currently associated with the WebView becomes responsive.
|
|
///
|
|
///After a WebView renderer becomes unresponsive, which is notified to the application by [onRenderProcessUnresponsive],
|
|
///it is possible for the blocking renderer task to complete, returning the renderer to a responsive state.
|
|
///In that case, this method is called once to indicate responsiveness.
|
|
///
|
|
///No action is taken by WebView as a result of this method call.
|
|
///
|
|
///**NOTE**: available only on Android 29+.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewRenderProcessClient.onRenderProcessResponsive](https://developer.android.com/reference/android/webkit/WebViewRenderProcessClient#onRenderProcessResponsive(android.webkit.WebView,%20android.webkit.WebViewRenderProcess)))
|
|
final Future<WebViewRenderProcessAction?> Function(
|
|
InAppWebViewController controller, Uri? url)? onRenderProcessResponsive;
|
|
|
|
///Use [onRenderProcessGone] instead.
|
|
@Deprecated("Use onRenderProcessGone instead")
|
|
final void Function(
|
|
InAppWebViewController controller, RenderProcessGoneDetail detail)?
|
|
androidOnRenderProcessGone;
|
|
|
|
///Event fired when the given WebView's render process has exited.
|
|
///The application's implementation of this callback should only attempt to clean up the WebView.
|
|
///The WebView should be removed from the view hierarchy, all references to it should be cleaned up.
|
|
///
|
|
///[detail] the reason why it exited.
|
|
///
|
|
///**NOTE**: available only on Android 26+.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onRenderProcessGone](https://developer.android.com/reference/android/webkit/WebViewClient#onRenderProcessGone(android.webkit.WebView,%20android.webkit.RenderProcessGoneDetail)))
|
|
final void Function(
|
|
InAppWebViewController controller, RenderProcessGoneDetail detail)?
|
|
onRenderProcessGone;
|
|
|
|
///Use [onFormResubmission] instead.
|
|
@Deprecated('Use onFormResubmission instead')
|
|
final Future<FormResubmissionAction?> Function(
|
|
InAppWebViewController controller, Uri? url)? androidOnFormResubmission;
|
|
|
|
///As the host application if the browser should resend data as the requested page was a result of a POST. The default is to not resend the data.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onFormResubmission](https://developer.android.com/reference/android/webkit/WebViewClient#onFormResubmission(android.webkit.WebView,%20android.os.Message,%20android.os.Message)))
|
|
final Future<FormResubmissionAction?> Function(
|
|
InAppWebViewController controller, Uri? url)? onFormResubmission;
|
|
|
|
///Use [onZoomScaleChanged] instead.
|
|
@Deprecated('Use onZoomScaleChanged instead')
|
|
final void Function(
|
|
InAppWebViewController controller, double oldScale, double newScale)?
|
|
androidOnScaleChanged;
|
|
|
|
///Use [onReceivedIcon] instead.
|
|
@Deprecated('Use onReceivedIcon instead')
|
|
final void Function(InAppWebViewController controller, Uint8List icon)?
|
|
androidOnReceivedIcon;
|
|
|
|
///Event fired when there is new favicon for the current page.
|
|
///
|
|
///[icon] represents the favicon for the current page.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onReceivedIcon](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedIcon(android.webkit.WebView,%20android.graphics.Bitmap)))
|
|
final void Function(InAppWebViewController controller, Uint8List icon)?
|
|
onReceivedIcon;
|
|
|
|
///Use [onReceivedTouchIconUrl] instead.
|
|
@Deprecated('Use onReceivedTouchIconUrl instead')
|
|
final void Function(
|
|
InAppWebViewController controller, Uri url, bool precomposed)?
|
|
androidOnReceivedTouchIconUrl;
|
|
|
|
///Event fired when there is an url for an apple-touch-icon.
|
|
///
|
|
///[url] represents the icon url.
|
|
///
|
|
///[precomposed] is `true` if the url is for a precomposed touch icon.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onReceivedTouchIconUrl](https://developer.android.com/reference/android/webkit/WebChromeClient#onReceivedTouchIconUrl(android.webkit.WebView,%20java.lang.String,%20boolean)))
|
|
final void Function(
|
|
InAppWebViewController controller, Uri url, bool precomposed)?
|
|
onReceivedTouchIconUrl;
|
|
|
|
///Use [onJsBeforeUnload] instead.
|
|
@Deprecated('Use onJsBeforeUnload instead')
|
|
final Future<JsBeforeUnloadResponse?> Function(
|
|
InAppWebViewController controller,
|
|
JsBeforeUnloadRequest jsBeforeUnloadRequest)? androidOnJsBeforeUnload;
|
|
|
|
///Event fired when the client should display a dialog to confirm navigation away from the current page.
|
|
///This is the result of the `onbeforeunload` javascript event.
|
|
///If [JsBeforeUnloadResponse.handledByClient] is `true`, WebView will assume that the client will handle the confirm dialog.
|
|
///If [JsBeforeUnloadResponse.handledByClient] is `false`, a default value of `true` will be returned to javascript to accept navigation away from the current page.
|
|
///The default behavior is to return `false`.
|
|
///Setting the [JsBeforeUnloadResponse.action] to [JsBeforeUnloadResponseAction.CONFIRM] will navigate away from the current page,
|
|
///[JsBeforeUnloadResponseAction.CANCEL] will cancel the navigation.
|
|
///
|
|
///[jsBeforeUnloadRequest] contains the message to be displayed in the alert dialog and the of the page requesting the dialog.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebChromeClient.onJsBeforeUnload](https://developer.android.com/reference/android/webkit/WebChromeClient#onJsBeforeUnload(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)))
|
|
final Future<JsBeforeUnloadResponse?> Function(
|
|
InAppWebViewController controller,
|
|
JsBeforeUnloadRequest jsBeforeUnloadRequest)? onJsBeforeUnload;
|
|
|
|
///Use [onReceivedLoginRequest] instead.
|
|
@Deprecated('Use onReceivedLoginRequest instead')
|
|
final void Function(
|
|
InAppWebViewController controller, LoginRequest loginRequest)?
|
|
androidOnReceivedLoginRequest;
|
|
|
|
///Event fired when a request to automatically log in the user has been processed.
|
|
///
|
|
///[loginRequest] contains the realm, account and args of the login request.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView ([Official API - WebViewClient.onReceivedLoginRequest](https://developer.android.com/reference/android/webkit/WebViewClient#onReceivedLoginRequest(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20java.lang.String)))
|
|
final void Function(
|
|
InAppWebViewController controller, LoginRequest loginRequest)?
|
|
onReceivedLoginRequest;
|
|
|
|
///Use [onWebContentProcessDidTerminate] instead.
|
|
@Deprecated('Use onWebContentProcessDidTerminate instead')
|
|
final void Function(InAppWebViewController controller)?
|
|
iosOnWebContentProcessDidTerminate;
|
|
|
|
///Invoked when the web view's web content process is terminated.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- iOS ([Official API - WKNavigationDelegate.webViewWebContentProcessDidTerminate](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455639-webviewwebcontentprocessdidtermi))
|
|
final void Function(InAppWebViewController controller)?
|
|
onWebContentProcessDidTerminate;
|
|
|
|
///Use [onDidReceiveServerRedirectForProvisionalNavigation] instead.
|
|
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
|
|
final void Function(InAppWebViewController controller)?
|
|
iosOnDidReceiveServerRedirectForProvisionalNavigation;
|
|
|
|
///Called when a web view receives a server redirect.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455627-webview))
|
|
final void Function(InAppWebViewController controller)?
|
|
onDidReceiveServerRedirectForProvisionalNavigation;
|
|
|
|
///Use [onNavigationResponse] instead.
|
|
@Deprecated('Use onNavigationResponse instead')
|
|
final Future<IOSNavigationResponseAction?> Function(
|
|
InAppWebViewController controller,
|
|
IOSWKNavigationResponse navigationResponse)? iosOnNavigationResponse;
|
|
|
|
///Called when a web view asks for permission to navigate to new content after the response to the navigation request is known.
|
|
///
|
|
///[navigationResponse] represents the navigation response.
|
|
///
|
|
///**NOTE**: In order to be able to listen this event, you need to set [InAppWebViewSettings.useOnNavigationResponse] option to `true`.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/1455643-webview))
|
|
final Future<NavigationResponseAction?> Function(
|
|
InAppWebViewController controller,
|
|
NavigationResponse navigationResponse)? onNavigationResponse;
|
|
|
|
///Use [shouldAllowDeprecatedTLS] instead.
|
|
@Deprecated('Use shouldAllowDeprecatedTLS instead')
|
|
final Future<IOSShouldAllowDeprecatedTLSAction?> Function(
|
|
InAppWebViewController controller,
|
|
URLAuthenticationChallenge challenge)? iosShouldAllowDeprecatedTLS;
|
|
|
|
///Called when a web view asks whether to continue with a connection that uses a deprecated version of TLS (v1.0 and v1.1).
|
|
///
|
|
///[challenge] represents the authentication challenge.
|
|
///
|
|
///**NOTE**: available only on iOS 14.0+.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- iOS ([Official API - WKNavigationDelegate.webView](https://developer.apple.com/documentation/webkit/wknavigationdelegate/3601237-webview))
|
|
final Future<ShouldAllowDeprecatedTLSAction?> Function(
|
|
InAppWebViewController controller,
|
|
URLAuthenticationChallenge challenge)? shouldAllowDeprecatedTLS;
|
|
|
|
///Event fired when a change in the camera capture state occurred.
|
|
///
|
|
///**NOTE**: available only on iOS 15.0+.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- iOS
|
|
final Future<void> Function(
|
|
InAppWebViewController controller,
|
|
MediaCaptureState? oldState,
|
|
MediaCaptureState? newState,
|
|
)? onCameraCaptureStateChanged;
|
|
|
|
///Event fired when a change in the microphone capture state occurred.
|
|
///
|
|
///**NOTE**: available only on iOS 15.0+.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- iOS
|
|
final Future<void> Function(
|
|
InAppWebViewController controller,
|
|
MediaCaptureState? oldState,
|
|
MediaCaptureState? newState,
|
|
)? onMicrophoneCaptureStateChanged;
|
|
|
|
///Initial url request that will be loaded.
|
|
///
|
|
///**NOTE for Android**: when loading an URL Request using "POST" method, headers are ignored.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
///- Web
|
|
final URLRequest? initialUrlRequest;
|
|
|
|
///Initial asset file that will be loaded. See [InAppWebViewController.loadFile] for explanation.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
///- Web
|
|
final String? initialFile;
|
|
|
|
///Initial [InAppWebViewInitialData] that will be loaded.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
///- Web
|
|
final InAppWebViewInitialData? initialData;
|
|
|
|
///Use [initialSettings] instead.
|
|
@Deprecated('Use initialSettings instead')
|
|
final InAppWebViewGroupOptions? initialOptions;
|
|
|
|
///Initial settings that will be used.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
///- Web
|
|
final InAppWebViewSettings? initialSettings;
|
|
|
|
///Context menu which contains custom menu items to be shown when [ContextMenu] is presented.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
final ContextMenu? contextMenu;
|
|
|
|
///Initial list of user scripts to be loaded at start or end of a page loading.
|
|
///To add or remove user scripts, you have to use the [InAppWebViewController]'s methods such as [InAppWebViewController.addUserScript],
|
|
///[InAppWebViewController.removeUserScript], [InAppWebViewController.removeAllUserScripts], etc.
|
|
///
|
|
///**NOTE for iOS**: this property will be ignored if the [WebView.windowId] has been set.
|
|
///There isn't any way to add/remove user scripts specific to iOS window WebViews.
|
|
///This is a limitation of the native iOS WebKit APIs.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
final UnmodifiableListView<UserScript>? initialUserScripts;
|
|
|
|
///Represents the pull-to-refresh feature controller.
|
|
///
|
|
///**NOTE for Android**: to be able to use the "pull-to-refresh" feature, [InAppWebViewSettings.useHybridComposition] must be `true`.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
final PullToRefreshController? pullToRefreshController;
|
|
|
|
///Represents the find interaction feature controller.
|
|
///
|
|
///**Supported Platforms/Implementations**:
|
|
///- Android native WebView
|
|
///- iOS
|
|
final FindInteractionController? findInteractionController;
|
|
|
|
///Represents the WebView native implementation to be used.
|
|
///The default value is [WebViewImplementation.NATIVE].
|
|
final WebViewImplementation implementation;
|
|
|
|
WebView(
|
|
{this.windowId,
|
|
this.onWebViewCreated,
|
|
this.onLoadStart,
|
|
this.onLoadStop,
|
|
@Deprecated('Use onReceivedError instead')
|
|
this.onLoadError,
|
|
this.onReceivedError,
|
|
@Deprecated("Use onReceivedHttpError instead")
|
|
this.onLoadHttpError,
|
|
this.onReceivedHttpError,
|
|
this.onProgressChanged,
|
|
this.onConsoleMessage,
|
|
this.shouldOverrideUrlLoading,
|
|
this.onLoadResource,
|
|
this.onScrollChanged,
|
|
@Deprecated('Use onDownloadStartRequest instead')
|
|
this.onDownloadStart,
|
|
this.onDownloadStartRequest,
|
|
@Deprecated('Use onLoadResourceWithCustomScheme instead')
|
|
this.onLoadResourceCustomScheme,
|
|
this.onLoadResourceWithCustomScheme,
|
|
this.onCreateWindow,
|
|
this.onCloseWindow,
|
|
this.onJsAlert,
|
|
this.onJsConfirm,
|
|
this.onJsPrompt,
|
|
this.onReceivedHttpAuthRequest,
|
|
this.onReceivedServerTrustAuthRequest,
|
|
this.onReceivedClientCertRequest,
|
|
@Deprecated('Use FindInteractionController.onFindResultReceived instead')
|
|
this.onFindResultReceived,
|
|
this.shouldInterceptAjaxRequest,
|
|
this.onAjaxReadyStateChange,
|
|
this.onAjaxProgress,
|
|
this.shouldInterceptFetchRequest,
|
|
this.onUpdateVisitedHistory,
|
|
@Deprecated("Use onPrintRequest instead")
|
|
this.onPrint,
|
|
this.onPrintRequest,
|
|
this.onLongPressHitTestResult,
|
|
this.onEnterFullscreen,
|
|
this.onExitFullscreen,
|
|
this.onPageCommitVisible,
|
|
this.onTitleChanged,
|
|
this.onWindowFocus,
|
|
this.onWindowBlur,
|
|
this.onOverScrolled,
|
|
this.onZoomScaleChanged,
|
|
@Deprecated('Use onSafeBrowsingHit instead')
|
|
this.androidOnSafeBrowsingHit,
|
|
this.onSafeBrowsingHit,
|
|
@Deprecated('Use onPermissionRequest instead')
|
|
this.androidOnPermissionRequest,
|
|
this.onPermissionRequest,
|
|
@Deprecated('Use onGeolocationPermissionsShowPrompt instead')
|
|
this.androidOnGeolocationPermissionsShowPrompt,
|
|
this.onGeolocationPermissionsShowPrompt,
|
|
@Deprecated('Use onGeolocationPermissionsHidePrompt instead')
|
|
this.androidOnGeolocationPermissionsHidePrompt,
|
|
this.onGeolocationPermissionsHidePrompt,
|
|
@Deprecated('Use shouldInterceptRequest instead')
|
|
this.androidShouldInterceptRequest,
|
|
this.shouldInterceptRequest,
|
|
@Deprecated('Use onRenderProcessGone instead')
|
|
this.androidOnRenderProcessGone,
|
|
this.onRenderProcessGone,
|
|
@Deprecated('Use onRenderProcessResponsive instead')
|
|
this.androidOnRenderProcessResponsive,
|
|
this.onRenderProcessResponsive,
|
|
@Deprecated('Use onRenderProcessUnresponsive instead')
|
|
this.androidOnRenderProcessUnresponsive,
|
|
this.onRenderProcessUnresponsive,
|
|
@Deprecated('Use onFormResubmission instead')
|
|
this.androidOnFormResubmission,
|
|
this.onFormResubmission,
|
|
@Deprecated('Use onZoomScaleChanged instead')
|
|
this.androidOnScaleChanged,
|
|
@Deprecated('Use onReceivedIcon instead')
|
|
this.androidOnReceivedIcon,
|
|
this.onReceivedIcon,
|
|
@Deprecated('Use onReceivedTouchIconUrl instead')
|
|
this.androidOnReceivedTouchIconUrl,
|
|
this.onReceivedTouchIconUrl,
|
|
@Deprecated('Use onJsBeforeUnload instead')
|
|
this.androidOnJsBeforeUnload,
|
|
this.onJsBeforeUnload,
|
|
@Deprecated('Use onReceivedLoginRequest instead')
|
|
this.androidOnReceivedLoginRequest,
|
|
this.onReceivedLoginRequest,
|
|
@Deprecated('Use onWebContentProcessDidTerminate instead')
|
|
this.iosOnWebContentProcessDidTerminate,
|
|
this.onWebContentProcessDidTerminate,
|
|
@Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead')
|
|
this.iosOnDidReceiveServerRedirectForProvisionalNavigation,
|
|
this.onDidReceiveServerRedirectForProvisionalNavigation,
|
|
@Deprecated('Use onNavigationResponse instead')
|
|
this.iosOnNavigationResponse,
|
|
this.onNavigationResponse,
|
|
@Deprecated('Use shouldAllowDeprecatedTLS instead')
|
|
this.iosShouldAllowDeprecatedTLS,
|
|
this.shouldAllowDeprecatedTLS,
|
|
this.onCameraCaptureStateChanged,
|
|
this.onMicrophoneCaptureStateChanged,
|
|
this.initialUrlRequest,
|
|
this.initialFile,
|
|
this.initialData,
|
|
@Deprecated('Use initialSettings instead')
|
|
this.initialOptions,
|
|
this.initialSettings,
|
|
this.contextMenu,
|
|
this.initialUserScripts,
|
|
this.pullToRefreshController,
|
|
this.findInteractionController,
|
|
this.implementation = WebViewImplementation.NATIVE});
|
|
}
|