当前位置:网站首页>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 同目录下
边栏推荐
- What is cross site scripting (XSS)?
- [go] how to control the maximum number of concurrent processes
- CPU的三种模式
- FreeBSD bNXT Ethernet driver source code reading record 2:
- FFT用于估计插值后的图像重采样因子
- poj1521
- Understand Linglong platform unified access service from simple to deep Monet
- 言语理解中心理解总结
- Analysis of zeromq
- AUTOCAD——计算面积的方法
猜你喜欢

【Verilog数字系统设计(夏宇闻)4-----Verilog语法的基本概念2】

MDK编译过程及ARM编译工具链

Iftnews | suppose this is what the metauniverse looks like 20 years later

Analysis of zeromq

Leetcode 537. 复数乘法(网友思路,自愧不如)

Leetcode537. 复数乘法(可以,已解决)

《分布式微服务电商》专题(一)-项目简介

2022 love analysis ― bank digitalization practice report

3、 Pinda general permission system__ pd-tools-swagger2

言语理解-片段阅读的结构剖析练习
随机推荐
[combinational logic circuit] - encoder
Leetcode537. Complex multiplication (yes, solved)
Integer data type in C language (do you really understand it)
学习笔记:原码, 反码, 补码
Ideal Path(UVA - 1599)
leetcode/只出现一次的数字
FFT is used to estimate the image resampling factor after interpolation
How to modify Oracle functions?
The detailed knowledge summary of MySQL can be collected
Google gson usage details
Mysql_ Note1
Nodejs builds cloud native microservice applications based on dapr, a quick start guide from 0 to 1
I just test it
The sales volume has won the championship repeatedly. Is the secret of Wuling's success only low price?
Dijkstra 求最短路
Zombie‘s Treasure Chest(枚举)
FFT用于估计插值后的图像重采样因子
The best way to practice Animation: cover transition
Is it safe to open an account for stock speculation through the online account manager?
网络之IP地址