nextInteger static method
Generates a integer in the range 'min', 'max'
. If 'max' is omitted, then the range will be set to 0, 'min'
.
min
minimum value of the integer that will be generated. If 'max' is omitted, then 'max' is set to 'min' and 'min' is set to 0.max
(optional) maximum value of the float that will be generated. Defaults to 'min' if omitted. Returns generated random integer value.
Implementation
static int nextInteger(int min, [int? max]) {
if (max == null) {
max = min;
min = 0;
}
if (max - min <= 0) return min;
return (min + _random.nextDouble() * (max - min)).floor();
}