onCreateWindow method

  1. @override
FutureOr<bool?>? onCreateWindow(
  1. CreateWindowAction createWindowAction
)
override

Event fired when the 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 InAppWebViewSettings.javaScriptCanOpenWindowsAutomatically setting to true.

Officially Supported Platforms/Implementations:

Parameters - Officially Supported Platforms/Implementations:

  • createWindowAction: all platforms

Use the PlatformInAppBrowserEvents.isMethodSupported method to check if this method is supported at runtime.

Implementation

@override
FutureOr<bool?>? onCreateWindow(CreateWindowAction createWindowAction) {
  return null;
}