buildFromObject static method

ByteBuffer buildFromObject(
  1. Object? value
)

Use this method in order to turn an object into a FlexBuffer directly.

Use the manual instantiation of the Builder and gradual addition of values, if performance is more important than convenience.

Implementation

static ByteBuffer buildFromObject(Object? value) {
  final builder = Builder();
  builder._add(value);
  final buffer = builder.finish();
  final byteData = ByteData(buffer.lengthInBytes);
  byteData.buffer.asUint8List().setAll(0, buffer);
  return byteData.buffer;
}