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 anothern
bytes. After.grow(n)
, at leastn
bytes can be written to the buffer without another allocation. Ifn
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 nextp.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 fromr
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 fromr
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 nextp.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 firstn
unread bytes from the buffer but continues to use the same allocated storage. It throws ifn
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 withWriter
interface. -
writeSync(
Uint8List p) → num -
Available on Buffer, provided by the Buffer$Typings extension
Writesp.byteLength
bytes fromp
to the underlying data stream. It returns the number of bytes written fromp
(0
<=n
<=p.byteLength
) and any error encountered that caused the write to stop early.writeSync()
must throw a non-null error if it returnsn
<p.byteLength
.writeSync()
must not modify the slice data, even temporarily.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited