Lara
Lara

Reputation: 172

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

Upvotes: 0

Views: 1181

Answers (1)

jamesdlin
jamesdlin

Reputation: 89965

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.

Upvotes: 2

Related Questions