writeBytes method

void writeBytes(
  1. Uint8List input,
  2. {int bytes = 0,
  3. int bits = 0}
)

Writes a byte array to the stream of length bytes and bits

Implementation

void writeBytes(Uint8List input, {int bytes = 0, int bits = 0}) {
  var len = (bytes * 8) + bits;
  var totBytes = len ~/ 8;
  var remBits = len % 8;

  var numBytes = input.lengthInBytes;
  if (remBits > 0) {
    var firstByte = (numBytes - totBytes) - 1;
    write(input[firstByte], bits: remBits);
  }
  for (var x = numBytes - totBytes; x < numBytes; x++) {
    write(input[x], bytes: 1);
  }
}