flutter 静态资源管理问题

来源:1-1 课程介绍与学习指南

希卡利

2022-05-20

════════ Exception caught by image resource service ════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: lib/assets/images/defalut-head-portrait.png

When the exception was thrown, this was the stack
#0      PlatformAssetBundle.load
package:flutter/…/services/asset_bundle.dart:237
<asynchronous suspension>
#1      AssetBundleImageProvider._loadAsync
package:flutter/…/painting/image_provider.dart:675
<asynchronous suspension>
Image provider: AssetImage(bundle: null, name: "lib/assets/images/defalut-head-portrait.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#679c4(), name: "lib/assets/images/defalut-head-portrait.png", scale: 1.0)
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:
    - ./lib/assets/images/default-head-portrait.png

图片描述

写回答

1回答

CrazyCodeBoy

2022-05-20

看是不是你在pub文件中定义图片路径的缩进有问题呢,可以对照下这块课程源码的缩进看看
0
0

Flutter从入门到进阶 实战携程网App 一网打尽核心技术

解锁Flutter开发新姿势,,系统掌握Flutter开发核心技术。

4788 学习 · 3270 问题

查看课程