rewind method Null safety

  1. @override
void rewind(
  1. [int count = 1]
)
override

Rewind the read head of the stream by the given number of bytes.

Implementation

@override
void rewind([int count = 1]) {
  if (_bufferPosition - count < 0) {
    var remaining = (_bufferPosition - count).abs();
    _filePosition = _filePosition - _bufferSize - remaining;
    if (_filePosition < 0) {
      _filePosition = 0;
    }
    _file.setPositionSync(_filePosition);
    _readBuffer();
    return;
  }
  _bufferPosition -= count;
}