InAppWebViewController class

Properties

android AndroidInAppWebViewController
Use InAppWebViewController instead.
getter/setter pair
hashCode int
The hash code for this object.
no setterinherited
ios IOSInAppWebViewController
Use InAppWebViewController instead.
getter/setter pair
platform PlatformInAppWebViewController
Implementation of PlatformInAppWebViewController for the current platform.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
webStorage WebStorage
Provides access to the JavaScript Web Storage API: window.sessionStorage and window.localStorage.
no setter

Methods

addJavaScriptHandler({required String handlerName, required JavaScriptHandlerCallback callback}) → void
Adds a JavaScript message handler callback (JavaScriptHandlerCallback) that listen to post messages sent from JavaScript by the handler with name handlerName.
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(WebMessageListener webMessageListener) Future<void>
Adds a PlatformWebMessageListener to the WebView and injects a JavaScript object into each frame that the PlatformWebMessageListener will listen on.
callAsyncJavaScript({required String functionBody, Map<String, dynamic> arguments = const <String, dynamic>{}, ContentWorld? contentWorld}) Future<CallAsyncJavaScriptResult?>
Executes the specified string as an asynchronous JavaScript function.
canGoBack() Future<bool>
Returns a boolean value indicating whether the WebView can move backward.
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.
canGoForward() Future<bool>
Returns a boolean value indicating whether the WebView can move forward.
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.
clearCache() Future<void>
Use PlatformInAppWebViewController.clearAllCache instead
clearFocus() Future<void>
Clears the current focus. On iOS and Android native WebView, it will clear also, for example, the current text selection.
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.
clearHistory() Future<void>
Clears the internal back/forward list.
clearMatches() Future<void>
Use PlatformFindInteractionController.clearMatches instead.
clearSslPreferences() Future<void>
Clears the SSL preferences table stored in response to proceeding with SSL certificate errors.
closeAllMediaPresentations() Future<void>
Closes all media the web view is presenting, including picture-in-picture video and fullscreen video.
createPdf({IOSWKPDFConfiguration? iosWKPdfConfiguration, PDFConfiguration? pdfConfiguration}) Future<Uint8List?>
Generates PDF data from the web view’s contents asynchronously. Returns null if a problem occurred.
createWebArchiveData() Future<Uint8List?>
Creates a web archive of the web view’s current contents asynchronously. Returns null if a problem occurred.
createWebMessageChannel() Future<WebMessageChannel?>
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.
dispose({bool isKeepAlive = false}) → void
Disposes the controller.
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.
findNext({required bool forward}) Future<void>
Use PlatformFindInteractionController.findNext instead.
getCameraCaptureState() Future<MediaCaptureState?>
Returns a MediaCaptureState that indicates whether the webpage is using the camera to capture images or video.
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).
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.
getFavicons() Future<List<Favicon>>
Gets the list of all favicons for the current page.
getHitTestResult() Future<InAppWebViewHitTestResult?>
Gets the hit result for hitting an HTML elements.
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.
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.
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.
getScale() Future<double?>
Use getZoomScale instead.
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.
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.
getViewId() → dynamic
View ID used internally.
getZoomScale() Future<double?>
Gets the current zoom scale of the WebView.
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.
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.
hasUserScript({required UserScript userScript}) bool
Returns true if the userScript has been already added, otherwise false.
hasWebMessageListener(WebMessageListener webMessageListener) bool
Returns true if the webMessageListener has been already added, otherwise false.
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.
isInFullscreen() Future<bool>
Returns true if the WebView is in fullscreen mode, otherwise false.
isLoading() Future<bool>
Check if the WebView instance is in a loading state.
isSecureContext() Future<bool>
Indicates whether the webpage context is capable of using features that require secure contexts. This is implemented using Javascript (see window.isSecureContext).
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.
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
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.
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.
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.
pauseAllMediaPlayback() Future<void>
Pauses playback of all media in the web view.
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.
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.
printCurrentPage({PrintJobSettings? settings}) Future<PrintJobController?>
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.
removeAllUserScripts() Future<void>
Removes all the user scripts from the webpage’s content.
removeJavaScriptHandler({required String handlerName}) JavaScriptHandlerCallback?
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.
requestFocusNodeHref() Future<RequestFocusNodeHrefResult?>
Requests the anchor or image element URL at the last tapped point.
requestImageRef() Future<RequestImageRefResult?>
Requests the URL of the image last touched by the user.
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.
resume() Future<void>
Resumes a WebView after a previous call to pause.
resumeTimers() Future<void>
On Android, it resumes all layout, parsing, and JavaScript timers for all WebViews. This will resume dispatching all timers.
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.
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.
setCameraCaptureState({required MediaCaptureState state}) Future<void>
Changes whether the webpage is using the camera to capture images or video.
setContextMenu(ContextMenu? contextMenu) Future<void>
Sets or updates the WebView context menu to be used next time it will appear.
setMicrophoneCaptureState({required MediaCaptureState state}) Future<void>
Changes whether the webpage is using the microphone to capture audio.
setOptions({required InAppWebViewGroupOptions options}) Future<void>
Use setSettings instead.
setSettings({required InAppWebViewSettings settings}) Future<void>
Sets the WebView settings with the new settings and evaluates them.
startSafeBrowsing() Future<bool>
Starts Safe Browsing initialization.
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.
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.
zoomIn() Future<bool>
Performs zoom in in this WebView. Returns true if zoom in succeeds, false if no zoom changes.
zoomOut() Future<bool>
Performs zoom out in this WebView. Returns true if zoom out succeeds, false if no zoom changes.

Operators

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

Static Properties

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

Static Methods

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.
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.
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.
disposeKeepAlive(InAppWebViewKeepAlive keepAlive) Future<void>
Disposes the WebView that is using the keepAlive instance for the keep alive feature.
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.
getDefaultUserAgent() Future<String>
Gets the default user agent.
getSafeBrowsingPrivacyPolicyUrl() Future<WebUri?>
Returns a URL pointing to the privacy policy for Safe Browsing reporting.
getVariationsHeader() Future<String?>
Gets the WebView variations encoded to be used as the X-Client-Data HTTP header.
handlesURLScheme(String urlScheme) Future<bool>
Returns a Boolean value that indicates whether WebKit natively supports resources with the specified URL scheme.
isMultiProcessEnabled() Future<bool>
Returns true if WebView is running in multi process mode.
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.
setSafeBrowsingWhitelist({required List<String> hosts}) Future<bool>
Use setSafeBrowsingAllowlist instead.
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.