fillRange method

IList<T> fillRange(
  1. int start,
  2. int end, [
  3. T? fillValue
])

Sets the objects in the range start inclusive to end exclusive to the given fillValue.

The provided range, given by start and end, must be valid. A range from start to 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.

Example with List:

final List<int> list = List(3);
list.fillRange(0, 2, 1);
print(list);  // [1, 1, null]

Example with IList:

final IList<int> ilist = IList();
ilist.fillRange(0, 2, 1);
print(ilist); // [1, 1, null]

If the element type is not nullable, omitting fillValue or passing null as fillValue will make the fillRange fail.

Implementation

IList<T> fillRange(int start, int end, [T? fillValue]) {
  // TODO: Still need to implement efficiently.
  return IList._unsafeFromList(toList(growable: false)..fillRange(start, end, fillValue),
      config: config);
}