https://github.com/raomengyun/auto_assets
assets management tool for Flutter
https://github.com/raomengyun/auto_assets
assets assets-management cli flutter
Last synced: about 1 year ago
JSON representation
assets management tool for Flutter
- Host: GitHub
- URL: https://github.com/raomengyun/auto_assets
- Owner: raomengyun
- License: mit
- Created: 2019-08-28T03:40:13.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2022-12-04T09:16:11.000Z (over 3 years ago)
- Last Synced: 2025-03-21T18:52:15.458Z (over 1 year ago)
- Topics: assets, assets-management, cli, flutter
- Language: JavaScript
- Homepage:
- Size: 422 KB
- Stars: 16
- Watchers: 1
- Forks: 1
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# 1. 解决的问题
1. 自动生成 pubspec.yaml 资源声明。
2. 自动压缩资源(目前支持: jpg/jpeg/png/svg)。
3. 自动资源类型化,类似于的 Android 的 R.java,例如:
```dart
class Assets {
Assets._();
static const String commonIconClose = "assets/common/icon_close.png";
}
class AssetImages {
AssetImages._();
static AssetImage get commonIconClose => const AssetImage(Assets.commonIconClose);
}
```
# 2. 工具安装
`auto_assets` 是使用 `nodejs` 开发的工具,安装需要有 `node` 环境。
1. 安装 `nodejs`:https://nodejs.org/en/download/
2. 执行命令:`npm install auto_assets -g`
3. 安装完之后即可使用 `auto_assets` 命令
# 3. 工具使用
## 3.1. 项目配置
在项目根目录下新建 `assets_config.json` 文件,文件内容:
```json
{
"assets": "assets/",
"code": "lib/assets/"
}
```
- `assets` 代表项目中资源文件的根目录,有多个的时候可以传入数组。
- `code` 代表自动生成的代码的根目录。
## 3.2. 执行命令
```shell
auto_assets [Flutter项目根目录]
```
## 3.3. VSCode 插件
1. 在 VSCode -> Extensions 下搜索 `auto_assets` 并安装。
2. 重新打开项目。
# 4. 样例
TODO