Buffer class

Buffer

Inheritance

Constructors

Buffer(int length)
Creates a fixed length list of 8-bit unsigned integers.
Buffer.flatten(List<Iterable<int>> buffers)
Creates a Buffer from a List of Buffers.
factory
Buffer.fromBool(bool value)
Creates a Buffer from an bool value.
factory
Buffer.fromDateTime(DateTime dateTime)
Creates a Buffer from a DateTime.
factory
Buffer.fromFloat32(double value)
Creates a Buffer from an f32 value.
factory
Buffer.fromFloat64(double value)
Creates a Buffer from a f64 value.
factory
Buffer.fromInt8(int value)
Creates a Buffer from an i8 value.
factory
Buffer.fromInt16(int value)
Creates a Buffer from an i16 value.
factory
Buffer.fromInt32(int value)
Creates a Buffer from an i32 value.
factory
Buffer.fromInt64(int value)
Creates a Buffer from an i64 value.
factory
Buffer.fromInt128(BigInt value)
Creates a Buffer from an i128 value.
factory
Buffer.fromList(Iterable<int> bytes, [int? length])
Creates a Buffer from a list of bytes.
factory
Buffer.fromString(String encoded, [BufferEncoding encoding = BufferEncoding.utf8])
Creates a Buffer from an encoded string.
factory
Buffer.fromUint8(int value)
Creates a Buffer from a u8 value.
factory
Buffer.fromUint8List(Uint8List data)
Creates a Buffer from a Uint8List.
Buffer.fromUint16(int value)
Creates a Buffer from a u16 value.
factory
Buffer.fromUint32(int value)
Creates a Buffer from a u32 value.
factory
Buffer.fromUint64(BigInt value)
Creates a Buffer from a u64 value.
factory
Buffer.fromUint128(BigInt value)
Creates a Buffer from a u128 value.
factory
Buffer.generate(int length, int generator(int index))
Creates a Buffer of size length, initialised to the values returned by calling generator for each index.
factory
Buffer.random(int length, [Random? random])
Creates a Buffer of size length, initialised with random values in the range of [0:maxUint8].
factory

Properties

first → int
The first element.
no setterinherited
hashCode → int
The hash code for this object.
no setterinherited
isEmpty → bool
Whether this collection has no elements.
no setterinherited
isNotEmpty → bool
Whether this collection has at least one element.
no setterinherited
iterator → Iterator<int>
Returns a new Iterator to walk through the items in the buffer.
no setteroverride
last → int
The last element.
no setterinherited
length → int
The number of items in the buffer.
no setteroverride
reader → BufferReader
Creates a new BufferReader to traverse this buffer.
no setter
reversed → Iterable<int>
Returns an Iterable to walk through the items in reverse order.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
single → int
Checks that this iterable has only one element, and returns that element.
no setterinherited
writer → BufferWriter
Creates a new BufferWriter of size length.
no setter

Methods

