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