copyWithMoved method
Returns a copy with elements moved from oldIndex to newIndex
Implementation
List<T> copyWithMoved(int oldIndex, int newIndex) {
if (oldIndex < 0 || oldIndex >= length) {
throw RangeError('oldIndex $oldIndex out of bounds');
}
if (newIndex < 0 || newIndex >= length) {
throw RangeError('newIndex $newIndex out of bounds');
}
if (oldIndex == newIndex) return List.of(this);
final item = this[oldIndex];
final temp = List<T>.from(this);
temp.removeAt(oldIndex);
temp.insert(newIndex, item);
return temp;
}