any(bool test(int element)) → bool
Checks whether any element of this iterable satisfies test.
inherited
asByteData([int offset = 0, int? length]) → ByteData
Creates a ByteData view over a region of the buffer.
asUint8List() → Uint8List
Creates a Uint8List view over the buffer.
cast<R>() → Iterable<R>
A view of this iterable as an iterable of R instances.
inherited
contains(Object? element) → bool
Whether the collection contains an element equal to element.
inherited
copy(Buffer dst, [int dstOffset = 0, int offset = 0, int? length]) → void
Copies items from this buffer to the destination (dst) buffer.
elementAt(int index) → int
Returns the indexth element.
inherited
every(bool test(int element)) → bool
Checks whether every element of this iterable satisfies test.
inherited
expand<T>(Iterable<T> toElements(int element)) → Iterable<T>
Expands each element of this Iterable into zero or more elements.
inherited
firstWhere(bool test(int element), {int orElse()?}) → int
The first element that satisfies the given predicate test.
inherited
fold<T>(T initialValue, T combine(T previousValue, int element)) → T
Reduces a collection to a single value by iteratively combining each element of the collection with an existing value
inherited
followedBy(Iterable<int> other) → Iterable<int>
Creates the lazy concatenation of this iterable and other.
inherited
forEach(void action(int steps)) → void
Invokes action on each element of this iterable in iteration order.
inherited
getAll(int offset) → Iterable<int>
Reads the buffer starting at offset into a byte array.
getBigInt(int offset, int length, [Endian endian = Endian.little]) → BigInt
Reads a region of the buffer as a signed big integer.
getBigUint(int offset, int length, [Endian endian = Endian.little]) → BigInt
Reads a region of the buffer as an unsigned big integer.
getBool(int offset) → bool
Reads 1-byte as a boolean.
getDateTime(int offset, [Endian endian = Endian.little]) → DateTime
Reads an i64 from the buffer as an epoch timestamp.
getFloat32(int offset, [Endian endian = Endian.little]) → double
Reads 4-bytes as a floating point value.
getFloat64(int offset, [Endian endian = Endian.little]) → double
Reads 8-bytes as a double precision floating point value.
getInt(int offset, int length, [Endian endian = Endian.little]) → int
Reads a region of the buffer as a signed integer.
getInt128(int offset, [Endian endian = Endian.little]) → BigInt
Reads 16-bytes as a signed integer.
getInt16(int offset, [Endian endian = Endian.little]) → int
Reads 2-bytes as a signed integer.
getInt32(int offset, [Endian endian = Endian.little]) → int
Reads 4-bytes as a signed integer.
getInt64(int offset, [Endian endian = Endian.little]) → int
Reads 8-bytes as a signed integer.
getInt8(int offset) → int
Reads 1-byte as a signed integer.
getString(BufferEncoding encoding, [int offset = 0, int? length]) → String
Reads a region of the buffer as an encoded string.
getUint(int offset, int length, [Endian endian = Endian.little]) → int
Reads a region of the buffer as an unsigned integer.
getUint128(int offset, [Endian endian = Endian.little]) → BigInt
Reads 16-bytes as an unsigned integer.
getUint16(int offset, [Endian endian = Endian.little]) → int
Reads 2-bytes as an unsigned integer.
getUint32(int offset, [Endian endian = Endian.little]) → int
Reads 4-bytes as an unsigned integer.
getUint64(int offset, [Endian endian = Endian.little]) → BigInt
Reads 8-bytes as an unsigned integer.
getUint8(int offset) → int
Reads 1-byte as an unsigned integer.
join([String separator = ""]) → String
Converts each element to a String and concatenates the strings.
inherited
lastWhere(bool test(int element), {int orElse()?}) → int
The last element that satisfies the given predicate test.
inherited
map<T>(T toElement(int e)) → Iterable<T>
The current elements of this iterable modified by toElement.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
reduce(int combine(int value, int element)) → int
Reduces a collection to a single value by iteratively combining elements of the collection using the provided function.
inherited
setAll(int offset, Iterable<int> bytes) → void
Writes a byte array to a region of the buffer starting at offset.
setBigInt(BigInt value, int offset, [int? length, Endian endian = Endian.little]) → int
Writes a big signed integer to a region of the buffer.
setBigUint(BigInt value, int offset, [int? length, Endian endian = Endian.little]) → int
Writes a big unsigned integer to a region of the buffer.
setBool(bool value, int offset) → int
Writes a boolean value to 1-byte.
setDateTime(DateTime value, int offset, [Endian endian = Endian.little]) → void
Writes a DateTime to the buffer as an i64.
setFloat32(double value, int offset, [Endian endian = Endian.little]) → void
Writes a floating point value to 4-bytes.
setFloat64(double value, int offset, [Endian endian = Endian.little]) → void
Writes a double precision floating point value to 8-bytes.
setInt(int value, int offset, int length, [Endian endian = Endian.little]) → int
Writes a signed integer to a region of the buffer.
setInt128(BigInt value, int offset, [Endian endian = Endian.little]) → void
Writes a signed integer to 16-bytes.
setInt16(int value, int offset, [Endian endian = Endian.little]) → void
Writes a signed integer to 2-bytes.
setInt32(int value, int offset, [Endian endian = Endian.little]) → void
Writes a signed integer to 4-bytes.
setInt64(int value, int offset, [Endian endian = Endian.little]) → void
Writes a signed integer to 8-bytes.
setInt8(int value, int offset) → void
Writes a signed integer to 1-byte.
setString(String value, BufferEncoding encoding, [int offset = 0, int? length]) → int
Writes an `encoded value to a region of the buffer.
setUint(int value, int offset, int length, [Endian endian = Endian.little]) → int
Writes an unsigned integer to a region of the buffer.
setUint128(BigInt value, int offset, [Endian endian = Endian.little]) → void
Writes an unsigned integer to 16-bytes.
setUint16(int value, int offset, [Endian endian = Endian.little]) → void
Writes an unsigned integer to 2-bytes.
setUint32(int value, int offset, [Endian endian = Endian.little]) → void
Writes an unsigned integer to 4-bytes.
setUint64(BigInt value, int offset, [Endian endian = Endian.little]) → void
Writes an unsigned integer to 8-bytes.
setUint8(int value, int offset) → void
Writes an unsigned integer to 1-byte.
singleWhere(bool test(int element), {int orElse()?}) → int
The single element that satisfies test.
inherited
skip(int count) → Iterable<int>
Creates an Iterable that provides all but the first count elements.
inherited
skipWhile(bool test(int element)) → Iterable<int>
Creates an Iterable that skips leading elements while test is satisfied.
inherited
slice([int offset = 0, int? length]) → Buffer
Creates a new Buffer from a region of this buffer.
take(int count) → Iterable<int>
Creates a lazy iterable of the count first elements of this iterable.
inherited
takeWhile(bool test(int element)) → Iterable<int>
Creates a lazy iterable of the leading elements satisfying test.
inherited
toList({bool growable = true}) → List<int>
Creates a List containing the elements of this Iterable.
inherited
toSet() → Set<int>
Creates a Set containing the same elements as this iterable.
inherited
toString() → String
Returns a string representation of (some of) the elements of this.
inherited
where(bool test(int element)) → Iterable<int>
Creates a new lazy Iterable with all elements that satisfy the predicate test.
inherited
whereType<T>() → Iterable<R>
Creates a new lazy Iterable with all elements that have type T.
inherited

Operators

operator +(Iterable<int> other) → Buffer
Creates a new Buffer by concatenating this and [other].
operator ==(Object other) → bool
The equality operator.
inherited
operator [](int index) → int
Returns the byte at index.
operator []=(int index, int value) → void
Sets the byte value at index.