InAppWebViewController class Null safety

Controls a WebView, such as an InAppWebView widget instance, a HeadlessInAppWebView instance or InAppBrowser 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 InAppBrowser instance, you can get it through the InAppBrowser.webViewController attribute.


InAppWebViewController(dynamic id, WebView webview)
InAppWebViewController.fromInAppBrowser(MethodChannel channel, InAppBrowser inAppBrowser, UnmodifiableListView<UserScript>? initialUserScripts)


android AndroidInAppWebViewController
Android controller that contains only android-specific methods
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
ios IOSInAppWebViewController
iOS controller that contains only ios-specific methods
read / write
javaScriptHandlersMap Map<String, JavaScriptHandlerCallback>
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
webStorage WebStorage
Provides access to the JavaScript Web Storage API: window.sessionStorage and window.localStorage.
read / write


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 WebMessageListener to the WebView and injects a JavaScript object into each frame that the WebMessageListener 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>
Clears all the webview's cache.
clearFocus() Future<void>
Clears the current focus. It will clear also, for example, the current text selection. [...]
clearMatches() Future<void>
Clears the highlighting surrounding text matches created by findAllAsync(). [...]
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. [...]
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>
Finds all instances of find on the page and highlights them. Notifies WebView.onFindResultReceived listener. [...]
findNext({required bool forward}) Future<void>
Highlights and scrolls to the next match found by findAllAsync(). Notifies WebView.onFindResultReceived listener. [...]
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. [...]
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: [...]
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. [...]
getOptions() Future<InAppWebViewGroupOptions?>
Gets the current WebView options. Returns null if it wasn't able to get them.
getProgress() Future<int?>
Gets the progress for the current page. The progress value is between 0 and 100. [...]
getScale() Future<double?>
Use getZoomScale instead.
@Deprecated('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. [...]
getTitle() Future<String?>
Gets the title for the current page. [...]
getTRexRunnerCss() Future<String>
Gets the css of the Chromium's t-rex runner game. Used in combination with getTRexRunnerHtml().
getTRexRunnerHtml() Future<String>
Gets the html (with javascript) of the Chromium's t-rex runner game. Used in combination with getTRexRunnerCss().
getUrl() Future<Uri?>
Gets the URL for the current page. This is not always the same as the URL passed to WebView.onLoadStart because although the load for that URL has begun, the current page may not have changed. [...]
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.
handleMethod(MethodCall call) Future
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 Uri 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 Uri urlFile, ScriptHtmlTagAttributes? scriptHtmlTagAttributes}) Future<void>
Injects an external JavaScript file into the WebView from a defined url. [...]
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", Uri? baseUrl, Uri? androidHistoryUrl, Uri? iosAllowingReadAccessTo}) 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. [...]
loadUrl({required URLRequest urlRequest, Uri? iosAllowingReadAccessTo}) Future<void>
Loads the given urlRequest. [...]
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
pauseTimers() Future<void>
On Android, 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 Uri 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, Uri? 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() Future<void>
Prints the current page. [...]
reload() Future<void>
Reloads the WebView. [...]
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. [...]
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. [...]
setContextMenu(ContextMenu? contextMenu) Future<void>
Sets or updates the WebView context menu to be used next time it will appear.
setOptions({required InAppWebViewGroupOptions options}) Future<void>
Sets the WebView options with the new options and evaluates them.
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. [...]
zoomBy({required double zoomFactor, bool iosAnimated = false}) Future<void>
Performs a zoom operation in this WebView. [...]


operator ==(Object other) bool
The equality operator. [...]

Static Methods

getDefaultUserAgent() Future<String>
Gets the default user agent. [...]