Hello Guys. Many times we Face Flutter Pub: Expected a key while parsing a block mapping. path:. So in this tutorial, we are going to Solve this error.
How Flutter Pub: Expected a key while parsing a block mapping. path: Error Occurs ?
So Error That I have faced is as below.
Error on line 30, column 6 of pubspec.yaml: Expected a key while parsing a block mapping. assets: ^
Here is my pubspec.yaml File:
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^0.1.0
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- loadjson/person.json
How to Solve Flutter Pub: Expected a key while parsing a block mapping. path?
- How to Solve Flutter Pub: Expected a key while parsing a block mapping. path?
to Solve Flutter Pub: Expected a key while parsing a block mapping. path It is because of the indentation of your code. Spaces are significant in YAML. so you have to manage all lines in indentation. in my case assets is indented too far. that's why I am facing that error. So its all About Spaces are significant in YAML so you cant add extra space in yaml file else it will cause error Flutter Pub: Expected a key while parsing a block mapping. path:
- Flutter Pub: Expected a key while parsing a block mapping path?
to Solve Flutter Pub: Expected a key while parsing a block mapping. path It is because of the indentation of your code. Spaces are significant in YAML. so you have to manage all lines in indentation. in my case assets is indented too far. that's why I am facing that error. So its all About Spaces are significant in YAML so you cant add extra space in yaml file else it will cause error Flutter Pub: Expected a key while parsing a block mapping. path:
Solution 1: Set proper Indentation in your pubspec.yaml
It is because of the indentation of your code.
Spaces are significant in YAML. so you have to manage all lines in indentation.
in my case assets
is indented too far. that’s why I am facing that error.
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- loadjson/person.json
So its all About Spaces are significant in YAML so you cant add extra space in yaml file else it will cause error Flutter Pub: Expected a key while parsing a block mapping. path:
Summery
Now, Error is solved. If you still facing this error so Comment below your error with code. I Will help You. Comment below Your thoughts and your queries. And Also Comment on your suggestion here.
Also Check Out Below Tutorials
- Drop down button in flutter not switching values to the selected value
- Version code 1 has already been used. Try another version code flutter
- Flutter Text Underline
- The iOS deployment target ‘IPHONEOS_DEPLOYMENT_TARGET’ is set to 8.0, in Flutter How can I change the minimum IOS Deploying Target
- Textfield validation in Flutter
Leave a Reply