onJsAlert property

  1. @SupportedPlatforms.new(platforms: [AndroidPlatform(apiName: 'WebChromeClient.onJsAlert', apiUrl: 'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)'), IOSPlatform(apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview'), MacOSPlatform(apiName: 'WKUIDelegate.webView', apiUrl: 'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview'), LinuxPlatform(apiName: 'WebKitWebView::script-dialog', apiUrl: 'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/signal.WebView.script-dialog.html', note: 'Handles WEBKIT_SCRIPT_DIALOG_ALERT dialog type.')])
FutureOr<JsAlertResponse?> Function(T controller, JsAlertRequest jsAlertRequest)? onJsAlert
final

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.

jsAlertRequest contains the message to be displayed in the alert dialog and the of the page requesting the dialog.

Officially Supported Platforms/Implementations:

Parameters - Officially Supported Platforms/Implementations:

  • jsAlertRequest: all platforms

Use the PlatformWebViewCreationParams.isPropertySupported method to check if this property is supported at runtime.

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(
      apiName: 'WebChromeClient.onJsAlert',
      apiUrl:
          'https://developer.android.com/reference/android/webkit/WebChromeClient#onJsAlert(android.webkit.WebView,%20java.lang.String,%20java.lang.String,%20android.webkit.JsResult)',
    ),
    IOSPlatform(
      apiName: 'WKUIDelegate.webView',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview',
    ),
    MacOSPlatform(
      apiName: 'WKUIDelegate.webView',
      apiUrl:
          'https://developer.apple.com/documentation/webkit/wkuidelegate/1537406-webview',
    ),
    LinuxPlatform(
      apiName: 'WebKitWebView::script-dialog',
      apiUrl:
          'https://wpewebkit.org/reference/stable/wpe-webkit-2.0/signal.WebView.script-dialog.html',
      note: 'Handles WEBKIT_SCRIPT_DIALOG_ALERT dialog type.',
    ),
  ],
)
final FutureOr<JsAlertResponse?> Function(
  T controller,
  JsAlertRequest jsAlertRequest,
)?
onJsAlert;