InAppBrowser class

This class represents a native WebView displayed on top of the Flutter App, so it's not integrated into the Flutter widget tree. It uses the native WebView of the platform. The webViewController field can be used to access the PlatformInAppWebViewController API.

Officially Supported Platforms/Implementations:

  • Android native WebView
  • iOS
  • MacOS
  • Windows
Implemented types

Constructors

InAppBrowser({ContextMenu? contextMenu, PullToRefreshController? pullToRefreshController, FindInteractionController? findInteractionController, UnmodifiableListView<UserScript>? initialUserScripts, int? windowId, WebViewEnvironment? webViewEnvironment})
Constructs a InAppBrowser.
InAppBrowser.fromPlatform(PlatformInAppBrowser platform)
Constructs a InAppBrowser from a specific platform implementation.
InAppBrowser.fromPlatformCreationParams(PlatformInAppBrowserCreationParams params)
Constructs a InAppBrowser from creation params for a specific platform.

Properties

contextMenu ContextMenu?
Context menu used by the browser. It should be set before opening the browser.
no setter
findInteractionController FindInteractionController?
Represents the find interaction feature controller.
no setter
hashCode int
The hash code for this object.
no setterinherited
id String
View ID used internally.
no setter
initialUserScripts UnmodifiableListView<UserScript>?
Initial list of user scripts to be loaded at start or end of a page loading.
no setter
platform PlatformInAppBrowser
Implementation of PlatformInAppBrowser for the current platform.
final
pullToRefreshController PullToRefreshController?
Represents the pull-to-refresh feature controller.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
webViewController InAppWebViewController?
WebView Controller that can be used to access the PlatformInAppWebViewController API. When onExit is fired, this will be null and cannot be used anymore.
no setter
windowId int?
The window id of a CreateWindowAction.windowId.
no setter

Methods

