dataAndClear property

Uint8List get dataAndClear

Returns a copy of the currently stored data and clears the buffer.

Implementation

Uint8List get dataAndClear {
  if (_usedLength == 0) return Uint8List(0);
  final Uint8List newBuffer = Uint8List(_usedLength);
  newBuffer.setAll(0, data);
  if (_usedLength > _kInitialSize) _buffer = Uint8List(_kInitialSize);
  _usedLength = 0;
  return newBuffer;
}