writeBytes method

void writeBytes(
  1. List<int> value,
  2. [int index = 0,
  3. int writtenLength]
)

Writes bytes from a list.

Implementation

void writeBytes(List<int> value, [int index = 0, int writtenLength]) {
  if (writtenLength == null) {
    writtenLength = value.length - index;
  }
  if (writtenLength >= _minLengthForUin32CopyMethod && value is Uint8List) {
    writeByteData(
      new ByteData.view(
        value.buffer,
        value.offsetInBytes + index,
        writtenLength,
      ),
    );
    return;
  }
  ensureAvailableLength(writtenLength);

  final buffer = this._byteData;
  var bufferIndex = this._length;
  for (final end = index + writtenLength; index < end; index++) {
    buffer.setUint8(bufferIndex, value[index]);
    bufferIndex++;
  }
  this._length = bufferIndex;
}