output method

Uint8List output()

Outputs/emits all the written bytes.

Implementation

Uint8List output() {
  final length = this.length;

  var all = Uint8List(length);
  var offset = 0;

  for (var e in _data) {
    Uint8List bs;

    if (e is int) {
      all[offset] = e;
      ++offset;
    } else {
      if (e is BytesEmitter) {
        bs = e.output();
      } else if (e is Uint8List) {
        bs = e;
      } else {
        throw StateError("Can't handle type: $e");
      }

      var lng = bs.length;
      all.setRange(offset, offset + lng, bs);

      offset += lng;
    }
  }

  return all;
}