addUserScript method
- required UserScript userScript,
Injects the specified userScript into the webpage’s content.
Officially Supported Platforms/Implementations:
- Android WebView
- iOS WKWebView (Official API - WKUserContentController.addUserScript):
- This method will throw an error if the PlatformWebViewCreationParams.windowId has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs.
- Linux WPE WebKit (Official API - webkit_user_content_manager_add_script)
- macOS WKWebView (Official API - WKUserContentController.addUserScript):
- This method will throw an error if the PlatformWebViewCreationParams.windowId has been set. There isn't any way to add/remove user scripts specific to window WebViews. This is a limitation of the native WebKit APIs.
- Web <iframe> but requires same origin
- Windows WebView2
Parameters - Officially Supported Platforms/Implementations:
userScript: all platforms
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
Future<void> addUserScript({required UserScript userScript}) =>
platform.addUserScript(userScript: userScript);