msg_pck 0.1.0 copy "msg_pck: ^0.1.0" to clipboard
msg_pck: ^0.1.0 copied to clipboard

Message pack serializer/deserializer for dart similar to its csharp API

Using with objects #

class MyClass with Message {
  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];
  }
}

To serialize an object to Message Pack format:

MyClass mc = MyClass()
  ..id = 1
  ..name = "aeb"
  ..time = DateTime.now();
Uint8List data = mc.toMessagePack();

To deserialize an object from Message Pack format:

Uint8List data = ... data from somewhere;
MyClass mc = fromMessagePack(data, MyClass.fromMessagePack);

Manually writing #

MessagePackWriter writer = MessagePackWriter();
writer.writeString("Hello");
Uint8List data = writer.takeBytes();

Manually reading #

Uint8List data = ... data from somewhere;
MessagePackReader reader = MessagePackReader.fromTypedData(data); // there are other alternatives
String sValue = reader.readString();
int iValue = reader.readInt();
1
likes
0
points
83
downloads

Publisher

verified publisheraeb-dev.me

Weekly Downloads

Message pack serializer/deserializer for dart similar to its csharp API

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

meta

More

Packages that depend on msg_pck