randomBetween function

int randomBetween(
  1. int from,
  2. int to
)

Implementation

int randomBetween(int from, int to) {
  if (from > to) throw Exception('$from cannot be > $to');
  final rand = Random();
  return ((to - from) * rand.nextDouble()).toInt() + from;
}