randomNumber static method

int randomNumber({
  1. int min = 0,
  2. int max = 100,
})

randomNumber(10 ,100) will output : 10,55,95,99 ..etc..

Implementation

static int randomNumber({
  int min = 0,
  int max = 100,
}) {
  if (min > max) {
    throw Exception("Min can't be greather than max");
  }

  if (max < min) {
    throw Exception("Max can't be less than min");
  }
  final rn = Random();
  return min + rn.nextInt(max - min);
}