takeBytes method

Uint8List takeBytes()

Takes the list of bytes from the buffer as a Uint8List

Returns the final list of bytes

Implementation

Uint8List takeBytes() {
  if (_builder.isEmpty) {
    // Just take scratch data
    final res = Uint8List.view(
      _scratchBuffer!.buffer,
      _scratchBuffer!.offsetInBytes,
      _scratchOffset,
    );
    _scratchOffset = 0;
    _scratchBuffer = null;
    _scratchData = null;
    return res;
  } else {
    _appendScratchBuffer();
    return _builder.takeBytes();
  }
}