{"id":19273049,"url":"https://github.com/fluttercandies/flutter_asset_generator","last_synced_at":"2025-07-03T03:06:21.378Z","repository":{"id":42627966,"uuid":"143665175","full_name":"fluttercandies/flutter_asset_generator","owner":"fluttercandies","description":"Generate an R file for mapping all assets. Supports preview of image.","archived":false,"fork":false,"pushed_at":"2024-06-24T09:37:46.000Z","size":160,"stargazers_count":89,"open_issues_count":2,"forks_count":21,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-30T20:49:59.301Z","etag":null,"topics":["asset","cli","dart","flutter","flutter-asset","r"],"latest_commit_sha":null,"homepage":"","language":"Dart","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fluttercandies.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-08-06T02:15:26.000Z","updated_at":"2025-04-04T04:07:25.000Z","dependencies_parsed_at":"2024-06-24T11:11:33.461Z","dependency_job_id":null,"html_url":"https://github.com/fluttercandies/flutter_asset_generator","commit_stats":null,"previous_names":["fluttercandies/flutter_resource_generator"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/fluttercandies/flutter_asset_generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercandies%2Fflutter_asset_generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercandies%2Fflutter_asset_generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercandies%2Fflutter_asset_generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercandies%2Fflutter_asset_generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fluttercandies","download_url":"https://codeload.github.com/fluttercandies/flutter_asset_generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fluttercandies%2Fflutter_asset_generator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263250600,"owners_count":23437288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asset","cli","dart","flutter","flutter-asset","r"],"created_at":"2024-11-09T20:40:35.891Z","updated_at":"2025-07-03T03:06:21.351Z","avatar_url":"https://github.com/fluttercandies.png","language":"Dart","funding_links":[],"categories":[],"sub_categories":[],"readme":"# flutter_asset_generator\n\nEnglish | [中文文档](README_CHN.md)\n\nAutomatically generate the dart file for pubspec.yaml\n\nThe purpose of this library is to help flutter developers\nautomatically generate asset corresponding dart files\nto help developers release their hands from this meaningless job,\nand the open source community has a lot of the same functionality.\n\nThis library is based on dartlang's build library.\n\n- [flutter\\_asset\\_generator](#flutter_asset_generator)\n  - [screenshot](#screenshot)\n  - [Usage](#usage)\n    - [Run from source](#run-from-source)\n    - [Run from pub global](#run-from-pub-global)\n    - [Support options](#support-options)\n  - [File name](#file-name)\n  - [Config file](#config-file)\n    - [Config schema for vscode](#config-schema-for-vscode)\n    - [exclude and include rules](#exclude-and-include-rules)\n    - [Replacement Rules](#replacement-rules)\n      - [Example](#example)\n    - [Other config](#other-config)\n\n## screenshot\n\n![img](https://raw.githubusercontent.com/CaiJingLong/some_asset/master/asset_gen_3.0.gif)\n\n## Usage\n\n### Run from source\n\nAdd `dart` to your `$PATH` environment.\n\n```bash\ngit clone https://github.com/fluttercandies/flutter_asset_generator\ncd flutter_asset_generator\ndart pub get\ndart bin/asset_generator.dart $flutter_project\n```\n\n### Run from pub global\n\n1. Install using [pub global][]:\n\n```bash\ndart pub global activate flutter_asset_generator\n\n# or \n\ndart pub global activate -s git https://github.com/fluttercandies/flutter_asset_generator.git                 \n```\n\n1. Run below commands:\n`fgen`\nor\n`fgen -s $flutter_project`\n\n### Support options\n\nUse `$ fgen -h` or `$ fgen --help` see usage document.\n\n```bash\nfgen -h\n-w, --[no-]watch    Continue to monitor changes after execution of orders.\n                    (defaults to on)\n\n-p, --[no-]preview  Generate file with preview comments.\n                    (defaults to on)\n\n-o, --output        Your resource file path.\n                    If it's a relative path, the relative flutter root directory\n                    (defaults to \"lib/const/resource.dart\")\n\n-s, --src           Flutter project root path\n                    (defaults to \".\")\n\n-n, --name          The class name for the constant.\n                    (defaults to \"R\")\n\n-h, --[no-]help     Help usage\n\n-d, --[no-]debug    debug info\n```\n\n## File name\n\n`Space`, '.' and '-' in the path will be converted to `_`. `@` will be converted to `_AT_`.\n\nconvert filed name example:\n\n```log\nimages/1.png =\u003e IMAGES_PNG\nimages/hello_world.jpg =\u003e IMAGES_HELLO_WORLD_JPG\nimages/hello-world.jpg =\u003e IMAGES_HELLO_WORLD_JPG\n```\n\nErrors will occur in the following situations:\n\n```bash\nimages/\n├── main_login.png\n├── main/\n    ├── login.png\n```\n\nBecause the two field names will be exactly the same.\n\n## Config file\n\nThe location of the configuration file is conventional.\nConfiguration via commands is **not supported**.\nThe specified path is `fgen.yaml` in the flutter project root directory.\n\n### Config schema for vscode\n\nInstall [YAML Support](https://marketplace.visualstudio.com/items?itemName=redhat.vscode-yaml) plugin.\n\nConfig your vscode `settings.json` file.\n\nIt can be used to prompt the configuration file.\n\n```json\n{\n  \"yaml.schemas\": {\n    \"https://raw.githubusercontent.com/fluttercandies/flutter_asset_generator/master/fgen_schema.json\": [\"fgen.yaml\"]\n  }\n}\n```\n\n### exclude and include rules\n\nThe file is yaml format, every element is `glob` style.\n\nThe name of the excluded file is under the `exclude` node, and the type is a string array. If no rule is included, it means no file is excluded.\n\nThe `include` node is the name of the file that needs to be imported, and the type is a string array. If it does not contain any rules, all file are allowed.\n\nIn terms of priority, exclude is higher than include, in other words:\n\nFirst import the file according to the include nodes, and then exclude the files.\n\n### Replacement Rules\n\nFile names can be replaced according to the configuration file as shown below:\n\n```yaml\n\nreplace:\n  - from: “\n    to: \n  - from: ”\n    to: \n  - from: ’\n    to:\n  - from: (\n    to:\n  - from: )\n    to:\n  - from: \"!\"\n    to:\n```\n\n#### Example\n\n```yaml\nexclude:\n  - \"**/add*.png\"\n  - \"**_**\"\n\ninclude:\n  - \"**/a*.png\"\n  - \"**/b*\"\n  - \"**/c*\"\n```\n\n```sh\nassets\n├── address.png           # exclude by \"**/add*.png\"\n├── address@at.png        # exclude by \"**/add*.png\"\n├── bluetoothon-fjdfj.png\n├── bluetoothon.png\n└── camera.png\n\nimages\n├── address space.png     # exclude by \"**/add*.png\"\n├── address.png           # exclude by \"**/add*.png\"\n├── addto.png             # exclude by \"**/add*.png\"\n├── audio.png\n├── bluetooth_link.png    # exclude by **_**\n├── bluetoothoff.png\n├── child.png\n└── course.png\n```\n\n```dart\n/// Generate by [asset_generator](https://github.com/fluttercandies/flutter_asset_generator) library.\n/// PLEASE DO NOT EDIT MANUALLY.\nclass R {\n  const R._();\n\n  /// ![preview](file:///Users/jinglongcai/code/dart/self/flutter_resource_generator/example/assets/bluetoothon-fjdfj.png)\n  static const String ASSETS_BLUETOOTHON_FJDFJ_PNG = 'assets/bluetoothon-fjdfj.png';\n\n  /// ![preview](file:///Users/jinglongcai/code/dart/self/flutter_resource_generator/example/assets/bluetoothon.png)\n  static const String ASSETS_BLUETOOTHON_PNG = 'assets/bluetoothon.png';\n\n  /// ![preview](file:///Users/jinglongcai/code/dart/self/flutter_resource_generator/example/assets/camera.png)\n  static const String ASSETS_CAMERA_PNG = 'assets/camera.png';\n\n  /// ![preview](file:///Users/jinglongcai/code/dart/self/flutter_resource_generator/example/images/audio.png)\n  static const String IMAGES_AUDIO_PNG = 'images/audio.png';\n\n  /// ![preview](file:///Users/jinglongcai/code/dart/self/flutter_resource_generator/example/images/bluetoothoff.png)\n  static const String IMAGES_BLUETOOTHOFF_PNG = 'images/bluetoothoff.png';\n\n  /// ![preview](file:///Users/jinglongcai/code/dart/self/flutter_resource_generator/example/images/child.png)\n  static const String IMAGES_CHILD_PNG = 'images/child.png';\n\n  /// ![preview](file:///Users/jinglongcai/code/dart/self/flutter_resource_generator/example/images/course.png)\n  static const String IMAGES_COURSE_PNG = 'images/course.png';\n}\n```\n\n### Other config\n\nSince version 1.1.0:\n\nNext command config option also support in config file.\n\nBut the command line option has a higher priority than the config file.\n\n```yaml\n\nwatch: false\n# watch: true\n\npreview: false\n\noutput: lib/const/r.dart\n# output: lib/const/resource.dart\n\nname: RRR\n```\n\n[pub global]: https://dart.dev/tools/pub/cmd/pub-global#running-a-script-from-your-path\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluttercandies%2Fflutter_asset_generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffluttercandies%2Fflutter_asset_generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffluttercandies%2Fflutter_asset_generator/lists"}