HeadlessInAppWebView class

Class that represents a WebView in headless mode. It can be used to run a WebView in background without attaching an InAppWebView to the widget tree.

NOTE: Remember to dispose it when you don't need it anymore.

Officially Supported Platforms/Implementations:

  • Android native WebView
  • iOS
  • Web
  • MacOS
  • Windows

Constructors

HeadlessInAppWebView({Size initialSize = const Size(-1, -1), int? windowId, HeadlessInAppWebView? headlessWebView, InAppWebViewKeepAlive? keepAlive, bool? preventGestureDelay, WebViewEnvironment? webViewEnvironment, @Deprecated('Use onGeolocationPermissionsHidePrompt instead') void androidOnGeolocationPermissionsHidePrompt(InAppWebViewController controller)?, @Deprecated('Use onGeolocationPermissionsShowPrompt instead') Future<GeolocationPermissionShowPromptResponse?> androidOnGeolocationPermissionsShowPrompt(InAppWebViewController controller, String origin)?, @Deprecated('Use onPermissionRequest instead') Future<PermissionRequestResponse?> androidOnPermissionRequest(InAppWebViewController controller, String origin, List<String> resources)?, @Deprecated('Use onSafeBrowsingHit instead') Future<SafeBrowsingResponse?> androidOnSafeBrowsingHit(InAppWebViewController controller, Uri url, SafeBrowsingThreat? threatType)?, InAppWebViewInitialData? initialData, String? initialFile, @Deprecated('Use initialSettings instead') InAppWebViewGroupOptions? initialOptions, InAppWebViewSettings? initialSettings, URLRequest? initialUrlRequest, UnmodifiableListView<UserScript>? initialUserScripts, PullToRefreshController? pullToRefreshController, FindInteractionController? findInteractionController, ContextMenu? contextMenu, void onPageCommitVisible(InAppWebViewController controller, WebUri? url)?, void onTitleChanged(InAppWebViewController controller, String? title)?, @Deprecated('Use onDidReceiveServerRedirectForProvisionalNavigation instead') void iosOnDidReceiveServerRedirectForProvisionalNavigation(InAppWebViewController controller)?, @Deprecated('Use onWebContentProcessDidTerminate instead') void iosOnWebContentProcessDidTerminate(InAppWebViewController controller)?, @Deprecated('Use onNavigationResponse instead') Future<IOSNavigationResponseAction?> iosOnNavigationResponse(InAppWebViewController controller, IOSWKNavigationResponse navigationResponse)?, @Deprecated('Use shouldAllowDeprecatedTLS instead') Future<IOSShouldAllowDeprecatedTLSAction?> iosShouldAllowDeprecatedTLS(InAppWebViewController controller, URLAuthenticationChallenge challenge)?, Future<AjaxRequestAction> onAjaxProgress(InAppWebViewController controller, AjaxRequest ajaxRequest)?, Future<AjaxRequestAction?> onAjaxReadyStateChange(InAppWebViewController controller, AjaxRequest ajaxRequest)?, void onConsoleMessage(InAppWebViewController controller, ConsoleMessage consoleMessage)?, Future<bool?> onCreateWindow(InAppWebViewController controller, CreateWindowAction createWindowAction)?, void onCloseWindow(InAppWebViewController controller)?, void onWindowFocus(InAppWebViewController controller)?, void onWindowBlur(InAppWebViewController controller)?, @Deprecated('Use onReceivedIcon instead') void androidOnReceivedIcon(InAppWebViewController controller, Uint8List icon)?, @Deprecated('Use onReceivedTouchIconUrl instead') void androidOnReceivedTouchIconUrl(InAppWebViewController controller, Uri url, bool precomposed)?, @Deprecated('Use onDownloadStartRequest instead') void onDownloadStart(InAppWebViewController controller, Uri url)?, void onDownloadStartRequest(InAppWebViewController controller, DownloadStartRequest downloadStartRequest)?, @Deprecated('Use FindInteractionController.onFindResultReceived instead') void onFindResultReceived(InAppWebViewController controller, int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting)?, Future<JsAlertResponse?> onJsAlert(InAppWebViewController controller, JsAlertRequest jsAlertRequest)?, Future<JsConfirmResponse?> onJsConfirm(InAppWebViewController controller, JsConfirmRequest jsConfirmRequest)?, Future<JsPromptResponse?> onJsPrompt(InAppWebViewController controller, JsPromptRequest jsPromptRequest)?, @Deprecated("Use onReceivedError instead") void onLoadError(InAppWebViewController controller, Uri? url, int code, String message)?, void onReceivedError(InAppWebViewController controller, WebResourceRequest request, WebResourceError error)?, @Deprecated("Use onReceivedHttpError instead") void onLoadHttpError(InAppWebViewController controller, Uri? url, int statusCode, String description)?, void onReceivedHttpError(InAppWebViewController controller, WebResourceRequest request, WebResourceResponse errorResponse)?, void onLoadResource(InAppWebViewController controller, LoadedResource resource)?, @Deprecated('Use onLoadResourceWithCustomScheme instead') Future<CustomSchemeResponse?> onLoadResourceCustomScheme(InAppWebViewController controller, Uri url)?, Future<CustomSchemeResponse?> onLoadResourceWithCustomScheme(InAppWebViewController controller, WebResourceRequest request)?, void onLoadStart(InAppWebViewController controller, WebUri? url)?, void onLoadStop(InAppWebViewController controller, WebUri? url)?, void onLongPressHitTestResult(InAppWebViewController controller, InAppWebViewHitTestResult hitTestResult)?, @Deprecated("Use onPrintRequest instead") void onPrint(InAppWebViewController controller, Uri? url)?, Future<bool?> onPrintRequest(InAppWebViewController controller, WebUri? url, PlatformPrintJobController? printJobController)?, void onProgressChanged(InAppWebViewController controller, int progress)?, Future<ClientCertResponse?> onReceivedClientCertRequest(InAppWebViewController controller, URLAuthenticationChallenge challenge)?, Future<HttpAuthResponse?> onReceivedHttpAuthRequest(InAppWebViewController controller, URLAuthenticationChallenge challenge)?, Future<ServerTrustAuthResponse?> onReceivedServerTrustAuthRequest(InAppWebViewController controller, URLAuthenticationChallenge challenge)?, void onScrollChanged(InAppWebViewController controller, int x, int y)?, void onUpdateVisitedHistory(InAppWebViewController controller, WebUri? url, bool? isReload)?, void onWebViewCreated(InAppWebViewController controller)?, Future<AjaxRequest?> shouldInterceptAjaxRequest(InAppWebViewController controller, AjaxRequest ajaxRequest)?, Future<FetchRequest?> shouldInterceptFetchRequest(InAppWebViewController controller, FetchRequest fetchRequest)?, Future<NavigationActionPolicy?> shouldOverrideUrlLoading(InAppWebViewController controller, NavigationAction navigationAction)?, void onEnterFullscreen(InAppWebViewController controller)?, void onExitFullscreen(InAppWebViewController controller)?, void onOverScrolled(InAppWebViewController controller, int x, int y, bool clampedX, bool clampedY)?, void onZoomScaleChanged(InAppWebViewController controller, double oldScale, double newScale)?, @Deprecated('Use shouldInterceptRequest instead') Future<WebResourceResponse?> androidShouldInterceptRequest(InAppWebViewController controller, WebResourceRequest request)?, @Deprecated('Use onRenderProcessUnresponsive instead') Future<WebViewRenderProcessAction?> androidOnRenderProcessUnresponsive(InAppWebViewController controller, Uri? url)?, @Deprecated('Use onRenderProcessResponsive instead') Future<WebViewRenderProcessAction?> androidOnRenderProcessResponsive(InAppWebViewController controller, Uri? url)?, @Deprecated('Use onRenderProcessGone instead') void androidOnRenderProcessGone(InAppWebViewController controller, RenderProcessGoneDetail detail)?, @Deprecated('Use onFormResubmission instead') Future<FormResubmissionAction?> androidOnFormResubmission(InAppWebViewController controller, Uri? url)?, @Deprecated('Use onZoomScaleChanged instead') void androidOnScaleChanged(InAppWebViewController controller, double oldScale, double newScale)?, @Deprecated('Use onJsBeforeUnload instead') Future<JsBeforeUnloadResponse?> androidOnJsBeforeUnload(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)?, @Deprecated('Use onReceivedLoginRequest instead') void androidOnReceivedLoginRequest(InAppWebViewController controller, LoginRequest loginRequest)?, void onDidReceiveServerRedirectForProvisionalNavigation(InAppWebViewController controller)?, Future<FormResubmissionAction?> onFormResubmission(InAppWebViewController controller, WebUri? url)?, void onGeolocationPermissionsHidePrompt(InAppWebViewController controller)?, Future<GeolocationPermissionShowPromptResponse?> onGeolocationPermissionsShowPrompt(InAppWebViewController controller, String origin)?, Future<JsBeforeUnloadResponse?> onJsBeforeUnload(InAppWebViewController controller, JsBeforeUnloadRequest jsBeforeUnloadRequest)?, Future<NavigationResponseAction?> onNavigationResponse(InAppWebViewController controller, NavigationResponse navigationResponse)?, Future<PermissionResponse?> onPermissionRequest(InAppWebViewController controller, PermissionRequest permissionRequest)?, void onReceivedIcon(InAppWebViewController controller, Uint8List icon)?, void onReceivedLoginRequest(InAppWebViewController controller, LoginRequest loginRequest)?, void onPermissionRequestCanceled(InAppWebViewController controller, PermissionRequest permissionRequest)?, void onRequestFocus(InAppWebViewController controller)?, void onReceivedTouchIconUrl(InAppWebViewController controller, WebUri url, bool precomposed)?, void onRenderProcessGone(InAppWebViewController controller, RenderProcessGoneDetail detail)?, Future<WebViewRenderProcessAction?> onRenderProcessResponsive(InAppWebViewController controller, WebUri? url)?, Future<WebViewRenderProcessAction?> onRenderProcessUnresponsive(InAppWebViewController controller, WebUri? url)?, Future<SafeBrowsingResponse?> onSafeBrowsingHit(InAppWebViewController controller, WebUri url, SafeBrowsingThreat? threatType)?, void onWebContentProcessDidTerminate(InAppWebViewController controller)?, Future<ShouldAllowDeprecatedTLSAction?> shouldAllowDeprecatedTLS(InAppWebViewController controller, URLAuthenticationChallenge challenge)?, Future<WebResourceResponse?> shouldInterceptRequest(InAppWebViewController controller, WebResourceRequest request)?, Future<void> onCameraCaptureStateChanged(InAppWebViewController controller, MediaCaptureState? oldState, MediaCaptureState? newState)?, Future<void> onMicrophoneCaptureStateChanged(InAppWebViewController controller, MediaCaptureState? oldState, MediaCaptureState? newState)?, void onContentSizeChanged(InAppWebViewController controller, Size oldContentSize, Size newContentSize)?})
HeadlessInAppWebView.fromPlatform({required PlatformHeadlessInAppWebView platform})
Constructs a HeadlessInAppWebView from a specific platform implementation.
HeadlessInAppWebView.fromPlatformCreationParams({required PlatformHeadlessInAppWebViewCreationParams params})
Constructs a HeadlessInAppWebView.

Properties

hashCode int
The hash code for this object.
no setterinherited
id String
View ID.
no setter
platform PlatformHeadlessInAppWebView
Implementation of PlatformHeadlessInAppWebView for the current platform.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
webViewController InAppWebViewController?
WebView Controller that can be used to access the InAppWebViewController API.
no setter

Methods

dispose() Future<void>
Disposes the headless WebView.
getSize() Future<Size?>
Gets the current size in pixels of the WebView.
isRunning() bool
Indicates if the headless WebView is running or not.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run() Future<void>
Runs the headless WebView.
setSize(Size size) Future<void>
Set the size of the WebView in pixels.
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited