Publish and resolve private Dart and Flutter packages
Pub serves versions, pubspecs, archive_url, and SHA-256 under api/packages. Publish to Hosted, then use Dart or Flutter to resolve packages from the same registry.
Create repositories
Run these Bash commands with an authenticated administrator arkactl profile and jq. Replace the example address with your HTTPS endpoint. Publish to Hosted. Group looks in Hosted first, then in Proxy. Grant the publishing account write access to Hosted and the consuming account read access to Group and the relevant members.
For each consuming or publishing identity, sign in with its profile and run arkactl --json tokens create --name pub-ci --expires-in-days 30 | jq -er .plaintext. Send the output directly to the CI secret store. Use a separate read and write token for the examples below.
export ARKA_URL=https://packages.example.org
hosted=$(arkactl --json repo create --name pub-hosted --type hosted --format pub | jq -er .id)
proxy=$(arkactl --json repo create --name pub-proxy --type proxy --format pub \
--upstream-url https://pub.dev | jq -er .id)
arkactl repo create --name pub-group --type group --format pub --member "$hosted,$proxy"
WRITE="$ARKA_URL/repository/pub-hosted"
READ="$ARKA_URL/repository/pub-group"Publish a package
Declare the destination in the library’s pubspec.yaml. Package names start with a letter and use lowercase letters, digits, or underscores. Use a SemVer version.
name: acme_widget
version: 1.2.3
environment:
sdk: '>=3.0.0 <4.0.0'
publish_to: https://packages.example.org/repository/pub-hostedOver production HTTPS, configure the write token with dart pub token add "$WRITE" --env-var ARKA_WRITE_TOKEN. Check the archive with dart pub publish --dry-run, then run dart pub publish. Arka supports api/packages/versions/new, multipart upload, and finalize. The test matrix prepares the package using the archive PUT below, then verifies Dart resolution and dependency execution.
tar -czf ../acme_widget-1.2.3.tar.gz pubspec.yaml lib/
curl -fsS -H "Authorization: Bearer $ARKA_WRITE_TOKEN" \
-T ../acme_widget-1.2.3.tar.gz "$WRITE/packages/acme_widget/versions/1.2.3.tar.gz"Configure the consuming project
dependencies:
acme_widget: 1.2.3export PUB_HOSTED_URL="$READ"
dart pub token add "$PUB_HOSTED_URL" --env-var ARKA_READ_TOKEN
PUB_CACHE="$(mktemp -d)" dart pub get
dart pub depsFlutter projects can run flutter pub get. Check the application’s pubspec.lock for version, hosted URL, and SHA-256. If only one dependency comes from the private registry, set the full Group URL in that dependency’s hosted property.
| Symptom | What to check |
|---|---|
| Client prompts for a token | Check the registered URL with dart pub token list. Verify HTTPS and confirm the variable named in --env-var is visible to the process. |
| Archive exists but resolution fails | Inspect api/packages/acme_widget for archive_url, archive_sha256, version, and SDK constraints. pubspec.yaml must be at the archive root. |
| pub get works but CI uses the wrong source | Check the lockfile, PUB_HOSTED_URL, and dependency-level hosted configuration. Verify with a fresh PUB_CACHE. |