addJavaScriptOnEvent method
- @SupportedPlatforms(platforms: [AndroidPlatform(apiName: 'WebViewCompat.addJavaScriptOnEvent', note: 'Requires a WebView provider that advertises the document-event script feature.')])
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 platformsevent: 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',
);
}