pbconv 0.6.0 copy "pbconv: ^0.6.0" to clipboard
pbconv: ^0.6.0 copied to clipboard

A implement of Dart:convert for [Protobuf](https://developers.google.com/protocol-buffers/).

example/example.dart

import "dart:io";
import 'package:pbconv/pbconv.dart';

final List<Field> fields = [
  RequiredField(1, 'ID', Type.uint32),
  RequiredField(2, "Name", Type.string),
  OptionalField(3, "Email", Type.string, 'tom@example.com')
];

main() {
  File file = File("example.bin");
  if (file.existsSync()) {
    var bytes = file.readAsBytesSync();
    print(bytes);
    var message = protobuf.decode(ProtoBytes(fields, bytes));
    print(message.toString());
  } else {
    var message = EncoderMessage(fields);
    message[fields[0]] = 1;
    message[fields[1]] = 'Tom';
    var proto = protobuf.encode(message);
    print(proto.bytes);
    file.writeAsBytesSync(proto.bytes);
  }
}
0
likes
40
pub points
0%
popularity

Publisher

unverified uploader

A implement of Dart:convert for [Protobuf](https://developers.google.com/protocol-buffers/).

Repository (GitHub)
View/report issues

License

BSD-3-Clause (LICENSE)

More

Packages that depend on pbconv