coin static method

bool coin(
  1. double probability
)

Returns true with the given probability (between 0.0 and 1.0).

Implementation

static bool coin(double probability) {
  if (probability < 0.0 || probability > 1.0) {
    throw ArgumentError('probability must be from 0.0 to 1.0');
  }
  final rand = math.Random();
  return rand.nextDouble() < probability;
}