Dart package dependency to subdirectory of git repo


I have a couple of small dart demo projects together in one git repository. Thus each project is in a subfolder of the repository and the yaml files of each of these projects is in the corresponding folder, not under the root of the repo. Is there a way to specify a git dependency to such a subfolder within a git repo? I know that I can clone the repository manually and use a file path in the dependency specification. But what I’m looking for is a way to have a direct git url for that package in a subdir. Is this possible?


Several years on, support for this has been added:


You can now split the git dependency into a url and path:

      url: git://github.com/dart-lang/protobuf.git
      path: protobuf

Further reading: https://dart.dev/tools/pub/dependencies#git-packages

Answered By – Danny Tuppeny

Answer Checked By – Willingham (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *