Dart Repository

Cloudsmith provides public & private repositories for Dart packages

Dart SDK Versions

From February 28th 2025, Cloudsmith will only support Dart SDK version 2.15.1 or greater. After this date support for SDK versions <=2.14, and associated workflows, will no longer be supported.

Dart is a client-optimized programming language developed by Google.

For more information on Dart, please see:

  • Dart.dev: The official website for Dart
  • Pub.dev: The official public repository for Dart packages

Contextual Documentation

The examples in this document are generic. Cloudsmith provides contextual setup instructions within each repository, complete with copy and paste snippets (with your namespace/repo/rsa-key pre-configured).

In the following examples:

IdentifierDescription
OWNERYour Cloudsmith account name or organization name (namespace)
REPOSITORYYour Cloudsmith Repository name (also called "slug")
TOKENYour Cloudsmith Entitlement Token (see Entitlements for more details)
USERNAMEYour Cloudsmith username
PASSWORDYour Cloudsmith password
API-KEYYour Cloudsmith API Key
PACKAGE_NAMEThe name of your package
PACKAGE_VERSIONThe version number of your package
DEPENDENCY_NAMEA name for a dependency in a pubspec file

Upload a Package

Publish via Dart

Note

Please note that Dart SDK >= 2.15 is required to use Dart Repositories.

The endpoint for the native Dart API is:

https://dart.cloudsmith.io/OWNER/REPOSITORY/

Your project pubspec.yaml defines the location that artifacts should be published to. Add the following to the root of this file:

yaml
publish_to: https://dart.cloudsmith.io/OWNER/REPOSITORY/

In order to authenticate for native publishing, you'll need run dart pub token, as follows:

shell
echo 'API-KEY' | dart pub token add https://dart.cloudsmith.io/OWNER/REPOSITORY/
Enter secret token:
Requests to "https://dart.cloudsmith.io/OWNER/REPOSITORY/" will now be authenticated using the secret token.

You can then publish from your project directory using dart pub publish:

dart pub publish
Uploading...
Upload complete. Package will available following synchronization.

Limitation

When publishing via the native API package sizes are limited to 200.0 MB per file. If this is an issue, please use the Cloudsmith CLI or API (which support up to 5GB for single-part uploads and beyond for multi-part), or contact us if that's not an option.

Upload via the Cloudsmith CLI

Note

Please see Dart's documentation on creating packages for more information on building your own packages.

Creating Dart Packages

To upload via the Cloudsmith API/CLI, you'll need to generate a package first.

You can build a package with standard command-line tooling like tar. To illustrate the process we'll use cli_util as an example:

First, check out the version of cli_util we want to pack (v0.1.3 for example purposes):

shell
git clone https://github.com/dart-lang/cli_util@v0.1.3
cd cli_util
shell
tar --exclude='.dart_tool' -czvf cli_util_0.1.3.tar.gz ./*

For full details of how to install and setup the Cloudsmith CLI, see Command Line Interface.

The command to upload a Dart package via the Cloudsmith CLI is:

shell
cloudsmith push dart OWNER/REPOSITORY PACKAGE_NAME-PACKAGE_VERSION.tgz

Example:

shell
cloudsmith push dart org/repo your-package-1.0.0.tgz

Upload via Cloudsmith Website

Please see Upload a Package for details of how to upload via the Cloudsmith web app.


Download / Install a Package

Public Repositories

No further setup is required with public repositories, you can add a dependency from this repository to your package pubspec.yaml automatically with dart pub. See Installing a Package

Private Repositories

In order to authenticate, you need to run dart pub token, as follows:

shell
echo 'TOKEN' | dart pub token add https://dart.cloudsmith.io/OWNER/REPOSITORY/
Enter secret token:
Requests to "https://dart.cloudsmith.io/OWNER/REPOSITORY/" will now be authenticated using the secret token.
yaml
echo 'PASSWORD' | dart pub token add https://dart.cloudsmith.io/OWNER/REPOSITORY/
Enter secret token:
Requests to "https://dart.cloudsmith.io/OWNER/REPOSITORY/" will now be authenticated using the secret token.
yaml
echo 'API-KEY' | dart pub token add https://dart.cloudsmith.io/OWNER/REPOSITORY/
Enter secret token:
Requests to "https://dart.cloudsmith.io/OWNER/REPOSITORY/" will now be authenticated using the secret token.
yaml
echo 'TOKEN' | dart pub token add https://dart.cloudsmith.io/OWNER/REPOSITORY/
Enter secret token:
Requests to "https://dart.cloudsmith.io/OWNER/REPOSITORY/" will now be authenticated using the secret token.

Installing a package

dart pub is capable of adding a dependency from this repository to your package pubspec.yaml automatically:

Public Or Private Repositories

shell
dart pub add PACKAGE_NAME:PACKAGE_VERSION --hosted-url https://dart.cloudsmith.io/OWNER/REPOSITORY/
Resolving dependencies...
+ your-package 1.2.3
Downloading your-package 1.2.3...
Changed 1 dependency!

Please also see the pubspec docs for further examples of pubspec files.

Security Scanning

Supported

Please see our Security Scanning documentation for further information.

Upstream Proxying / Caching

Configurable Proxying Caching
You can configure upstream Dart repositories that you wish to use for packages that are not available in your Cloudsmith repository. Catching Dart packages is not supported.

Please see our Upstream Proxying documentation for further instructions.

Key Signing Support

Not Supported by Format

Troubleshooting

Please see the Troubleshooting page for further help and information.