先在命令行cd package/path
检查
flutter packages pub publish --dry-run
没有错误就可以发布了
发布
flutter packages pub publish --server=https://pub.dartlang.org
该命令会验证代码无误,再去获取谷歌登录授权,如果授权过,会直接去发布.
发布的时候是需要fq的,开启全局模式,但是命令行默认是没有fq的.
可以使用以下命令测试一下:
curl -I https://google.com
如果返回了包含200的XML表示可以了,如果不行就需要命令行fq.
我碰到了这样的报错:
Uploading...
It looks like pub.dev is having some trouble.
Pub will wait for a while before trying to connect again.
OS Error: Connection refused, errno = 61, address = 127.0.0.1, port = 52187
pub finished with exit code 69
命令行
我的命令行是zsh,添加两个快捷命令,命令行填写
echo "alias pon='export http_proxy=127.0.0.1:1087;export https_proxy=$http_proxy'\nalias poff='unset http_proxy;unset https_proxy'" >> ~/.zshrc
把这两个别名放入了~/.zshrc
,这样每次命令行启动都会启用别名.
ip和端口填写自己的配置
关闭命令行,重新启动,或者输入'source ~/.zshrc'也行,然后运行
pon
curl -I https://google.com
如果返回包含200的XML,就表示可以正常发布了.
成功:
Uploading...
Successfully uploaded package.
在https://pub.dev/可以搜索到自己发布的package.