Builder class

Class that helps building flat buffers.

Constructors

Builder({int initialSize = 1024, bool internStrings = false, Allocator allocator = const DefaultAllocator(), bool deduplicateTables = true})
Creates a new FlatBuffers Builder.

Properties

buffer Uint8List
Returns the finished buffer. You must call finish before accessing this.
no setter
deduplicateTables bool
final
hashCode int
The hash code for this object.
no setterinherited
initialSize int
final
offset int
The number of bytes that have been written to the buffer so far. The most recently written byte is this many bytes from the end of the buffer.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addBool(int field, bool? value, [bool? def]) → void
Add the field with the given boolean value. The field is not added if the value is equal to def. Booleans are stored as 8-bit fields with 0 for false and 1 for true.
addFloat32(int field, double? value, [double? def]) → void
Add the field with the given 32-bit float value. The field is not added if the value is equal to def.
addFloat64(int field, double? value, [double? def]) → void
Add the field with the given 64-bit double value. The field is not added if the value is equal to def.
addInt16(int field, int? value, [int? def]) → void
Add the field with the given 32-bit signed integer value. The field is not added if the value is equal to def.
addInt32(int field, int? value, [int? def]) → void
Add the field with the given 32-bit signed integer value. The field is not added if the value is equal to def.
addInt64(int field, int? value, [double? def]) → void
Add the field with the given 64-bit unsigned integer value. The field is not added if the value is equal to def.
addInt8(int field, int? value, [int? def]) → void
Add the field with the given 8-bit signed integer value. The field is not added if the value is equal to def.
addOffset(int field, int? offset) → void
Add the field referencing an object with the given offset.
addStruct(int field, int offset) → void
addUint16(int field, int? value, [int? def]) → void
Add the field with the given 32-bit unsigned integer value. The field is not added if the value is equal to def.
addUint32(int field, int? value, [int? def]) → void
Add the field with the given 32-bit unsigned integer value. The field is not added if the value is equal to def.
addUint64(int field, int? value, [double? def]) → void
Add the field with the given 64-bit unsigned integer value. The field is not added if the value is equal to def.
addUint8(int field, int? value, [int? def]) → void
Add the field with the given 8-bit unsigned integer value. The field is not added if the value is equal to def.
endStructVector(int count) int
Finish a Struct vector. Most callers should preferto use writeListOfStructs.
endTable() int
End the current table and return its offset.
finish(int offset, [String? fileIdentifier]) → void
Finish off the creation of the buffer. The given offset is used as the root object offset, and usually references directly or indirectly every written object. If fileIdentifier is specified (and not null), it is interpreted as a 4-byte Latin-1 encoded string that should be placed at bytes 4-7 of the file.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pad(int howManyBytes) → void
Zero-pads the buffer, which may be required for some struct layouts.
putBool(bool value) → void
Writes a bool to the tail of the buffer after preparing space for it. Bools are represented as a Uint8, with the value set to '1' for true, and '0' for false
putFloat32(double value) → void
Writes a Float32 to the tail of the buffer after preparing space for it.
putFloat64(double value) → void
Writes a Float64 to the tail of the buffer after preparing space for it.
putInt16(int value) → void
Writes a Uint16 to the tail of the buffer after preparing space for it.
putInt32(int value) → void
Writes a Uint32 to the tail of the buffer after preparing space for it.
putInt64(int value) → void
Writes a Int64 to the tail of the buffer after preparing space for it.
putInt8(int value) → void
Writes a Uint8 to the tail of the buffer after preparing space for it.
putUint16(int value) → void
Writes a Uint16 to the tail of the buffer after preparing space for it.
putUint32(int value) → void
Writes a Uint32 to the tail of the buffer after preparing space for it.
putUint64(int value) → void
Writes a Uint64 to the tail of the buffer after preparing space for it.
putUint8(int value) → void
Writes a Uint8 to the tail of the buffer after preparing space for it.
reset() → void
Reset the builder and make it ready for filling a new buffer.
size() int
Calculate the finished buffer size (aligned).
startTable(int numFields) → void
Start a new table. Must be finished with endTable invocation.
toString() String
A string representation of this object.
inherited
writeList(List<int> values) int
Write the given list of values.
writeListBool(List<bool> values) int
Write the given list of bools as unsigend 8-bit integer values.
writeListFloat32(List<double> values) int
Write the given list of 32-bit float values.
writeListFloat64(List<double> values) int
Write the given list of 64-bit float values.
writeListInt16(List<int> values) int
Write the given list of signed 16-bit integer values.
writeListInt32(List<int> values) int
Write the given list of signed 32-bit integer values.
writeListInt64(List<int> values) int
Write the given list of signed 64-bit integer values.
writeListInt8(List<int> values) int
Write the given list of signed 8-bit integer values.
writeListOfStructs(List<ObjectBuilder> structBuilders) int
Writes a list of Structs to the buffer, returning the offset
writeListUint16(List<int> values) int
Write the given list of unsigned 16-bit integer values.
writeListUint32(List<int> values) int
Write the given list of unsigned 32-bit integer values.
writeListUint64(List<int> values) int
Write the given list of signed 64-bit integer values.
writeListUint8(List<int> values) int
Write the given list of unsigned 8-bit integer values.
writeString(String value, {bool asciiOptimization = false}) int
Write the given string value and return its offset.

Operators

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