Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Pub: Expected a key while parsing a block mapping. path:

I'm using JSON file and register in Pubspec.ymal but showing error and also when I use an image and register it, the same error also occurs. Maybe there is a formatting mistake in it, but don't know what the problem is.this is the doc I followed.

Error on line 29, column 5 of pubspec.yaml: Expected a key while parsing a block mapping. assets: ^

This is my pubspec.yaml file

name: jsondata description: A new Flutter application.    dependencies:      flutter:    sdk: flutter    cupertino_icons: ^0.1.0    dev_dependencies:      flutter_test:        sdk: flutter      flutter:      uses-material-design: true        assets:         - loadjson/person.json 

enter image description here

like image 778
Farhana Naaz Ansari Avatar asked May 04 '18 09:05

Farhana Naaz Ansari


2 Answers

Spaces are significant in YAML

assets is indented too far

flutter_test:   sdk: flutter  flutter:   uses-material-design: true   assets:     - loadjson/person.json 
like image 83
Günter Zöchbauer Avatar answered Sep 20 '22 17:09

Günter Zöchbauer


It is because of the indentation of your code.The uses-material-design should be on the same line vertically as the assets:.

 uses-material-design: true   assets:    - images/picture.png 
like image 41
EngineerDanny Avatar answered Sep 17 '22 17:09

EngineerDanny