Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use my dart packages private and not show on pub dart lang?

I have dart packages that I don't want to publish to pub because of my company agreement. How to use my dart packages for only my company and not show on pub dart lang?

I've looked up on this link https://github.com/dart-lang/pub/issues/1050 but still need more information about that.

like image 272
nhuluseda Avatar asked Jan 11 '19 09:01

nhuluseda


People also ask

How do you make a private package on Flutter?

To create a flutter package, open your IDE and create a new flutter project. The only difference is to select Project Type as Package this time. In your package pubspec. yaml file, add publish_to: none to prevent publishing.

What is the Pubspec lock?

lock file lets you test your package against the latest compatible versions of its dependencies. For application packages, we recommend that you commit the pubspec. lock file.

Where are Dart packages stored?

By default, the system package cache is located in the . pub-cache subdirectory of your home directory (on macOS and Linux), or in %LOCALAPPDATA%\Pub\Cache (on Windows; the location might vary depending on the Windows version).


2 Answers

Günter Zöchbauer answer is correct but he hasn't provided it with examples.

So to use pub/package/lib without publishing on pub.dev :

1. Local - Save in some local folder

dependencies:
  library_name:
   path: /path/to/library_name

2. Hosted - Pushed on Github, Gitlab etc.

dependencies:
  library_name:
   git: https://github.com/username/library_name

Or to target exact branch

dependencies:
  library_name:
   git:
    url: https://github.com/username/library_name.git
    ref: dev    #branch name

Or to target exact commit

dependencies:
  library_name:
   git:
    url: https://github.com/username/library_name.git
    ref: e234072340    #commit reference id

Where 'library_name' has to be the same as the 'name' declared in pubspec.yaml of that pub.

like image 199
Rahul Dange Avatar answered Jan 31 '23 18:01

Rahul Dange


If you publish a package to https://pub.dartlang.org it will show up. There is no way around that.

Alternatives.

You can use

  • path dependencies to packages stored on a local or network drive for example.
  • Git dependencies to packages stored in a Git repository
    • on a local or network drive
    • hosted on GitHub, GitLab, or any other Git server
  • run your own private Pub server.

See also

  • https://www.dartlang.org/tools/pub/dependencies
  • https://github.com/dart-lang/pub_server
like image 25
Günter Zöchbauer Avatar answered Jan 31 '23 16:01

Günter Zöchbauer