Dart pub

What Dart pub is
Dart pub is Dart’s package manager for finding and managing shared libraries and tools. It resolves package versions that work with each other and with the installed Dart SDK, then records selected versions in a lockfile to help application teams keep dependencies consistent. Packages can come from pub.dev, other hosted repositories, Git repositories, local paths, or supported SDKs. Pub works through the dart or Flutter command-line tools, and most Dart-savvy IDEs support package workflows. Developers can publish packages to pub.dev; before publishing, pub checks for potential secret leaks using limited patterns and may warn or refuse publication. Published packages cannot have Git or local path dependencies in their pubspec. Security advisories draw on the GitHub Advisory Database for Dart and Flutter packages. Pub can often resolve dependencies offline from its shared cache. It is free and open source, supports Windows, Linux, and macOS, and is focused on Dart packages.
Who it suits
Pub suits Dart developers who need to manage shared libraries and tools, whether using command-line tools or a Dart-savvy IDE. It also supports teams that want dependency versions recorded in a lockfile.
What it does well
- Resolves versions against the installed Dart SDK.
- Supports lockfiles and workspaces.
- Can resolve cached dependencies offline.
- Available through Dart and Flutter command-line tools.
- Free and open source.
What to know first
- Focused on Dart packages.
- Published packages cannot use Git dependencies.
- Published packages cannot use local path dependencies.
- Secret checks use limited patterns.
Limits
Packages published to pub.dev cannot include Git or local path dependencies in their pubspec. The publishing guide recommends keeping package size below 100 MB compressed and 256 MB uncompressed; published packages generally cannot be unpublished.
Getting started
- Open the Dart or Flutter command-line tools, or a Dart-savvy IDE.
- Add dependencies from pub.dev, another hosted repository, Git, a local path, or a supported SDK.
- Resolve dependencies and use the generated pubspec.lock to keep selected versions consistent.
- For production installs, use dart pub get --enforce-lockfile to require the locked versions and content hashes.
- Use dart pub publish to upload a package to pub.dev.
Verdict
Pub covers dependency resolution, publishing, and offline use for Dart projects. Its publishing rules and limited-pattern secret checks are worth noting before releasing packages.
Questions
How much does Dart pub cost?
Dart pub is free, with a free plan.
Which operating systems does it support?
It supports Windows, Linux, and macOS.
Can I publish packages with it?
Yes. The `dart pub publish` command uploads packages to pub.dev. Published packages cannot have Git or local path dependencies in their pubspec.
Can pub resolve dependencies offline?
It can often resolve dependencies offline using packages already in its shared system cache.
Is Dart pub open source?
Yes. Its license model is open source.
Can published packages be unpublished?
Published packages generally cannot be unpublished, though publishers can upload new versions and mark packages as discontinued.
Facts from Dart pub's own pages
- Automated publishing
- After publishing a package’s first version, publishers can configure automated publishing through GitHub Actions or Google Cloud service accounts. · dart.dev, 7 Oct 2026
- Command line
- Pub can be used from the command line with the `dart pub` tool. · dart.dev, 7 Oct 2026
- Command line and IDEs
- Pub can be used through the dart or Flutter command-line tools, and most Dart-savvy IDEs support package workflows. · dart.dev, 28 Sept 2026
- Dependency management
- Pub resolves package versions that work together and with the installed Dart SDK. · dart.dev, 28 Sept 2026
- Dependency resolution
- Pub manages dependency versions to find versions compatible with each other and with the Dart SDK version. · dart.dev, 7 Oct 2026
- Free plan
- Yes · dart.dev, 21 Sept 2026
- IDE support
- The page says most Dart-savvy IDEs support creating, downloading, updating, and publishing packages. · dart.dev, 7 Oct 2026
- Lockfiles
- Pub creates a `pubspec.lock` file listing the specific versions of a package’s direct and transitive dependencies. · dart.dev, 7 Oct 2026
- Lockfile support
- Yes · dart.dev, 21 Sept 2026
- Offline installation
- Yes · dart.dev, 21 Sept 2026
- Offline use
- Pub can often resolve dependencies offline from packages already stored in its shared system cache. · dart.dev, 28 Sept 2026
- Package formats
- Dart packages · dart.dev, 21 Sept 2026
- Package integrity
- Pub uses SHA256 content hashes maintained by pub.dev to validate package integrity. · dart.dev, 7 Oct 2026
- Package sources
- Packages can come from pub.dev, the local file system, or other locations such as Git repositories. · dart.dev, 7 Oct 2026
- Private registry auth
- Yes · dart.dev, 21 Sept 2026
- Production installs
- The `dart pub get --enforce-lockfile` command fails if dependency constraints cannot be satisfied with the exact locked versions and content hashes. · dart.dev, 7 Oct 2026
- Publication permanence
- Published packages generally cannot be unpublished, though publishers can upload new versions and mark packages as discontinued. · dart.dev, 7 Oct 2026
- Publisher verification
- pub.dev verifies verified-publisher identities through domain ownership checks using Google Search Console logic. · dart.dev, 28 Sept 2026
- Publishing
- The `dart pub publish` command validates a package and uploads it to pub.dev. · dart.dev, 7 Oct 2026
- Publishing limit
- Packages published to pub.dev cannot have Git or local path dependencies in their pubspec. · dart.dev, 28 Sept 2026
- Publishing limits
- The publishing guide recommends package sizes below 100 MB compressed and 256 MB uncompressed. · dart.dev, 7 Oct 2026
- Purpose
- Pub is Dart’s package manager for managing package dependencies. · dart.dev, 7 Oct 2026
- SDK platforms
- The Dart SDK system requirements list Windows, Linux, and macOS. · dart.dev, 7 Oct 2026
- Secret detection
- Before publishing, pub checks for potential secret leaks using limited patterns and warns or refuses publication when it detects a possible leak. · dart.dev, 28 Sept 2026
Where Dart pub stands on Freedom251
- Package Managers#35 of 93
- Code Transpilers#13 of 28
