randomInRange function
Generates a random integer within the specified range.
Returns a random integer between min and max, inclusive.
min and max are treated as integer bounds via toInt().
Throws ArgumentError if min is greater than max.
If a seed is provided, it is used to initialize the random number generator
for reproducible results.
Example:
int randomNumber = randomInRange(1, 10);
Implementation
int randomInRange(num min, num max, [int? seed]) {
if (min > max) {
throw ArgumentError('min must be less than or equal to max.');
}
return ((max - min + 1).random(seed) + min).toInt();
}