incrementBytesRead method
Update the read position by amount
bytes.
Bumps the internal readCount pointer by an amount
.
If amount
is negative, a RangeError is thrown.
If the additional offset by an amount
would be > writeCount,
a ArgumentError is thrown.
Implementation
void incrementBytesRead(int amount) {
RangeError.checkNotNegative(amount);
final nextRead = readCount + amount;
if (nextRead > writeCount) {
final overRead = nextRead - writeCount;
final bytes = overRead == 1 ? 'byte' : 'bytes';
throw ArgumentError(
'illegal attempt to read $overRead $bytes more than was written');
} else {
readCount = nextRead;
}
}