DEV Community

Muhammad Manan
Muhammad Manan

Posted on

Publish Flutter Package on pub.dev

Preparing to publish

When publishing a package, it’s important to follow the pubspec format and package layout conventions. Some of these are required in order for others to be able to use your package. Others are suggestions to help make it easier for users to understand and work with your package. In both cases, pub tries to help you by pointing out what changes will help make your package play nicer with the Dart ecosystem. There are a few additional requirements for uploading a package:

  • You must include a LICENSE file. We recommend the BSD 3-clause license, which the Dart and Flutter teams typically use. However, you can use any license that’s appropriate for your package. You must also have the legal right to redistribute anything that you upload as part of your package.
    Your package must be smaller than 100 MB after gzip compression. If it’s too large, consider splitting it into multiple packages, using a .pubignore file to remove unnecessary content, or cutting down on the number of included resources or examples.

  • Your package should depend only on hosted dependencies (from the default pub package server) and SDK dependencies (sdk: flutter). These restrictions ensure that dependencies of your packages cannot become unavailable in the future.
    You must have a Google Account, which pub uses to manage package upload permissions. Your Google Account can be associated with a Gmail address or with any other email address.

Important files

Pub uses the contents of a few files to create a page for your package at pub.dev/packages/. Here are the files that affect how your package’s page looks:

  1. README.md: The README.md file is the main content featured in your package’s page. The file’s contents are rendered as Markdown. For guidance on how to write a great README, see Writing package pages.

  2. CHANGELOG.md: Your package’s CHANGELOG.md file, if found, is also featured in a tab on your package’s page, so that developers can read it right from pub.dev. The file’s contents are rendered as Markdown.

  3. The pubspec: Your package’s pubspec.yaml file is used to fill out details about your package on the right side of your package’s page, like its description, homepage, etc.
    Publishing your package
    Use the dart pub publish command to publish your package for the first time, or to update it to a new version.

Performing a dry run

To test how dart pub publish will work, you can perform a dry run:

$ dart pub publish --dry-run
Enter fullscreen mode Exit fullscreen mode

Hurray!! NOW FINALLY you can publish now.

Publishing

When you’re ready to publish your package, remove the --dry-run argument:

$ dart pub publish
Enter fullscreen mode Exit fullscreen mode

You will receive and email of package published on pub.dev and u can now flex with your friends about the package u uploaded and saved developers life…

Keep sure to check out my packages and leave a suggestion:
https://pub.dev/packages/fancy_button_new
https://pub.dev/packages/fancy_field_new

Top comments (0)