serialize function
Serializes value into the MessagePack binary format.
The resulting Uint8List contains the encoded representation of the provided object.
Supported types include:
null,bool,int,doubleString(UTF-8 encoded)Uint8List,ByteData(binary data)List,Map,Iterable(collections)DateTime(using the MessagePack timestamp extension)- Float (for explicit 32-bit floating point numbers)
encodeExt can be provided to handle custom extension types.
initialBufferSize determines the starting capacity of the internal
encoder buffer (default is 1024 bytes).
Throws a MessagePackException if serialization fails.
Note: For repetitive serialization of similar custom types, consider using the MessagePack class which implements advanced caching for faster lookups.
Implementation
@pragma('vm:prefer-inline')
Uint8List serialize(
Object? value, {
EncodeExt? encodeExt,
int initialBufferSize = 1024,
}) => Packer.encode(
value,
encodeExt: encodeExt,
initialBufferSize: initialBufferSize,
);