Метод insertAll
void insertAll(Вставляет все объекты iterable в эту коллекцию по позиции index.
Это увеличивает длину списка на длину iterable и сдвигает все последующие объекты к концу списка.
Возникает ошибка, если index меньше 0 или больше длины. Возникает UnsupportedError , если список имеет фиксированную длину.
Исходный код
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);
}
© 2012 the Dart project authors
Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
https://api.dartlang.org/stable/1.24.3/dart-collection/ListMixin/insertAll.html