To add to the list of alternates:
As of dart 2.15, authenticated private repositories are now supported.
You can publish a package to a private repository using the standard dart CLI tools.
Dart allows you to add and manage authentication tokens to via dart pub token add
and dart pub token list
.
Some private repositories require that you use third party tools to do the publishing.
With a repo like OnePub (https://onepub.dev) you publish as follows:
dart pub global activate onepub
onepub login // onepub adds the onepub token to the dart pub token list
cd my_package
onepub pub private // onepub adds publish_to to your pubspec.yaml
dart pub publish
You could have manually added the publish_to key to your pubspec.yaml which is of the form:
name: my_package
publish_to: https://onepub.dev/api/jbbxpsdavu/
Obviously the url will be dependant on the private repo you are using.
To use the published package in another project use:
cd <my app>
onepub pub add my_package
This results in onepub adding a private dependency of the form: (which you could have done manually)
dependencies:
my_package:
hosted:
url: https://onepub.dev/api/jbbxpsdavu/
name: my_package
version: ^0.3.2
A big advantage of this method over a git reference is that running:
dart pub upgrade
will upgrade you to the latest version of the my_package where as with a git tag dart pub upgrade
will do nothing.
This method also makes it easier for your team to add private dependencies as they only need to know the package name (i.e. they don't need to know the url nor the git tag/ref to add a dependency).
Here is a more detailed explanation of the process. It is specific to OnePub but the broad principles apply to any private repo and the exceptions have been noted above.
https://onepub.dev/show/86646173-a968-4281-af39-3c37d349bcdc
Disclaimer: I'm associated with OnePub.