Skip to content
pubscout

proto_generator

10.1.0, released 6 weeks ago by squarealfa.com

Code generation of .proto and Dart mapper classes for using PODOs with gRPC.

$ flutter pub add proto_generator
Source repository

What it does

Generates Protocol Buffer .proto files and Dart mapper classes from plain old Dart objects annotated with @proto and @ProtoField. It facilitates seamless serialization between your custom Dart models and gRPC messages, including support for polymorphism and well-known types.

AI-written summary of version 10.1.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You are building a Dart/Flutter application that communicates with gRPC backends
  • You want to avoid manually writing boilerplate mapping code between Dart models and gRPC protobuf messages

Skip it when

  • You are not using gRPC or protocol buffers in your project
  • You prefer writing manual serialization mappers instead of relying on build_runner

Strengths

  • Significantly reduces boilerplate for gRPC model mapping
  • Supports polymorphism and class inheritance mapping
  • Compatible with primary constructors and Google Well Known Types

Weaknesses

  • Requires maintaining external tools like protoc compiler and build_runner
  • Additional setup steps required outside of standard pub dependency management

Setup

Kind
Pure Dart
Effort
Medium
Code generation
Yes (build_runner)
Direct dependencies
9

Requires adding proto_annotations and proto_generator, installing the Dart protoc plugin, running build_runner, and compiling proto files manually using protoc.

import 'package:proto_annotations/proto_annotations.dart';

part 'ingredient.proto.dart';

@proto
class Ingredient {
  const Ingredient({
    required this.description,
    required this.quantity,
  });

  @ProtoField(2)
  final String description;

  @ProtoField(3)
  final double quantity;
}

Works with

Packages commonly used together with proto_generator: ones it builds on, ones built on it, and its own family.