Buffer$Typings extension

on

Properties

capacity num
The read only capacity of the buffer's underlying byte slice, that is, the total space allocated for the buffer's data.
no setter
length num
A read only number of bytes of the unread portion of the buffer.
no setter

Methods

bytes([IInline8? options]) Uint8List
Returns a slice holding the unread portion of the buffer.
empty() bool
Returns whether the unread portion of the buffer is empty.
grow(num n) → void
Grows the buffer's capacity, if necessary, to guarantee space for another n bytes. After .grow(n), at least n bytes can be written to the buffer without another allocation. If n is negative, .grow() will throw. If the buffer can't grow it will throw an error.
read(Uint8List p) Future<num?>
Reads the next p.length bytes from the buffer or until the buffer is drained. Resolves to the number of bytes read. If the buffer has no data to return, resolves to EOF (null).
readFrom(Reader r) Future<num>
Reads data from r until EOF (null) and appends it to the buffer, growing the buffer as needed. It resolves to the number of bytes read. If the buffer becomes too large, .readFrom() will reject with an error.
readFromSync(ReaderSync r) num
Reads data from r until EOF (null) and appends it to the buffer, growing the buffer as needed. It returns the number of bytes read. If the buffer becomes too large, .readFromSync() will throw an error.
readSync(Uint8List p) num?
Reads the next p.length bytes from the buffer or until the buffer is drained. Returns the number of bytes read. If the buffer has no data to return, the return is EOF (null).
reset() → void
Resets the buffer to be empty, but it retains the underlying storage for use by future writes. .reset() is the same as .truncate(0).
truncate(num n) → void
Discards all but the first n unread bytes from the buffer but continues to use the same allocated storage. It throws if n is negative or greater than the length of the buffer.
write(Uint8List p) Future<num>
NOTE: This methods writes bytes synchronously; it's provided for compatibility with Writer interface.
writeSync(Uint8List p) num
Writes p.byteLength bytes from p to the underlying data stream. It returns the number of bytes written from p (0 <= n <= p.byteLength) and any error encountered that caused the write to stop early. writeSync() must throw a non-null error if it returns n < p.byteLength. writeSync() must not modify the slice data, even temporarily.