toFlexBuffer function

Uint8List? toFlexBuffer(
  1. dynamic value
)

Serializes any FlexBuffer-compatible value to bytes.

Supported types: null, bool, int, double, String, List<dynamic>, Map<String, dynamic>, and nested combinations of these.

Returns null if the input value is null.

Implementation

@pragma('vm:prefer-inline')
Uint8List? toFlexBuffer(dynamic value) {
  if (value == null) return null;
  final buffer = flex.Builder.buildFromObject(value);
  return buffer.asUint8List();
}