copyList method

List<T> copyList(
  1. Iterable<T> list, {
  2. int? length,
  3. T? fillValue,
})

Creates a fixed-length list copy of this data type, possibly with a modified length and if necessary populated with fillValue.

Implementation

List<T> copyList(Iterable<T> list, {int? length, T? fillValue}) {
  final listLength = list.length;
  final result = newList(length ?? listLength, fillValue ?? defaultValue);
  result.setRange(0, math.min(result.length, listLength), list);
  return result;
}