1. Package

  • Only the Dart code is included

1.1 create Package

  • To create the Dart package, end up using parameters--template=packageTo perform theflutter create
    % flutter create --template=package 'package_name'
    Copy the code
  • -i,-a: Specifies the language,The default iOS is OC.Android for Java
    % flutter create --template=plugin -i swift -a kotlin 'plugin_name'
    Copy the code

1.2. Content optimization of upload Package

1.2.1. Upload local image resources
  • It is best to use the system icon, no complex configuration, user-friendly to download package, reduce error
  • Upload the lib folder, so directlyPlace the image folder image in the lib folderCan be
1.2.2. Use image resources in package
  • Configure the full image path

  • WidgetIncreases when called inPackage attributesWhich tag comes frompackagepackage
    Image(
        image:AssetImage('images/imageName.png', package:'package_demo'),
    )
    Copy the code

1.3. Release Package(need ladder 🪜)

  • Publishing the Package requires thepubspec.yamlFile Configuration
    • Contains image resources to configurepubspec.yamlResource path in file, removeassetsThe annotation
1.3.1. Check packages
  • CD to the FLUTTER project folder
  • % flutter packages pub publish --dry-run
1.3.2. Release packages
  • % flutter packages pub publish
    • Publishing plug-ins and packages requires a Google account, as well as climbing the wall
    • Copy the link and paste it into Google to select your account to log in and complete the authorization
    • If wall scaling cannot be resolved, it may be related to mirroring. You are advised to configure mirroring. The following error message is displayed:
      • The solution is not to use the official publishing mode, but to specify the server, image publishing:
        % flutter packages pub publish --server=https://pub.dartlang.org
        Copy the code
      • Configuration is requiredLICENSECopyright certificate, configure it
1.3.3. Generate a LICENSE
  • GithubSelect new warehouse onlicenseoptions
  • Click on theLICENSEPaste content into the Flutter projectLICENSE fileIn the

1.4. create example for package

  • Dart create the flutter project,get the package uploaded, write the sample code and put all the data in main.dart file.
  • Copy the main.dart file of the created project into the example folder you created in the packaged package file
  • The package bagpackage_demo.dartYou may need to split functionality into multiple.Dart’spartIn the file:
    • The split DART file is passed at this pointpart of 'package_demo.dart'Specify belongs
    • Master filepackage_demo.dartaddPart 'Split file name. Dart'

2. Plugin

  • Contains not only the Dart code,It also includes apis for iOS and Android

2.1. Create a Plugin

  • To create a plug-in package, you can end up using parameters--template=pluginTo perform theflutter create
    % flutter create --template=plugin 'plugin_name'
    Copy the code
  • --org: Specify organization, reverse domain name notation,Dart packageThe package does not require an organization name,–orgThis only works if –template=plugin
    % flutter create --org com.example --template=plugin 'plugin_name'
    Copy the code

2.2. Write Plugin

  • It can be written in the iOS Runner project and replaced in the iOS code of the Plugin

2.3. Detect and publish in exactly the same way as commands and packages