addJavaScriptOnEvent method

  1. @SupportedPlatforms(platforms: [AndroidPlatform(apiName: 'WebViewCompat.addJavaScriptOnEvent', note: 'Requires a WebView provider that advertises the document-event script feature.')])
Future<void> addJavaScriptOnEvent({
  1. required String source,
  2. String event = 'DOMContentLoaded',
})

Injects persistent JavaScript that runs as part of a document lifecycle event.

This is the Android isolated-world / document-event injection API. When the feature is unavailable the call is a no-op.

Officially Supported Platforms/Implementations:

  • Android WebView (Official API - WebViewCompat.addJavaScriptOnEvent):
    • Requires a WebView provider that advertises the document-event script feature.

Parameters - Officially Supported Platforms/Implementations:

  • source: all platforms
  • event: all platforms

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

Implementation

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(
      apiName: 'WebViewCompat.addJavaScriptOnEvent',
      note:
          'Requires a WebView provider that advertises the document-event script feature.',
    ),
  ],
)
Future<void> addJavaScriptOnEvent({
  required String source,
  String event = 'DOMContentLoaded',
}) {
  throw UnimplementedError(
    '${PlatformInAppWebViewControllerMethod.addJavaScriptOnEvent.name} is not implemented on the current platform',
  );
}