ReorderCallback typedef
The callback used by ReorderableListView to move an item to a new position in a list.
Implementations should remove the corresponding list item at oldIndex
and reinsert it at newIndex.
If oldIndex is before newIndex, removing the item at oldIndex from the
list will reduce the list's length by one. Implementations used by
ReorderableListView will need to account for this when inserting before
newIndex.
final List<MyDataObject> backingList = <MyDataObject>[/* ... */];
void handleReorder(int oldIndex, int newIndex) {
if (oldIndex < newIndex) {
// removing the item at oldIndex will shorten the list by 1.
newIndex -= 1;
}
final MyDataObject element = backingList.removeAt(oldIndex);
backingList.insert(newIndex, element);
}
Implementation
typedef ReorderCallback = void Function(int oldIndex, int newIndex);