简体   繁体   中英

Flutter pubspec.yaml - Adding forked dependency from branch - A dependency may only have one source

I had to modify an existing pub package which has multiple branches besides the main one. I needed the branch 3x_null_safety So I forked the repo, modified the code and pushed it to my github.

dependencies:
  geoflutterfire:
    git:
      url: https://github.com/[myUsername]/GeoFlutterFire
    ref: 3x_null_safety

Also tried this:

dependencies:
  geoflutterfire:
    git: git://github.com/[myUsername]/GeoFlutterFire.git
    ref: 3x_null_safety

In both cases I'm getting this error:

pubspec.yaml: A dependency may only have one source

Indentation is important.

As shown in the pubspec.yaml examples for Git repositories , you should use:

dependencies:
  geoflutterfire:
    git:
      url: https://github.com/[myUsername]/GeoFlutterFire
      ref: 3x_null_safety

That is, ref should be a field of git , not of geoflutterfire . By using the wrong indentation, ref: was treated as a source in addition to the git one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM