ImmortalList<T>.generate constructor

ImmortalList<T>.generate(
  1. int length,
  2. T valueGenerator(
    1. int index
    )
)

Generates an ImmortalList of values.

Creates a list with length positions and fills it with values created by calling valueGenerator for each index in the range 0 .. length - 1 in increasing order.

Will return an empty list if length is negative.

Implementation

factory ImmortalList.generate(
  int length,
  T Function(int index) valueGenerator,
) =>
    ImmortalList._internal(List.generate(
      max(length, 0),
      valueGenerator,
      growable: false,
    ));