[英]how to add a picture path on pubspec.yaml file on flutter
I have modified my pubspec.yaml
file by adding the folder path of the picture that I want to add but I an error:我通过添加要添加的图片的文件夹路径修改了我的
pubspec.yaml
文件,但出现错误:
Running "flutter pub get" in drawer2...
Error on line 44, column 5 of pubspec.yaml: Expected a key while parsing a block mapping.
╷
44 │ assets :
│ ^
╵
Oops; flutter has exited unexpectedly.
Sending crash report to Google.
Crash report sent (report ID: 7f0c2ad768060692)
Crash report written to C:\Users\Mohamed bh\Desktop\files\flutter operations\drawer2\flutter_06.log;
please let us know at https://github.com/flutter/flutter/issues.
//My pubspec.yaml code //我的pubspec.yaml代码
flutter:扑:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets :
- assets/
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
Running "flutter pub get" in drawer2...
Error on line 44, column 5 of pubspec.yaml: Expected a key while parsing a block mapping.
╷
44 │ assets :
│ ^
╵
Oops; flutter has exited unexpectedly.
Sending crash report to Google.
Crash report sent (report ID: 7f0c2ad768060692)
Crash report written to C:\Users\Mohamed bh\Desktop\files\flutter operations\drawer2\flutter_06.log;
please let us know at https://github.com/flutter/flutter/issues.
You should respect the indentation, it won't work if you add or remove even one space, this is how you should do it:您应该尊重缩进,即使添加或删除一个空格也不会起作用,这是您应该这样做的方式:
flutter:
assets:
- assets/my_icon.png
- assets/background.png
The best way is to copy/past it from the official documentation .最好的方法是从官方文档中复制/过去。
If the above solutions did not work如果上述解决方案不起作用
Try to restart your IDE(Andriod studio/VSCode), its work for me尝试重新启动您的 IDE(Andriod studio/VSCode),它对我有用
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.