writeBytes method
Implementation
void writeBytes(List<int> bytes) {
final length = bytes.length;
if (length == 0) {
return;
}
_ensureSize(length);
if (_scratchOffset == 0) {
// we can add it directly
_builder.add(bytes);
} else {
// there is enough room in _scratchBuffer, otherwise _ensureSize
// would have added _scratchBuffer to _builder and _scratchOffset would
// be 0
if (bytes is Uint8List) {
_scratchBuffer?.setRange(
_scratchOffset, _scratchOffset + length, bytes);
} else {
for (int i = 0; i < length; i++) {
_scratchBuffer?[_scratchOffset + i] = bytes[i];
}
}
_scratchOffset += length;
}
}