random property

num get random

Generates a random number between 0 and this number. If this number is an integer, the result is an integer. If this number is a double, the result is a double scaled by this value.

Example:

print(10.random); // random int 0-9

Implementation

num get random => this is int ? Random().nextInt(this as int) : Random().nextDouble() * this;