如何在國內發佈Flutter Plugin

因爲Flutter正式版的發佈,Flutter在國內也變得火熱起來。忽然心血來潮的想寫個Plugin,跟個風蹭一蹭Flutter的熱度,可是奈何國內的一些環境,一直卡在發佈這一步。幾經周折,最後終於發佈成功了!
過程以下:git

1.補全配置


首先配置 pubspec.yaml,能夠根據須要,將pubspec補全:github

description: Flutter Easemob  SDK
version: 0.0.1
author: kayshen <kayshen_xu@163.com>
homepage: https://github.com/Kayshenxu/hyphenate_plugin
複製代碼

注* 發佈到 Pub上在根目錄須要包含一個LICENSEweb

2.檢查錯誤


運行 flutter packages pub publish --dry-run 根據提示修改至終端顯示Package has 0 warnings.瀏覽器

3.發佈Plugin


首先須要根據本身的代理工具給終端設置代理:bash

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".
複製代碼

注* ui

  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
相關文章
相關標籤/搜索