removeAllUserScripts method
Removes all the user scripts from the webpage’s content.
Officially Supported Platforms/Implementations:
- Android WebView
- iOS WKWebView (Official API - WKUserContentController.removeAllUserScripts):
- This method will throw an error if the
PlatformWebViewCreationParams.windowIdhas 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.
- This method will throw an error if the
- Linux WPE WebKit (Official API - webkit_user_content_manager_remove_all_scripts)
- macOS WKWebView (Official API - WKUserContentController.removeAllUserScripts):
- This method will throw an error if the
PlatformWebViewCreationParams.windowIdhas 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.
- This method will throw an error if the
- Web <iframe> but requires same origin
- Windows WebView2
Use the PlatformInAppWebViewController.isMethodSupported method to check if this method is supported at runtime.
Implementation
@override
Future<void> removeAllUserScripts() async {
assert(webviewParams?.windowId == null);
_userScripts[UserScriptInjectionTime.AT_DOCUMENT_START]?.clear();
_userScripts[UserScriptInjectionTime.AT_DOCUMENT_END]?.clear();
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('removeAllUserScripts', args);
}