nextBool method

  1. @override
  2. @useResult
bool nextBool()
override

Returns the next boolean in the iterable.

Contract

Throws a StateError if there are no more booleans in the iterable.

Example

final random = FakeRandom(bools: [true, false]);
random.nextBool(); // true
random.nextBool(); // false
random.nextBool(); // throws StateError

Implementation

@override
@useResult bool nextBool() {
  if (!_bools.moveNext()) {
    throw StateError('FakeRandom presently does not contain a boolean. Try supply more booleans to `FakeRandom(bools: [...])`.');
  }

  return _bools.current;
}