setRange method

  1. @override
void setRange(
  1. int start,
  2. int end,
  3. Iterable<T> iterable, [
  4. int skipCount = 0,
])
override

Writes some elements of iterable into a range of this list. Copies the objects of iterable, skipping skipCount objects first, into the range from start, inclusive, to end, exclusive, of this slice.

Implementation

@override
void setRange(int start, int end, Iterable<T> iterable, [int skipCount = 0]) {
  final (normalizedStart, normalizedEnd) =
      _validateAndNormalizeRange(start, end);
  final iterator = iterable.skip(skipCount).iterator;
  for (int i = normalizedStart; i < normalizedEnd; i++) {
    if (!iterator.moveNext()) {
      return;
    }
    _list[i] = iterator.current;
  }
}