项目场景:
因为项目开发中用到支付宝授权功能,需要集成支付宝SDK,由于产品经理考虑支付SDK会影响store上架(你懂的嘿嘿),所以我们使用的是只有授权的SDK并做成插件上传到了pub.dev
废话不多说直入主题。
1、创建package工程
new Flutter Project >Project type选择Plugin
img.png
2、完成你的插件
写好插件功能
在example工程下编写示例代码
修改 CHANGELOG.md
3. 添加License(我这里用的是Dart推荐的BSD-3-Clause)
Copyright 2022, the Dart project authors. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are
met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above
copyright notice, this list of conditions and the following
disclaimer in the documentation and/or other materials provided
with the distribution.
* Neither the name of Google Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4. 修改pubspec.yaml文件
name: alipay_auth
description: 项目描述.
version: 0.0.1
author: cwdsgi@gmail.com
homepage: https://github.com/yiqimanbu/flutter_alipay_auth
5、开启梯子(翻墙),并设置终端代理
export https_proxy=http://127.0.0.1:1087
export http_proxy=http://127.0.0.1:1087
注意!windows电脑使用下面的命令
set https_proxy=https://127.0.0.1:1087
set http_proxy=http://127.0.0.1:1087
6、检查下包有木得问题,一般是没有许可证书,readme中存在todo字眼等问题
flutter packages pub publish --dry-run
7、开始发布
flutter packages pub publish --server=https://pub.dartlang.org
7.1、输入后会提示是否继续:
img_4.png
7.2、 提示 Google 验证:
复制到浏览器并登录验证
img_5.png
8、成功
Waiting for your authorization...
Authorization received, processing...
Successfully authorized.
Uploading...
Successfully uploaded package.