nextInt method

int nextInt(
  1. int max
)

Implementation

int nextInt(int max) {
  if (max <= 0) throw ArgumentError("max must be greater than 0");

  // Generate a random double in the range [0.0, 1.0)
  double fraction =
      nextUint32 / 4294967296.0; // Divide by 2^32 to get a fraction
  return (fraction * max).floor();
}