【发布时间】:2021-08-08 05:01:22
【问题描述】:
我需要创建一个列表,它应该能够在其中重新排序,但如果拖动到特定的拖动目标,我应该能够删除一个项目。现在,我已将这两个功能合并到两个不同的屏幕中。一个使用 ReorderabelListView,另一个使用 Draggable。有没有办法将两者结合起来?
【问题讨论】:
我需要创建一个列表,它应该能够在其中重新排序,但如果拖动到特定的拖动目标,我应该能够删除一个项目。现在,我已将这两个功能合并到两个不同的屏幕中。一个使用 ReorderabelListView,另一个使用 Draggable。有没有办法将两者结合起来?
【问题讨论】:
你可以通过reorderables plugin来实现
ReorderableColumn(
onReorder: (oldIndex, newIndex) {
},
children: someList.map((item) {
final index = someList.indexOf(item);
return Dismissible(
key: ObjectKey(item),
onDismissed: (direction) {
},
background: Container(color: Colors.red),
child: Container(),
);
}).toList(),
);
【讨论】: