copyWithNewArraySize<T> static method

List<T> copyWithNewArraySize<T>(
  1. List<T> array,
  2. int size,
  3. T defaultValue
)

Implementation

static List<T> copyWithNewArraySize<T>(
    List<T> array, int size, T defaultValue) {
  final int oldSize = array.length;
  return oldSize == size
      ? array
      : <T>[
          ...array.take(size),
          for (int i = oldSize; i < size; i++) defaultValue
        ];
}