iota method

void iota(
  1. T value, [
  2. T step(
    1. T
    )?
])

Fills the list with successively increasing values, starting with value.

Similar to std::iota. Each element is produced by calling step on the previous value. If step is not provided, it defaults to incrementing by 1. Example: given a list of length 3 and value = 5, produces [5, 6, 7].

Implementation

void iota(T value, [T Function(T)? step]) {
  step ??= (T val) => ((val as dynamic) + 1) as T;
  var current = value;
  for (int i = 0; i < length; i++) {
    this[i] = current;
    current = step(current);
  }
}