nextFloat static method
Generates a float in the range 'min', 'max'
. If 'max' is omitted, then the range will be set to 0, 'min'
.
min
minimum value of the float 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 float value.
Implementation
/// - [min] minimum value of the float 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 float value.
static double nextFloat(double min, [double? max]) {
if (max == null) {
max = min;
min = 0;
}
if (max - min <= 0) return min;
return min + _random.nextDouble() * (max - min);
}