0

How do I use a nested package on GitHub?

I have forked a repository that has subfolder packages with the main package and other packages it depends on.

When I try to use this nested package like this

audioplayers:
  git:
    url: https://github.com/JonasJW/audioplayers/tree/main/packages/audioplayers.git
    ref: main

I get the error

Git error. Command: `git clone --mirror https://github.com/JonasJW/audioplayers/tree/main/packages.git /Users/jonas/Documents/flutter/.pub-cache/git/cache/packages-c53372e52e6b77435233d1879066ce0db95c1888`
stdout: 
stderr: Cloning into bare repository '/Users/jonas/Documents/flutter/.pub-cache/git/cache/packages-c53372e52e6b77435233d1879066ce0db95c1888'...
fatal: repository 'https://github.com/JonasJW/audioplayers/tree/main/packages.git/' not found
exit code: 128

Any ideas how to handle this?

Jonas
  • 7,089
  • 15
  • 49
  • 110
  • 1
    Use `path` to the subfolder. I think similar question has been answered in https://stackoverflow.com/a/53760890/13617136 – iqfareez Jan 10 '23 at 21:25

1 Answers1

2

You have to use path Parameter to define path of your package root folder

Update dependency in your pubspec.yaml like this:

dependencies:
   audioplayers:
     git:
       url: https://github.com/JonasJW/audioplayers.git
       ref: main
       path: packages/audioplayers

Hope it will help you!

Milan Surelia
  • 884
  • 1
  • 8
  • 18