【问题标题】:How to pan only with left mouse button in flutter interactive viewer?如何在颤动交互式查看器中仅使用鼠标左键平移?
【发布时间】:2022-08-21 17:20:55
【问题描述】:

我有一个封装图像的交互式查看器。我希望用户只能用鼠标左键平移并在右键单击时打开菜单。当前菜单通过右键单击打开,并且图像也通过右键单击进行平移。有没有办法在交互式查看器中通过右键单击停止平移?

Widget build(BuildContext context) {
    return Center(
      child: InteractiveViewer(
        transformationController: _controller,
        boundaryMargin: EdgeInsets.all(10000),
        clipBehavior: Clip.none,
        minScale: 0.0001,
        maxScale: 10,
        constrained: true,
        child: Stack(
          children: [
            Align(
              alignment: AlignmentDirectional(0, 0),
              child: Image(
                image: AssetImage(widget.imagePat),
                filterQuality: FilterQuality.medium,
                isAntiAlias: true,
              ),
            ),
            Align(
              alignment: AlignmentDirectional(0.11, 0.09),
              child: SizedBox(
                width: 40,
                height: 40,
                child: TextButton(
                  style: ElevatedButton.styleFrom(
                      primary: Color.fromARGB(24, 0, 0, 0)),
                  onPressed: () => {},
                  child: Container(),
                ),
              ),
            ),
          ],
        ),
      ),
    );
  }

    标签: flutter interactive viewer pan zoom-sdk


    【解决方案1】:
    • 将 InteractiveViewer 脚本复制到您的库中。
    • 找到 GestureDetector,并将“onScale”事件更改为“onPan”。
    • 然后对这些功能进行一些调整。

    (之后流畅的动画将不起作用) 此外,它可能无法在移动设备上运行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-09
      • 2022-01-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多