WebPlatformInAppWebViewController class

Controls a WebView, such as an InAppWebView widget instance, a WebPlatformHeadlessInAppWebView instance or WebPlatformInAppBrowser WebView instance.

If you are using the InAppWebView widget, an InAppWebViewController instance can be obtained by setting the InAppWebView.onWebViewCreated callback. Instead, if you are using an WebPlatformInAppBrowser instance, you can get it through the WebPlatformInAppBrowser.webViewController attribute.

Inheritance
  • Object
  • PlatformInterface
  • WebPlatformInAppWebViewController

Constructors

WebPlatformInAppWebViewController(PlatformInAppWebViewControllerCreationParams params)
WebPlatformInAppWebViewController.static()
factory

Properties

hashCode int
The hash code for this object.
no setterinherited
id → dynamic
WebView ID.
no setterinherited
params → PlatformInAppWebViewControllerCreationParams
The parameters used to initialize the PlatformInAppWebViewController.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tRexRunnerCss Future<String>
Gets the css of the Chromium's t-rex runner game. Used in combination with tRexRunnerHtml
no setter
tRexRunnerHtml Future<String>
Gets the html (with javascript) of the Chromium's t-rex runner game. Used in combination with tRexRunnerCss.
no setter
webStorage WebPlatformWebStorage
Provides access to the JavaScript Web Storage API: window.sessionStorage and window.localStorage.
getter/setter pair
webviewParams → PlatformWebViewCreationParams?
WebView params.
no setterinherited

Methods

