done method Null safety

ByteData done()

Finalize and return the written ByteData.

Implementation

ByteData done() {
  if (_isDone) {
    throw StateError('done() must not be called more than once on the same $runtimeType.');
  }
  final ByteData result = _buffer.buffer.asByteData(0, _currentSize);
  _buffer = Uint8List(0);
  _isDone = true;
  return result;
}