close
專案中需要有手動可以排序的動作,這邊記錄一下
透過ReorderableListView 官網
使用onReorder重新繪製動作 填上__onReorder
_onReorder(int oldIndex, int newIndex) {
print("$oldIndex --- $newIndex");
setState(() {
if (oldIndex < newIndex) {
newIndex -= 1;
}
var temp = ch1.elementAt(oldIndex);
ch1.removeAt(oldIndex);
//print("$oldIndex --- $newIndex");
ch1.insert(newIndex, temp);
});
}
CH1為提出的LIST資料列透過MAP顯示
e.Number 關鍵的排序KEY
ch1 = state.data;
return SizedBox(
height: 500,
child: ReorderableListView(
onReorder: _onReorder,
children: ch1
.map(
(e) => Container(
key: Key(e.Number.toString()),
margin: const EdgeInsets.all(10.0),
padding: const EdgeInsets.all(5.0),
decoration: BoxDecoration(
border: Border.all(color: Colors.grey)),
child: GestureDetector(
全站熱搜
留言列表