copyList method
Creates a fixed-length list copy of the iterable
, possibly with a
modified length
and if necessary populated with fillValue
.
Implementation
List<T> copyList(Iterable<T> iterable,
{int? length, T? fillValue, bool readonly = false}) {
final listLength = iterable.length;
final result =
newList(length ?? listLength, fillValue: fillValue ?? defaultValue);
result.setRange(0, math.min(result.length, listLength), iterable);
return readonly ? UnmodifiableListView<T>(result) : result;
}