简体   繁体   English

Flutter中Draggable和InteractiveViewer如何一起使用

[英]How to use Draggable and InteractiveViewer together in Flutter

In Flutter, I can use Draggable to drag an object, say an image.在 Flutter 中,我可以使用 Draggable 来拖动一个 object,比如一个图像。 Also, using InteractiveViewer, I can pinch-zoom the same image.此外,使用 InteractiveViewer,我可以双指缩放同一图像。 Am able to do these actions separately with the individual widgets, but not able to figure out how to do both together -我能够使用各个小部件分别执行这些操作,但无法弄清楚如何同时执行这两个操作 -

  1. Load image载入图片
  2. Pinch-zoom out to shrink the image双指缩小以缩小图像
  3. Drag the above image to another location in the screen将上面的图像拖到屏幕中的另一个位置

How can I achieve this in Flutter?我怎样才能在 Flutter 中实现这一点?

If you just want to scale an image (zoom in/out), you don't have to use InteractiveViewer .如果您只想缩放图像(放大/缩小),则不必使用InteractiveViewer You can use GestureDetector to do scaling, rotating, and moving, all at once.您可以使用GestureDetector同时进行缩放、旋转和移动。

You can check out my answer to a similar question here .您可以在此处查看我对类似问题的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM