int32 method
generates a random Int32 whose value falls between min
(inclusive) and max
(exclusive)
Implementation
Int32 int32({$core.int min = 0, $core.int? max}) {
max ??= Int32.MAX_VALUE.toInt(); // -- force default even if `null` is explicitly passed
if (min > Int32.MAX_VALUE.toInt()) {
throw ArgumentError.value(min, 'min', 'must be a 32-bit number');
}
if (min > max) {
throw ArgumentError('Value passed for `min` ($min) must be less than value passed for `max` ($max)');
}
return Int32(integer($math.min(Int32.MAX_VALUE.toInt(), max), min: $math.min(Int32.MAX_VALUE.toInt(), min)));
}