一、package分类
1. flutter package 纯dart包 只写flutter代码,不涉及原生
2. flutter plugin 插件包 设计原生代码
本文只讨论dart包
二、创建dart包
flutter create ---template=package packageName(名称)
三、结构
lib/xiangjbtest.dart Dart实现代码
pubspec.yaml 配置文件
CHANGELOG.md. 修改记录
LICENSE 许可证文件
README.md 描述文件 用来介绍自己的package
四、发布前的配置
pubspec.yam
name: xiangjbtest #标题
description: 这是一个简介
version: 0.0.1 #版本
homepage: https://github.com/xxx/xxx.git #该package对应的git地址
LICENSE文件。随便在pub.dev库里找一个复制就行
MIT License
Copyright (c) 2019 Remi Rousselet
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
五、发布前的检查
flutter packages pub publish --dry-run
六、发布
flutter packages pub publish
"y" 继续
不出意外下面会有一个链接 复制去浏览器登录google账号验证一下即可
最后来一张成功的照片(我这个是因为之前上传过 所以没有链接直接就成功啦)
七、遇到的问题
1、
这个界面一直没反应了 是因为需要翻*墙 设置好之后在命令行执行(端口改成自己的)
export https_proxy=http://127.0.0.1:19180
export http_proxy=http://127.0.0.1:19180
set https_proxy=https://127.0.0.1:19180
set http_proxy=http://127.0.0.1:19180
2、判断有没有外网
这个样子是没有外网的
这个样子是有外网的
有其他问题欢迎留言讨论