【问题标题】:enable pinch and zoom in webview_flutter, where to add code snippet [this.webView.getSettings().setBuiltInZoomControls(true);]在 webview_flutter 中启用捏合和缩放,在哪里添加代码片段 [this.webView.getSettings().setBuiltInZoomControls(true);]
【发布时间】:2020-04-24 09:49:12
【问题描述】:

想要缩放到 webview_flutter

(我知道flutter_webview_plugin 可以做到这一点,但出于其他原因我想坚持使用flutter_webview。)

Zoom support #34

Flutter: how to enable gestures in a web view?

Flutter webview plugin - enable pinch zoom

他们都提到了

this.webView.getSettings().setBuiltInZoomControls(true);

this.webView.getSettings().setSupportZoom(true);允许捏合/缩放。

原谅我的愚蠢,我找不到在哪里添加这个代码sn-p,请帮助。

【问题讨论】:

  • 只需调用替换this.webView 为您的变量名?

标签: flutter dart flutterwebviewplugin


【解决方案1】:

下载此存储库:https://github.com/FisherWL/plugins/tree/add-zoom(感谢FisherWL

将位于包内的文件夹 webview_flutter 复制到您的项目根文件夹,

然后在 pubspec.yaml 上像这样引用文件夹:

  webview_flutter:
    path: ./webview_flutter

【讨论】:

    【解决方案2】:

    您是否尝试使用缩放属性?这个问题是两年前问的,用 zoom 属性解决了。

    本机库代码中的 this.webView.getSettings 也是如此。如果要使用,首先会用java原生代码编写Webview管理器,然后称你为管理器。

    多看源码库(这个管理器类有setSupportZoom & setBuiltInZoomControls,只能用zoom属性设置为true)WebviewManager Source

    【讨论】:

      【解决方案3】:

      在 webview_flutter 包中有一种放大或缩小的方法,但我认为它不是很有效。尽管如此,它仍然有效✌?。

      import 'package:webview_flutter/webview_flutter.dart';
      import 'package:zoom_widget/zoom_widget.dart';
      
      Size size = MediaQuery.of(context).size;
      Zoom(
      maxZoomWidth: size.width * 3,
      maxZoomHeight: size.height * 3,
      child: WebView(
         initialUrl: myUrl),
      ),
      

      根据您的需要,您可以修改最大ZoonWidth和高度

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2011-10-31
        • 2017-10-28
        • 1970-01-01
        • 2018-04-15
        • 2016-02-10
        • 1970-01-01
        • 2017-09-23
        • 1970-01-01
        相关资源
        最近更新 更多