不说废话,直接贴步骤
brew install protobufbrew tap dart-lang/dart
brew install dartdart 安装好后,就有pub命令了。
pub global activate protoc_plugin将protoc-gen-dart添加到path
在用户根目录:.bash_profile添加
export "$PATH:$PWD/.pub-cache/bin"安装好后,就有protoc-gen-dart 命令了。
.proto文件编译成dart文件protoc --dart_out=. test.proto如果没有添加path
protoc --dart_out=. test.proto --plugin ~/.pub-cache/bin/protoc-gen-dart在pubspec.ymal中添加以下依赖
protobuf: ^0.13.4