removeAllUserScripts method

Future<void> removeAllUserScripts()

Removes all the user scripts from the webpage’s content.

NOTE for iOS: this method will throw an error if the WebView.windowId has been set. There isn't any way to add/remove user scripts specific to iOS window WebViews. This is a limitation of the native iOS WebKit APIs.

Official iOS API: https://developer.apple.com/documentation/webkit/wkusercontentcontroller/1536540-removealluserscripts

Implementation

Future<void> removeAllUserScripts() async {
  assert(_webview?.windowId == null ||
      defaultTargetPlatform != TargetPlatform.iOS);

  _userScripts[UserScriptInjectionTime.AT_DOCUMENT_START]?.clear();
  _userScripts[UserScriptInjectionTime.AT_DOCUMENT_END]?.clear();

  Map<String, dynamic> args = <String, dynamic>{};
  await _channel.invokeMethod('removeAllUserScripts', args);
}