1,我这边使用的是 https://github.com/yangyanzhan/protobuf
2,clone下来,
3,然后在protoc_plugin的目录下执行 brew install protobuf 如果 出现 Updating Homebrew... 直接control + C 跳过就行
4,然后在protoc_plugin的目录下执行 brew tap dart-lang/dart 和 brew install dart 如果 出现 Updating Homebrew... 直接control + C 跳过就行
5,配置环境: open ~/.zshrc
export PATH=$PATH:/Users/apple/Desktop/工作/protobuf/protobuf-master/protoc_plugin/bin
到bin目录
6,随便任何地方执行pub查看pub是否安装
7,配置proto文件:FeedBackResponse.proto 的内容
syntax = "proto3"; //proto解析转json用
message GetFeedbackResponse {
message ReasonIndex{
repeated uint32 reason_index = 1; // reason的index
}
uint32 star = 1; // 星级数量
repeated ReasonIndex reason = 2; // 每个星级
string tip = 3; // ***,
repeated string star_name = 4;
repeated string reason_name = 5; // 所有理由集合
}
8,随便任何地方执行 protoc --dart_out=/Users/apple/Desktop/工作/protobuf/proto_dart --proto_path=/Users/apple/Desktop /Users/apple/Desktop/FeedBackResponse.proto
第一个是配置输出的路径,第二个是配置proto文件的路径,第三个是配置proto文件的全路径
执行以后在输出路径就可以得到转化后的dart文件。