首页 > 解决方案 > OSx 上的 gRPC、ProtoCol BUffer 和 Flutter

问题描述

我想在 OSx 上开发的 Flutter/Dart 应用程序和 GoLang 服务器之间使用 gRPC / ProtoBuffers。我的想法是替换 REST 连接。我的问题是我无法在 OSx 上为 DART 安装 Protobuf .... 或者至少,我似乎无法弄清楚。
这个 URL 最后说 Protobuf for DART 仅支持 Ubuntu。 https://chromium.googlesource.com/external/github.com/google/protobuf/+/HEAD/README.md

问题

  1. 对于 Dart Flutter 的 OSx 上的 Protobuf 还没有工作,这是正确的吗?
  2. 有什么提示或技巧可以让它发挥作用吗?我在这里错过了什么?

标签: dartflutterprotocol-buffersosx-yosemitegrpc

解决方案


首先,您应该通过 homebrew 安装 protobuf。 brew install protobuf 如果您没有brew命令,请参阅如何为 MacOsX 安装包管理器 HomeBrew。

其次,你应该安装 Dart,见这里https://www.dartlang.org/tools/sdk#install

三、安装插件 dart-protoc-plugin https://github.com/dart-lang/dart-protoc-plugin#how-to-build-and-use

四、查看本指南如何生成 .dart 类 https://developers.google.com/protocol-buffers/docs/darttutorial

第五,遵循 dart-grpc 的本指南 https://grpc.io/docs/tutorials/basic/dart.html


推荐阅读