1. Create a Package

flutter create –template=package popup_widget

2. The Package

Add functionality in the lib/ XXXX. dart file or in the lib directory of the Package project

For example, I wrote a popup control popup_widget below

3. Release the Package

3.1 Information Perfection

Pubspec yaml description

Changelog. md Version records

LICENSE Open Source LICENSE

Example Use case

3.2 verify packages

flutter packages pub publish –dry-run

3.3 release packages

flutter packages pub publish

Note: The first upload will require a Google account. At this point, the terminal will display a URL address, as shown in the image above: Copy the address, enter the browser URL, open the address, allow to log in to Google account. After confirming your login, the terminal will start connecting to Google and uploading our plug-in package. However, this step is not surprising because the wall will fail.

At this point we need to set up the HTTP proxy for the terminal

3.4 Configuring the Terminal Proxy

open ~/.zshrc

I’m using.zshrc, and some of you are using.bash_profile, and I’ll go ahead and add:

Export http_proxy = http://127.0.0.1:1087 export https_proxy = http://127.0.0.1:1087Copy the code

Then comment the previously added internal mirror of Flutter

#export PUB_HOSTED_URL=https://pub.flutter-io.cn
#export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
Copy the code

Start the

source ~/.zshrc

CD to the written plug-in repository root directory, execute once

flutter packages get

At this point, the lock file in your plugin will transfer the domestic image to the official source

4. Normal use

sudo flutter packages pub publish -v

or

flutter packages pub publish –server=pub.dartlang.org

4. Check the Package

Then you can go to the official search, Perfect!

4. Reference:

www.jianshu.com/p/6d479dcc9… Github.com/flutter/flu… www.jianshu.com/p/292b0c37e… Blog.csdn.net/talkxin/art…