Skip to content

[webview_flutter] Calling setOnConsoleMessage multiple times throws #180914

Description

@limonadev

Use case

  1. Create a WebViewController
  2. Register the callback for console messages with setOnConsoleMessage
  3. If the same controller is reused later and we try to register the same callback with setOnConsoleMessage it's going to throw an Exception.

There is no real way to avoid this as there is no way to unregister that channel.

Proposal

To add a new method in the WebViewController class to unregister the one created by setOnConsoleMessage.

A workaround for this is to manually call:

webViewController.removeJavaScriptChannel(
  'fltConsoleMessage', // this is the channel name according to source code
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listp: webviewThe WebView pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyplatform-macosBuilding on or for macOS specificallyteam-ecosystemOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem team

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions