random method

int random([
  1. int? seed
])

Generates a random integer between 0 (inclusive) and this value (exclusive), with an optional seed for reproducibility.

Throws RangeError if this value is less than 1.

Implementation

int random([int? seed]) {
  if (this < 1) {
    throw RangeError('Upper bound must be at least 1.');
  }
  return math.Random(seed).nextInt(toInt());
}