检索 web 资产时出错(flutter)

Error on retrieving assets for web (flutter)

我遇到了 Flutter WEB 问题。我遵循了 Flutter 团队 (https://flutter.dev/docs/development/ui/assets-and-images) 的资产教程,但是我收到错误

 ══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/images/my_custom_image.png

When the exception was thrown, this was the stack:
dart:sdk_internal 4602:11                                  throw_
load
package:flutter_web/…/services/asset_bundle.dart:220
dart:sdk_internal 25309:9                                  <fn>
...

Image provider: AssetImage(bundle: null, name: "assets/images/my_custom_image.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#078a9(), name:
  "assets/images/my_custom_image.png", scale: 1)
════════════════════════════════════════════════════════════════════════════════════════════════════ 

我的pubspecs.yaml

flutter:
  uses-material-design: true

  assets:
    - assets/images/

我正在加载这样的图片

Image.asset("assets/images/my_custom_image.png")

我哪里搞砸了?

由于 flutter for web 的状态仍然是 preview,资产处理与移动设备不同。assets 文件夹应该在 web 文件夹中,并且图片的参考路径不应包含 assets:

Image.asset("images/my_custom_image.png")

flutter for web中,我们不需要引用pubspec.yaml中的资产。