generateRandomInt method

int generateRandomInt({
  1. int minimum = 0,
  2. int maximum = 10,
})

Implementation

int generateRandomInt({int minimum = 0, int maximum = 10}) {
  if (minimum < 0 || minimum >= maximum) {
    minimum = 0;
  }
  if (maximum <= minimum) {
    maximum = minimum + 10;
  }
  int randomInt = _random.nextInt(maximum);
  if (randomInt < minimum) {
    randomInt = randomInt + minimum;
    if (randomInt >= maximum) {
      return generateRandomInt(minimum: 0, maximum: 10);
    }
  }
  return randomInt;
}