add method
Adds a chunk to the buffer, truncating if maxBytes is reached.
Implementation
void add(List<int> chunk) {
_totalBytes += chunk.length;
if (_isCapped) return;
if (maxBytes <= 0) {
_builder.add(chunk);
return;
}
final remaining = maxBytes - _builder.length;
if (chunk.length <= remaining) {
_builder.add(chunk);
} else {
if (remaining > 0) {
_builder.add(chunk.sublist(0, remaining));
}
_isCapped = true;
}
}