toBytes method

Uint8List toBytes({
  1. bool? copy,
})

Concatenate the byte arrays and return them as a single unit.

Implementation

Uint8List toBytes({bool? copy}) {
  if (_chunks.length == 1 && !(copy ?? _copy)) {
    return _chunks.single;
  }
  final list = Uint8List(_length);
  var offset = 0;
  for (var i = 0; i < _chunks.length; i++) {
    final chunk = _chunks[i];
    list.setRange(offset, offset + chunk.length, chunk);
    offset += chunk.length;
  }
  return list;
}