当前位置:网站首页>proto转换Dart | 项目使用Protobuf | flutter 使用grpc
proto转换Dart | 项目使用Protobuf | flutter 使用grpc
2022-07-26 01:42:00 【疯狐狸12138】
配置环境
安装protobuf
a. 命令行安装
brew install protobufb. 直接gitHub下载
https://github.com/protocolbuffers/protobuf到probuf目录下,终端命令 - 设置编译目录
./configure --prefix=/usr/local/protobuf
protoc --version 可查看安装的protobuf版本
- 配置环境变量
a. 打开.bash_profile
b. 添加如下配置open ~/.bash_profile
#Dart环境变量
export PATH=/Users/crazyfox/Desktop/Resources/flutter/bin/cache/dart-sdk/bin:$PATH
export PATH=/Users/crazyfox/Desktop/Resources/flutter/bin/cache/dart-sdk:$PATH
#D先配置后面需要
export PATH="$PATH":"$HOME/.pub-cache/bin"
- 安装protoc_plugin
随便创建个新的项目或者是在自己原本项目处理也是可以的。
在项目里面处理
在pubspec.yaml里面添加 grpc用的时候再添加也可以,
grpc: ^3.0.0
protobuf: ^2.1.0
protoc_plugin: ^20.0.1
fixnum: ^1.0.1
为了处理protoc_plugin global 事件
flutter pub global activate protoc_plugin
或pub global activate protoc_plugin
- 使用
protoc --dart_out=grpc:src/generated -Iprotos protos/xxx.proto
其中:
src/generated:表示lib下存放生成文件的路径
Iprotos:I+编辑的.proto文件文件夹路径
protos/helloworld.proto:表示lib下存放编写.proto文件的路径
也可以直接处理
protoc --dart_out=. test.proto
直接生成和test.proto 同目录下
边栏推荐
- CPU的三种模式
- Fastjason handles generics
- Is it safe to buy funds in stock accounts? Professional answers
- NodeJS 基于 Dapr 构建云原生微服务应用,从 0 到 1 快速上手指南
- The detailed knowledge summary of MySQL can be collected
- Record a failure caused by a custom redis distributed lock
- poj1521
- U++ learning notes ustruct, uenum declaration and function library simple function implementation
- Ideal Path(UVA - 1599)
- [go] III. The simplest restful API server
猜你喜欢

Kubernetes pod start process
SQL injection tutorial: learn through examples

Silicon Valley classroom - official account cloud on demand Silicon Valley classroom microservice project practical notes

Prime Ring Problem

Record a failure caused by a custom redis distributed lock

SVN版本控制分支、合并功能使用

推荐⼀款超好⽤的UI⾃动化⼯具: UiAutomator2!

U++ learning notes ustruct, uenum declaration and function library simple function implementation

zeromq浅析

元素和小于等于阈值的正方形的最大边长(来源:力扣(LeetCode))
随机推荐
Nodejs builds cloud native microservice applications based on dapr, a quick start guide from 0 to 1
Format JS code and debug JS code
How to obtain the cash flow data of advertising services to help analyze the advertising effect?
Silicon Valley classroom - official account cloud on demand Silicon Valley classroom microservice project practical notes
Ideal Path(UVA - 1599)
Maximum side length of elements and squares less than or equal to the threshold (source: leetcode)
Overview of database stress testing methods
Leetcode 537. 复数乘法(网友思路,自愧不如)
Is it safe to buy funds on e fund? Professional answers
“蔚来杯“2022牛客暑期多校训练营2 H.[Take the Elevator] 维护线段
QTreeWidget虚线设置
Kubernetes pod start process
Speech comprehension - structural analysis exercise of fragment reading
Quickly create a topic folder
元素和小于等于阈值的正方形的最大边长(来源:力扣(LeetCode))
销量连连夺冠,五菱的成功秘诀只有低价吗?
[data mining] differences, advantages and disadvantages between generative model and discriminant model
言语理解中心理解总结
The e-commerce project is written in the resume. How to answer it during the interview
I just test it