what does the leading '+' in the pubspec.yaml file mean?

Issue

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?

Solution

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:

picture

Answered By – rya

Answer Checked By – Candace Johnson (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.