如何在屏幕上快速移动小部件 [英] how to move a Widget in the screen in flutter

查看:55
本文介绍了如何在屏幕上快速移动小部件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在颤抖

我有一个使用此代码的圆形容器

i have a container with the shape of circle using this code

new Container(
 width: 50.0,
  height: 50.0,
   decoration: new BoxDecoration(
   shape: BoxShape.circle)

我想让这个圆圈在屏幕上像这样

I want to make this circle move in the screen like this

我该怎么做.谢谢

推荐答案

您正在寻找的是

What you are looking for is Draggable widget. You can then handle the translation using onDraggableCanceled which is passed and offset that you can be used to update the placement

onDraggableCanceled :(velocity,offset){ 
//update the position here
} 

更新

在检查完图像后,您将需要将我拖放到此处"部分作为 DragTarget 具有方法onAccept,该方法将在您拖放Draggable

After checking the image you will need "Drop me here" part to be a DragTarget that has a method onAccept which will handles the logic when you drag and drop your Draggable

这篇关于如何在屏幕上快速移动小部件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