amount method

List amount (
  1. dynamic fn(
    1. int i
    ),
  2. int max,
  3. {int min: 1}
)

Generates a list of random length filled by return value of fn.

Example:

    random.amount((_) => random.string(10), 10);

    random.amount((_) => random.string(15), 10, min: 5);

Implementation

List amount(fn(int i), int max, {int min = 1}) {
  var length = integer(max, min: min);
  return List.generate(length, fn);
}