removeAllUserScripts method
Removes all the user scripts from the webpage’s content.
NOTE for iOS and MacOS: 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.
Officially Supported Platforms/Implementations:
- Android native WebView
- iOS (Official API - WKUserContentController.removeAllUserScripts)
- MacOS (Official API - WKUserContentController.removeAllUserScripts)
- Windows
Implementation
@override
Future<void> removeAllUserScripts() async {
_userScripts[UserScriptInjectionTime.AT_DOCUMENT_START]?.clear();
_userScripts[UserScriptInjectionTime.AT_DOCUMENT_END]?.clear();
Map<String, dynamic> args = <String, dynamic>{};
await channel?.invokeMethod('removeAllUserScripts', args);
}