Hi does flutter team's webview plugin have a function to disable pinch zoom in iOS? In the community plugin, its withZoom but I don't know how to do it in Flutter team's webview. Or is there a equivalent function to do it in the team's plugin ?

I have reasons why I want to use the official webview plugin.

Kindly help. Thanks.


Solution 1: Michelangelo Pucci

I inject javascript code to replace the meta tag with name = "viewport" to disable the maximum zoom.

controller.evaluateJavascript("var meta = document.getElementsByTagName('meta');"
    "for (var i = 0; i < meta.length; i++) {"
      "if (meta[I].attribute('name') == null) continue;"
      "if (meta[i].attribute('name').includes('viewport')) {"
        "document.getElementsByTagName('meta')[i].remove();"
        "break;"
        "}"
    "}"
    "document.getElementsByTagName('head')[0].innerHTML += "
    "\"<meta name='viewport' content='initial-scale=1.0, maximum-scale=1.0'>\";"
);

Of course, you need to enable Javascript in your WebView.