Buffer class
A collection of bytes in memory.
- Implemented types
- Available Extensions
Constructors
- Buffer()
Properties
- buffer → Buffer
-
This source's internal buffer.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setteroverride
- head ↔ Segment?
-
getter/setter pair
- isEmpty → bool
-
no setter
- isNotEmpty → bool
-
no setter
- length → int
-
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
asBytes(
[int start = 0, int? end]) → Uint8List -
clear(
) → void -
close(
) → void -
Closes this source and releases the resources held by this source. It is
an error to read a closed source. It is safe to close a source more than
once.
override
-
completeSegmentByteCount(
) → int - Returns the number of bytes in segments that are not writable. This is the number of bytes that can be flushed immediately to an underlying sink without harming throughput.
-
copy(
) → Buffer -
copyTo(
Buffer buffer, [int start = 0, int? end]) → void -
emit(
) → void -
Writes all buffered data to the underlying sink, if one exists. Like flush, but weaker. Call
this before this buffered sink goes out of scope so that its data can reach its destination.
override
-
emitCompleteSegments(
) → void -
Writes complete segments to the underlying sink, if one exists. Like flush, but weaker. Use
this to limit the memory held in the buffer to a single segment. Typically application code
will not need to call this: it is only necessary when application code writes directly to this
sink's buffer.
override
-
exhausted(
) → bool -
Returns true if there are no more bytes in this source.
override
-
flush(
) → void -
Pushes all buffered bytes to their final destination.
override
-
indexOf(
int element, [int start = 0, int? end]) → int -
Returns the index of
element
if it is found in the range ofstart
inclusive toend
exclusive. Ifelement
isn't found, or ifstart == end
, then -1 is returned.override -
indexOfBytes(
Uint8List bytes, [int start = 0, int? end]) → int -
Returns the index of the first match for
bytes
in the range ofstart
inclusive toend
exclusive. This expands the buffer as necessary untilbytes
is found. This reads an unbounded number of bytes into the buffer. Returns -1 if the stream is exhausted before the requested bytes are found.override -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
peek(
) → BufferedSource -
Returns a new
BufferedSource
that can read data from thisBufferedSource
without consuming it. The returned source becomes invalid once this source is next read or closed.override -
rangeEquals(
int offset, List< int> bytes, [int start = 0, int? end]) → bool -
Returns true if
end
-start
bytes atoffset
in this source equalbytes
atstart
. This expands the buffer as necessary until a byte does not match, all bytes are matched, or if the stream is exhausted before enough bytes could determine a match.override -
read(
Buffer sink, int count) → int -
Removes at least 1, and up to
count
bytes from this and appends them tosink
. Returns the number of bytes read, or 0 if this source is exhausted.override -
readBytes(
[int? count]) → Uint8List -
Removes bytes (all bytes if
count
is null) from this and returns them as a list of bytes.override -
readFloat32(
[Endian endian = Endian.big]) → double -
Removes four bytes from this source.
override
-
readFloat64(
[Endian endian = Endian.big]) → double -
Removes eight bytes from this source.
override
-
readInt16(
[Endian endian = Endian.big]) → int -
Removes two bytes from this source.
override
-
readInt32(
[Endian endian = Endian.big]) → int -
Removes four bytes from this source.
override
-
readInt64(
[Endian endian = Endian.big]) → int -
Removes eight bytes from this source.
override
-
readInt8(
) → int -
Removes a byte from this source.
override
-
readIntoBytes(
List< int> sink, [int start = 0, int? end]) → int -
Removes exactly
end - start
bytes from this and copies them intosink
.override -
readIntoSink(
Sink sink) → Future< int> -
Removes all bytes from this and appends them to
sink
. Returns the total number of bytes written tosink
which will be 0 if this is exhausted.override -
readLine(
{Encoding encoding = utf8, int? newline}) → String? -
Removes and returns characters up to but not including the next line break. A line break is
either
"\n"
or"\r\n"
; these characters are not included in the result.override -
readLineStrict(
{Encoding encoding = utf8, int? end}) → String -
Removes and returns characters up to but not including the next line break. A line break is
either
"\n"
or"\r\n"
; these characters are not included in the result.override -
readString(
{Encoding encoding = utf8, int? count}) → String -
Removes bytes (all bytes if
count
is null) from this and returns the string. Returns the empty string if this source is empty.override -
readUint16(
[Endian endian = Endian.big]) → int -
Removes two bytes from this source.
override
-
readUint32(
[Endian endian = Endian.big]) → int -
Removes four bytes from this source.
override
-
readUint64(
[Endian endian = Endian.big]) → int -
Removes eight bytes from this source.
override
-
readUint8(
) → int -
Removes a byte from this source.
override
-
request(
int count) → bool -
Returns true when the buffer contains at least
count
bytes, expanding it as necessary. Returns false if the source is exhausted before the requested bytes can be read.override -
require(
int count) → void -
Returns when the buffer contains at least
count
bytes. Throws an EOFException if the source is exhausted before the required bytes can be read.override -
seek(
int index) → (Segment, int)? -
Searches from the front or the back depending on what's closer to
index
. -
skip(
int count) → void -
Reads and discards
count
bytes from this source. Throws an EOFException if the source is exhausted before the requested bytes can be skipped.override -
toString(
) → String -
A string representation of this object.
override
-
writableSegment(
int minimumCapacity) → Segment -
write(
Buffer source, int count) → void -
Removes
count
bytes fromsource
and appends them to this.override -
writeCharCode(
int charCode) → void -
Writes the character represented by
charCode
.override -
writeFloat32(
double value, [Endian endian = Endian.big]) → void -
Writes four bytes to this sink.
override
-
writeFloat64(
double value, [Endian endian = Endian.big]) → void -
Writes eight bytes to this sink.
override
-
writeFromBytes(
List< int> source, [int start = 0, int? end]) → void -
This writes
byteCount
bytes ofsource
, starting atstart
.override -
writeFromSource(
Source source) → Future< int> -
Removes all bytes from
source
and appends them to this sink. Returns the number of bytes read which will be 0 ifsource
is exhausted.override -
writeInt16(
int value, [Endian endian = Endian.big]) → void -
Writes two bytes to this sink.
override
-
writeInt32(
int value, [Endian endian = Endian.big]) → void -
Writes four bytes to this sink.
override
-
writeInt64(
int value, [Endian endian = Endian.big]) → void -
Writes eight bytes to this sink.
override
-
writeInt8(
int value) → void -
Writes a byte to this sink.
override
-
writeLine(
[String string = '', Encoding encoding = utf8]) → void -
Writes
string
followed by a newline,"\n"
.override -
writeString(
String string, [Encoding encoding = utf8]) → void -
Encodes
string
inencoding
and writes it to this sink.override -
writeUint16(
int value, [Endian endian = Endian.big]) → void -
Writes two bytes to this sink.
override
-
writeUint32(
int value, [Endian endian = Endian.big]) → void -
Writes four bytes to this sink.
override
-
writeUint64(
int value, [Endian endian = Endian.big]) → void -
Writes eight bytes to this sink.
override
-
writeUint8(
int value) → void -
Writes a byte to this sink.
override
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override
-
operator [](
int index) → int