flutter 图片资源找不到No file or variants found for asset:
先说下加载图片的流程
1.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
assets: // 对齐上面的依赖内容
- images/apple.png// 该路径是相对pubspec.yaml的文件路径
/ - -images/apple.png// 该路径是相对pubspec.yaml的文件路径,相当于在pubspec.yaml目录级别下建立images文件夹。如果图片比较多,可以只配置图片的路径:如
flutter:
uses-material-design: true
assets:
//代表配置图片目录的路径
- images/
2.复制文件到文件夹

3.使用
Image.asset("images/apron.png",
width: 100,
height: 100)
网友评论