【发布时间】:2021-06-21 22:10:05
【问题描述】:
我为资产提供了两个空格,为图像位置提供了 4 个空格,但我也收到了错误。
这是我的pubspec.yaml
flutter:
uses-material-design: true
assets:
- assets/port.jpeg
我收到错误消息
════════ Exception caught by image resource service ════════════════════════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/port.jpeg
When the exception was thrown, this was the stack:
dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 236:49 throw_
packages/flutter/src/services/asset_bundle.dart 227:55 load
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 45:50 <fn>
dart-sdk/lib/async/zone.dart 1362:47 _rootRunUnary
dart-sdk/lib/async/zone.dart 1265:19 runUnary
...
Image provider: AssetImage(bundle: null, name: "assets/port.jpeg")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#5a8a3(), name: "assets/port.jpeg", scale: 1)
════════════════════════════════════════════════════════════════════════════════════════════════════
这是我的目录
【问题讨论】:
-
你能在你使用图像的地方显示代码吗?通常,在 pubspec.yaml 中的 assets 下,您只声明一个名为“images”的文件夹(您再次将其命名为“assets”),然后在代码中从该文件夹中输入您想要的图像。
-
感谢您的回应