concat static method

Uint8List concat(
  1. List<Uint8List> parts
)

Concatenates multiple byte arrays into a single Uint8List.

HINT: Preserve order: concat(a, b, c) -> a||b||c

Implementation

static Uint8List concat(List<Uint8List> parts) {
  final total = parts.fold<int>(0, (n, p) => n + p.length);
  final out = Uint8List(total);
  var offset = 0;
  for (final p in parts) {
    out.setAll(offset, p);
    offset += p.length;
  }
  return out;
}