nextIntBetween method

int nextIntBetween(
  1. int min,
  2. int max
)

Generates a non-negative random integer uniformly distributed in the range from min, inclusive, to max, exclusive.

Implementation

int nextIntBetween(int min, int max) {
  final val = nextInt(max - min);
  return min + val;
}