準(zhǔn)備
官方資料:https://dart.dev/tools/pub/publishing
Preparing to publish 之后有四點說明毯辅,必須需要一個google賬號用來登陸pub.dev和發(fā)布認(rèn)證温圆,verified publisher可以不創(chuàng)建。
開發(fā)插件
android studio new flutter plugin 項目犁珠,會自動創(chuàng)建一個可以發(fā)布的插件柳恐,我開發(fā)的是一個叫sprite_chart折線圖插件盼樟,功能開發(fā)完上傳到github
執(zhí)行
flutter packages pub publish --dry-run --server=https://pub.dartlang.org
會出現(xiàn)讓你在pubspec.yaml配置發(fā)布信息
name: sprite_chart
description: A new Flutter plugin.
version: 0.0.1
#author: 這個建議不用寫了
homepage: https://github.com/xiake-chen/sprite_chart.git//項目github地址
成功后提示
Package has 0 warnings.
發(fā)布
flutter packages pub publish --server=https://pub.dartlang.org
成功的樣子,第一次需要點擊這個鏈接,做一次google 賬戶登陸認(rèn)證旬痹。
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?access_type=offline&approval_prompt=force&response_type=code&client_id=818368855108-8grd2eg9tj9f38os6f1urbcvsq399u8n.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A60995&scope=openid+https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fuserinfo.email
Then click "Allow access".
Waiting for your authorization...
Authorization received, processing...
Successfully authorized.
Uploading...
Successfully uploaded package.
然后會在郵箱中收到一封發(fā)布成功的郵件
has published a new version (0.0.1) of the
sprite_chart package to the Dart package site (pub.dev).
For details, go to https://pub.dev/packages/sprite_chart/versions/0.0.1
If you have any concerns about this package, file an issue at
https://github.com/dart-lang/pub-dev/issues
Thanks for your contributions to the Dart community!
With appreciation, the Dart package site admin
遇到的問題
Waiting for your authorization...
Authorization received, processing...
。讨越。两残。
pub finished with exit code 69
之后會報賬戶認(rèn)證錯誤,發(fā)布之前驗證終端能不能墻把跨,
~%: curl google.com
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A >here</A>.
</BODY></HTML>
刪除 國內(nèi)代理配置
export PUB_HOSTED_URL=https://pub.flutter-io.cn
export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
命令行翻墻工具:mac端可使用proxifier + ss
proxifier配置教程:http://blackwolfsec.cc/2016/09/19/Proxifier_Shadowshocks/
我的是https