jaguar_serializer_protobuf 2.2.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 39

Pub Build Status Gitter

jaguar_serializer_protobuf #

Protobuf support for jaguar_serializer

Getting Started #

Install #


Usage #

Import jaguar_serializer_protobuf

import 'package:jaguar_serializer/jaguar_serializer_protobuf.dart';

Generate your Dart model from your proto definition with proto compiler.

protoc --dart_out=. ./person.proto -I=.

Once your models are generated, you can use them like this:

final serializerRepo = ProtoSerializerRepo()
    ..add((data)=>Person.fromBuffer(data), toJson: (data)=>Person.fromJson(data));

You can then serialize like this:

Person person = Person(); = 1; = 'name'; = '';
List<int> data =  

And deserialize like this:

Person person2 = serializerRepo.from<Person>(data)

You can also enable JSON support if you need to debug your network layer. To do so use the isJsonFormatEnabled param of the repo:

final serializerJsonRepo = ProtoSerializerRepo(isJsonFormatEnabled: true)
    ..add((data)=>Person.fromBuffer(data), toJson: (data)=>Person.fromJson(data));
Person personJson = serializerJsonRepo.from<Person>('{"1": "name", "2": 1, "3": ""}');

Changelog #

2.2.1 #

  • Implemented ProtoCodecRepo
  • Implemented ProtoSerializerRepo


import 'package:collection/collection.dart';
import 'package:jaguar_serializer_protobuf/proto_repo.dart';

import 'test.pb.dart';

main() {
  Person data = Person(); = 1; = 'name'; = '';

  final List<int> buffer = data.writeToBuffer();

  final serializer = ProtoSerializerRepo()
    ..add((data) => Person.fromBuffer(data));

  dynamic person = serializer.from<Person>(buffer);
  final List<int> personData =;

  final serializerJson = ProtoSerializerRepo(isJsonFormatEnabled: true)
    ..add((data) => Person.fromBuffer(data),
        toJson: (data) => Person.fromJson(data));
  dynamic personJson = serializerJson
      .from<Person>('{"1": "name", "2": 1, "3": ""}');

  assert(const ListEquality().equals(personData, buffer));
  assert( == 'name');
  assert( == 'name');

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  jaguar_serializer_protobuf: ^2.2.2

2. Install it

You can install packages from the command line:

with pub:

$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:jaguar_serializer_protobuf/proto_repo.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 1, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Health issues and suggestions

Fix lib/proto_repo.dart. (-43.75 points)

Analysis of lib/proto_repo.dart failed with 2 errors:

line 9 col 7: Superinterfaces don't have a valid override for 'getByType': SerializerRepo.getByType (getByType), ProtoSerializerRepo.getByType (getByType).

line 94 col 16: 'ProtoSerializerRepo.getByType' ('dynamic Function(dynamic) Function(Type)') isn't a valid override of 'SerializerRepo.getByType' ('Serializer

Maintenance issues and suggestions

No valid SDK. (-20 points)

The analysis could not detect a valid SDK that can use this package.

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (protobuf).

Package is getting outdated. (-22.47 points)

The package was last published 63 weeks ago.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
jaguar_serializer ^2.2.6 2.2.12
protobuf ^0.10.5 0.10.8 1.0.1
Transitive dependencies
fixnum 0.10.11