如何以简单的方式在pubspec.yaml中添加100多个手动图像? [英] How to add 100+ manual images in pubspec.yaml in a easy way?

查看:235
本文介绍了如何以简单的方式在pubspec.yaml中添加100多个手动图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在我的应用程序中添加很多图像.并计划使应用程序保持脱机状态.编写"assets/image1.jpg"令人心痛.我是新手,我不知道是否还有其他方法.有吗?

I need to add quite a lot of images in my app. And plan to keep the app offline. And writing 'assets/image1.jpg' is painful to the mind. I'm new to flutter and i don't know if there is any other way. Is there any?

推荐答案

包括资产:

flutter:
  assets:
    - assets/my_icon.png
    - assets/background.png

要在目录下包含所有资产,请在目录名末尾添加/字符:

To include all assets under a directory, specify the directory name with the / character at the end:

flutter:
  assets:
    - assets/

请注意,仅包含直接位于目录中的文件;要添加位于子目录中的文件,请在每个目录中创建一个条目.

Note that only files located directly in the directory will be included; to add files located in subdirectories, create an entry per directory.

来自Flutter Docs:( https://flutter.dev/docs/development/ui/assets-and-images )

From Flutter Docs: (https://flutter.dev/docs/development/ui/assets-and-images)

这篇关于如何以简单的方式在pubspec.yaml中添加100多个手动图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