copyWithInsertedAll method

List<T> copyWithInsertedAll(
  1. int index,
  2. Iterable<T> items
)

Returns a copy with items inserted at index

Implementation

List<T> copyWithInsertedAll(int index, Iterable<T> items) {
  if (index < 0 || index > length) {
    throw RangeError('Index $index out of bounds for list of length $length');
  }
  return [...sublist(0, index), ...items, ...sublist(index)];
}