writeBytes method

void writeBytes(
  1. ByteArray bytes, [
  2. int offset = 0,
  3. int length = 0
])

Writes a sequence of length bytes from the specified byte array, bytes, starting offset(zero-based index) bytes into the byte stream.

Implementation

void writeBytes(ByteArray bytes, [int offset = 0, int length = 0]) {
  int writeLength = 0;
  if (length < 0) {
    return;
  } else if (length == 0) {
    writeLength = bytes.length - offset;
  } else {
    writeLength = min(bytes.length - offset, length);
  }
  List<int> sourceBytes = bytes._bytes.sublist(offset, offset + writeLength);
  _setAll(_position, sourceBytes);
  _position += sourceBytes.length;
}