Buffer class

A variable-sized buffer of bytes with read() and write() methods.

Implemented types
Available extensions
Annotations
  • @JS()
  • @staticInterop

Constructors

Buffer([ByteBuffer? ab])
factory

Properties

capacity num

Available on Buffer, provided by the Buffer$Typings extension

The read only capacity of the buffer's underlying byte slice, that is, the total space allocated for the buffer's data.
no setter
hashCode int
The hash code for this object.
no setterinherited
length num

Available on Buffer, provided by the Buffer$Typings extension

A read only number of bytes of the unread portion of the buffer.
no setter
read Future<num?> Function(Uint8List)

Available on Reader, provided by the Reader$Typings extension

getter/setter pair
readSync num? Function(Uint8List)

Available on ReaderSync, provided by the ReaderSync$Typings extension

getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
write Future<num> Function(Uint8List)

Available on Writer, provided by the Writer$Typings extension

getter/setter pair
writeSync num Function(Uint8List)

Available on WriterSync, provided by the WriterSync$Typings extension

getter/setter pair

Methods

bytes([IInline8? options]) Uint8List

Available on Buffer, provided by the Buffer$Typings extension

Returns a slice holding the unread portion of the buffer.
empty() bool

Available on Buffer, provided by the Buffer$Typings extension

Returns whether the unread portion of the buffer is empty.
grow(num n) → void

Available on Buffer, provided by the Buffer$Typings extension

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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
read(Uint8List p) Future<num?>

Available on Buffer, provided by the Buffer$Typings extension

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>

Available on Buffer, provided by the Buffer$Typings extension

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

Available on Buffer, provided by the Buffer$Typings extension

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?

Available on Buffer, provided by the Buffer$Typings extension

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

Available on Buffer, provided by the Buffer$Typings extension

Resets the buffer to be empty, but it retains the underlying storage for use by future writes. .reset() is the same as .truncate(0).
toString() String
A string representation of this object.
inherited
truncate(num n) → void

Available on Buffer, provided by the Buffer$Typings extension

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>

Available on Buffer, provided by the Buffer$Typings extension

NOTE: This methods writes bytes synchronously; it's provided for compatibility with Writer interface.
writeSync(Uint8List p) num

Available on Buffer, provided by the Buffer$Typings extension

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.

Operators

operator ==(Object other) bool
The equality operator.
inherited