如何在国内发布Flutter Plugin

由于Flutter正式版的发布,Flutter在国内也变得火热起来。突然心血来潮的想写个Plugin,跟个风蹭一蹭Flutter的热度,但是奈何国内的一些环境,一直卡在发布这一步。几经周折,最后终于发布成功了!
过程如下:

1.补全配置


首先配置 pubspec.yaml,可以根据需要,将pubspec补全:

description: Flutter Easemob  SDK
version: 0.0.1
author: kayshen <[email protected]>
homepage: https://github.com/Kayshenxu/hyphenate_plugin
复制代码

注* 发布到 Pub上在根目录需要包含一个LICENSE

2.检查错误


运行 flutter packages pub publish --dry-run 根据提示修改至终端显示Package has 0 warnings.

3.发布Plugin


首先需要根据自己的代理工具给终端设置代理:

export http_proxy=http://127.0.0.1:1087;
export https_proxy=http://127.0.0.1:1087;
复制代码

然后运行flutter packages pub publish
第一次发布会出现以下授权界面,复制链接到浏览器授权即可:

Looks great! Are you ready to upload your package (y/n)? y
Pub needs your authorization to upload packages on your behalf.
In a web browser, go to https://accounts.google.com/o/oauth2/auth?*******userinfo.email
Then click "Allow access".
复制代码

注*

  1. 使用ss给终端设置代理时一定不要用sock5协议,不然就会出现Invalid request method
  2. 如果按照官网推荐设置了:
    export PUB_HOSTED_URL=https://pub.flutter-io.cn
    export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
    复制代码
    一定要在上传前注释掉,不然会出现pub finished with exit code 1

猜你喜欢

转载自juejin.im/post/5c26d97de51d452f2c2f0fae