nextBool method
Generates a random boolean value.
Example:
var boolValue = Random().nextBool(); // true or false, with equal chance.
Implementation
@override
bool nextBool() {
// we're returning bits from higher to lower: like uint32s from int64s
if (boolCache_prevShift == 0) {
boolCache = nextRaw32();
boolCache_prevShift = 31;
return boolCache & 0x80000000 != 0;
} else {
assert(boolCache_prevShift > 0);
boolCache_prevShift--;
final result = (boolCache & (1 << boolCache_prevShift)) != 0;
return result;
}
}