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.
The list must be growable. The index
value must be non-negative and no greater than 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 ConcurrentModificationError(iterable); } setRange(index + insertionLength, this.length, this, index); setAll(index, iterable); }
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dart.dev/stable/2.5.0/dart-collection/ListMixin/insertAll.html