protoc_plugin
25.1.0, released 2 months ago by google.dev
Generates Dart source files from Protocol Buffer (.proto) definitions using the protoc compiler.
What it does
The package provides a protoc plugin that reads .proto files and emits Dart code compatible with the protobuf runtime. It supports options for gRPC stubs and metadata generation.
AI-written summary of version 25.1.0, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need strongly‑typed Dart models from .proto schemas
- You are building gRPC services or clients in Dart
- You want a reproducible build step for protobuf files
Skip it when
- You only need JSON serialization without protobuf
- You cannot install the protoc compiler on the target platform
Strengths
- Produces clean, formatted Dart code
- Integrates with standard protobuf workflow
- Supports gRPC and Kythe metadata options
Weaknesses
- Requires external protoc installation
- Only works with protobuf package versions
Setup
- Kind
- Pure Dart
- Effort
- Medium
- Code generation
- No
- Direct dependencies
- 6
Install protoc (>=3.0.0), then run `dart pub global activate protoc_plugin` and ensure `~/.pub-cache/bin` is in PATH.
// After installing protoc and protoc_plugin
// Generate Dart code from a .proto file
// $ protoc --dart_out=. my_message.protoAlternatives
Packages that do the same job and could replace protoc_plugin.
- json_serializable
Automatically generate code for converting Dart classes to and from JSON.
94Compare - copy_with_extension_gen
Generate type‑safe copyWith extensions for annotated classes and record typedefs.
85Compare - data_class_plugin
A tool that uses Dart's Analyzer to generate data classes, unions, and enums.
71Compare - json2model
Generates Dart model classes from JSON strings via command line
69Compare
Works with
Packages commonly used together with protoc_plugin: ones it builds on, ones built on it, and its own family.
- pub_semverprotoc_plugin depends on itVersions and version constraints implementing pub's versioning policy.
- dart_styleprotoc_plugin depends on itProvides an API and CLI to format Dart source code automatically.
- fixnumprotoc_plugin depends on itProvides 32‑ and 64‑bit signed fixed‑width integer types for Dart.
- protobufprotoc_plugin depends on itProvides runtime support for Dart protocol buffer messages generated by protoc_plugin.