Home > Blockchain >  How to add a nested package from GitHub as a dependency tp pubspec?
How to add a nested package from GitHub as a dependency tp pubspec?

Time:01-11

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?

CodePudding user response:

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!

  • Related