writeBytes method Null safety

  1. @override
void writeBytes(
  1. List<int> bytes,
  2. [int? len]
)
override

Write a set of bytes to the end of the buffer.

Implementation

@override
void writeBytes(List<int> bytes, [int? len]) {
  len ??= bytes.length;
  if (_bufferPosition + len >= _buffer.length) {
    flush();

    if (_bufferPosition + len < _buffer.length) {
      for (int i = 0, j = _bufferPosition; i < len; ++i, ++j) {
        _buffer[j] = bytes[i];
      }
      _bufferPosition += len;
      _length += len;
      return;
    }
  }

  flush();
  _fp.writeFromSync(bytes, 0, len);
  _length += len;
}