如何将 ReorderableListView 与 ListView.builder 一起使用

问题描述 投票:0回答:0

我正在尝试使我的列表可重新排序,我已经遵循了一些关于使用 ReorderableListView 的教程,但它不适用于我正在使用的列表类型。我该怎么办?

ReorderableListView 之前的代码

      body: ListView.builder(
    itemCount: db.toDoList.length,
    itemBuilder: (context, index) {
      return toDoTile(
        taskName: db.toDoList[index][0],
        taskCompleted: db.toDoList[index][1],
        onChanged: (value) => checkBoxChanged(value, index),
        deleteFunction: (context) => deleteTask(index),
        editTask: (context) => editTask(index),
      );

在 ReorderableListView 上做教程时,我最终得到这个:

body: ReorderableListView(
    children: [
      for (final tile in myTiles)
        ListTile(
          key: ValueKey(tile),
          title: Text(tile),
        )
    ],
    onReorder: (oldIndex, newIndex) => updatMyTiles(oldIndex, newIndex),
  ),

但问题是我如何将两者一起实施?

flutter
© www.soinside.com 2019 - 2024. All rights reserved.