reorderList method

void reorderList({
  1. required int oldIndex,
  2. required int newIndex,
})

Implementation

void reorderList({required int oldIndex, required int newIndex}) {
  if (canWrite) {
    reorderListTextController(oldIndex: oldIndex, newIndex: newIndex);
  }
  if (oldIndex < newIndex) newIndex -= 1;
  final updatedList = List<ListModel>.from(draggableLists.value);
  final item = updatedList.removeAt(oldIndex);
  updatedList.insert(newIndex, item);
  draggableLists.value = updatedList;
}