replaceRange method Null safety
Removes the objects in the range
start inclusive to
and inserts the contents of
replacement in its place.
List<int> list = [1, 2, 3, 4, 5]; list.replaceRange(1, 4, [6, 7]); list.join(', '); // '1, 6, 7, 5'
The provided range, given by
end, must be valid.
A range from
end is valid if
0 <= start <= end <= len, where
len is this list's
length. The range starts at
start and has length
end - start. An empty range (with
end == start) is valid.
This method does not work on fixed-length lists, even when
has the same number of elements as the replaced range. In that case use
void replaceRange(int start, int end, Iterable<E> replacement);