1. Createpackages

flutter create --template=package flutter_easy_use_tools

2. Implement functions

The SRC folder is created in lib. Files in the SRC file are not open to the public. Flutter_easy_use_tools.

library flutter_easy_use_tools;

export 'src/extension/string_extension.dart';
export 'src/utils/num_util.dart';
export 'src/utils/string_util.dart';
export 'src/widgets/custom_inner_shadow.dart';
Copy the code

3. Checkpubspec.yaml
name: flutter_easy_use_tools
description: A new Flutter project.
version: 0.0.1
homepage: https://github.com/yuanzhiying/flutter_easy_use_tools
Copy the code
4. Verifypackages

$ flutter packages pub publish --dry-run

$ flutter packages pub publish --dry-run
Publishing flutter_easy_use_tools 0.0.1 to https://pub.flutter-io.cn:
|-- .gitignore
|-- .metadata
|-- CHANGELOG.md
|-- LICENSE
|-- README.md
|-- lib
|   |-- extension
|   |   '-- string_extension.dart
|   |-- flutter_easy_use_tools.dart
|   '-- widgets
|       '-- custom_inner_shadow.dart
|-- pubspec.yaml
'-- test
    '-- flutter_easy_use_tools_test.dart

Package has 0 warnings.

Copy the code

5. Releasepackages

To execute flutter Packages pub publish, click on the linked browser to open the license. You need to log into your Google account.

Test to see if you can access Google: $curl www.google.com

$ flutter packages pub publishPublishing Flutter_easy_use_tools 0.0.1 to https://pub.flutter-io.cn: |-- .gitignore |-- .metadata |-- CHANGELOG.md |-- LICENSE |-- README.md |-- lib | |-- extension | | '-- string_extension.dart | |-- flutter_easy_use_tools.dart | '-- widgets | '-- custom_inner_shadow.dart |-- pubspec.yaml '-- test '-- flutter_easy_use_tools_test.dart Publishing is forever; packages cannot be unpublished. Policy details are available at https://pub.dev/policy Do you want to publish Flutter_easy_use_tools 0.0.1 (y/N)? Y Pub needs your authorization to upload packages on your behalf. go to https://accounts.google.com/o/oauth2/auth?access_type=offline&approval_prompt=force&response_type=code&client_id=8183688 55108-8grd2eg9tj9f38os6f1urbcvsq399u8n.apps.googleusercontent.com&redirect_uri=http%3A%2F%2Flocalhost%3A58974&code_chall enge=Nc8EH9vceyITk7SeK9H9iEXvcPTlLxzBLhFWE9zwnm0&code_challenge_method=S256&scope=openid+https%3A%2F%2Fwww.googleapis.co m%2Fauth%2Fuserinfo.email Then click "Allow access". Waiting for your authorization...Copy the code

Successful release:

$ flutter packages pub publishPublishing flutter_easy_use_tools 0.0.1 to https://pub.dartlang.org: |-- .gitignore |-- .metadata |-- CHANGELOG.md |-- LICENSE |-- README.md |-- lib | |-- extension | | '-- string_extension.dart | |-- flutter_easy_use_tools.dart | '-- widgets | '-- custom_inner_shadow.dart |-- pubspec.yaml '-- test '-- flutter_easY_use_tools_test. dart Downloading VECtor_math 2.1.0... Publishing is forever; packages cannot be unpublished. Policy details are available at https://pub.dev/policy Do you want to publish Flutter_easy_use_tools 0.0.1 (Y /N)? Y Uploading... Successfully uploaded package.Copy the code

If a proxy is used, run the terminal proxy command on the client as follows: export HTTP_PROXY=http://127.0.0.1:1081; Export HTTPS_PROXY = http://127.0.0.1:1081; Export ALL_PROXY = socks5: / / 127.0.0.1:1080

After the command is executed, run the issue command.

6. Check your postspackages

Using your Google account, log on to the website pub.dev/

View your own published plug-ins:

Search for self-published plug-ins:

7. Update the plug-in

After writing the new plug-in code:

① Change version: 0.0.1 in pubspec.yaml to version: 0.0.2.

② Changelog. md Adds the update log, and the latest version is displayed at the top.

③ Modify the readme. md file.

4) Submit git code and add tag. $flutter packages pub publish re-published.

8. Add for the plug-inexample

In the Packages directory, create the Example project. Add a plugin to example

dependencies:
  flutter:
    sdk: flutter

  flutter_easy_use_tools:
    path: ../
Copy the code

Example uses:

import 'package:flutter_easy_use_tools/flutter_easy_use_tools.dart';
Copy the code

View on the Packages page:

9. Plug-in problems are improved

In the background of my plugin, I can see the imperfections and irregularities of the plugin, which can be improved to improve the score.

The code formatting command is executed: flutter format.

$ flutter format .
Formatting directory .:
Unchanged example/lib/main.dart
Unchanged example/test/widget_test.dart
Unchanged lib/flutter_easy_use_tools.dart
Formatted lib/src/extension/string_extension.dart
Formatted lib/src/utils/num_util.dart
Formatted lib/src/utils/string_util.dart
Formatted lib/src/widgets/custom_inner_shadow.dart
Unchanged test/flutter_easy_use_tools_test.dart
Copy the code

10. Avoid passingpackage:flutter_easy_use_tools/src/...To use the plug-in.

It should be used from the external file provided by the plug-in: import ‘package:flutter_easy_use_tools/flutter_easy_use_tools.dart’;

For 11.packagesCreate a document

You can use DartDoc to generate API documentation for the Library. Dartdoc parses source files to find document comments annotated with /// syntax. Go to the Packages root and execute the dartdoc command.

$ dartdoc
Documenting flutter_easy_use_tools...

dartdoc failed: Top level package requires Flutter but FLUTTER_ROOT environment variable not set.
Copy the code

The execution failed. Procedure Check FLUTTER_ROOT,

$ echo $FLUTTER_ROOT
Copy the code

Add FLUTTER_ROOT

Add FLUTTER_ROOT, run, and view.

$ source~ /.. bash_profile

$ echo $FLUTTER_ROOT
/Users/yuanzhiying/fvm/versions/stable
Copy the code
$ dartdoc
Documenting flutter_easy_use_tools...
Initialized dartdoc with 393 libraries in 48.6 seconds
Generating docs for library flutter_easy_use_tools from package:flutter_easy_use_tools/flutter_easy_use_tools.dart...
  warning: flutter_easy_use_tools has no library level documentation comments, from flutter_easy_use_tools: (file:///Users/yuanzhiying/github/flutter_easy_use_tools/lib/flutter_easy_use_tools.dart:1:9)
Validating docs...
Found 1 warning and 0 errors.
Documented 1 public library in 2.6 seconds
Success! Docs generated into /Users/yuanzhiying/github/flutter_easy_use_tools/doc/api
Copy the code