copy method

void copy(
  1. Buffer dst, [
  2. int dstOffset = 0,
  3. int offset = 0,
  4. int? length,
])

Copies items from this buffer to the destination (dst) buffer. Items are copied to dst starting at position dstOffset. Items are copied from the range [offset : offset+length]. If length is omitted, the range extends to the end of this or [dst] (whichever has the minimum length). The range must satisfy the relations 0offsetoffset+lengththis.length.

Implementation

void copy(
  final Buffer dst, [
  final int dstOffset = 0,
  final int offset = 0,
  final int? length,
]) {
  final int rngLength = length ?? min(dst.length - dstOffset, this.length - offset);
  final Iterable<int> src = _data.getRange(offset, offset + rngLength);
  dst._data.setRange(dstOffset, dstOffset + rngLength, src);
}