flutter Unable to load asset: assets/images/lake.jpg

flutter 中加载本地资源图片 碰到Unable to load asset: assets/images/lake.jpg 错误

1.在根目录下创建assets文件夹

2.在assets下创建images文件夹,将lake.jpg图片放入

3.在pubspec.yml 中配置

assets:
  - assets/images/lake.jpg

,如图

flutter Unable to load asset: assets/images/lake.jpg_第1张图片

4.使用方式

new Image.asset(
              'assets/images/lake.jpg',
              height: 240,
              fit: BoxFit.cover,
            ),

你可能感兴趣的:(flutter)