randomBool function
Returns a random boolean value (true or false).
You may define an optional likelihood
from 0 to 1.
Implementation
bool randomBool([double? likelihood]) {
if (likelihood == null) {
return _random.nextBool();
}
if (likelihood > 1 || likelihood < 0) {
throw RangeError('likelihood must be within range of 0 and 1');
}
return _random.nextDouble() < likelihood;
}