random function

dynamic random(
  1. num upper, {
  2. num? lower,
  3. bool floating = false,
})

Implementation

dynamic random(num upper, {num? lower, bool floating = false}) {
  lower ??= 0;
  if (floating || upper.runtimeType == double || lower.runtimeType == double) {
    return lower + r.nextDouble() * (upper - lower);
  }
  return lower + (r.nextInt((upper - lower).toInt()));
}