一:主要配置

1. pubspec.yaml

name: 包名
description: 自用插件包
version: 0.0.1
authors: 你的名字
homepage: https://github.com/NeverOvO

2.CHANGELOG.md

## 0.0.1

版本更新内容

* TODO: Describe initial release.

3. LICENSE

  • 1:先在Github上创建你的项目的仓库
  • 2:创建时选择LICENSE-BSD 3-Clause "New" or "Revised" License
  • 3:复制其中内容到本地

例:

BSD 3-Clause License

Copyright (c) 2021, Haibo Lai
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this
   list of conditions and the following disclaimer.

2. 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.

3. Neither the name of the copyright holder 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 HOLDER 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.

二:上传

1:执行

flutter packages pub publish --server=https://pub.dartlang.org

2:第一次上传,会要求登录谷歌账号。在命令行中会有一个URL,点击认证即可

3:如果出现以下提示,输入Y

Package has 1 warning.. Do you want to publish neveruseless 0.0.1 (y/N)? y

4:Successfully uploaded package. 即成功,等待一段时间后可以在托管中看到

三:补充

1.创建Example项目

1.在lib同级目录下,新建文件夹,命名为 Example

2. cd ./Example

3. flutter create .