美文网首页Flutter圈子FlutterFlutter中文社区
[Flutter]在Flutter中使用protobuf

[Flutter]在Flutter中使用protobuf

作者: Brant白叔 | 来源:发表于2019-03-23 22:51 被阅读4次

不说废话,直接贴步骤

安装protoc

brew install protobuf

安装dart

brew tap dart-lang/dart
brew install dart

dart 安装好后,就有pub命令了。

安装protoc_plugin

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

在Flutter项目中引入protobuf库

在pubspec.ymal中添加以下依赖

protobuf: ^0.13.4

相关文章

网友评论

    本文标题:[Flutter]在Flutter中使用protobuf

    本文链接:https://www.haomeiwen.com/subject/dagevqtx.html