moveItem method
void
moveItem({})
Moves an item from one position to another
Implementation
void moveItem({
required int fromListIndex,
required int fromItemIndex,
required int toListIndex,
required int toItemIndex,
}) {
if (fromListIndex >= 0 && fromListIndex < _lists.length &&
fromItemIndex >= 0 && fromItemIndex < _lists[fromListIndex].length &&
toListIndex >= 0 && toListIndex < _lists.length &&
toItemIndex >= 0 && toItemIndex <= _lists[toListIndex].length) {
final item = _lists[fromListIndex].removeAt(fromItemIndex);
_lists[toListIndex].insert(toItemIndex, item);
// Notify about the move
if (fromListIndex == toListIndex) {
_callbacks?.onItemReorder?.call(fromListIndex, fromItemIndex, toItemIndex);
} else {
_callbacks?.onItemMove?.call(fromListIndex, fromItemIndex, toListIndex, toItemIndex);
}
notifyListeners();
}
}