void insertAll(int index, Iterable<E> iterable)

Inserts all objects of iterable at position index in this list.

This increases the length of the list by the length of iterable and shifts all later objects towards the end of the list.

An error occurs if the index is less than 0 or greater than length. An UnsupportedError occurs if the list is fixed-length.


void insertAll(int index, Iterable<E> iterable) {
  RangeError.checkValueInInterval(index, 0, length, "index");
  if (iterable is! EfficientLengthIterable || identical(iterable, this)) {
    iterable = iterable.toList();
  int insertionLength = iterable.length;
  // There might be errors after the length change, in which case the list
  // will end up being modified but the operation not complete. Unless we
  // always go through a "toList" we can't really avoid that.
  this.length += insertionLength;
  if (iterable.length != insertionLength) {
    // If the iterable's length is linked to this list's length somehow,
    // we can't insert one in the other.
    this.length -= insertionLength;
    throw new ConcurrentModificationError(iterable);
  setRange(index + insertionLength, this.length, this, index);
  setAll(index, iterable);