Use the InAppWebViewController class instance to control and interact with the WebView.

Cross-platform methods

This list is generated from the InAppWebViewController API Reference.

  • addJavaScriptHandler: Adds a JavaScript message handler callback (JavaScriptHandlerCallback) that listen to post messages sent from JavaScript by the handler with name handlerName. (READ MORE)
  • addUserScript: Injects the specified userScript into the webpage’s content. (READ MORE)
  • addUserScripts: Injects the userScripts into the webpage’s content. (READ MORE)
  • addWebMessageListener: Adds a WebMessageListener to the WebView and injects a JavaScript object into each frame that the WebMessageListener will listen on. (READ MORE)
  • callAsyncJavaScript: Executes the specified string as an asynchronous JavaScript function. (READ MORE)
  • canGoBack: Returns a boolean value indicating whether the WebView can move backward. (READ MORE)
  • canGoBackOrForward: 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. (READ MORE)
  • canGoForward: Returns a boolean value indicating whether the WebView can move forward. (READ MORE)
  • canScrollHorizontally: Returns true if the webpage can scroll horizontally, otherwise false. (READ MORE)
  • canScrollVertically: Returns true if the webpage can scroll vertically, otherwise false. (READ MORE)
  • clearCache: Clears all the webview's cache. (READ MORE)
  • clearFocus: Clears the current focus. It will clear also, for example, the current text selection. (READ MORE)
  • clearMatches: Clears the highlighting surrounding text matches created by findAllAsync(). (READ MORE)
  • createWebMessageChannel: 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. (READ MORE)
  • evaluateJavascript: Evaluates JavaScript source code into the WebView and returns the result of the evaluation. (READ MORE)
  • findAllAsync: Finds all instances of find on the page and highlights them. Notifies WebView.onFindResultReceived listener. (READ MORE)
  • findNext: Highlights and scrolls to the next match found by findAllAsync(). Notifies WebView.onFindResultReceived listener. (READ MORE)
  • getCertificate: Gets the SSL certificate for the main top-level page or null if there is no certificate (the site is not secure). (READ MORE)
  • getContentHeight: Gets the height of the HTML content. (READ MORE)
  • getCopyBackForwardList: 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. (READ MORE)
  • getFavicons: Gets the list of all favicons for the current page. (READ MORE)
  • getHitTestResult: Gets the hit result for hitting an HTML elements. (READ MORE)
  • getHtml: 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: (READ MORE)
  • getMetaTags: Returns the list of <meta> tags of the current WebView. (READ MORE)
  • getMetaThemeColor: 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. (READ MORE)
  • getOptions: Gets the current WebView options. Returns null if it wasn't able to get them. (READ MORE)
  • getProgress: Gets the progress for the current page. The progress value is between 0 and 100. (READ MORE)
  • getScale: Use getZoomScale instead. @<a href="https://api.dart.dev/stable/2.12.1/dart-core/Deprecated-class.html">Deprecated</a>('Use `getZoomScale` instead') (READ MORE)
  • getScrollX: Returns the scrolled left position of the current WebView. (READ MORE)
  • getScrollY: Returns the scrolled top position of the current WebView. (READ MORE)
  • getSelectedText: Gets the selected text. (READ MORE)
  • getTitle: Gets the title for the current page. (READ MORE)
  • getTRexRunnerCss: Gets the css of the Chromium's t-rex runner game. Used in combination with getTRexRunnerHtml(). (READ MORE)
  • getTRexRunnerHtml: Gets the html (with javascript) of the Chromium's t-rex runner game. Used in combination with getTRexRunnerCss(). (READ MORE)
  • getUrl: 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. (READ MORE)
  • getZoomScale: Gets the current zoom scale of the WebView. (READ MORE)
  • goBack: Goes back in the history of the WebView. (READ MORE)
  • goBackOrForward: 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. (READ MORE)
  • goForward: Goes forward in the history of the WebView. (READ MORE)
  • goTo: Navigates to a WebHistoryItem from the back-forward WebHistory.list and sets it as the current item. (READ MORE)
  • injectCSSCode: Injects CSS into the WebView. (READ MORE)
  • injectCSSFileFromAsset: Injects a CSS file into the WebView from the flutter assets directory. (READ MORE)
  • injectCSSFileFromUrl: Injects an external CSS file into the WebView from a defined url. (READ MORE)
  • injectJavascriptFileFromAsset: Evaluates the content of a JavaScript file into the WebView from the flutter assets directory. (READ MORE)
  • injectJavascriptFileFromUrl: Injects an external JavaScript file into the WebView from a defined url. (READ MORE)
  • isLoading: Check if the WebView instance is in a loading state. (READ MORE)
  • isSecureContext: Indicates whether the webpage context is capable of using features that require secure contexts. This is implemented using Javascript (see window.isSecureContext). (READ MORE)
  • loadData: Loads the given data into this WebView, using baseUrl as the base URL for the content. (READ MORE)
  • loadFile: Loads the given assetFilePath. (READ MORE)
  • loadUrl: Loads the given urlRequest. (READ MORE)
  • pauseTimers: 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. (READ MORE)
  • postUrl: Loads the given url with postData (x-www-form-urlencoded) using POST method into this WebView. (READ MORE)
  • postWebMessage: 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. (READ MORE)
  • printCurrentPage: Prints the current page. (READ MORE)
  • reload: Reloads the WebView. (READ MORE)
  • removeAllUserScripts: Removes all the user scripts from the webpage’s content. (READ MORE)
  • removeJavaScriptHandler: 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. (READ MORE)
  • removeUserScript: 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. (READ MORE)
  • removeUserScripts: 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. (READ MORE)
  • removeUserScriptsByGroupName: 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. (READ MORE)
  • requestFocusNodeHref: Requests the anchor or image element URL at the last tapped point. (READ MORE)
  • requestImageRef: Requests the URL of the image last touched by the user. (READ MORE)
  • resumeTimers: On Android, it resumes all layout, parsing, and JavaScript timers for all WebViews. This will resume dispatching all timers. (READ MORE)
  • saveWebArchive: 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. (READ MORE)
  • scrollBy: Moves the scrolled position of the WebView. (READ MORE)
  • scrollTo: Scrolls the WebView to the position. (READ MORE)
  • setContextMenu: Sets or updates the WebView context menu to be used next time it will appear. (READ MORE)
  • setOptions: Sets the WebView options with the new options and evaluates them. (READ MORE)
  • stopLoading: Stops the WebView from loading. (READ MORE)
  • takeScreenshot: Takes a screenshot of the WebView's visible viewport and returns a Uint8List. Returns null if it wasn't be able to take it. (READ MORE)
  • zoomBy: Performs a zoom operation in this WebView. (READ MORE)
  • static getDefaultUserAgent: Gets the default user agent. (READ MORE)

Android-specific methods

This list is generated from the AndroidInAppWebViewController API Reference.

  • clearHistory: Clears the internal back/forward list. (READ MORE)
  • clearSslPreferences: Clears the SSL preferences table stored in response to proceeding with SSL certificate errors. (READ MORE)
  • getOriginalUrl: Gets the URL that was originally requested for the current page. This is not always the same as the URL passed to InAppWebView.onLoadStarted 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. (READ MORE)
  • pageDown: Scrolls the contents of this WebView down by half the page size. Returns true if the page was scrolled. (READ MORE)
  • pageUp: Scrolls the contents of this WebView up by half the view size. Returns true if the page was scrolled. (READ MORE)
  • pause: 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 InAppWebViewController.pauseTimers. To resume WebView, call resume. (READ MORE)
  • resume: Resumes a WebView after a previous call to pause. (READ MORE)
  • startSafeBrowsing: Starts Safe Browsing initialization. (READ MORE)
  • zoomIn: Performs zoom in in this WebView. Returns true if zoom in succeeds, false if no zoom changes. (READ MORE)
  • zoomOut: Performs zoom out in this WebView. Returns true if zoom out succeeds, false if no zoom changes. (READ MORE)
  • static clearClientCertPreferences: 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. (READ MORE)
  • static getCurrentWebViewPackage: 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. (READ MORE)
  • static getSafeBrowsingPrivacyPolicyUrl: Returns a URL pointing to the privacy policy for Safe Browsing reporting. (READ MORE)
  • static setSafeBrowsingWhitelist: Sets the list of hosts (domain names/IP addresses) that are exempt from SafeBrowsing checks. The list is global for all the WebViews. (READ MORE)
  • static setWebContentsDebuggingEnabled: 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. (READ MORE)

iOS-specific methods

This list is generated from the IOSInAppWebViewController API Reference.

  • createPdf: Generates PDF data from the web view’s contents asynchronously. Returns null if a problem occurred. (READ MORE)
  • createWebArchiveData: Creates a web archive of the web view’s current contents asynchronously. Returns null if a problem occurred. (READ MORE)
  • hasOnlySecureContent: A Boolean value indicating whether all resources on the page have been loaded over securely encrypted connections. (READ MORE)
  • reloadFromOrigin: Reloads the current page, performing end-to-end revalidation using cache-validating conditionals if possible. (READ MORE)
  • static handlesURLScheme: Returns a Boolean value that indicates whether WebKit natively supports resources with the specified URL scheme. (READ MORE)