What you’ll learn: How to create, structure, score with pana, and publish a Flutter/Dart package to pub.dev — step by step.

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)

</>
bash
# Creates a Flutter package (can include widgets)
flutter create --template=package my_awesome_packages

⚫ Dart-only Package (no Flutter dependency)

</>
bash
dart create --template=package-simple my_dart_package

Flutter Plugin (with native platform code)

</>
bash
flutter create --template=plugin \
  --platforms=android,ios \
  my_native_plugin

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 tree
my_awesome_package/
├── pubspec.yaml              # heart of your package
├── README.md                 # shown on pub.dev (important!)
├── CHANGELOG.md              # version history
├── LICENSE                   # required for pub points
├── lib/
│   ├── my_awesome_package.dart   # barrel export file
│   └── src/
│       └── my_widget.dart
├── test/
│   └── my_awesome_package_test.dart
└── example/
    └── lib/main.dart             # example app
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.

</>
yaml — pubspec.yaml
name: my_awesome_package
description: "A brief, clear description (60-180 chars). Be specific!"
version: 0.1.0
homepage: https://github.com/yourusername/my_awesome_package
repository: https://github.com/yourusername/my_awesome_package
issue_tracker: https://github.com/yourusername/my_awesome_package/issues

environment:
  sdk: ">=3.0.0 <4.0.0"
  flutter: ">=3.10.0"

dependencies:
  flutter:
    sdk: flutter

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^3.0.0

# Helps with pub.dev search ranking
topics:
  - ui
  - widgets
  - animation

# Shown on pub.dev gallery tab
screenshots:
  - description: Main widget preview
    path: screenshots/preview.png

ℹ️ 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

</>
bash
# Install pana globally
dart pub global activate pana

# Run in your package root directory
pana .

# Export a JSON report (useful for CI pipelines)
pana --json . > pana_report.json

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

</>
pana output
 Follow Dart file conventions            30/30
 Provide documentation                   20/20
 Platform support (android, ios, web)    20/20
 Pass static analysis                    50/50
~ Up-to-date dependencies                 35/40
  ⚠ some_dep 1.0.0 outdated, latest: 1.2.0

Total: 155/160 pub points

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 LICENSE file (MIT, BSD-3, or Apache 2.0 recommended)
  • Write tests in test/ and confirm flutter test passes
  • Fill README.md with usage examples and screenshots
  • Update CHANGELOG.md with 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

</>
bash
# Validates without uploading — always do this first
dart pub publish --dry-run

The Real Publish

</>
bash
# The real deal — this uploads to pub.dev
dart pub 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.md with 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.

Visit pub.dev →

You may also like

Leave a Reply