错误:无法在pubspec.yaml中找到目录条目 [英] Error: unable to find directory entry in pubspec.yaml
问题描述
我正在尝试从我的flutter应用程序中的外部程序包中添加资产 如下所述: https://flutter. dev/docs/development/ui/assets-and-images#bundling-of-package-assets
I am trying to add assets from an external package in my flutter application as mentioned here: https://flutter.dev/docs/development/ui/assets-and-images#bundling-of-package-assets
即使添加了这个不能为空的简单条目,我也得到了这个Error: unable to find directory entry in pubspec.yaml /project/location/<project_name>/packages
.
I am getting this Error: unable to find directory entry in pubspec.yaml /project/location/<project_name>/packages
even for adding this simple entry which cant be null.
assets:
- packages/
推荐答案
https://flutter.dev/docs/development/ui/assets-and-images#asset-images-in-package-dependencies 解释了如何从依赖关系中添加资产
https://flutter.dev/docs/development/ui/assets-and-images#asset-images-in-package-dependencies explains how to add assets from dependencies
assets:
- packages/some_package/backgrounds/background1.png
将从软件包some_package
中添加资产lib/backgrounds/background1.png
.
Would add asset lib/backgrounds/background1.png
from package some_package
.
来自程序包的资产尚不支持添加整个目录,您需要单独添加每个资产文件(不过,可以自动识别分辨率子目录中的文件)
Assets from packages do not support adding whole directories yet and you need to add each asset file individually (files from resolution sub-directories are recognized automatically though)
添加资产目录还不支持从应用程序包中添加目录树.仅会识别列出目录下的所有文件(同样包括分辨率子目录)
Adding an asset directory also does not support adding a directory tree from the application package. Only all files directly below a listed directory are recognized (again including resolution sub-directories)
这篇关于错误:无法在pubspec.yaml中找到目录条目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!