addDevToolsProtocolEventListener({required String eventName, required dynamic callback(dynamic data)}) Future<void>
Subscribe to a DevToolsProtocol event.
inherited
addJavaScriptHandler({required String handlerName, required Function callback}) → void
Adds a JavaScript message handler callback (JavaScriptHandlerCallback or JavaScriptHandlerFunction) that listen to post messages sent from JavaScript by the handler with name handlerName. Forbidden handlerNames are represented by kJavaScriptHandlerForbiddenNames, they are used internally by this plugin.
addUserScript({required UserScript userScript}) Future<void>
Injects the specified userScript into the webpage’s content.
addUserScripts({required List<UserScript> userScripts}) Future<void>
Injects the userScripts into the webpage’s content.
addWebMessageListener(PlatformWebMessageListener webMessageListener) Future<void>
Adds a PlatformWebMessageListener to the WebView and injects a JavaScript object into each frame that the PlatformWebMessageListener will listen on.
inherited
callAsyncJavaScript({required String functionBody, Map<String, dynamic> arguments = const <String, dynamic>{}, ContentWorld? contentWorld}) Future<CallAsyncJavaScriptResult?>
Executes the specified string as an asynchronous JavaScript function.
inherited
callDevToolsProtocolMethod({required String methodName, Map<String, dynamic>? parameters}) Future
Runs an asynchronous DevToolsProtocol method.
inherited
canGoBack() Future<bool>
Returns a boolean value indicating whether the WebView can move backward.
inherited
canGoBackOrForward({required int steps}) Future<bool>
Returns a boolean value indicating whether the WebView can go back or forward the given number of steps. Steps is negative if backward and positive if forward.
inherited
canGoForward() Future<bool>
Returns a boolean value indicating whether the WebView can move forward.
inherited
canScrollHorizontally() Future<bool>
Returns true if the webpage can scroll horizontally, otherwise false.
canScrollVertically() Future<bool>
Returns true if the webpage can scroll vertically, otherwise false.
clearAllCache({bool includeDiskFiles = true}) Future<void>
Clears the resource cache. Note that the cache is per-application, so this will clear the cache for all WebViews used.
inherited
clearCache() Future<void>
Use PlatformInAppWebViewController.clearAllCache instead
inherited
clearClientCertPreferences() Future<void>
Clears the client certificate preferences stored in response to proceeding/cancelling client cert requests. Note that WebView automatically clears these preferences when the system keychain is updated. The preferences are shared by all the WebViews that are created by the embedder application.
inherited
clearFocus() Future<void>
Clears the current focus. On iOS and Android native WebView, it will clear also, for example, the current text selection.
inherited
clearFormData() Future<void>
Removes the autocomplete popup from the currently focused form field, if present. Note this only affects the display of the autocomplete popup, it does not remove any saved form data from this WebView's store.
inherited
clearHistory() Future<void>
Clears the internal back/forward list.
inherited
clearMatches() Future<void>
Use PlatformFindInteractionController.clearMatches instead.
inherited
clearSslPreferences() Future<void>
Clears the SSL preferences table stored in response to proceeding with SSL certificate errors.
inherited
closeAllMediaPresentations() Future<void>
Closes all media the web view is presenting, including picture-in-picture video and fullscreen video.
inherited
createPdf({IOSWKPDFConfiguration? iosWKPdfConfiguration, PDFConfiguration? pdfConfiguration}) Future<Uint8List?>
Generates PDF data from the web view’s contents asynchronously. Returns null if a problem occurred.
inherited
createWebArchiveData() Future<Uint8List?>
Creates a web archive of the web view’s current contents asynchronously. Returns null if a problem occurred.
inherited
createWebMessageChannel() Future<PlatformWebMessageChannel?>
Creates a message channel to communicate with JavaScript and returns the message channel with ports that represent the endpoints of this message channel. The HTML5 message channel functionality is described here.
inherited
disableWebView() Future<void>
Indicate that the current process does not intend to use WebView, and that an exception should be thrown if a WebView is created or any other methods in the android.webkit package are used.
inherited
dispose({bool isKeepAlive = false}) → void
Disposes the controller.
disposeKeepAlive(InAppWebViewKeepAlive keepAlive) Future<void>
Disposes the WebView that is using the keepAlive instance for the keep alive feature.
inherited
enableSlowWholeDocumentDraw() Future<void>
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.
inherited
evaluateJavascript({required String source, ContentWorld? contentWorld}) Future
Evaluates JavaScript source code into the WebView and returns the result of the evaluation.
findAllAsync({required String find}) Future<void>
Use PlatformFindInteractionController.findAll instead.
inherited
findNext({required bool forward}) Future<void>
Use PlatformFindInteractionController.findNext instead.
inherited
getCameraCaptureState() Future<MediaCaptureState?>
Returns a MediaCaptureState that indicates whether the webpage is using the camera to capture images or video.
inherited
getCertificate() Future<SslCertificate?>
Gets the SSL certificate for the main top-level page or null if there is no certificate (the site is not secure).
inherited
getContentHeight() Future<int?>
Gets the height of the HTML content.
getContentWidth() Future<int?>
Gets the width of the HTML content.
getCopyBackForwardList() Future<WebHistory?>
Gets the WebHistory for this WebView. This contains the back/forward list for use in querying each item in the history stack. This contains only a snapshot of the current state. Multiple calls to this method may return different objects. The object returned from this method will not be updated to reflect any new state.
inherited
getCurrentWebViewPackage() Future<WebViewPackageInfo?>
If WebView has already been loaded into the current process this method will return the package that was used to load it. Otherwise, the package that would be used if the WebView was loaded right now will be returned; this does not cause WebView to be loaded, so this information may become outdated at any time. The WebView package changes either when the current WebView package is updated, disabled, or uninstalled. It can also be changed through a Developer Setting. If the WebView package changes, any app process that has loaded WebView will be killed. The next time the app starts and loads WebView it will use the new WebView package instead.
inherited
getDefaultUserAgent() Future<String>
Gets the default user agent.
getFavicon({required WebUri url, FaviconImageFormat faviconImageFormat = FaviconImageFormat.PNG}) Future<Uint8List?>
Gets the favicon bytes for the given favicon url.
inherited
getFavicons() Future<List<Favicon>>
Gets the list of all favicons for the current page.
getFrameId() Future<int?>
Gets the ID of the main frame.
inherited
getHitTestResult() Future<InAppWebViewHitTestResult?>
Gets the hit result for hitting an HTML elements.
inherited
getHtml() Future<String?>
Gets the content html of the page. It first tries to get the content through javascript. If this doesn't work, it tries to get the content reading the file:
getIFrameId() Future<String?>
Returns the iframe id attribute used on the Web platform.
getJavaScriptBridgeName() Future<String>
Gets the name of the JavaScript Bridge object that is used to interact with the WebView. Use setJavaScriptBridgeName to set a custom name. The default name used by this plugin is flutter_inappwebview.
getMemoryUsageTargetLevel() Future<MemoryUsageTargetLevel?>
Gets the WebView memory usage target level.
inherited
getMetaTags() Future<List<MetaTag>>
Returns the list of <meta> tags of the current WebView.
getMetaThemeColor() Future<Color?>
Returns an instance of Color representing the content value of the <meta name="theme-color" content=""> tag of the current WebView, if available, otherwise null.
getMicrophoneCaptureState() Future<MediaCaptureState?>
Returns a MediaCaptureState that indicates whether the webpage is using the microphone to capture audio.
inherited
getOptions() Future<InAppWebViewGroupOptions?>
Use getSettings instead.
getOriginalUrl() Future<WebUri?>
Gets the URL that was originally requested for the current page. This is not always the same as the URL passed to InAppWebView.onLoadStart because although the load for that URL has begun, the current page may not have changed. Also, there may have been redirects resulting in a different URL to that originally requested.
getProgress() Future<int?>
Gets the progress for the current page. The progress value is between 0 and 100.
inherited
getSafeBrowsingPrivacyPolicyUrl() Future<WebUri?>
Returns a URL pointing to the privacy policy for Safe Browsing reporting.
inherited
getScale() Future<double?>
Use getZoomScale instead.
inherited
getScreenScale() Future<double>
Gets the device pixel ratio (scale factor) of the screen where the WebView is displayed.
inherited
getScrollX() Future<int?>
Returns the scrolled left position of the current WebView.
getScrollY() Future<int?>
Returns the scrolled top position of the current WebView.
getSelectedText() Future<String?>
Gets the selected text.
getSettings() Future<InAppWebViewSettings?>
Gets the current WebView settings. Returns null if it wasn't able to get them.
getTargetRefreshRate() Future<int>
Gets the current target refresh rate for the WebView in Hz.
inherited
getTitle() Future<String?>
Gets the title for the current page.
getTRexRunnerCss() Future<String>
Use tRexRunnerCss instead.
getTRexRunnerHtml() Future<String>
Use tRexRunnerHtml instead.
getUrl() Future<WebUri?>
Gets the URL for the current page. This is not always the same as the URL passed to PlatformWebViewCreationParams.onLoadStart because although the load for that URL has begun, the current page may not have changed.
getVariationsHeader() Future<String?>
Gets the WebView variations encoded to be used as the X-Client-Data HTTP header.
inherited
getViewId() → dynamic
View ID used internally.
getZoomScale() Future<double?>
Gets the current zoom scale of the WebView.
inherited
goBack() Future<void>
Goes back in the history of the WebView.
goBackOrForward({required int steps}) Future<void>
Goes to the history item that is the number of steps away from the current item. Steps is negative if backward and positive if forward.
goForward() Future<void>
Goes forward in the history of the WebView.
goTo({required WebHistoryItem historyItem}) Future<void>
Navigates to a WebHistoryItem from the back-forward WebHistory.list and sets it as the current item.
inherited
handlesURLScheme(String urlScheme) Future<bool>
Returns a Boolean value that indicates whether WebKit natively supports resources with the specified URL scheme.
inherited
hasJavaScriptHandler({required String handlerName}) bool
Returns true if a JavaScript handler with handlerName already exists, otherwise false.
hasOnlySecureContent() Future<bool>
A Boolean value indicating whether all resources on the page have been loaded over securely encrypted connections.
inherited
hasUserScript({required UserScript userScript}) bool
Returns true if the userScript has been already added, otherwise false.
hasWebMessageListener(PlatformWebMessageListener webMessageListener) bool
Returns true if the webMessageListener has been already added, otherwise false.
inherited
hideInputMethod() Future<void>
Request to hide the soft input view from the context of the view that is currently accepting input.
inherited
injectCSSCode({required String source}) Future<void>
Injects CSS into the WebView.
injectCSSFileFromAsset({required String assetFilePath}) Future<void>
Injects a CSS file into the WebView from the flutter assets directory.
injectCSSFileFromUrl({required WebUri urlFile, CSSLinkHtmlTagAttributes? cssLinkHtmlTagAttributes}) Future<void>
Injects an external CSS file into the WebView from a defined url.
injectJavascriptFileFromAsset({required String assetFilePath}) Future
Evaluates the content of a JavaScript file into the WebView from the flutter assets directory.
injectJavascriptFileFromUrl({required WebUri urlFile, ScriptHtmlTagAttributes? scriptHtmlTagAttributes}) Future<void>
Injects an external JavaScript file into the WebView from a defined url.
isClassSupported({TargetPlatform? platform}) bool
Check if the current class is supported by the defaultTargetPlatform or a specific platform.
inherited
isInFullscreen() Future<bool>
Returns true if the WebView is in fullscreen mode, otherwise false.
inherited
isInterfaceSupported(WebViewInterface interface) Future<bool>
Returns true if the WebView supports the specified interface, otherwise false.
inherited
isLoading() Future<bool>
Check if the WebView instance is in a loading state.
isMethodSupported(PlatformInAppWebViewControllerMethod method, {TargetPlatform? platform}) bool
Check if the given method is supported by the defaultTargetPlatform or a specific platform.
inherited
isMultiProcessEnabled() Future<bool>
Returns true if WebView is running in multi process mode.
inherited
isMuted() Future<bool>
Returns whether the webpage audio is muted.
inherited
isPlayingAudio() Future<bool>
Returns whether the webpage is playing audio.
inherited
isPropertySupported(PlatformInAppWebViewControllerProperty property, {TargetPlatform? platform}) bool
Check if the given property is supported by the defaultTargetPlatform or a specific platform.
inherited
isSecureContext() Future<bool>
Indicates whether the webpage context is capable of using features that require secure contexts.
isVisible() Future<bool>
Returns whether the WebView is currently visible.
inherited
loadData({required String data, String mimeType = "text/html", String encoding = "utf8", WebUri? baseUrl, Uri? androidHistoryUrl, WebUri? historyUrl, Uri? iosAllowingReadAccessTo, WebUri? allowingReadAccessTo}) Future<void>
Loads the given data into this WebView, using baseUrl as the base URL for the content.
loadFile({required String assetFilePath}) Future<void>
Loads the given assetFilePath.
loadSimulatedRequest({required URLRequest urlRequest, required Uint8List data, URLResponse? urlResponse}) Future<void>
Loads the web content from the data you provide as if the data were the response to the request. If urlResponse is null, it loads the web content from the data as an utf8 encoded HTML string as the response to the request.
inherited
loadUrl({required URLRequest urlRequest, Uri? iosAllowingReadAccessTo, WebUri? allowingReadAccessTo}) Future<void>
Loads the given urlRequest.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
openDevTools() Future<void>
Opens the DevTools window for the current document in the WebView. Does nothing if run when the DevTools window is already open.
inherited
pageDown({required bool bottom}) Future<bool>
Scrolls the contents of this WebView down by half the page size. Returns true if the page was scrolled.
inherited
pageUp({required bool top}) Future<bool>
Scrolls the contents of this WebView up by half the view size. Returns true if the page was scrolled.
inherited
pause() Future<void>
Does a best-effort attempt to pause any processing that can be paused safely, such as animations and geolocation. Note that this call does not pause JavaScript. To pause JavaScript globally, use PlatformInAppWebViewController.pauseTimers. To resume WebView, call resume.
inherited
pauseAllMediaPlayback() Future<void>
Pauses playback of all media in the web view.
inherited
pauseTimers() Future<void>
On Android native WebView, it pauses all layout, parsing, and JavaScript timers for all WebViews. This is a global requests, not restricted to just this WebView. This can be useful if the application has been paused.
inherited
postUrl({required WebUri url, required Uint8List postData}) Future<void>
Loads the given url with postData (x-www-form-urlencoded) using POST method into this WebView.
postWebMessage({required WebMessage message, WebUri? targetOrigin}) Future<void>
Post a message to main frame. The embedded application can restrict the messages to a certain target origin. See HTML5 spec for how target origin can be used.
inherited
printCurrentPage({PrintJobSettings? settings}) Future<PlatformPrintJobController?>
Prints the current page.
reload() Future<void>
Reloads the WebView.
reloadFromOrigin() Future<void>
Reloads the current page, performing end-to-end revalidation using cache-validating conditionals if possible.
inherited
removeAllUserScripts() Future<void>
Removes all the user scripts from the webpage’s content.
removeDevToolsProtocolEventListener({required String eventName}) Future<void>
Remove an event handler previously added with addDevToolsProtocolEventListener.
inherited
removeJavaScriptHandler({required String handlerName}) Function?
Removes a JavaScript message handler previously added with the addJavaScriptHandler associated to handlerName key. Returns the value associated with handlerName before it was removed. Returns null if handlerName was not found.
removeUserScript({required UserScript userScript}) Future<bool>
Removes the specified userScript from the webpage’s content. User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. Returns true if userScript was in the list, false otherwise.
removeUserScripts({required List<UserScript> userScripts}) Future<void>
Removes the userScripts from the webpage’s content. User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load.
removeUserScriptsByGroupName({required String groupName}) Future<void>
Removes all the UserScripts with groupName as group name from the webpage’s content. User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load.
requestEnterFullscreen() Future<void>
Requests the WebView to enter fullscreen mode. This dispatches a fullscreen request to the WPE backend.
inherited
requestExitFullscreen() Future<void>
Requests the WebView to exit fullscreen mode. This dispatches an exit fullscreen request to the WPE backend.
inherited
requestFocus({FocusDirection? direction, InAppWebViewRect? previouslyFocusedRect}) Future<bool?>
Call this method when you want to try the WebView to be the first responder.
inherited
requestFocusNodeHref() Future<RequestFocusNodeHrefResult?>
Requests the anchor or image element URL at the last tapped point.
inherited
requestImageRef() Future<RequestImageRefResult?>
Requests the URL of the image last touched by the user.
inherited
requestMediaPlaybackState() Future<MediaPlaybackState?>
Requests the playback status of media in the web view. Returns a MediaPlaybackState that indicates whether the media in the web view is playing, paused, or suspended. If there’s no media in the web view to play, this method provides MediaPlaybackState.NONE.
inherited
requestPointerLock() Future<bool>
Requests pointer lock for the WebView. Pointer lock is useful for games and immersive applications. Returns true if the request was granted, false otherwise.
inherited
requestPointerUnlock() Future<bool>
Releases the pointer lock for the WebView. Returns true if the unlock was successful, false otherwise.
inherited
restoreState(Uint8List state) Future<bool>
Restores the state of this WebView from the given state returned by the saveState method. If it is called after this WebView has had a chance to build state (load pages, create a back/forward list, etc.), there may be undesirable side-effects.
inherited
resume() Future<void>
Resumes a WebView after a previous call to pause.
inherited
resumeTimers() Future<void>
On Android, it resumes all layout, parsing, and JavaScript timers for all WebViews. This will resume dispatching all timers.
inherited
saveState() Future<Uint8List?>
Returns the current state of interaction in a web view so that you can restore that state later to another web view using the restoreState method.
inherited
saveWebArchive({required String filePath, bool autoname = false}) Future<String?>
Saves the current WebView as a web archive. Returns the file path under which the web archive file was saved, or null if saving the file failed.
inherited
scrollBy({required int x, required int y, bool animated = false}) Future<void>
Moves the scrolled position of the WebView.
scrollTo({required int x, required int y, bool animated = false}) Future<void>
Scrolls the WebView to the position.
setAllMediaPlaybackSuspended({required bool suspended}) Future<void>
Changes whether the webpage is suspending playback of all media in the page. Pass true to pause all media the web view is playing. Neither the user nor the webpage can resume playback until you call this method again with false.
inherited
setCameraCaptureState({required MediaCaptureState state}) Future<void>
Changes whether the webpage is using the camera to capture images or video.
inherited
setContextMenu(ContextMenu? contextMenu) Future<void>
Sets or updates the WebView context menu to be used next time it will appear.
inherited
setInputMethodEnabled(bool enabled) Future<void>
Enables/Disables the input method (system-supplied keyboard) whilst interacting with the webview.
inherited
setJavaScriptBridgeName(String bridgeName) Future<void>
Sets the name of the JavaScript Bridge object that will be used to interact with the WebView. This method should be called before any WebViews are created or when there are no WebViews. Calling this method after a WebView has been created will not change the current JavaScript Bridge object and could lead to errors.
setMemoryUsageTargetLevel(MemoryUsageTargetLevel level) Future<void>
Sets the WebView memory usage target level.
inherited
setMicrophoneCaptureState({required MediaCaptureState state}) Future<void>
Changes whether the webpage is using the microphone to capture audio.
inherited
setMuted({required bool muted}) Future<void>
Sets the mute state of the webpage.
inherited
setOptions({required InAppWebViewGroupOptions options}) Future<void>
Use setSettings instead.
setSafeBrowsingAllowlist({required List<String> hosts}) Future<bool>
Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews.
inherited
setSafeBrowsingWhitelist({required List<String> hosts}) Future<bool>
Use setSafeBrowsingAllowlist instead.
inherited
setScreenScale({required double scale}) Future<void>
Sets the device pixel ratio (scale factor) for the screen where the WebView is displayed.
inherited
setSettings({required InAppWebViewSettings settings}) Future<void>
Sets the WebView settings with the new settings and evaluates them.
setTargetRefreshRate({required int rate}) Future<void>
Sets the target refresh rate for the WebView in Hz. A value of 0 means the default rate.
inherited
setVisible({required bool visible}) Future<void>
Sets the visibility state of the WebView. When set to false, the WebView is marked as hidden which may reduce resource usage.
inherited
setWebContentsDebuggingEnabled(bool debuggingEnabled) Future<void>
Enables debugging of web contents (HTML / CSS / JavaScript) loaded into any WebViews of this application. This flag can be enabled in order to facilitate debugging of web layouts and JavaScript code running inside WebViews. Please refer to WebView documentation for the debugging guide. The default is false.
inherited
showInputMethod() Future<void>
Explicitly request that the current input method's soft input area be shown to the user, if needed.
inherited
showSaveAsUI() Future<SaveAsUIResult?>
Shows the Save As UI for the current document.
inherited
startSafeBrowsing() Future<bool>
Starts Safe Browsing initialization.
inherited
stopLoading() Future<void>
Stops the WebView from loading.
takeScreenshot({ScreenshotConfiguration? screenshotConfiguration}) Future<Uint8List?>
Takes a screenshot of the WebView's visible viewport and returns a Uint8List. Returns null if it wasn't be able to take it.
inherited
terminateWebProcess() Future<void>
Terminates the web process associated to the WebView.
inherited
toString() String
A string representation of this object.
inherited
zoomBy({required double zoomFactor, bool? iosAnimated, bool animated = false}) Future<void>
Performs a zoom operation in this WebView.
inherited
zoomIn() Future<bool>
Performs zoom in in this WebView. Returns true if zoom in succeeds, false if no zoom changes.
inherited
zoomOut() Future<bool>
Performs zoom out in this WebView. Returns true if zoom out succeeds, false if no zoom changes.
inherited

Operators

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