msgPackWrite function

Uint8List msgPackWrite(
  1. dynamic value, {
  2. Map<String, dynamic> toEncodable(
    1. dynamic
    )?,
  3. List<MsgPackExtension>? extensions,
})

Shortcut function to write a object to a Uint8List buffer

  • toEncodable: A custom function that converts the object to a Map<String, dynamic> representation
  • extensions: A optional list of extensions to use

Returns a Uint8List buffer with the object representation in bytes after successful serialization

Implementation

Uint8List msgPackWrite(dynamic value,
    {Map<String, dynamic> Function(dynamic)? toEncodable,
    List<MsgPackExtension>? extensions}) {
  final writer =
      MsgPackWriter(toEncodable: toEncodable, extensions: extensions);
  writer.write(value);
  return writer.takeBytes();
}