onCreateWindow method Null safety

Future<bool?>? onCreateWindow(
  1. CreateWindowAction createWindowAction
)

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.

createWindowAction represents the request.

NOTE: to allow JavaScript to open windows, you need to set InAppWebViewOptions.javaScriptCanOpenWindowsAutomatically option to true.

NOTE: on Android you need to set AndroidInAppWebViewOptions.supportMultipleWindows option to true.

NOTE: on iOS, setting these initial options: InAppWebViewOptions.supportZoom, InAppWebViewOptions.useOnLoadResource, InAppWebViewOptions.useShouldInterceptAjaxRequest, InAppWebViewOptions.useShouldInterceptFetchRequest, InAppWebViewOptions.applicationNameForUserAgent, InAppWebViewOptions.javaScriptCanOpenWindowsAutomatically, InAppWebViewOptions.javaScriptEnabled, InAppWebViewOptions.minimumFontSize, InAppWebViewOptions.preferredContentMode, InAppWebViewOptions.incognito, InAppWebViewOptions.cacheEnabled, InAppWebViewOptions.mediaPlaybackRequiresUserGesture, InAppWebViewOptions.resourceCustomSchemes, IOSInAppWebViewOptions.sharedCookiesEnabled, IOSInAppWebViewOptions.enableViewportScale, IOSInAppWebViewOptions.allowsAirPlayForMediaPlayback, IOSInAppWebViewOptions.allowsPictureInPictureMediaPlayback, IOSInAppWebViewOptions.isFraudulentWebsiteWarningEnabled, IOSInAppWebViewOptions.allowsInlineMediaPlayback, IOSInAppWebViewOptions.suppressesIncrementalRendering, IOSInAppWebViewOptions.selectionGranularity, IOSInAppWebViewOptions.ignoresViewportScaleLimits, will have no effect due to a WKWebView limitation when creating a new window WebView: it's impossible to return a new WKWebView with a different WKWebViewConfiguration instance (see https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview). So, these options will be inherited from the caller WebView. Also, note that calling InAppWebViewController.setOptions method using the controller of the new created WebView, it will update also the WebView options of the caller WebView.

Official Android API: https://developer.android.com/reference/android/webkit/WebChromeClient#onCreateWindow(android.webkit.WebView,%20boolean,%20boolean,%20android.os.Message)

Official iOS API: https://developer.apple.com/documentation/webkit/wkuidelegate/1536907-webview

Implementation

Future<bool?>? onCreateWindow(CreateWindowAction createWindowAction) {}