removeUserScript method

  1. @SupportedPlatforms.new(platforms: [AndroidPlatform(), IOSPlatform(note: "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."), LinuxPlatform(), MacOSPlatform(note: "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."), WebPlatform(), WindowsPlatform()])
Future<bool> removeUserScript({
  1. required UserScript userScript,
})

Removes the specified userScript from the webpage’s content. User scripts already loaded into the webpage's content cannot be removed. This will have effect only on the next page load. Returns true if userScript was in the list, false otherwise.

Officially Supported Platforms/Implementations:

  • Android WebView
  • iOS WKWebView:
    • 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
  • macOS WKWebView:
    • 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

@SupportedPlatforms(
  platforms: [
    AndroidPlatform(),
    IOSPlatform(
      note:
          "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.",
    ),
    LinuxPlatform(),
    MacOSPlatform(
      note:
          "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.",
    ),
    WebPlatform(),
    WindowsPlatform(),
  ],
)
Future<bool> removeUserScript({required UserScript userScript}) {
  throw UnimplementedError(
    '${PlatformInAppWebViewControllerMethod.removeUserScript.name} is not implemented on the current platform',
  );
}