InAppBrowser class Null safety

This class uses the native WebView of the platform. The webViewController field can be used to access the InAppWebViewController API.

Constructors

InAppBrowser({int? windowId, UnmodifiableListView<UserScript>? initialUserScripts})

Properties

contextMenu ContextMenu?
Context menu used by the browser. It should be set before opening the browser.
read / write
hashCode int
The hash code for this object. [...]
read-only, inherited
id String
View ID used internally.
late, final
initialUserScripts UnmodifiableListView<UserScript>?
Initial list of user scripts to be loaded at start or end of a page loading.
final
pullToRefreshController PullToRefreshController?
Represents the pull-to-refresh feature controller.
read / write
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
webViewController InAppWebViewController
WebView Controller that can be used to access the InAppWebViewController API.
late, final
windowId int?
The window id of a CreateWindowAction.windowId.
final

Methods

androidOnFormResubmission(Uri? 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. [...]
androidOnGeolocationPermissionsHidePrompt() → void
Notify the host application that a request for Geolocation permissions, made with a previous call to androidOnGeolocationPermissionsShowPrompt has been canceled. Any related UI should therefore be hidden. [...]
androidOnGeolocationPermissionsShowPrompt(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. [...]
androidOnJsBeforeUnload(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. [...]
androidOnPermissionRequest(String origin, List<String> resources) Future<PermissionRequestResponse?>?
Event fired when the WebView is requesting permission to access the specified resources and the permission currently isn't granted or denied. [...]
androidOnReceivedIcon(Uint8List icon) → void
Event fired when there is new favicon for the current page. [...]
androidOnReceivedLoginRequest(LoginRequest loginRequest) → void
Event fired when a request to automatically log in the user has been processed. [...]
androidOnReceivedTouchIconUrl(Uri url, bool precomposed) → void
Event fired when there is an url for an apple-touch-icon. [...]
androidOnRenderProcessGone(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. [...]
androidOnRenderProcessResponsive(Uri? url) Future<WebViewRenderProcessAction?>?
Event called once when an unresponsive renderer currently associated with the WebView becomes responsive. [...]
androidOnRenderProcessUnresponsive(Uri? 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. [...]
androidOnSafeBrowsingHit(Uri 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. [...]
androidOnScaleChanged(double oldScale, double newScale) → void
Use onZoomScaleChanged instead.
@Deprecated('Use `onZoomScaleChanged` instead')
androidShouldInterceptRequest(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. [...]
close() Future<void>
Closes the InAppBrowser window.
getOptions() Future<InAppBrowserClassOptions?>
Gets the current InAppBrowser options. Returns null if it wasn't able to get them.
handleMethod(MethodCall call) Future
hide() Future<void>
Hides the InAppBrowser window. Calling this has no effect if the InAppBrowser was already hidden.
iosOnDidReceiveServerRedirectForProvisionalNavigation() → void
Called when a web view receives a server redirect. [...]
iosOnNavigationResponse(IOSWKNavigationResponse navigationResponse) Future<IOSNavigationResponseAction?>?
Called when a web view asks for permission to navigate to new content after the response to the navigation request is known. [...]
iosOnWebContentProcessDidTerminate() → void
Invoked when the web view's web content process is terminated. [...]
iosShouldAllowDeprecatedTLS(URLAuthenticationChallenge challenge) Future<IOSShouldAllowDeprecatedTLSAction?>?
Called when a web view asks whether to continue with a connection that uses a deprecated version of TLS (v1.0 and v1.1). [...]
isHidden() Future<bool>
Check if the Web View of the InAppBrowser instance is hidden.
isOpened() bool
Returns true if the InAppBrowser instance is opened, otherwise false.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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. [...]
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. [...]
onBrowserCreated() → void
Event fired when the InAppBrowser is created.
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. [...]
onConsoleMessage(ConsoleMessage consoleMessage) → void
Event fired when the InAppBrowser webview receives a ConsoleMessage. [...]
onCreateWindow(CreateWindowAction createWindowAction) Future<bool?>?
Event fired when the InAppBrowser 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. [...]
onDownloadStart(Uri url) → void
Event fired when InAppBrowser recognizes and starts a downloadable file. [...]
onEnterFullscreen() → void
Event fired when the current page has entered full screen mode. [...]
onExit() → void
Event fired when the InAppBrowser window is closed.
onExitFullscreen() → void
Event fired when the current page has exited full screen mode. [...]
onFindResultReceived(int activeMatchOrdinal, int numberOfMatches, bool isDoneCounting) → void
Event fired as find-on-page operations progress. The listener may be notified multiple times while the operation is underway, and the numberOfMatches value should not be considered final unless isDoneCounting is true. [...]
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. [...]
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. [...]
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. [...]
onLoadError(Uri? url, int code, String message) → void
Event fired when the InAppBrowser encounters an error loading an url. [...]
onLoadHttpError(Uri? url, int statusCode, String description) → void
Event fired when the InAppBrowser main page receives an HTTP error. [...]
onLoadResource(LoadedResource resource) → void
Event fired when the InAppBrowser webview loads a resource. [...]
onLoadResourceCustomScheme(Uri url) Future<CustomSchemeResponse?>?
Event fired when the InAppBrowser 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. [...]
onLoadStart(Uri? url) → void
Event fired when the InAppBrowser starts to load an url. [...]
onLoadStop(Uri? url) → void
Event fired when the InAppBrowser finishes loading an url. [...]
onLongPressHitTestResult(InAppWebViewHitTestResult hitTestResult) → void
Event fired when an HTML element of the webview has been clicked and held. [...]
onOverScrolled(int x, int y, bool clampedX, bool clampedY) → void
Event fired to respond to the results of an over-scroll operation. [...]
onPageCommitVisible(Uri? url) → void
Called when the web view begins to receive web content. [...]
onPrint(Uri? url) → void
Event fired when window.print() is called from JavaScript side. [...]
onProgressChanged(int progress) → void
Event fired when the current progress (range 0-100) of loading a page is changed. [...]
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. [...]
onReceivedHttpAuthRequest(URLAuthenticationChallenge challenge) Future<HttpAuthResponse?>?
Event fired when the WebView received an HTTP authentication request. The default behavior is to cancel the request. [...]
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. [...]
onScrollChanged(int x, int y) → void
Event fired when the InAppBrowser webview scrolls. [...]
onTitleChanged(String? title) → void
Event fired when a change in the document title occurred. [...]
onUpdateVisitedHistory(Uri? url, bool? androidIsReload) → 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). [...]
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.
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.
onZoomScaleChanged(double oldScale, double newScale) → void
Event fired when the zoom scale of the WebView has changed. [...]
openData({required String data, String mimeType = "text/html", String encoding = "utf8", Uri? baseUrl, Uri? androidHistoryUrl, InAppBrowserClassOptions? options}) Future<void>
Opens the InAppBrowser instance with data as a content, using baseUrl as the base URL for it. [...]
openFile({required String assetFilePath, InAppBrowserClassOptions? options}) Future<void>
Opens the InAppBrowser instance with the given assetFilePath file. [...]
openUrlRequest({required URLRequest urlRequest, InAppBrowserClassOptions? options}) Future<void>
Opens the InAppBrowser instance with an urlRequest. [...]
setOptions({required InAppBrowserClassOptions options}) Future<void>
Sets the InAppBrowser options with the new options and evaluates them.
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. [...]
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. [...]
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. [...]
show() Future<void>
Displays an InAppBrowser window that was opened hidden. Calling this has no effect if the InAppBrowser was already visible.
throwIfAlreadyOpened({String message = ''}) → void
throwIfNotOpened({String message = ''}) → void
toString() String
A string representation of this object. [...]
inherited

Operators

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

Static Methods

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