How to Publish a Dart Package
Publish a Dart or Flutter package to your organization’s dart registry using the dart pub publish command.
Prerequisites
- An organization on pckgs.io. See Create an Organization.
- A pckgs.io access token with write access to your organization. See Create an Access Token.
- Authentication configured. See Dart Package Registry Authentication.
Configure pubspec.yaml
Add the pckgs.io hosted URL as the publish_to field in your pubspec.yaml:
name: my_package
version: 1.0.0
publish_to: https://dart.pckgs.io/<YOUR_ORG_NAME>
environment:
sdk: ">=3.0.0 <4.0.0" Publish the Package
Run the following command from your package root:
dart pub publish pub validates your pubspec.yaml, packages your source into a tarball, and uploads it to pckgs.io using your stored access token. It prints a summary of what will be published and asks you to confirm before the upload completes.
Skip the Confirmation Prompt
For CI pipelines or scripts, skip the interactive confirmation with --force:
dart pub publish --force Preview Before Publishing
To check for validation issues without actually uploading anything, run a dry run first:
dart pub publish --dry-run Publishing a New Version
pub doesn’t allow re-publishing an existing version. Bump the version field in pubspec.yaml before running dart pub publish again.
Related
- Dart Package Registry
- How to Install a Dart Package
- Dart Package Registry Authentication
- How to Import a Dart Package
Need help? Contact us here or at [email protected].