addMenuItem(InAppBrowserMenuItem menuItem) → void
Adds a InAppBrowserMenuItem to the menu. If the browser is already open, it will take effect the next time it is opened.
addMenuItems(List<InAppBrowserMenuItem> menuItems) → void
Adds a list of InAppBrowserMenuItem to the menu. If the browser is already open, it will take effect the next time it is opened.
androidOnFormResubmission(Uri? url) Future<FormResubmissionAction?>?
Use onFormResubmission instead.
override
androidOnGeolocationPermissionsHidePrompt() → void
Use onGeolocationPermissionsHidePrompt instead.
override
androidOnGeolocationPermissionsShowPrompt(String origin) Future<GeolocationPermissionShowPromptResponse?>?
Use onGeolocationPermissionsShowPrompt instead.
override
androidOnJsBeforeUnload(JsBeforeUnloadRequest jsBeforeUnloadRequest) Future<JsBeforeUnloadResponse?>?
Use onJsBeforeUnload instead.
override
androidOnPermissionRequest(String origin, List<String> resources) Future<PermissionRequestResponse?>?
Use onPermissionRequest instead.
override
androidOnReceivedIcon(Uint8List icon) → void
Use onReceivedIcon instead.
override
androidOnReceivedLoginRequest(LoginRequest loginRequest) → void
Use onReceivedLoginRequest instead.
override
androidOnReceivedTouchIconUrl(Uri url, bool precomposed) → void
Use onReceivedTouchIconUrl instead.
override
androidOnRenderProcessGone(RenderProcessGoneDetail detail) → void
Use onRenderProcessGone instead.
override
androidOnRenderProcessResponsive(Uri? url) Future<WebViewRenderProcessAction?>?
Use onRenderProcessResponsive instead.
override
androidOnRenderProcessUnresponsive(Uri? url) Future<WebViewRenderProcessAction?>?
Use onRenderProcessUnresponsive instead.
override
androidOnSafeBrowsingHit(Uri url, SafeBrowsingThreat? threatType) Future<SafeBrowsingResponse?>?
Use onSafeBrowsingHit instead.
override
androidOnScaleChanged(double oldScale, double newScale) → void
Use onZoomScaleChanged instead.
override
androidShouldInterceptRequest(WebResourceRequest request) Future<WebResourceResponse?>?
Use shouldInterceptRequest instead.
override
close() Future<void>
Closes the PlatformInAppBrowser window.
dispose() → void
Disposes the channel and controllers.
getOptions() Future<InAppBrowserClassOptions?>
Use getSettings instead.
getSettings() Future<InAppBrowserClassSettings?>
Gets the current PlatformInAppBrowser settings. Returns null if it wasn't able to get them.
hasMenuItem(InAppBrowserMenuItem menuItem) bool
Returns true if the menuItem has been already added, otherwise false.
hide() Future<void>
Hides the PlatformInAppBrowser window. Calling this has no effect if the PlatformInAppBrowser was already hidden.
iosOnDidReceiveServerRedirectForProvisionalNavigation() → void
Use onDidReceiveServerRedirectForProvisionalNavigation instead.
override
iosOnNavigationResponse(IOSWKNavigationResponse navigationResponse) Future<IOSNavigationResponseAction?>?
Use onNavigationResponse instead.
override
iosOnWebContentProcessDidTerminate() → void
Use onWebContentProcessDidTerminate instead.
override
iosShouldAllowDeprecatedTLS(URLAuthenticationChallenge challenge) Future<IOSShouldAllowDeprecatedTLSAction?>?
Use shouldAllowDeprecatedTLS instead.
override
isHidden() Future<bool>
Check if the Web View of the PlatformInAppBrowser instance is hidden.
isOpened() bool
Returns true if the PlatformInAppBrowser instance is opened, otherwise false.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
onAjaxProgress(AjaxRequest ajaxRequest) Future<AjaxRequestAction?>?
Event fired as an XMLHttpRequest progress. It gives the host application a chance to abort the request.
override
onAjaxReadyStateChange(AjaxRequest ajaxRequest) Future<AjaxRequestAction?>?
Event fired whenever the readyState attribute of an XMLHttpRequest changes. It gives the host application a chance to abort the request.
override
onBrowserCreated() → void
Event fired when the PlatformInAppBrowser is created.
override
onCameraCaptureStateChanged(MediaCaptureState? oldState, MediaCaptureState? newState) → void
Event fired when a change in the camera capture state occurred.
override
onCloseWindow() → void
Event fired when the host application should close the given WebView and remove it from the view system if necessary. At this point, WebCore has stopped any loading in this window and has removed any cross-scripting ability in javascript.
override
onConsoleMessage(ConsoleMessage consoleMessage) → void
Event fired when the PlatformInAppBrowser webview receives a ConsoleMessage.
override
onContentSizeChanged(Size oldContentSize, Size newContentSize) → void
Event fired when the content size of the WebView changes.
override
onCreateWindow(CreateWindowAction createWindowAction) Future<bool?>?
Event fired when the PlatformInAppBrowser webview requests the host application to create a new window, for example when trying to open a link with target="_blank" or when window.open() is called by JavaScript side. If the host application chooses to honor this request, it should return true from this method, create a new WebView to host the window. If the host application chooses not to honor the request, it should return false from this method. The default implementation of this method does nothing and hence returns false.
override
onDidReceiveServerRedirectForProvisionalNavigation() → void
Called when a web view receives a server redirect.
override
onDownloadStart(Uri url) → void
Use onDownloadStartRequest instead
override
onDownloadStartRequest(DownloadStartRequest downloadStartRequest) → void
Event fired when WebView recognizes a downloadable file. To download the file, you can use the flutter_downloader plugin.
override
onEnterFullscreen() → void
Event fired when the current page has entered full screen mode.
override
onExit() → void
Event fired when the PlatformInAppBrowser window is closed.
override
onExitFullscreen() → void
Event fired when the current page has exited full screen mode.
override
onFindResultReceived(int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting) → void
Use FindInteractionController.onFindResultReceived instead.
override
onFormResubmission(WebUri? url) Future<FormResubmissionAction?>?
As the host application if the browser should resend data as the requested page was a result of a POST. The default is to not resend the data.
override
onGeolocationPermissionsHidePrompt() → void
Notify the host application that a request for Geolocation permissions, made with a previous call to onGeolocationPermissionsShowPrompt has been canceled. Any related UI should therefore be hidden.
override
onGeolocationPermissionsShowPrompt(String origin) Future<GeolocationPermissionShowPromptResponse?>?
Event that notifies the host application that web content from the specified origin is attempting to use the Geolocation API, but no permission state is currently set for that origin. Note that for applications targeting Android N and later SDKs (API level > Build.VERSION_CODES.M) this method is only called for requests originating from secure origins such as https. On non-secure origins geolocation requests are automatically denied.
override
onJsAlert(JsAlertRequest jsAlertRequest) Future<JsAlertResponse?>?
Event fired when javascript calls the alert() method to display an alert dialog. If JsAlertResponse.handledByClient is true, the webview will assume that the client will handle the dialog.
override
onJsBeforeUnload(JsBeforeUnloadRequest jsBeforeUnloadRequest) Future<JsBeforeUnloadResponse?>?
Event fired when the client should display a dialog to confirm navigation away from the current page. This is the result of the onbeforeunload javascript event. If JsBeforeUnloadResponse.handledByClient is true, WebView will assume that the client will handle the confirm dialog. If JsBeforeUnloadResponse.handledByClient is false, a default value of true will be returned to javascript to accept navigation away from the current page. The default behavior is to return false. Setting the JsBeforeUnloadResponse.action to JsBeforeUnloadResponseAction.CONFIRM will navigate away from the current page, JsBeforeUnloadResponseAction.CANCEL will cancel the navigation.
override
onJsConfirm(JsConfirmRequest jsConfirmRequest) Future<JsConfirmResponse?>?
Event fired when javascript calls the confirm() method to display a confirm dialog. If JsConfirmResponse.handledByClient is true, the webview will assume that the client will handle the dialog.
override
onJsPrompt(JsPromptRequest jsPromptRequest) Future<JsPromptResponse?>?
Event fired when javascript calls the prompt() method to display a prompt dialog. If JsPromptResponse.handledByClient is true, the webview will assume that the client will handle the dialog.
override
onLoadError(Uri? url, int code, String message) → void
Use onReceivedError instead.
override
onLoadHttpError(Uri? url, int statusCode, String description) → void
Use onReceivedHttpError instead.
override
onLoadResource(LoadedResource resource) → void
Event fired when the PlatformInAppBrowser webview loads a resource.
override
onLoadResourceCustomScheme(Uri url) Future<CustomSchemeResponse?>?
Use onLoadResourceWithCustomScheme instead.
override
onLoadResourceWithCustomScheme(WebResourceRequest request) Future<CustomSchemeResponse?>?
Event fired when the PlatformInAppBrowser webview finds the custom-scheme while loading a resource. Here you can handle the url request and return a CustomSchemeResponse to load a specific resource encoded to base64.
override
onLoadStart(WebUri? url) → void
Event fired when the PlatformInAppBrowser starts to load an url.
override
onLoadStop(WebUri? url) → void
Event fired when the PlatformInAppBrowser finishes loading an url.
override
onLongPressHitTestResult(InAppWebViewHitTestResult hitTestResult) → void
Event fired when an HTML element of the webview has been clicked and held.
override
onMainWindowWillClose() → void
Event fired when the main window is about to close.
override
onMicrophoneCaptureStateChanged(MediaCaptureState? oldState, MediaCaptureState? newState) → void
Event fired when a change in the microphone capture state occurred. Event fired when a change in the microphone capture state occurred.
override
onNavigationResponse(NavigationResponse navigationResponse) Future<NavigationResponseAction?>?
Called when a web view asks for permission to navigate to new content after the response to the navigation request is known.
override
onOverScrolled(int x, int y, bool clampedX, bool clampedY) → void
Event fired to respond to the results of an over-scroll operation.
override
onPageCommitVisible(WebUri? url) → void
Called when the web view begins to receive web content.
override
onPermissionRequest(PermissionRequest permissionRequest) Future<PermissionResponse?>?
Event fired when the WebView is requesting permission to access the specified resources and the permission currently isn't granted or denied.
override
onPermissionRequestCanceled(PermissionRequest permissionRequest) → void
Notify the host application that the given permission request has been canceled. Any related UI should therefore be hidden.
override
onPrint(Uri? url) → void
Use onPrintRequest instead
override
onPrintRequest(WebUri? url, PlatformPrintJobController? printJobController) Future<bool?>?
Event fired when window.print() is called from JavaScript side. Return true if you want to handle the print job. Otherwise return false, so the PlatformPrintJobController will be handled and disposed automatically by the system.
override
onProgressChanged(int progress) → void
Event fired when the current progress (range 0-100) of loading a page is changed.
override
onReceivedClientCertRequest(URLAuthenticationChallenge challenge) Future<ClientCertResponse?>?
Notify the host application to handle an SSL client certificate request. Webview stores the response in memory (for the life of the application) if ClientCertResponseAction.PROCEED or ClientCertResponseAction.CANCEL is called and does not call onReceivedClientCertRequest again for the same host and port pair. Note that, multiple layers in chromium network stack might be caching the responses.
override
onReceivedError(WebResourceRequest request, WebResourceError error) → void
Event fired when the PlatformInAppBrowser encounters an error loading a request.
override
onReceivedHttpAuthRequest(URLAuthenticationChallenge challenge) Future<HttpAuthResponse?>?
Event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request.
override
onReceivedHttpError(WebResourceRequest request, WebResourceResponse errorResponse) → void
Event fired when the PlatformInAppBrowser receives an HTTP error.
override
onReceivedIcon(Uint8List icon) → void
Event fired when there is new favicon for the current page.
override
onReceivedLoginRequest(LoginRequest loginRequest) → void
Event fired when a request to automatically log in the user has been processed.
override
onReceivedServerTrustAuthRequest(URLAuthenticationChallenge challenge) Future<ServerTrustAuthResponse?>?
Event fired when the WebView need to perform server trust authentication (certificate validation). The host application must return either ServerTrustAuthResponse instance with ServerTrustAuthResponseAction.CANCEL or ServerTrustAuthResponseAction.PROCEED.
override
onReceivedTouchIconUrl(WebUri url, bool precomposed) → void
Event fired when there is an url for an apple-touch-icon.
override
onRenderProcessGone(RenderProcessGoneDetail detail) → void
Event fired when the given WebView's render process has exited. The application's implementation of this callback should only attempt to clean up the WebView. The WebView should be removed from the view hierarchy, all references to it should be cleaned up.
override
onRenderProcessResponsive(WebUri? url) Future<WebViewRenderProcessAction?>?
Event called once when an unresponsive renderer currently associated with the WebView becomes responsive.
override
onRenderProcessUnresponsive(WebUri? url) Future<WebViewRenderProcessAction?>?
Event called when the renderer currently associated with the WebView becomes unresponsive as a result of a long running blocking task such as the execution of JavaScript.
override
onRequestFocus() → void
Request display and focus for this WebView. This may happen due to another WebView opening a link in this WebView and requesting that this WebView be displayed.
override
onSafeBrowsingHit(WebUri url, SafeBrowsingThreat? threatType) Future<SafeBrowsingResponse?>?
Event fired when the WebView notifies that a loading URL has been flagged by Safe Browsing. The default behavior is to show an interstitial to the user, with the reporting checkbox visible.
override
onScrollChanged(int x, int y) → void
Event fired when the PlatformInAppBrowser webview scrolls.
override
onTitleChanged(String? title) → void
Event fired when a change in the document title occurred.
override
onUpdateVisitedHistory(WebUri? url, bool? isReload) → void
Event fired when the host application updates its visited links database. This event is also fired when the navigation state of the InAppWebView changes through the usage of javascript History API functions (pushState(), replaceState()) and onpopstate event or, also, when the javascript window.location changes without reloading the webview (for example appending or modifying an hash to the url).
override
onWebContentProcessDidTerminate() → void
Invoked when the web view's web content process is terminated.
override
onWindowBlur() → void
Event fired when the JavaScript window object of the WebView has lost focus. This is the result of the blur javascript event applied to the window object.
override
onWindowFocus() → void
Event fired when the JavaScript window object of the WebView has received focus. This is the result of the focus javascript event applied to the window object.
override
onZoomScaleChanged(double oldScale, double newScale) → void
Event fired when the zoom scale of the WebView has changed.
override
openData({required String data, String mimeType = "text/html", String encoding = "utf8", WebUri? baseUrl, Uri? androidHistoryUrl, WebUri? historyUrl, InAppBrowserClassOptions? options, InAppBrowserClassSettings? settings}) Future<void>
Opens the PlatformInAppBrowser instance with data as a content, using baseUrl as the base URL for it.
openFile({required String assetFilePath, InAppBrowserClassOptions? options, InAppBrowserClassSettings? settings}) Future<void>
Opens the PlatformInAppBrowser instance with the given assetFilePath file.
openUrlRequest({required URLRequest urlRequest, InAppBrowserClassOptions? options, InAppBrowserClassSettings? settings}) Future<void>
Opens the PlatformInAppBrowser instance with an urlRequest.
removeAllMenuItem() → void
Removes all the menu items from the list. If the browser is already open, it will take effect the next time it is opened.
removeMenuItem(InAppBrowserMenuItem menuItem) bool
Removes the menuItem from the list. Returns true if it was in the list, false otherwise. If the browser is already open, it will take effect the next time it is opened.
removeMenuItems(List<InAppBrowserMenuItem> menuItems) → void
Removes a list of menuItems from the list. If the browser is already open, it will take effect the next time it is opened.
setOptions({required InAppBrowserClassOptions options}) Future<void>
Use setSettings instead.
setSettings({required InAppBrowserClassSettings settings}) Future<void>
Sets the PlatformInAppBrowser settings with the new settings and evaluates them.
shouldAllowDeprecatedTLS(URLAuthenticationChallenge challenge) Future<ShouldAllowDeprecatedTLSAction?>?
Called when a web view asks whether to continue with a connection that uses a deprecated version of TLS (v1.0 and v1.1).
override
shouldInterceptAjaxRequest(AjaxRequest ajaxRequest) Future<AjaxRequest?>?
Event fired when an XMLHttpRequest is sent to a server. It gives the host application a chance to take control over the request before sending it.
override
shouldInterceptFetchRequest(FetchRequest fetchRequest) Future<FetchRequest?>?
Event fired when a request is sent to a server through Fetch API. It gives the host application a chance to take control over the request before sending it.
override
shouldInterceptRequest(WebResourceRequest request) Future<WebResourceResponse?>?
Notify the host application of a resource request and allow the application to return the data. If the return value is null, the WebView will continue to load the resource as usual. Otherwise, the return response and data will be used.
override
shouldOverrideUrlLoading(NavigationAction navigationAction) Future<NavigationActionPolicy?>?
Give the host application a chance to take control when a URL is about to be loaded in the current WebView. This event is not called on the initial load of the WebView.
override
show() Future<void>
Displays a PlatformInAppBrowser window that was opened hidden. Calling this has no effect if the PlatformInAppBrowser was already visible.
toString() String
A string representation of this object.
inherited

Operators

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

Static Methods

openWithSystemBrowser({required WebUri url}) Future<void>
This is a static method that opens an url in the system browser. You wont be able to use the PlatformInAppBrowser methods here!