Error on line 17, column 5 of pubspec.yaml: A dependency may only have one source

5,276

Solution 1

Indentation is significant in YAML

It should be instead

dpendencies:
  flutter:
    sdk: flutter
  http: ^0.12.0+^ # indentation like `flutter:` above, not like `sdk: ...`

Solution 2

Write http: ^0.12.0+1 below cupertino_icons: ^0.1.2 dependency and run command flutter packages get command.

Solution 3

You should put your http dependency outside.

dependencies:
  flutter:
    sdk: flutter
  http: ^0.12.0+1

or

dependencies:
  http: ^0.12.0+1
  flutter:
    sdk: flutter
Share:
5,276
Sai Sushmitha
Author by

Sai Sushmitha

Updated on December 09, 2022

Comments

  • Sai Sushmitha
    Sai Sushmitha over 1 year

    Added http package in the pubspec file and getting the error as :A dependency may only have one source, shown in the image below too.

    enter image description here

    Please help me how to resolve that issue.

    Thanks.

    • Günter Zöchbauer
      Günter Zöchbauer about 5 years
      Please post code as text not as screenshot.