Reputation: 549
I am following this flutter tutorial, adding the follwing dependency:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.3
+ english_words: ^4.0.0
Interestingly, if I remove the little '+' and try to download the english_words package I get
Error on line 32, column 4: Expected a key while parsing a block mapping.
╷
32 │ english_words: ^4.0.0
│ ^
╵
With the '+' it works perfectly. In the pubspec documentation I could only find an explananation for a '+' symbol as part of the verison range, but not at the start of the line. Does anybody have an explanation?
Upvotes: 0
Views: 127
Reputation: 1154
Plus sign does not have to do anything with it. spaces are significant when working with external packages and you should put them in pubspec.yaml file exactly as they appear. I'm guessing that you deleted the sign and your package looked something like this:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.3
english_words: ^4.0.0
this is wrong because all of the dependencies under flutter should be exactly with the same spacing and beneath each other. so the right way to use them is this:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.3
english_words: ^4.0.0
I just added one space before english words package and now everything works just fine.
Upvotes: 0
Reputation: 1506
In the tutorial the writer meant "add" this line with the + symbol. It does not have anything to do with the flutter pubspec.yaml file. You are getting this error because you need a tab space infront of the dependency. Add a tab space in front of english_words: ^4.0.0 like so:
dependencies:
english_words: ^4.0.0
For example, here the writer means "add" certain lines with a + infront of it and "remove" certain lines with a - infront of it:
Upvotes: 3