copy method
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 satisy the relations 0 ≤ offset ≤ offset+length ≤ this.length.
final Buffer src = Buffer.fromList([1, 2, 3, 4, 5, 6, 7, 8]);
final Buffer dst = Buffer(4);
src.copy(dst, 0, 2);
print(src); // [1, 2, 3, 4, 5, 6, 7, 8]
print(dst); // [3, 4, 5, 6]
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);
}