padTo method

  1. @useResult
List<T> padTo(
  1. int length,
  2. T fill
)

New list padded with fill to at least length elements.

Implementation

@useResult
List<T> padTo(int length, T fill) {
  if (this.length >= length) return List<T>.of(this);
  return <T>[...this, ...List<T>.filled(length - this.length, fill)];
}