newList method

List<T> newList(
  1. int length,
  2. {bool growable = true}
)

Constructs a new list.

If growable is false and the kind is either IntKind or FloatKind, the method returns a TypedData object such as Uint32List.

Implementation

List<T> newList(int length, {bool growable = true}) {
  if (isPrimitive) {
    final fill = newInstance();
    return List<T>.filled(
      length,
      fill,
      growable: growable,
    );
  }
  return List<T>.generate(
    length,
    (index) => newInstance(),
    growable: growable,
  );
}