What you’ll learn: How to create, structure, score with pana, and publish a Flutter/Dart package to pub.dev — step by step.
Table of Contents
Step 1
Create Your Package
Use the Flutter or Dart CLI to scaffold your package. Pick the right template depending on what you’re building.
Flutter Package (with widgets)
⚫ Dart-only Package (no Flutter dependency)
Flutter Plugin (with native platform code)
Naming tip: Always use snake_case for package names. Check availability on pub.dev before starting!
Step 2
Understand the Package Structure
A well-organised package is easier to maintain and scores higher on pub.dev. Here’s what your package folder should look like:
| File | Why it matters | Pub points impact |
|---|---|---|
README.md |
Shown as package homepage on pub.dev | High |
LICENSE |
Required for OSI-approved license check | High |
CHANGELOG.md |
Shows version history to users | Medium |
example/ |
Shows users how to use your package | Medium |
test/ |
Proves your package is reliable | Builds trust |
⚠️ Missing these = lost pub points. No LICENSE, README, or CHANGELOG will directly lower your pub.dev score. Don’t skip them!
Step 3
Write a Good pubspec.yaml
Every field in pubspec.yaml is read by pub.dev. Filling them properly directly affects your package’s discoverability and score.
ℹ️ Topics = discoverability. You can add up to 5 topics. Use popular ones like animation, networking, state-management to appear in relevant searches.
Step 4
Score with Pana Before Publishing
Pana (Package ANAlysis) is the official tool pub.dev uses to score every package. Run it locally to catch and fix issues before you publish.
Install & Run Pana
The 5 Scoring Categories (Max 160 pts)
| Category | What pana checks | Points |
|---|---|---|
| Dart file conventions | Formatting, file naming, pubspec fields | 30 |
| Documentation | README quality, API doc coverage (/// comments) | 20 |
| Platform support | Works on Android, iOS, Web, macOS, Linux, Windows | 20 |
| Static analysis | Zero errors, warnings, hints from dart analyze | 50 |
| Up-to-date deps | Dependencies on latest compatible versions | 40 |
| Total maximum score | 160 | |
Sample Pana Output
Pre-publish Checklist
Fix these before running the real publish:
- Add
///dartdoc comments to all public APIs - Run
dart analyze— zero warnings, zero hints - Add a
LICENSEfile (MIT, BSD-3, or Apache 2.0 recommended) - Write tests in
test/and confirmflutter testpasses - Fill
README.mdwith usage examples and screenshots - Update
CHANGELOG.mdwith your current version notes - Keep SDK constraints realistic — not too tight, not too loose
- Run
pana .and resolve all reported issues
⚠️ Aim for 100+ pub points before publishing. Packages below 50 points rarely appear in search results.
Step 5
Publish to pub.dev
Before the real upload, always do a dry run. It validates everything without actually publishing.
Dry Run First
The Real Publish
You’ll be prompted to confirm in the browser (Google sign-in). Once confirmed, your package is live within a few minutes.
Publishing is permanent. You cannot delete a published version. You can retract it, but the version number is reserved forever. Always double-check your version number!
After Publishing
- Your package appears on pub.dev within a few minutes
- Pana runs automatically — check your score under the Scores tab
- Follow semantic versioning: patch fixes →
0.1.1, new features →0.2.0, breaking changes →1.0.0 - Update
CHANGELOG.mdwith every new release
Automate with GitHub Actions: Use the dart-package-publisher action to auto-publish every time you push a new git tag.
You’re ready to publish!
That’s the full flow: create → structure → pubspec → pana → publish. The Dart community is waiting for your package.