writeFrom method

  1. @override
int writeFrom(
  1. BytesIO io, [
  2. int? length
])
override

Writes length bytes from io.

Implementation

@override
int writeFrom(BytesIO io, [int? length]) {
  length ??= io.remaining;

  if (io is BytesUint8ListIO) {
    final bytes = _bytes;
    final bytes2 = io._bytes;

    final offset = _position;
    final offset2 = io._position;

    for (var i = 0; i < length; ++i) {
      var b = bytes2[offset2 + i];
      bytes[offset + i] = b;
    }

    incrementPosition(length);
    io.incrementPosition(length);

    return length;
  } else {
    var bs = io.readBytes(length);
    writeAll(bs);
    return bs.length;
  }
}