WriteBuffer constructor Null safety

WriteBuffer(
  1. {int startCapacity = 8}
)

Creates an interface for incrementally building a ByteData instance. startCapacity determines the start size of the WriteBuffer in bytes. The closer that value is to the real size used, the better the performance.

Implementation

factory WriteBuffer({int startCapacity = 8}) {
  assert(startCapacity > 0);
  final ByteData eightBytes = ByteData(8);
  final Uint8List eightBytesAsList = eightBytes.buffer.asUint8List();
  return WriteBuffer._(Uint8List(startCapacity), eightBytes, eightBytesAsList);
}