底部模态屏幕如何使用可拖动?

时间:2020-05-07 16:47:33

标签: flutter draggable

我激活了 showModalBottomScreen ,以在GridView中显示多个图像。 Here's my App Screen with BottomModalSheet on

所有这些图像都是可拖动的 Here's the Draggable Image

return Container(child: LongPressDraggable(data: img,feedback: img,child: img));

我需要我的应用程序执行的操作是:当我开始拖动其中一张图像时,底部模态表应关闭(弹出),并且我必须能够将可拖动对象提交到拖动目标上。但是底部模态表关闭,我无法保留可拖动的物体。

这是我使用的: onDragStarted: ()=> Navigator.of(context).pop()

该错误消息出现在我的调试控制台中:OPTS_INPUT:在优化之前先绘制了第一帧,所以跳过!

我该如何克服?

1 个答案:

答案 0 :(得分:0)

也许您应该在小部件内创建PersistentBottomSheetController controller,并为小部件的脚手架(用于控制showModalBottomSheet)创建GlobalKey<ScaffoldState> key

然后更改onDragStarted:() => controller.close()

如果您可以提供有关您的应用的更多详细信息,也许我会有所帮助。