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 f
Spaces are significant in YAML
assets
is indented too far
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- loadjson/person.json
**Error on line 46, column 4: Expected a key while parsing a block mapping. assets:
flutter: uses-material-design: true assets: - assets/dhaka.jpg**
Make sure when you uncomment the line please check indentation. if indentation is wrong it's going error. flowing this image. Happy coding !!!
Error on line 29, column 4: Expected a key while parsing a block mapping. assets:
flutter: uses-material-design: true assets: - assets/images/image.jpg
In my case i just added #
in front of uses-material-design: true
Try below code
flutter:
# uses-material-design: true
assets:
- assets/images/image.jpg
its working fine.
With removed comments, original, generated by default pubspec.yaml looks like this
flutter:
uses-material-design: true
assets:
- images/abc.jpg
But it isn't vaild. It doesn't works. It should be:
flutter:
uses-material-design: true
assets:
- images/abc.jpg
Important: Spaces are significant in YAML
As @Baftek
mentioned , just indent before uses-material-design:true and press Ctrl+Alt+l
(Intellij or Android Studio) to reformat file.
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