takeBytes method

Uint8List takeBytes()

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();
  }
}