msg_pck

Last updated:

0 purchases

msg_pck Image
msg_pck Images
Add to Cart

Description:

msg pck

Using with objects #
class MyClass with MessagePackObject {
late int id;
late String name;
late DateTime time;

@override
List get messagePackFields => [id, name, time];

MyClass();

MyClass.fromMessagePack(List<dynamic> items) {
id = items[0];
name = items[1];
time = items[2];
}
}
copied to clipboard
To serialize an object to Message Pack format:
MyClass mc = MyClass()
..id = 1
..name = "aeb"
..time = DateTime.now();
Uint8List data = mc.toMessagePack();
copied to clipboard
To deserialize an object from Message Pack format:
Uint8List data = ... data from somewhere;
MyClass mc = fromMessagePack(data, MyClass.fromMessagePack);
copied to clipboard
Manually writing #
MessagePackWriter writer = MessagePackWriter();
writer.writeString("Hello");
Uint8List data = writer.takeBytes();
copied to clipboard
Manually reading #
Uint8List data = ... data from somewhere;
MessagePackReader reader = MessagePackReader.fromTypedData(data); // there are other alternatives
String sValue = reader.readString();
int iValue = reader.readInt();
copied to clipboard

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.