copyWithInserted method
Returns a copy with item inserted at index
Implementation
List<T> copyWithInserted(int index, T item) {
if (index < 0 || index > length) {
throw RangeError('Index $index out of bounds for list of length $length');
}
return [...sublist(0, index), item, ...sublist(index)];
}