rangeInt function

TValueGenerator rangeInt(
  1. int min,
  2. int max, {
  3. required Random random,
})

Returns a generator that produces a random int in [min, max) on each call.

Throws ArgumentError if max is not greater than min.

Implementation

TValueGenerator rangeInt(
  int min,
  int max, {
  required Random random,
}) {
  _requireMinLessThanMax(min, max);
  return () => min + random.nextInt(max - min);
}