├── example ├── assets │ ├── dd.txt │ ├── test.txt │ └── images │ │ ├── 1.5x │ │ └── flutter_candies_logo.png │ │ ├── 2.0x │ │ └── flutter_candies_logo.png │ │ └── 3.0x │ │ └── flutter_candies_logo.png ├── module_a │ ├── assets │ │ ├── xxx.md │ │ ├── abc.txt │ │ └── images │ │ │ ├── test.txt │ │ │ └── flutter_candies_logo.png │ ├── LICENSE │ ├── assets_generator_arguments │ ├── CHANGELOG.md │ ├── .metadata │ ├── README.md │ ├── pubspec.yaml │ ├── lib │ │ ├── assets.dart │ │ └── main.dart │ └── .gitignore ├── module_b │ ├── LICENSE │ ├── CHANGELOG.md │ ├── lib │ │ └── module_b.dart │ ├── analysis_options.yaml │ ├── test │ │ └── module_b_test.dart │ ├── .gitignore │ ├── README.md │ └── pubspec.yaml ├── module_assets │ ├── LICENSE │ ├── CHANGELOG.md │ ├── lib │ │ └── module_assets.dart │ ├── analysis_options.yaml │ ├── .metadata │ ├── test │ │ └── module_assets_test.dart │ ├── .gitignore │ ├── README.md │ └── pubspec.yaml ├── ios │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ └── IDEWorkspaceChecks.plist │ │ ├── xcshareddata │ │ │ └── xcschemes │ │ │ │ └── Runner.xcscheme │ │ └── project.pbxproj │ └── .gitignore ├── analysis_options.yaml ├── assets_generator_arguments ├── android │ ├── gradle.properties │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── values │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── values-night │ │ │ │ │ │ └── styles.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ └── example │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── settings.gradle │ └── build.gradle ├── .metadata ├── README.md ├── lib │ ├── assets.dart │ └── main.dart ├── .gitignore └── pubspec.yaml ├── CODEOWNERS ├── assets_generator.gif ├── lib ├── src │ ├── arg │ │ ├── arg_parser.dart │ │ ├── help.dart │ │ ├── output.dart │ │ ├── path.dart │ │ ├── folder.dart │ │ ├── g_suffix.dart │ │ ├── watch.dart │ │ ├── const_ignore.dart │ │ ├── const_array.dart │ │ ├── folder_ignore.dart │ │ ├── package_ignore.dart │ │ ├── class_prefix.dart │ │ ├── use_key_name.dart │ │ ├── package.dart │ │ ├── root_package.dart │ │ ├── save.dart │ │ ├── type.dart │ │ ├── arg.dart │ │ ├── class.dart │ │ └── rule.dart │ ├── format.dart │ ├── watcher.dart │ ├── yaml.dart │ ├── template.dart │ └── assets_generator.dart ├── args.dart └── assets_generator.dart ├── .gitignore ├── .github ├── workflows │ ├── checker.yml │ ├── pub_publish.yml │ └── pub_dry_run.yml ├── FUNDING.yml └── stale.yml ├── pubspec.yaml ├── .vscode └── launch.json ├── LICENSE ├── analysis_options.yaml ├── CHANGELOG.md ├── README-ZH.md ├── README.md └── bin └── assets_generator.dart /example/assets/dd.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/assets/test.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @zmtzawqlp 2 | -------------------------------------------------------------------------------- /example/module_a/assets/xxx.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/module_a/assets/abc.txt: -------------------------------------------------------------------------------- 1 | dasdd -------------------------------------------------------------------------------- /example/module_a/assets/images/test.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/module_a/LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /example/module_b/LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /example/module_assets/LICENSE: -------------------------------------------------------------------------------- 1 | TODO: Add your license here. 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/module_a/assets_generator_arguments: -------------------------------------------------------------------------------- 1 | -s -t f --const-array --rule lwu --package -------------------------------------------------------------------------------- /example/module_b/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /example/module_assets/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 0.0.1 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /assets_generator.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/assets_generator.gif -------------------------------------------------------------------------------- /example/assets_generator_arguments: -------------------------------------------------------------------------------- 1 | -s -t f --const-array --rule lwu --no-watch --no-g-suffix --use-key-name 2 | -------------------------------------------------------------------------------- /example/module_a/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [0.0.1] - TODO: Add release date. 2 | 3 | * TODO: Describe initial release. 4 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | android.enableR8=true 5 | -------------------------------------------------------------------------------- /example/module_b/lib/module_b.dart: -------------------------------------------------------------------------------- 1 | /// A Calculator. 2 | class Calculator { 3 | /// Returns [value] plus 1. 4 | int addOne(int value) => value + 1; 5 | } 6 | -------------------------------------------------------------------------------- /example/assets/images/1.5x/flutter_candies_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/assets/images/1.5x/flutter_candies_logo.png -------------------------------------------------------------------------------- /example/assets/images/2.0x/flutter_candies_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/assets/images/2.0x/flutter_candies_logo.png -------------------------------------------------------------------------------- /example/assets/images/3.0x/flutter_candies_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/assets/images/3.0x/flutter_candies_logo.png -------------------------------------------------------------------------------- /example/module_assets/lib/module_assets.dart: -------------------------------------------------------------------------------- 1 | /// A Calculator. 2 | class Calculator { 3 | /// Returns [value] plus 1. 4 | int addOne(int value) => value + 1; 5 | } 6 | -------------------------------------------------------------------------------- /example/module_a/assets/images/flutter_candies_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/module_a/assets/images/flutter_candies_logo.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/module_b/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/module_assets/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() { 6 | } 7 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/fluttercandies/assets_generator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /lib/src/arg/arg_parser.dart: -------------------------------------------------------------------------------- 1 | import 'package:args/args.dart'; 2 | 3 | final ArgParser parser = ArgParser(); 4 | ArgResults? argResults; 5 | void parseArgs(List args) { 6 | argResults ??= parser.parse(args); 7 | } 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Fri Jun 23 08:50:38 CEST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Files and directories created by pub 2 | .idea/ 3 | .vscode/ 4 | .dart_tool/ 5 | .packages 6 | # Remove the following pattern if you wish to check in your lock file 7 | pubspec.lock 8 | 9 | # Conventional directory for build outputs 10 | build/ 11 | 12 | # Directory created by dartdoc 13 | doc/api/ 14 | -------------------------------------------------------------------------------- /lib/src/arg/help.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class Help extends Argument { 4 | @override 5 | String get abbr => 'h'; 6 | 7 | @override 8 | bool get defaultsTo => false; 9 | 10 | @override 11 | String get help => 'Help usage'; 12 | 13 | @override 14 | String get name => 'help'; 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/src/arg/output.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class Output extends Argument { 4 | @override 5 | String get abbr => 'o'; 6 | 7 | @override 8 | String get defaultsTo => 'lib'; 9 | 10 | @override 11 | String get help => 'The path of const Class'; 12 | 13 | @override 14 | String get name => 'out'; 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/arg/path.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class Path extends Argument { 4 | @override 5 | String get abbr => 'p'; 6 | 7 | @override 8 | String get defaultsTo => '.'; 9 | 10 | @override 11 | String get help => 'Flutter project root path'; 12 | 13 | @override 14 | String get name => 'path'; 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/src/arg/folder.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class Folder extends Argument { 4 | @override 5 | String get abbr => 'f'; 6 | 7 | @override 8 | String get defaultsTo => 'assets'; 9 | 10 | @override 11 | String get help => 'The root folder of assets'; 12 | 13 | @override 14 | String get name => 'folder'; 15 | } 16 | -------------------------------------------------------------------------------- /example/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: 3bf91b543678d6dc677a9c3f1f2ea32a769ddbcb 8 | channel: master 9 | 10 | project_type: app 11 | -------------------------------------------------------------------------------- /lib/src/arg/g_suffix.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class GSuffix extends Argument { 4 | @override 5 | String? get abbr => null; 6 | 7 | @override 8 | bool get defaultsTo => false; 9 | 10 | @override 11 | String get help => 'Whether the generated file is end with .g'; 12 | 13 | @override 14 | String get name => 'g-suffix'; 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/arg/watch.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class Watch extends Argument { 4 | @override 5 | String get abbr => 'w'; 6 | 7 | @override 8 | bool get defaultsTo => true; 9 | 10 | @override 11 | String get help => 'Whether continue to monitor the changes of assets'; 12 | 13 | @override 14 | String get name => 'watch'; 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/arg/const_ignore.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class ConstIgnore extends Argument { 4 | @override 5 | String? get abbr => null; 6 | 7 | @override 8 | String? get defaultsTo => null; 9 | 10 | @override 11 | String get help => 'The regular to ignore some consts'; 12 | 13 | @override 14 | String get name => 'const-ignore'; 15 | } 16 | -------------------------------------------------------------------------------- /example/module_a/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: ac751cc50cc28d329f4b7581bbadd960918a9b64 8 | channel: master 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /lib/src/arg/const_array.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class ConstArray extends Argument { 4 | @override 5 | String? get abbr => null; 6 | 7 | @override 8 | bool get defaultsTo => false; 9 | 10 | @override 11 | String get help => 'Whether generate the array of all the consts'; 12 | 13 | @override 14 | String get name => 'const-array'; 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/arg/folder_ignore.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class FolderIgnore extends Argument { 4 | @override 5 | String? get abbr => null; 6 | 7 | @override 8 | String? get defaultsTo => null; 9 | 10 | @override 11 | String get help => 'The regular to ignore some folders.'; 12 | 13 | @override 14 | String get name => 'folder-ignore'; 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/arg/package_ignore.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class PackageIgnore extends Argument { 4 | @override 5 | String? get abbr => null; 6 | 7 | @override 8 | String? get defaultsTo => null; 9 | 10 | @override 11 | String get help => 'The regular to ignore some packages.'; 12 | 13 | @override 14 | String get name => 'package-ignore'; 15 | } 16 | -------------------------------------------------------------------------------- /example/module_assets/.metadata: -------------------------------------------------------------------------------- 1 | # This file tracks properties of this Flutter project. 2 | # Used by Flutter tool to assess capabilities and perform upgrades etc. 3 | # 4 | # This file should be version controlled and should not be manually edited. 5 | 6 | version: 7 | revision: "d8a9f9a52e5af486f80d932e838ee93861ffd863" 8 | channel: "stable" 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/module_b/test/module_b_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | import 'package:module_b/module_b.dart'; 4 | 5 | void main() { 6 | test('adds one to input values', () { 7 | final calculator = Calculator(); 8 | expect(calculator.addOne(2), 3); 9 | expect(calculator.addOne(-7), -6); 10 | expect(calculator.addOne(0), 1); 11 | }); 12 | } 13 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md: -------------------------------------------------------------------------------- 1 | # Launch Screen Assets 2 | 3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory. 4 | 5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images. -------------------------------------------------------------------------------- /lib/src/arg/class_prefix.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class ClassPrefix extends Argument { 4 | @override 5 | String? get abbr => null; 6 | 7 | @override 8 | bool get defaultsTo => false; 9 | 10 | @override 11 | String get help => 12 | 'Whether use package name as prefix for the name of const Class'; 13 | 14 | @override 15 | String get name => 'class-prefix'; 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/arg/use_key_name.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class UseKeyName extends Argument { 4 | @override 5 | String? get abbr => null; 6 | 7 | @override 8 | bool get defaultsTo => false; 9 | 10 | @override 11 | String get help => 12 | 'Whether to use keyName style (packages/{package}/...) for asset paths'; 13 | 14 | @override 15 | String get name => 'use-key-name'; 16 | } 17 | -------------------------------------------------------------------------------- /example/module_assets/test/module_assets_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | 3 | import 'package:module_assets/module_assets.dart'; 4 | 5 | void main() { 6 | test('adds one to input values', () { 7 | final calculator = Calculator(); 8 | expect(calculator.addOne(2), 3); 9 | expect(calculator.addOne(-7), -6); 10 | expect(calculator.addOne(0), 1); 11 | }); 12 | } 13 | -------------------------------------------------------------------------------- /lib/src/arg/package.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class Package extends Argument { 4 | @override 5 | String? get abbr => null; 6 | 7 | @override 8 | bool get defaultsTo => false; 9 | 10 | @override 11 | String get help => 12 | 'Whether is it a package, if it is true, it will generate package name in Assets Class'; 13 | 14 | @override 15 | String get name => 'package'; 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/arg/root_package.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class RootPackage extends Argument { 4 | @override 5 | String? get abbr => null; 6 | 7 | @override 8 | String? get defaultsTo => null; 9 | 10 | @override 11 | String get help => 12 | 'Specify which package should be treated as the root project (by package name)'; 13 | 14 | @override 15 | String get name => 'root-package'; 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/arg/save.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class Save extends Argument { 4 | @override 5 | String get abbr => 's'; 6 | 7 | @override 8 | bool get defaultsTo => false; 9 | 10 | @override 11 | String get help => 12 | 'Whether save the arguments into the local\nIt will execute the local arguments if run "agen" without any arguments'; 13 | 14 | @override 15 | String get name => 'save'; 16 | } 17 | -------------------------------------------------------------------------------- /.github/workflows/checker.yml: -------------------------------------------------------------------------------- 1 | name: No Free usage issue checker 2 | 3 | on: 4 | issues: 5 | types: [opened, reopened] 6 | 7 | jobs: 8 | build: 9 | 10 | runs-on: ubuntu-latest 11 | 12 | steps: 13 | - uses: actions/checkout@v2 14 | - name: Check issue actor 15 | uses: ./ 16 | with: 17 | repo: $GITHUB_REPOSITORY 18 | user: $GITHUB_ACTOR 19 | token: ${{ secrets.GITHUB_TOKEN }} -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /.github/workflows/pub_publish.yml: -------------------------------------------------------------------------------- 1 | name: Pub Publish plugin 2 | 3 | on: 4 | release: 5 | types: [ published ] 6 | workflow_dispatch: 7 | 8 | jobs: 9 | publish: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Checkout 13 | uses: actions/checkout@v4 14 | - name: Publish 15 | uses: k-paxian/dart-package-publisher@master 16 | with: 17 | credentialJson: ${{ secrets.CREDENTIAL_JSON }} 18 | flutter: true 19 | skipTests: true 20 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/module_a/README.md: -------------------------------------------------------------------------------- 1 | # module_a 2 | 3 | A new Flutter package project. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Dart 8 | [package](https://flutter.dev/developing-packages/), 9 | a library module containing code that can be shared easily across 10 | multiple Flutter or Dart projects. 11 | 12 | For help getting started with Flutter, view our 13 | [online documentation](https://flutter.dev/docs), which offers tutorials, 14 | samples, guidance on mobile development, and a full API reference. 15 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 2 | 3 | A new Flutter application. 4 | 5 | ## Getting Started 6 | 7 | This project is a starting point for a Flutter application. 8 | 9 | A few resources to get you started if this is your first Flutter project: 10 | 11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook) 13 | 14 | For help getting started with Flutter, view our 15 | [online documentation](https://flutter.dev/docs), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /.github/workflows/pub_dry_run.yml: -------------------------------------------------------------------------------- 1 | name: Pub Publish dry run 2 | 3 | on: 4 | push: 5 | 6 | concurrency: 7 | group: ${{ github.workflow }}-${{ github.ref }} 8 | cancel-in-progress: true 9 | 10 | jobs: 11 | publish: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout 15 | uses: actions/checkout@v1 16 | - name: Publish dry run 17 | uses: k-paxian/dart-package-publisher@master 18 | with: 19 | credentialJson: "MockCredentialJson" 20 | accessToken: "MockAccessToken" 21 | refreshToken: "MockRefreshToken" 22 | flutter: true 23 | dryRunOnly: true 24 | -------------------------------------------------------------------------------- /lib/src/arg/type.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class Type extends Argument { 4 | @override 5 | String get abbr => 't'; 6 | 7 | @override 8 | String get defaultsTo => 'd'; 9 | 10 | @override 11 | String get help => 12 | '''The type in pubsepec.yaml \n"d" means directory "- assets/images/" \n"f" means file "- assets/images/xxx.jpg" '''; 13 | 14 | @override 15 | String get name => 'type'; 16 | 17 | FormatType type(String? value) { 18 | if (value == 'f') { 19 | return FormatType.file; 20 | } 21 | return FormatType.directory; 22 | } 23 | } 24 | 25 | enum FormatType { 26 | directory, 27 | file, 28 | } 29 | -------------------------------------------------------------------------------- /example/ios/.gitignore: -------------------------------------------------------------------------------- 1 | *.mode1v3 2 | *.mode2v3 3 | *.moved-aside 4 | *.pbxuser 5 | *.perspectivev3 6 | **/*sync/ 7 | .sconsign.dblite 8 | .tags* 9 | **/.vagrant/ 10 | **/DerivedData/ 11 | Icon? 12 | **/Pods/ 13 | **/.symlinks/ 14 | profile 15 | xcuserdata 16 | **/.generated/ 17 | Flutter/App.framework 18 | Flutter/Flutter.framework 19 | Flutter/Flutter.podspec 20 | Flutter/Generated.xcconfig 21 | Flutter/app.flx 22 | Flutter/app.zip 23 | Flutter/flutter_assets/ 24 | Flutter/flutter_export_environment.sh 25 | ServiceDefinitions.json 26 | Runner/GeneratedPluginRegistrant.* 27 | 28 | # Exceptions to above rules. 29 | !default.mode1v3 30 | !default.mode2v3 31 | !default.pbxuser 32 | !default.perspectivev3 33 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | #github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | #patreon: # Replace with a single Patreon username 5 | #open_collective: # Replace with a single Open Collective username 6 | #ko_fi: # Replace with a single Ko-fi username 7 | #tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | #community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | #liberapay: zmtzawqlp 10 | #issuehunt: # Replace with a single IssueHunt username 11 | #otechie: # Replace with a single Otechie username 12 | custom: http://zmtzawqlp.gitee.io/my_images/images/qrcode.png 13 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.3.50' 3 | repositories { 4 | google() 5 | jcenter() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:3.5.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | jcenter() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | task clean(type: Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /example/module_assets/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .flutter-plugins 30 | .flutter-plugins-dependencies 31 | build/ 32 | -------------------------------------------------------------------------------- /example/module_b/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 18 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 26 | /pubspec.lock 27 | **/doc/api/ 28 | .dart_tool/ 29 | .flutter-plugins 30 | .flutter-plugins-dependencies 31 | build/ 32 | .metadata -------------------------------------------------------------------------------- /lib/args.dart: -------------------------------------------------------------------------------- 1 | library; 2 | 3 | export 'src/arg/arg.dart'; 4 | export 'src/arg/arg_parser.dart'; 5 | export 'src/arg/class.dart'; 6 | export 'src/arg/class_prefix.dart'; 7 | export 'src/arg/const_array.dart'; 8 | export 'src/arg/const_ignore.dart'; 9 | export 'src/arg/folder.dart'; 10 | export 'src/arg/folder_ignore.dart'; 11 | export 'src/arg/g_suffix.dart'; 12 | export 'src/arg/help.dart'; 13 | export 'src/arg/output.dart'; 14 | export 'src/arg/package.dart'; 15 | export 'src/arg/package_ignore.dart'; 16 | export 'src/arg/path.dart'; 17 | export 'src/arg/root_package.dart'; 18 | export 'src/arg/rule.dart'; 19 | export 'src/arg/save.dart'; 20 | export 'src/arg/type.dart'; 21 | export 'src/arg/use_key_name.dart'; 22 | export 'src/arg/watch.dart'; 23 | -------------------------------------------------------------------------------- /.github/stale.yml: -------------------------------------------------------------------------------- 1 | # Number of days of inactivity before an issue becomes stale 2 | daysUntilStale: 60 3 | # Number of days of inactivity before a stale issue is closed 4 | daysUntilClose: 7 5 | # Issues with these labels will never be considered stale 6 | exemptLabels: 7 | - pinned 8 | - security 9 | # Label to use when marking an issue as stale 10 | staleLabel: wontfix 11 | # Comment to post when marking an issue as stale. Set to `false` to disable 12 | markComment: > 13 | This issue has been automatically marked as stale because it has not had 14 | recent activity. It will be closed if no further activity occurs. Thank you 15 | for your contributions. 16 | # Comment to post when closing a stale issue. Set to `false` to disable 17 | closeComment: true -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: assets_generator 2 | description: The flutter tool to generate assets‘s configs(yaml) and consts automatically for single project and multiple modules. 3 | version: 4.0.4+1 4 | homepage: https://github.com/fluttercandies/assets_generator 5 | 6 | environment: 7 | sdk: ^3.0.0 8 | 9 | dependencies: 10 | args: ^2.2.0 11 | build_runner_core: ">=7.1.0 <10.0.0" 12 | dart_style: ">=2.3.8 <4.0.0" 13 | io: ^1.0.3 14 | meta: ^1.7.0 15 | mime: ">=1.0.2 <3.0.0" 16 | source_span: ^1.8.1 17 | path: ^1.8.0 18 | pub_semver: ^2.2.0 19 | yaml: ^3.1.0 20 | 21 | dev_dependencies: 22 | lints: any 23 | 24 | executables: 25 | agen: assets_generator 26 | # dart pub global activate --source path ./ 27 | # dart pub global activate assets_generator 28 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "name": "assets_generator", 9 | "request": "launch", 10 | "type": "dart" 11 | }, 12 | { 13 | "name": "example", 14 | "cwd": "example", 15 | "request": "launch", 16 | "type": "dart" 17 | }, 18 | { 19 | "name": "module_a", 20 | "cwd": "example/module_a", 21 | "request": "launch", 22 | "type": "dart" 23 | } 24 | ] 25 | } -------------------------------------------------------------------------------- /lib/assets_generator.dart: -------------------------------------------------------------------------------- 1 | library assets_generator; 2 | 3 | export 'src/arg/arg.dart'; 4 | export 'src/arg/arg_parser.dart'; 5 | export 'src/arg/class.dart'; 6 | export 'src/arg/class_prefix.dart'; 7 | export 'src/arg/const_array.dart'; 8 | export 'src/arg/const_ignore.dart'; 9 | export 'src/arg/folder.dart'; 10 | export 'src/arg/folder_ignore.dart'; 11 | export 'src/arg/g_suffix.dart'; 12 | export 'src/arg/help.dart'; 13 | export 'src/arg/output.dart'; 14 | export 'src/arg/package.dart'; 15 | export 'src/arg/package_ignore.dart'; 16 | export 'src/arg/path.dart'; 17 | export 'src/arg/root_package.dart'; 18 | export 'src/arg/rule.dart'; 19 | export 'src/arg/save.dart'; 20 | export 'src/arg/type.dart'; 21 | export 'src/arg/use_key_name.dart'; 22 | export 'src/arg/watch.dart'; 23 | export 'src/assets_generator.dart'; 24 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 9.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/module_a/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: module_a 2 | description: A new Flutter package project. 3 | version: 0.0.1 4 | homepage: 5 | 6 | environment: 7 | sdk: ^3.0.0 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | dev_dependencies: 14 | flutter_test: 15 | sdk: flutter 16 | 17 | # For information on the generic Dart part of this file, see the 18 | # following page: https://dart.dev/tools/pub/pubspec 19 | 20 | # The following section is specific to Flutter. 21 | 22 | flutter: 23 | 24 | assets: 25 | 26 | # assets start 27 | 28 | # GENERATED CODE - DO NOT MODIFY MANUALLY 29 | # ************************************************************************** 30 | # Auto generated by https://github.com/fluttercandies/assets_generator 31 | # ************************************************************************** 32 | 33 | - assets/abc.txt 34 | - assets/images/flutter_candies_logo.png 35 | - assets/images/test.txt 36 | - assets/xxx.md 37 | 38 | # assets end 39 | 40 | 41 | # assets end -------------------------------------------------------------------------------- /example/lib/assets.dart: -------------------------------------------------------------------------------- 1 | // dart format off 2 | // coverage:ignore-file 3 | // ignore_for_file: constant_identifier_names 4 | // 5 | // GENERATED CODE - DO NOT MODIFY MANUALLY 6 | // ************************************************************************** 7 | // Auto generated by https://github.com/fluttercandies/assets_generator 8 | // ************************************************************************** 9 | 10 | abstract final class Assets { 11 | static const String assets_dd_txt = 'assets/dd.txt'; 12 | 13 | /// {@macro assets_generator.assets_images_flutter_candies_logo_png.preview} 14 | static const String assets_images_flutter_candies_logo_png = 15 | 'assets/images/flutter_candies_logo.png'; 16 | static const String assets_test_txt = 'assets/test.txt'; 17 | } 18 | 19 | final List assetsArray = [ 20 | Assets.assets_dd_txt, 21 | 22 | /// {@macro assets_generator.assets_images_flutter_candies_logo_png.preview} 23 | Assets.assets_images_flutter_candies_logo_png, 24 | Assets.assets_test_txt, 25 | ]; 26 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 zmtzawqlp 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /example/module_a/lib/assets.dart: -------------------------------------------------------------------------------- 1 | // dart format off 2 | // coverage:ignore-file 3 | // ignore_for_file: constant_identifier_names 4 | // 5 | // GENERATED CODE - DO NOT MODIFY MANUALLY 6 | // ************************************************************************** 7 | // Auto generated by https://github.com/fluttercandies/assets_generator 8 | // ************************************************************************** 9 | 10 | abstract final class Assets { 11 | static const String assets_abc_txt = 'packages/module_a/assets/abc.txt'; 12 | 13 | /// {@macro assets_generator.assets_images_flutter_candies_logo_png.preview} 14 | static const String assets_images_flutter_candies_logo_png = 15 | 'packages/module_a/assets/images/flutter_candies_logo.png'; 16 | static const String assets_images_test_txt = 17 | 'packages/module_a/assets/images/test.txt'; 18 | static const String assets_xxx_md = 'packages/module_a/assets/xxx.md'; 19 | } 20 | 21 | final List assetsArray = [ 22 | Assets.assets_abc_txt, 23 | 24 | /// {@macro assets_generator.assets_images_flutter_candies_logo_png.preview} 25 | Assets.assets_images_flutter_candies_logo_png, 26 | Assets.assets_images_test_txt, 27 | Assets.assets_xxx_md, 28 | ]; 29 | -------------------------------------------------------------------------------- /example/module_b/README.md: -------------------------------------------------------------------------------- 1 | 13 | 14 | TODO: Put a short description of the package here that helps potential users 15 | know whether this package might be useful for them. 16 | 17 | ## Features 18 | 19 | TODO: List what your package can do. Maybe include images, gifs, or videos. 20 | 21 | ## Getting started 22 | 23 | TODO: List prerequisites and provide or point to information on how to 24 | start using the package. 25 | 26 | ## Usage 27 | 28 | TODO: Include short and useful examples for package users. Add longer examples 29 | to `/example` folder. 30 | 31 | ```dart 32 | const like = 'sample'; 33 | ``` 34 | 35 | ## Additional information 36 | 37 | TODO: Tell users more about the package: where to find more information, how to 38 | contribute to the package, how to file issues, what response they can expect 39 | from the package authors, and more. 40 | -------------------------------------------------------------------------------- /example/module_assets/README.md: -------------------------------------------------------------------------------- 1 | 13 | 14 | TODO: Put a short description of the package here that helps potential users 15 | know whether this package might be useful for them. 16 | 17 | ## Features 18 | 19 | TODO: List what your package can do. Maybe include images, gifs, or videos. 20 | 21 | ## Getting started 22 | 23 | TODO: List prerequisites and provide or point to information on how to 24 | start using the package. 25 | 26 | ## Usage 27 | 28 | TODO: Include short and useful examples for package users. Add longer examples 29 | to `/example` folder. 30 | 31 | ```dart 32 | const like = 'sample'; 33 | ``` 34 | 35 | ## Additional information 36 | 37 | TODO: Tell users more about the package: where to find more information, how to 38 | contribute to the package, how to file issues, what response they can expect 39 | from the package authors, and more. 40 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:lints/recommended.yaml 2 | 3 | analyzer: 4 | errors: 5 | always_declare_return_types: error 6 | always_put_control_body_on_new_line: error 7 | avoid_renaming_method_parameters: error 8 | avoid_void_async: error 9 | camel_case_types: error 10 | constant_identifier_names: error 11 | deprecated_member_use_from_same_package: ignore 12 | non_constant_identifier_names: error 13 | prefer_single_quotes: error 14 | require_trailing_commas: error 15 | todo: ignore 16 | 17 | linter: 18 | rules: 19 | always_declare_return_types: true 20 | always_put_control_body_on_new_line: true 21 | avoid_renaming_method_parameters: true 22 | avoid_unnecessary_containers: true 23 | avoid_void_async: true 24 | curly_braces_in_flow_control_structures: true 25 | directives_ordering: true 26 | library_annotations: false 27 | prefer_const_constructors: true 28 | prefer_const_constructors_in_immutables: false 29 | prefer_final_fields: true 30 | prefer_final_in_for_each: true 31 | prefer_final_locals: true 32 | prefer_relative_imports: true 33 | prefer_single_quotes: true 34 | require_trailing_commas: true 35 | sort_constructors_first: true 36 | sort_unnamed_constructors_first: true 37 | unnecessary_await_in_return: true 38 | unnecessary_breaks: true 39 | unnecessary_late: true 40 | unnecessary_library_name: false 41 | unnecessary_parenthesis: true 42 | -------------------------------------------------------------------------------- /lib/src/arg/arg.dart: -------------------------------------------------------------------------------- 1 | import 'arg_parser.dart'; 2 | 3 | abstract class Argument { 4 | Argument() { 5 | if (false is T) { 6 | parser.addFlag( 7 | name, 8 | abbr: abbr, 9 | help: help, 10 | defaultsTo: defaultsTo as bool?, 11 | ); 12 | } else if ('' is T) { 13 | parser.addOption( 14 | name, 15 | abbr: abbr, 16 | help: help, 17 | defaultsTo: defaultsTo as String?, 18 | ); 19 | } else if ([] is T) { 20 | parser.addMultiOption( 21 | name, 22 | abbr: abbr, 23 | help: help, 24 | defaultsTo: defaultsTo as List?, 25 | ); 26 | } else { 27 | // TODO(zmtzawqlp): not implement for now. 28 | throw Exception('not implement fill method'); 29 | } 30 | } 31 | 32 | /// The name of the option that the user passes as an argument. 33 | String get name; 34 | 35 | /// A single-character string that can be used as a shorthand for this option. 36 | /// 37 | /// For example, `abbr: "a"` will allow the user to pass `-a value` or 38 | /// `-avalue`. 39 | String? get abbr; 40 | 41 | /// A description of this option. 42 | String get help; 43 | 44 | /// The value this option will have if the user doesn't explicitly pass it in 45 | T get defaultsTo; 46 | 47 | /// The value this option 48 | T? get value { 49 | if (argResults!.wasParsed(name)) { 50 | return argResults![name] as T?; 51 | } 52 | return defaultsTo; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | example 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | $(FLUTTER_BUILD_NAME) 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UISupportedInterfaceOrientations 30 | 31 | UIInterfaceOrientationPortrait 32 | UIInterfaceOrientationLandscapeLeft 33 | UIInterfaceOrientationLandscapeRight 34 | 35 | UISupportedInterfaceOrientations~ipad 36 | 37 | UIInterfaceOrientationPortrait 38 | UIInterfaceOrientationPortraitUpsideDown 39 | UIInterfaceOrientationLandscapeLeft 40 | UIInterfaceOrientationLandscapeRight 41 | 42 | UIViewControllerBasedStatusBarAppearance 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /lib/src/arg/class.dart: -------------------------------------------------------------------------------- 1 | import 'arg.dart'; 2 | 3 | class Class extends Argument { 4 | @override 5 | String get abbr => 'c'; 6 | 7 | @override 8 | String get defaultsTo => 'Assets'; 9 | 10 | @override 11 | String get help => 'The name of const Class'; 12 | 13 | @override 14 | String get name => 'class'; 15 | 16 | String? go(String rule, String prefix) { 17 | String input = prefix + value!; 18 | //upperCamelCase 19 | if (rule == 'ucc') { 20 | if (input.length > 1) { 21 | input = input[0].toUpperCase() + input.substring(1); 22 | input = input.replaceAllMapped(RegExp(r'_([A-z])'), (Match match) { 23 | return match.group(0)!.replaceAll('_', '').toUpperCase(); 24 | }).replaceAll('_', ''); 25 | } else { 26 | input = input.toUpperCase(); 27 | } 28 | } 29 | //lowercaseCamelCase 30 | else if (rule == 'lcc') { 31 | if (input.length > 1) { 32 | input = input[0].toLowerCase() + input.substring(1); 33 | input = input.replaceAllMapped(RegExp(r'_([A-z])'), (Match match) { 34 | return match.group(0)!.replaceAll('_', '').toUpperCase(); 35 | }).replaceAll('_', ''); 36 | } else { 37 | input = input.toLowerCase(); 38 | } 39 | } 40 | //lowercase_with_underscores 41 | else if (rule == 'lwu') { 42 | if (input.length > 1) { 43 | input = input[0].toLowerCase() + input.substring(1); 44 | input = input.replaceAllMapped(RegExp('([a-z])([A-Z])'), (Match match) { 45 | return '${match.group(0)![0]}_${match.group(0)![1].toLowerCase()}'; 46 | }); 47 | } else { 48 | input = input.toLowerCase(); 49 | } 50 | } 51 | 52 | return input; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /example/module_b/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: module_b 2 | description: "A new Flutter package project." 3 | version: 0.0.1 4 | homepage: 5 | 6 | environment: 7 | sdk: ^3.6.2 8 | flutter: ">=1.17.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | flutter_lints: ^5.0.0 18 | 19 | # For information on the generic Dart part of this file, see the 20 | # following page: https://dart.dev/tools/pub/pubspec 21 | 22 | # The following section is specific to Flutter packages. 23 | flutter: 24 | 25 | # To add assets to your package, add an assets section, like this: 26 | # assets: 27 | # - images/a_dot_burr.jpeg 28 | # - images/a_dot_ham.jpeg 29 | # 30 | # For details regarding assets in packages, see 31 | # https://flutter.dev/to/asset-from-package 32 | # 33 | # An image asset can refer to one or more resolution-specific "variants", see 34 | # https://flutter.dev/to/resolution-aware-images 35 | 36 | # To add custom fonts to your package, add a fonts section here, 37 | # in this "flutter" section. Each entry in this list should have a 38 | # "family" key with the font family name, and a "fonts" key with a 39 | # list giving the asset and other descriptors for the font. For 40 | # example: 41 | # fonts: 42 | # - family: Schyler 43 | # fonts: 44 | # - asset: fonts/Schyler-Regular.ttf 45 | # - asset: fonts/Schyler-Italic.ttf 46 | # style: italic 47 | # - family: Trajan Pro 48 | # fonts: 49 | # - asset: fonts/TrajanPro.ttf 50 | # - asset: fonts/TrajanPro_Bold.ttf 51 | # weight: 700 52 | # 53 | # For details regarding fonts in packages, see 54 | # https://flutter.dev/to/font-from-package 55 | -------------------------------------------------------------------------------- /example/module_assets/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: module_assets 2 | description: "A new Flutter package project." 3 | version: 0.0.1 4 | homepage: 5 | 6 | environment: 7 | sdk: ^3.6.2 8 | flutter: ">=1.17.0" 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | dev_dependencies: 15 | flutter_test: 16 | sdk: flutter 17 | flutter_lints: ^5.0.0 18 | 19 | # For information on the generic Dart part of this file, see the 20 | # following page: https://dart.dev/tools/pub/pubspec 21 | 22 | # The following section is specific to Flutter packages. 23 | flutter: 24 | 25 | # To add assets to your package, add an assets section, like this: 26 | # assets: 27 | # - images/a_dot_burr.jpeg 28 | # - images/a_dot_ham.jpeg 29 | # 30 | # For details regarding assets in packages, see 31 | # https://flutter.dev/to/asset-from-package 32 | # 33 | # An image asset can refer to one or more resolution-specific "variants", see 34 | # https://flutter.dev/to/resolution-aware-images 35 | 36 | # To add custom fonts to your package, add a fonts section here, 37 | # in this "flutter" section. Each entry in this list should have a 38 | # "family" key with the font family name, and a "fonts" key with a 39 | # list giving the asset and other descriptors for the font. For 40 | # example: 41 | # fonts: 42 | # - family: Schyler 43 | # fonts: 44 | # - asset: fonts/Schyler-Regular.ttf 45 | # - asset: fonts/Schyler-Italic.ttf 46 | # style: italic 47 | # - family: Trajan Pro 48 | # fonts: 49 | # - asset: fonts/TrajanPro.ttf 50 | # - asset: fonts/TrajanPro_Bold.ttf 51 | # weight: 700 52 | # 53 | # For details regarding fonts in packages, see 54 | # https://flutter.dev/to/font-from-package 55 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .packages 28 | .pub-cache/ 29 | .pub/ 30 | /build/ 31 | **/Flutter/ephemeral 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Generated.xcconfig 62 | **/ios/Flutter/app.flx 63 | **/ios/Flutter/app.zip 64 | **/ios/Flutter/flutter_assets/ 65 | **/ios/ServiceDefinitions.json 66 | **/ios/Runner/GeneratedPluginRegistrant.* 67 | 68 | # Exceptions to above rules. 69 | !**/ios/**/default.mode1v3 70 | !**/ios/**/default.mode2v3 71 | !**/ios/**/default.pbxuser 72 | !**/ios/**/default.perspectivev3 73 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages 74 | 75 | /lib/assets.preview.dart 76 | \lib\assets.preview.dart 77 | -------------------------------------------------------------------------------- /example/module_a/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .flutter-plugins 27 | .flutter-plugins-dependencies 28 | .packages 29 | .pub-cache/ 30 | .pub/ 31 | build/ 32 | 33 | # Android related 34 | **/android/**/gradle-wrapper.jar 35 | **/android/.gradle 36 | **/android/captures/ 37 | **/android/gradlew 38 | **/android/gradlew.bat 39 | **/android/local.properties 40 | **/android/**/GeneratedPluginRegistrant.java 41 | 42 | # iOS/XCode related 43 | **/ios/**/*.mode1v3 44 | **/ios/**/*.mode2v3 45 | **/ios/**/*.moved-aside 46 | **/ios/**/*.pbxuser 47 | **/ios/**/*.perspectivev3 48 | **/ios/**/*sync/ 49 | **/ios/**/.sconsign.dblite 50 | **/ios/**/.tags* 51 | **/ios/**/.vagrant/ 52 | **/ios/**/DerivedData/ 53 | **/ios/**/Icon? 54 | **/ios/**/Pods/ 55 | **/ios/**/.symlinks/ 56 | **/ios/**/profile 57 | **/ios/**/xcuserdata 58 | **/ios/.generated/ 59 | **/ios/Flutter/App.framework 60 | **/ios/Flutter/Flutter.framework 61 | **/ios/Flutter/Flutter.podspec 62 | **/ios/Flutter/Generated.xcconfig 63 | **/ios/Flutter/app.flx 64 | **/ios/Flutter/app.zip 65 | **/ios/Flutter/flutter_assets/ 66 | **/ios/Flutter/flutter_export_environment.sh 67 | **/ios/ServiceDefinitions.json 68 | **/ios/Runner/GeneratedPluginRegistrant.* 69 | 70 | # Exceptions to above rules. 71 | !**/ios/**/default.mode1v3 72 | !**/ios/**/default.mode2v3 73 | !**/ios/**/default.pbxuser 74 | !**/ios/**/default.perspectivev3 75 | 76 | /lib/assets.preview.dart 77 | \lib\assets.preview.dart -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion 29 30 | 31 | sourceSets { 32 | main.java.srcDirs += 'src/main/kotlin' 33 | } 34 | 35 | lintOptions { 36 | disable 'InvalidPackage' 37 | } 38 | 39 | defaultConfig { 40 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 41 | applicationId "com.example.example" 42 | minSdkVersion 16 43 | targetSdkVersion 29 44 | versionCode flutterVersionCode.toInteger() 45 | versionName flutterVersionName 46 | } 47 | 48 | buildTypes { 49 | release { 50 | // TODO: Add your own signing config for the release build. 51 | // Signing with the debug keys for now, so `flutter run --release` works. 52 | signingConfig signingConfigs.debug 53 | } 54 | } 55 | } 56 | 57 | flutter { 58 | source '../..' 59 | } 60 | 61 | dependencies { 62 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 63 | } 64 | -------------------------------------------------------------------------------- /lib/src/arg/rule.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_print 2 | 3 | import 'arg.dart'; 4 | 5 | class Rule extends Argument { 6 | @override 7 | String get abbr => 'r'; 8 | 9 | @override 10 | String get defaultsTo => 'lwu'; 11 | 12 | @override 13 | String get help => 14 | 'The rule for the names of assets\' consts\n"lwu"(lowercase_with_underscores) : "assets_images_xxx_jpg" \n"uwu"(uppercase_with_underscores) : "ASSETS_IMAGES_XXX_JPG" \n"lcc"(lowerCamelCase) : "assetsImagesXxxJpg" \n'; 15 | 16 | @override 17 | String get name => 'rule'; 18 | 19 | String go(String input) { 20 | //uppercase_with_underscores 21 | if (value == 'uwu') { 22 | return input.toUpperCase(); 23 | } 24 | //lowerCamelCase 25 | else if (value == 'lcc') { 26 | return input.replaceAllMapped(RegExp(r'_([A-z])'), (Match match) { 27 | return match.group(0)!.replaceAll('_', '').toUpperCase(); 28 | }).replaceAll('_', ''); 29 | } 30 | //lowercase_with_underscores 31 | else { 32 | return input.toLowerCase(); 33 | } 34 | } 35 | } 36 | 37 | void regExpTest() { 38 | // const String string = '{name : aName, hobby : [fishing, playing_guitar]}'; 39 | // final String newString = 40 | // string.replaceAllMapped(RegExp(r'\b\w+\b'), (Match match) { 41 | // return '"${match.group(0)}"'; 42 | // }); 43 | 44 | // //{"name" : "aName", "hobby" : ["fishing", "playing_guitar"]} 45 | // print(newString); 46 | 47 | // const String string = 'assets_images_xxx_jpg'; 48 | 49 | // final String newString = 50 | // string.replaceAllMapped(RegExp('_([A-z])'), (Match match) { 51 | // return match.group(0).replaceAll('_', '').toUpperCase(); 52 | // }); 53 | 54 | // //assetsImagesXxxJpg 55 | // print(newString); 56 | 57 | const String string = 'assetsImagesXxxJpg'; 58 | 59 | final String newString = 60 | string.replaceAllMapped(RegExp('([a-z])([A-Z])'), (Match match) { 61 | return '${match.group(0)![0]}_${match.group(0)![1].toLowerCase()}'; 62 | }); 63 | 64 | // assets_images_xxx_jpg 65 | print(newString); 66 | } 67 | -------------------------------------------------------------------------------- /lib/src/format.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io' as io show File; 2 | 3 | import 'package:dart_style/dart_style.dart'; 4 | import 'package:path/path.dart' as p; 5 | import 'package:pub_semver/pub_semver.dart'; 6 | import 'package:yaml/yaml.dart' show loadYaml; 7 | 8 | import 'template.dart' show headerFormatOff; 9 | 10 | class _Config { 11 | const _Config(this.sdk, this.pageWidth); 12 | 13 | final VersionRange? sdk; 14 | final int? pageWidth; 15 | } 16 | 17 | /// The formatter will only use the tall-style if the SDK constraint is ^3.7.0. 18 | DartFormatter _buildDartFormatter({ 19 | required VersionRange? sdk, 20 | required int? pageWidth, 21 | }) { 22 | return DartFormatter( 23 | languageVersion: sdk?.min ?? DartFormatter.latestLanguageVersion, 24 | pageWidth: pageWidth, 25 | ); 26 | } 27 | 28 | String formatDart( 29 | String content, 30 | String directory, 31 | ) { 32 | try { 33 | final _Config config = _readConfig(directory); 34 | final DartFormatter formatter = 35 | _buildDartFormatter(sdk: config.sdk, pageWidth: config.pageWidth); 36 | // Append headerFormatOff to avoid format again externally. 37 | return '$headerFormatOff\n${formatter.format(content)}'; 38 | } catch (e) { 39 | return content; 40 | } 41 | } 42 | 43 | _Config _readConfig(String directory) { 44 | final io.File pubspecFile = io.File(p.join(directory, 'pubspec.yaml')); 45 | final Map? pubspecSource = pubspecFile.existsSync() 46 | ? loadYaml(pubspecFile.readAsStringSync()) as Map? 47 | : null; 48 | final VersionRange? sdk; 49 | final String? rawSdk = pubspecSource?['environment']?['sdk'] as String?; 50 | if (rawSdk != null) { 51 | sdk = VersionConstraint.parse(rawSdk) as VersionRange; 52 | } else { 53 | sdk = null; 54 | } 55 | 56 | final io.File analysisFile = 57 | io.File(p.join(directory, 'analysis_options.yaml')); 58 | final Map? analysisSource = analysisFile.existsSync() 59 | ? loadYaml(analysisFile.readAsStringSync()) as Map? 60 | : null; 61 | final int? pageWidth = analysisSource?['formatter']?['page_width'] as int?; 62 | return _Config(sdk, pageWidth); 63 | } 64 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 6 | 13 | 17 | 21 | 26 | 30 | 31 | 32 | 33 | 34 | 35 | 37 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 4.0.4+1 2 | 3 | * Improve output file headers. 4 | 5 | ## 4.0.4 6 | 7 | * Append format off header after formatted. 8 | 9 | ## 4.0.3 10 | 11 | * Bump `mime` to allow v2. 12 | 13 | ## 4.0.2 14 | 15 | * Bump `dart_style` to ^2.3.8 for latest formatting fixes and improvements. 16 | * Bump `build_runner_core` to allow v9 & v10. 17 | * Raise the minimum Dart SDK to 3.0. 18 | 19 | ## 3.3.3 20 | 21 | * Add coverage and format ignore directives to generated code. 22 | 23 | ## 3.3.1 24 | 25 | * Support reading 'page_width' from analysis_options.yaml to control formatter page width. 26 | 27 | ## 3.3.0 28 | 29 | * add 'root-package', Specify which package should be treated as the root project (by package name) for workspace 30 | 31 | ## 3.2.3 32 | 33 | * add 'use-key-name', Whether to use keyName style (packages/{package}/...) for asset paths. 34 | 35 | ## 3.1.0 36 | 37 | * ignore: eol_at_end_of_file for preview file 38 | 39 | ## 3.0.9 40 | 41 | * ignore: dangling_library_doc_comments for preview file 42 | 43 | ## 3.0.8 44 | 45 | * It will not clean 'assets tag' in yaml if there are not assets. 46 | 47 | ## 3.0.7 48 | 49 | * add 'package-ignore', the regular to ignore some packages. 50 | 51 | ## 3.0.6 52 | 53 | * add 'g-suffix', whether the generated file is end with .g 54 | 55 | ## 3.0.5 56 | 57 | * add 'class-prefix', Whether use package name as prefix for the name of const Class 58 | 59 | ## 3.0.4 60 | 61 | * Support image preview 62 | 63 | ## 3.0.3 64 | 65 | * Add '--package' command 66 | 67 | ## 3.0.2 68 | 69 | * Add ignore_for_file: constant_identifier_names for generated file 70 | 71 | ## 3.0.1 72 | 73 | * Fix null safety error 74 | 75 | ## 3.0.0 76 | 77 | * Null safety 78 | 79 | ## 2.3.0 80 | 81 | * Add '--folder-array' command 82 | 83 | ## 2.2.0 84 | 85 | * Add '--const-array' command 86 | 87 | ## 2.1.2 88 | 89 | * Fix --no-watch not working 90 | 91 | ## 2.1.1 92 | 93 | * Fix '# assets start' position 94 | 95 | ## 2.1.0 96 | 97 | * Add '--const-ignore' command 98 | 99 | ## 2.0.9 100 | 101 | * Take care of empty assets 102 | 103 | ## 2.0.8 104 | 105 | * Format yaml 106 | 107 | ## 2.0.7 108 | 109 | * Fix indent in yaml 110 | 111 | ## 2.0.6 112 | 113 | * Delete consts file and clean yaml when assets are empty 114 | 115 | ## 2.0.5 116 | 117 | * Add license into yaml 118 | * Fix yaml error 119 | * Sort assets 120 | 121 | ## 2.0.4 122 | 123 | * Remove resolution image assets from yaml 124 | 125 | ## 2.0.3 126 | 127 | * Fix generate resolution image assets's consts 128 | 129 | ## 2.0.2 130 | 131 | * Fix generate file when assets is empty 132 | * Fix error on windows 133 | 134 | ## 2.0.0 135 | 136 | * Support watch 137 | * Support generate consts 138 | 139 | ## 1.1.1 140 | 141 | * Handle yaml has no assets node 142 | 143 | ## 1.0.0 144 | 145 | * Initial version, created by Stagehand 146 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "20x20", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-App-20x20@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "20x20", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-App-20x20@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "29x29", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-App-29x29@1x.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "29x29", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-App-29x29@2x.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "29x29", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-App-29x29@3x.png", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "size" : "40x40", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-App-40x40@2x.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "40x40", 41 | "idiom" : "iphone", 42 | "filename" : "Icon-App-40x40@3x.png", 43 | "scale" : "3x" 44 | }, 45 | { 46 | "size" : "60x60", 47 | "idiom" : "iphone", 48 | "filename" : "Icon-App-60x60@2x.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "60x60", 53 | "idiom" : "iphone", 54 | "filename" : "Icon-App-60x60@3x.png", 55 | "scale" : "3x" 56 | }, 57 | { 58 | "size" : "20x20", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-App-20x20@1x.png", 61 | "scale" : "1x" 62 | }, 63 | { 64 | "size" : "20x20", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-App-20x20@2x.png", 67 | "scale" : "2x" 68 | }, 69 | { 70 | "size" : "29x29", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-App-29x29@1x.png", 73 | "scale" : "1x" 74 | }, 75 | { 76 | "size" : "29x29", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-App-29x29@2x.png", 79 | "scale" : "2x" 80 | }, 81 | { 82 | "size" : "40x40", 83 | "idiom" : "ipad", 84 | "filename" : "Icon-App-40x40@1x.png", 85 | "scale" : "1x" 86 | }, 87 | { 88 | "size" : "40x40", 89 | "idiom" : "ipad", 90 | "filename" : "Icon-App-40x40@2x.png", 91 | "scale" : "2x" 92 | }, 93 | { 94 | "size" : "76x76", 95 | "idiom" : "ipad", 96 | "filename" : "Icon-App-76x76@1x.png", 97 | "scale" : "1x" 98 | }, 99 | { 100 | "size" : "76x76", 101 | "idiom" : "ipad", 102 | "filename" : "Icon-App-76x76@2x.png", 103 | "scale" : "2x" 104 | }, 105 | { 106 | "size" : "83.5x83.5", 107 | "idiom" : "ipad", 108 | "filename" : "Icon-App-83.5x83.5@2x.png", 109 | "scale" : "2x" 110 | }, 111 | { 112 | "size" : "1024x1024", 113 | "idiom" : "ios-marketing", 114 | "filename" : "Icon-App-1024x1024@1x.png", 115 | "scale" : "1x" 116 | } 117 | ], 118 | "info" : { 119 | "version" : 1, 120 | "author" : "xcode" 121 | } 122 | } 123 | -------------------------------------------------------------------------------- /lib/src/watcher.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_print 2 | 3 | import 'dart:async'; 4 | import 'dart:io'; 5 | 6 | import 'package:io/ansi.dart'; 7 | 8 | typedef AssetsChanged = void Function(); 9 | 10 | class Watcher { 11 | Watcher(this.dirList, this.assetsChanged); 12 | 13 | Watcher.single(Directory dir, this.assetsChanged) 14 | : dirList = [dir]; 15 | 16 | /// all of the directory with yaml. 17 | final List dirList; 18 | 19 | final AssetsChanged assetsChanged; 20 | 21 | bool _watching = false; 22 | 23 | /// when the directory is change 24 | /// refresh the code 25 | StreamSubscription? _watch(FileSystemEntity file) { 26 | if (FileSystemEntity.isWatchSupported) { 27 | return file.watch().listen((FileSystemEvent data) { 28 | if (data.isDirectory) { 29 | final Directory directory = Directory(data.path); 30 | 31 | if (data.type == FileSystemEvent.delete) { 32 | if (watchMap.containsKey(directory)) { 33 | watchMap[watchMap as FileSystemEntity]!.cancel(); 34 | } 35 | dirList.remove(directory); 36 | } 37 | //empty directory 38 | else if (directory.listSync().isEmpty) { 39 | return; 40 | } 41 | //watch new directory 42 | else { 43 | _watch(directory); 44 | dirList.add(directory); 45 | } 46 | } 47 | String? msg; 48 | switch (data.type) { 49 | case FileSystemEvent.create: 50 | msg = green.wrap('create'); 51 | case FileSystemEvent.delete: 52 | msg = red.wrap('delete'); 53 | case FileSystemEvent.move: 54 | msg = yellow.wrap('move'); 55 | case FileSystemEvent.modify: 56 | break; 57 | case FileSystemEvent.all: 58 | msg = yellow.wrap('operate'); 59 | default: 60 | } 61 | if (msg != null) { 62 | print('\n$msg ${data.path}.\n'); 63 | assetsChanged.call(); 64 | } 65 | }); 66 | } 67 | return null; 68 | } 69 | 70 | /// watch all of path 71 | Future startWatch() async { 72 | if (_watching) { 73 | return; 74 | } 75 | _watching = true; 76 | for (final Directory dir in dirList) { 77 | final StreamSubscription? sub = _watch(dir); 78 | if (sub != null) { 79 | sub.onDone(sub.cancel); 80 | } 81 | watchMap[dir] = sub; 82 | } 83 | 84 | print('watching ${dirList.first.path} !\n'); 85 | //print('For a more detailed help message, press "-h". To quit, press "-q".'); 86 | } 87 | 88 | void stopWatch() { 89 | _watching = false; 90 | for (final StreamSubscription? v in watchMap.values) { 91 | v!.cancel(); 92 | } 93 | 94 | watchMap.clear(); 95 | } 96 | 97 | Map?> watchMap = 98 | ?>{}; 99 | 100 | void removeAllWatches() { 101 | for (final StreamSubscription? sub in watchMap.values) { 102 | sub?.cancel(); 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /README-ZH.md: -------------------------------------------------------------------------------- 1 | # assets_generator 2 | 3 | 用于自动生成 assets 配置 (yaml) 以及 consts 的工具,支持单项目和多模块。 4 | 5 | [![pub package](https://img.shields.io/pub/v/assets_generator.svg)](https://pub.dartlang.org/packages/assets_generator) [![GitHub stars](https://img.shields.io/github/stars/fluttercandies/assets_generator)](https://github.com/fluttercandies/assets_generator/stargazers) [![GitHub forks](https://img.shields.io/github/forks/fluttercandies/assets_generator)](https://github.com/fluttercandies/assets_generator/network) [![GitHub license](https://img.shields.io/github/license/fluttercandies/assets_generator)](https://github.com/fluttercandies/assets_generator/blob/master/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/fluttercandies/assets_generator)](https://github.com/fluttercandies/assets_generator/issues) ![FlutterCandies QQ 群](https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Ffluttercandies%2F.github%2Frefs%2Fheads%2Fmain%2Fdata.yml&query=%24.qq_group_number&label=QQ%E7%BE%A4&logo=qq&color=1DACE8) 6 | 7 | ![](assets_generator.gif) 8 | 9 | Languages: [English](README.md) | 中文简体 10 | 11 | - [assets_generator](#assets_generator) 12 | - [使用](#使用) 13 | - [环境准备](#环境准备) 14 | - [激活 assets_generator](#激活-assets_generator) 15 | - [操作命令](#操作命令) 16 | - [帮助命令](#帮助命令) 17 | - [生成命令的例子](#生成命令的例子) 18 | - [全部命令](#全部命令) 19 | - [Dart](#dart) 20 | - [在单个项目中使用](#在单个项目中使用) 21 | - [在模块中使用](#在模块中使用) 22 | 23 | ## 使用 24 | 25 | ### 环境准备 26 | 27 | 把 pub bin 的路径放到你的系统路径中。 28 | 29 | | Platform | Cache location | 30 | | -------------- | :---------------------: | 31 | | macOS or Linux | $HOME/.pub-cache/bin | 32 | | Windows* | %APPDATA%\Pub\Cache\bin | 33 | 34 | [pub global](https://dart.dev/tools/pub/cmd/pub-global) 35 | 36 | ### 激活 assets_generator 37 | 38 | 执行 `dart pub global activate assets_generator` 39 | 40 | ### 操作命令 41 | 42 | #### 帮助命令 43 | 44 | `agen -h` 45 | 46 | #### 生成命令的例子 47 | 48 | `agen -t d -s -r lwu` 49 | 50 | #### 全部命令 51 | 52 | ``` markdown 53 | -h, --[no-]help 显示帮助信息 54 | -p, --path Flutter 项目的根路径 55 | (默认 ".") 56 | -f, --folder assets 文件夹的名字 57 | (默认 "assets") 58 | -w, --[no-]watch 是否继续监听 assets 的变化 59 | (默认 开启) 60 | -t, --type pubsepec.yaml 生成配置的类型 61 | "d" 代表以文件夹方式生成 "- assets/images/" 62 | "f" 代表以文件方式生成 "- assets/images/xxx.jpg" 63 | (默认 "d") 64 | -s, --[no-]save 是否保存命令到本地 65 | 如果执行 "agen" 不带任何命令,将优先使用本地的命令进行执行 66 | -o, --out const 类放置的位置 67 | (默认放置在 "lib" 下面) 68 | -r, --rule consts 的名字的命名规范 69 | "lwu"(小写带下划线) : "assets_images_xxx_jpg" 70 | "uwu"(大写带下划线) : "ASSETS_IMAGES_XXX_JPG" 71 | "lcc"(小驼峰) : "assetsImagesXxxJpg" 72 | (默认 "lwu") 73 | -c, --class const 类的名字 74 | (默认 "Assets") 75 | --const-ignore 使用正则表达式忽略一些const(不是全部const都希望生成) 76 | ``` 77 | 78 | ### Dart 79 | 80 | #### 在单个项目中使用 81 | 82 | ``` dart 83 | Image.asset(Assets.assets_images_xxx_jpg); 84 | ``` 85 | 86 | #### 在模块中使用 87 | 88 | ``` dart 89 | Image.asset( 90 | Assets.assets_images_xxx_jpg, 91 | package: Assets.package, 92 | ); 93 | ``` -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: A new Flutter application. 3 | 4 | # The following defines the version and build number for your application. 5 | # A version number is three numbers separated by dots, like 1.2.43 6 | # followed by an optional build number separated by a +. 7 | # Both the version and the builder number may be overridden in flutter 8 | # build by specifying --build-name and --build-number, respectively. 9 | # In Android, build-name is used as versionName while build-number used as versionCode. 10 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 11 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion. 12 | # Read more about iOS versioning at 13 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 14 | version: 1.0.0+1 15 | publish_to: none 16 | 17 | environment: 18 | sdk: ^3.0.0 19 | 20 | dependencies: 21 | flutter: 22 | sdk: flutter 23 | 24 | # The following adds the Cupertino Icons font to your application. 25 | # Use with the CupertinoIcons class for iOS style icons. 26 | module_a: 27 | path: module_a 28 | cupertino_icons: any 29 | # The "flutter_lints" package below contains a set of recommended lints to 30 | # encourage good coding practices. The lint set provided by the package is 31 | # activated in the `analysis_options.yaml` file located at the root of your 32 | # package. See that file for information about deactivating specific lint 33 | # rules and activating additional ones. 34 | flutter_lints: any 35 | module_assets: 36 | path: module_assets 37 | 38 | dev_dependencies: 39 | flutter_test: 40 | sdk: flutter 41 | 42 | # For information on the generic Dart part of this file, see the 43 | # following page: https://dart.dev/tools/pub/pubspec 44 | 45 | # The following section is specific to Flutter. 46 | flutter: 47 | 48 | # The following line ensures that the Material Icons font is 49 | # included with your application, so that you can use the icons in 50 | # the material Icons class. 51 | uses-material-design: true 52 | 53 | # To add assets to your application, add an assets section, like this: 54 | 55 | 56 | # An image asset can refer to one or more resolution-specific "variants", see 57 | # https://flutter.dev/assets-and-images/#resolution-aware. 58 | 59 | # For details regarding adding assets from package dependencies, see 60 | # https://flutter.dev/assets-and-images/#from-packages 61 | 62 | # To add custom fonts to your application, add a fonts section here, 63 | # in this "flutter" section. Each entry in this list should have a 64 | # "family" key with the font family name, and a "fonts" key with a 65 | # list giving the asset and other descriptors for the font. For 66 | # example: 67 | # fonts: 68 | # - family: Schyler 69 | # fonts: 70 | # - asset: fonts/Schyler-Regular.ttf 71 | # - asset: fonts/Schyler-Italic.ttf 72 | # style: italic 73 | # - family: Trajan Pro 74 | # fonts: 75 | # - asset: fonts/TrajanPro.ttf 76 | # - asset: fonts/TrajanPro_Bold.ttf 77 | # weight: 700 78 | # 79 | # For details regarding fonts from package dependencies, 80 | # see https://flutter.dev/custom-fonts/#from-packages 81 | assets: 82 | 83 | # assets start 84 | 85 | # GENERATED CODE - DO NOT MODIFY MANUALLY 86 | # ************************************************************************** 87 | # Auto generated by https://github.com/fluttercandies/assets_generator 88 | # ************************************************************************** 89 | 90 | - assets/dd.txt 91 | - assets/images/flutter_candies_logo.png 92 | - assets/test.txt 93 | 94 | # assets end -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # assets_generator 2 | 3 | The flutter tool to generate assets‘s configs(yaml) and consts automatically for single project and multiple modules. 4 | 5 | [![pub package](https://img.shields.io/pub/v/assets_generator.svg)](https://pub.dartlang.org/packages/assets_generator) [![GitHub stars](https://img.shields.io/github/stars/fluttercandies/assets_generator)](https://github.com/fluttercandies/assets_generator/stargazers) [![GitHub forks](https://img.shields.io/github/forks/fluttercandies/assets_generator)](https://github.com/fluttercandies/assets_generator/network) [![GitHub license](https://img.shields.io/github/license/fluttercandies/assets_generator)](https://github.com/fluttercandies/assets_generator/blob/master/LICENSE) [![GitHub issues](https://img.shields.io/github/issues/fluttercandies/assets_generator)](https://github.com/fluttercandies/assets_generator/issues) ![FlutterCandies QQ 群](https://img.shields.io/badge/dynamic/yaml?url=https%3A%2F%2Fraw.githubusercontent.com%2Ffluttercandies%2F.github%2Frefs%2Fheads%2Fmain%2Fdata.yml&query=%24.qq_group_number&label=QQ%E7%BE%A4&logo=qq&color=1DACE8) 6 | 7 | ![](assets_generator.gif) 8 | 9 | Languages: English | [中文简体](README-ZH.md) 10 | 11 | - [assets_generator](#assets_generator) 12 | - [Usage](#usage) 13 | - [Environment](#environment) 14 | - [Activate assets_generator](#activate-assets_generator) 15 | - [Command](#command) 16 | - [Help](#help) 17 | - [Demo](#demo) 18 | - [All Commands](#all-commands) 19 | - [Dart](#dart) 20 | - [Work in Project](#work-in-project) 21 | - [Work in Modules](#work-in-modules) 22 | 23 | ## Usage 24 | 25 | ### Environment 26 | 27 | you need to add pub bin path into your system path. 28 | 29 | | Platform | Cache location | 30 | | -------------- | :---------------------: | 31 | | macOS or Linux | $HOME/.pub-cache/bin | 32 | | Windows* | %APPDATA%\Pub\Cache\bin | 33 | 34 | [pub global](https://dart.dev/tools/pub/cmd/pub-global) 35 | 36 | ### Activate assets_generator 37 | 38 | `dart pub global activate assets_generator` 39 | 40 | ### Command 41 | 42 | #### Help 43 | 44 | `agen -h` 45 | 46 | #### Demo 47 | 48 | `agen -t d -s -r lwu` 49 | 50 | #### All Commands 51 | 52 | ``` markdown 53 | -h, --[no-]help Help usage 54 | -p, --path Flutter project root path 55 | (defaults to ".") 56 | -f, --folder The root folder of assets 57 | (defaults to "assets") 58 | -w, --[no-]watch Whether continue to monitor the changes of assets 59 | (defaults to on) 60 | -t, --type The type in pubsepec.yaml 61 | "d" means directory "- assets/images/" 62 | "f" means file "- assets/images/xxx.jpg" 63 | (defaults to "d") 64 | -s, --[no-]save Whether save the arguments into the local 65 | It will execute the local arguments if run "agen" without any arguments 66 | -o, --out The path of const Class 67 | (defaults to "lib") 68 | -r, --rule The rule for the names of assets' consts 69 | "lwu"(lowercase_with_underscores) : "assets_images_xxx_jpg" 70 | "uwu"(uppercase_with_underscores) : "ASSETS_IMAGES_XXX_JPG" 71 | "lcc"(lowerCamelCase) : "assetsImagesXxxJpg" 72 | (defaults to "lwu") 73 | -c, --class The name of const Class 74 | (defaults to "Assets") 75 | --const-ignore The regular to ignore some consts 76 | ``` 77 | 78 | ### Dart 79 | 80 | #### Work in Project 81 | 82 | ``` dart 83 | Image.asset(Assets.assets_images_xxx_jpg); 84 | ``` 85 | 86 | #### Work in Modules 87 | 88 | ``` dart 89 | Image.asset( 90 | Assets.assets_images_xxx_jpg, 91 | package: Assets.package, 92 | ); 93 | ``` -------------------------------------------------------------------------------- /bin/assets_generator.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_print 2 | 3 | import 'dart:io'; 4 | 5 | import 'package:assets_generator/args.dart'; 6 | import 'package:assets_generator/assets_generator.dart' show Generator; 7 | import 'package:build_runner_core/build_runner_core.dart'; 8 | import 'package:io/ansi.dart'; 9 | import 'package:path/path.dart'; 10 | 11 | const String argumentsFile = 'assets_generator_arguments'; 12 | const String debugArguments = '-p example/ -t f --const-ignore .md'; 13 | 14 | Future main(List arguments) async { 15 | //arguments = debugArguments.split(' '); 16 | //regExpTest(); 17 | bool runFromLocal = false; 18 | // debug 19 | // ignore: dead_code 20 | if (false) { 21 | final File file = File(join('example', argumentsFile)); 22 | if (file.existsSync()) { 23 | final String content = '${file.readAsStringSync()} -p example'; 24 | arguments = content.split(' ').map((String e) => e.trim()).toList(); 25 | runFromLocal = true; 26 | } 27 | } 28 | if (arguments.isEmpty) { 29 | final File file = File(join('./', argumentsFile)); 30 | if (file.existsSync()) { 31 | final String content = file.readAsStringSync(); 32 | arguments = content.split(' ').map((String e) => e.trim()).toList(); 33 | runFromLocal = true; 34 | } 35 | } 36 | 37 | final Help help = Help(); 38 | final Path path = Path(); 39 | final Folder folder = Folder(); 40 | final Watch watch = Watch(); 41 | final Type type = Type(); 42 | final Save save = Save(); 43 | final Output output = Output(); 44 | final Rule rule = Rule(); 45 | final Class class1 = Class(); 46 | final ConstIgnore constIgnore = ConstIgnore(); 47 | final ConstArray constArray = ConstArray(); 48 | final FolderIgnore folderIgnore = FolderIgnore(); 49 | final Package package = Package(); 50 | final ClassPrefix classPrefix = ClassPrefix(); 51 | final GSuffix gSuffix = GSuffix(); 52 | final PackageIgnore packageIgnore = PackageIgnore(); 53 | final UseKeyName useKeyNameFlag = UseKeyName(); 54 | final RootPackage rootPackage = RootPackage(); 55 | 56 | parseArgs(arguments); 57 | if (arguments.isEmpty || help.value!) { 58 | print(green.wrap(parser.usage)); 59 | return; 60 | } 61 | RegExp? folderIgnoreRegExp; 62 | if (packageIgnore.value != null) { 63 | folderIgnoreRegExp = RegExp(packageIgnore.value!); 64 | } 65 | 66 | final PackageGraph packageGraph = path.value != null 67 | ? await PackageGraph.forPath(path.value!) 68 | : await PackageGraph.forThisPackage(); 69 | 70 | final bool isWatch = watch.value!; 71 | 72 | print('generate assets start'); 73 | 74 | final PackageNode rootNode = packageGraph.root; 75 | for (final PackageNode packageNode in packageGraph.allPackages.values.where( 76 | (PackageNode packageGraph) => 77 | packageGraph.dependencyType == DependencyType.path && 78 | packageGraph.path.startsWith(rootNode.path), 79 | )) { 80 | if (folderIgnoreRegExp != null && 81 | folderIgnoreRegExp.hasMatch(packageNode.name)) { 82 | continue; 83 | } 84 | Generator( 85 | packageGraph: packageNode, 86 | folder: folder.value, 87 | formatType: type.type(type.value), 88 | watch: isWatch, 89 | output: output.value, 90 | rule: rule, 91 | class1: class1, 92 | constIgnore: 93 | constIgnore.value != null ? RegExp(constIgnore.value!) : null, 94 | constArray: constArray.value, 95 | folderIgnore: 96 | folderIgnore.value != null ? RegExp(folderIgnore.value!) : null, 97 | package: package.value ?? false, 98 | useKeyName: useKeyNameFlag.value ?? false, 99 | classPrefix: classPrefix.value ?? false, 100 | gSuffix: gSuffix.value ?? false, 101 | rootPackageName: rootPackage.value, 102 | ).go(); 103 | } 104 | 105 | if (save.value! && !runFromLocal) { 106 | final File file = File(join('./', argumentsFile)); 107 | if (!file.existsSync()) { 108 | file.createSync(); 109 | } 110 | String argumentsS = ''; 111 | for (final String item in arguments) { 112 | argumentsS += '$item '; 113 | } 114 | file.writeAsStringSync(argumentsS.trim()); 115 | } 116 | if (!isWatch) { 117 | print('generate assets end'); 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /example/module_a/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | void main() => runApp(MyApp()); 4 | 5 | class MyApp extends StatelessWidget { 6 | // This widget is the root of your application. 7 | @override 8 | Widget build(BuildContext context) { 9 | return MaterialApp( 10 | title: 'Flutter Demo', 11 | theme: ThemeData( 12 | // This is the theme of your application. 13 | // 14 | // Try running your application with "flutter run". You'll see the 15 | // application has a blue toolbar. Then, without quitting the app, try 16 | // changing the primarySwatch below to Colors.green and then invoke 17 | // "hot reload" (press "r" in the console where you ran "flutter run", 18 | // or simply save your changes to "hot reload" in a Flutter IDE). 19 | // Notice that the counter didn't reset back to zero; the application 20 | // is not restarted. 21 | primarySwatch: Colors.blue, 22 | ), 23 | home: const MyHomePage(title: 'Flutter Demo Home Page'), 24 | ); 25 | } 26 | } 27 | 28 | class MyHomePage extends StatefulWidget { 29 | const MyHomePage({super.key, required this.title}); 30 | 31 | // This widget is the home page of your application. It is stateful, meaning 32 | // that it has a State object (defined below) that contains fields that affect 33 | // how it looks. 34 | 35 | // This class is the configuration for the state. It holds the values (in this 36 | // case the title) provided by the parent (in this case the App widget) and 37 | // used by the build method of the State. Fields in a Widget subclass are 38 | // always marked "final". 39 | 40 | final String title; 41 | 42 | @override 43 | State createState() => _MyHomePageState(); 44 | } 45 | 46 | class _MyHomePageState extends State { 47 | int _counter = 0; 48 | 49 | void _incrementCounter() { 50 | setState(() { 51 | // This call to setState tells the Flutter framework that something has 52 | // changed in this State, which causes it to rerun the build method below 53 | // so that the display can reflect the updated values. If we changed 54 | // _counter without calling setState(), then the build method would not be 55 | // called again, and so nothing would appear to happen. 56 | _counter++; 57 | }); 58 | } 59 | 60 | @override 61 | Widget build(BuildContext context) { 62 | // This method is rerun every time setState is called, for instance as done 63 | // by the _incrementCounter method above. 64 | // 65 | // The Flutter framework has been optimized to make rerunning build methods 66 | // fast, so that you can just rebuild anything that needs updating rather 67 | // than having to individually change instances of widgets. 68 | return Scaffold( 69 | appBar: AppBar( 70 | // Here we take the value from the MyHomePage object that was created by 71 | // the App.build method, and use it to set our appbar title. 72 | title: Text(widget.title), 73 | ), 74 | body: Center( 75 | // Center is a layout widget. It takes a single child and positions it 76 | // in the middle of the parent. 77 | child: Column( 78 | // Column is also layout widget. It takes a list of children and 79 | // arranges them vertically. By default, it sizes itself to fit its 80 | // children horizontally, and tries to be as tall as its parent. 81 | // 82 | // Invoke "debug painting" (press "p" in the console, choose the 83 | // "Toggle Debug Paint" action from the Flutter Inspector in Android 84 | // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) 85 | // to see the wireframe for each widget. 86 | // 87 | // Column has various properties to control how it sizes itself and 88 | // how it positions its children. Here we use mainAxisAlignment to 89 | // center the children vertically; the main axis here is the vertical 90 | // axis because Columns are vertical (the cross axis would be 91 | // horizontal). 92 | mainAxisAlignment: MainAxisAlignment.center, 93 | children: [ 94 | const Text('You have pushed the button this many times:'), 95 | Text('$_counter'), 96 | ], 97 | ), 98 | ), 99 | floatingActionButton: FloatingActionButton( 100 | onPressed: _incrementCounter, 101 | tooltip: 'Increment', 102 | child: const Icon(Icons.add), 103 | ), // This trailing comma makes auto-formatting nicer for build methods. 104 | ); 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import 'assets.dart'; 4 | 5 | void main() => runApp(const MyApp()); 6 | 7 | class MyApp extends StatelessWidget { 8 | const MyApp({super.key}); 9 | 10 | // This widget is the root of your application. 11 | @override 12 | Widget build(BuildContext context) { 13 | return MaterialApp( 14 | title: 'Flutter Demo', 15 | theme: ThemeData( 16 | // This is the theme of your application. 17 | // 18 | // Try running your application with "flutter run". You'll see the 19 | // application has a blue toolbar. Then, without quitting the app, try 20 | // changing the primarySwatch below to Colors.green and then invoke 21 | // "hot reload" (press "r" in the console where you ran "flutter run", 22 | // or simply save your changes to "hot reload" in a Flutter IDE). 23 | // Notice that the counter didn't reset back to zero; the application 24 | // is not restarted. 25 | primarySwatch: Colors.blue, 26 | ), 27 | home: const MyHomePage(title: 'Flutter Demo Home Page'), 28 | ); 29 | } 30 | } 31 | 32 | class MyHomePage extends StatefulWidget { 33 | const MyHomePage({super.key, required this.title}); 34 | 35 | // This widget is the home page of your application. It is stateful, meaning 36 | // that it has a State object (defined below) that contains fields that affect 37 | // how it looks. 38 | 39 | // This class is the configuration for the state. It holds the values (in this 40 | // case the title) provided by the parent (in this case the App widget) and 41 | // used by the build method of the State. Fields in a Widget subclass are 42 | // always marked "final". 43 | 44 | final String title; 45 | 46 | @override 47 | State createState() => _MyHomePageState(); 48 | } 49 | 50 | class _MyHomePageState extends State { 51 | int _counter = 0; 52 | 53 | void _incrementCounter() { 54 | setState(() { 55 | // This call to setState tells the Flutter framework that something has 56 | // changed in this State, which causes it to rerun the build method below 57 | // so that the display can reflect the updated values. If we changed 58 | // _counter without calling setState(), then the build method would not be 59 | // called again, and so nothing would appear to happen. 60 | _counter++; 61 | }); 62 | } 63 | 64 | @override 65 | Widget build(BuildContext context) { 66 | // This method is rerun every time setState is called, for instance as done 67 | // by the _incrementCounter method above. 68 | // 69 | // The Flutter framework has been optimized to make rerunning build methods 70 | // fast, so that you can just rebuild anything that needs updating rather 71 | // than having to individually change instances of widgets. 72 | return Scaffold( 73 | appBar: AppBar( 74 | // Here we take the value from the MyHomePage object that was created by 75 | // the App.build method, and use it to set our appbar title. 76 | title: Text(widget.title), 77 | ), 78 | body: Center( 79 | // Center is a layout widget. It takes a single child and positions it 80 | // in the middle of the parent. 81 | child: Column( 82 | // Column is also layout widget. It takes a list of children and 83 | // arranges them vertically. By default, it sizes itself to fit its 84 | // children horizontally, and tries to be as tall as its parent. 85 | // 86 | // Invoke "debug painting" (press "p" in the console, choose the 87 | // "Toggle Debug Paint" action from the Flutter Inspector in Android 88 | // Studio, or the "Toggle Debug Paint" command in Visual Studio Code) 89 | // to see the wireframe for each widget. 90 | // 91 | // Column has various properties to control how it sizes itself and 92 | // how it positions its children. Here we use mainAxisAlignment to 93 | // center the children vertically; the main axis here is the vertical 94 | // axis because Columns are vertical (the cross axis would be 95 | // horizontal). 96 | mainAxisAlignment: MainAxisAlignment.center, 97 | children: [ 98 | const Text( 99 | 'You have pushed the button this many times:', 100 | ), 101 | Text( 102 | '$_counter', 103 | ), 104 | Image.asset(Assets.assets_images_flutter_candies_logo_png), 105 | ], 106 | ), 107 | ), 108 | floatingActionButton: FloatingActionButton( 109 | onPressed: _incrementCounter, 110 | tooltip: 'Increment', 111 | child: const Icon(Icons.add), 112 | ), // This trailing comma makes auto-formatting nicer for build methods. 113 | ); 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /lib/src/yaml.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_print 2 | 3 | import 'dart:io'; 4 | 5 | import 'package:io/ansi.dart'; 6 | import 'package:path/path.dart'; 7 | import 'package:source_span/source_span.dart'; 8 | import 'package:yaml/yaml.dart'; 9 | 10 | import 'arg/type.dart'; 11 | 12 | const String license = ''' 13 | 14 | {0}# GENERATED CODE - DO NOT MODIFY MANUALLY 15 | {0}# ************************************************************************** 16 | {0}# Auto generated by https://github.com/fluttercandies/assets_generator 17 | {0}# ************************************************************************** 18 | 19 | '''; 20 | 21 | const String assetsStart = '# assets start'; 22 | const String assetsEnd = '# assets end'; 23 | const String space = ' '; 24 | 25 | class Yaml { 26 | Yaml( 27 | this.yamlFile, 28 | this.assets, 29 | this.miss, 30 | this.formatType, 31 | ); 32 | 33 | final File yamlFile; 34 | final List assets; 35 | final List miss; 36 | final FormatType formatType; 37 | 38 | void write() { 39 | if (formatType == FormatType.directory) { 40 | final List directories = []; 41 | for (final String asset in assets) { 42 | // resolution image assets miss main asset entry 43 | // It should define as a file 44 | if (miss.contains(asset)) { 45 | directories.add(asset); 46 | } else { 47 | final String d = '${dirname(asset)}/'; 48 | if (!directories.contains(d)) { 49 | directories.add(d); 50 | } 51 | } 52 | } 53 | assets.clear(); 54 | assets.addAll(directories); 55 | } 56 | 57 | assets.sort((String a, String b) => a.compareTo(b)); 58 | 59 | String yamlString = yamlFile.readAsStringSync(); 60 | 61 | final YamlMap yaml = loadYaml(yamlString) as YamlMap; 62 | 63 | final String indent = getIndent(yaml); 64 | 65 | final StringBuffer pubspecSb = StringBuffer(); 66 | if (assets.isNotEmpty) { 67 | pubspecSb.write('$indent$assetsStart\n'); 68 | pubspecSb.write(license.replaceAll('{0}', indent)); 69 | for (final String asset in assets) { 70 | pubspecSb.write('${indent * 2}- $asset\n'); 71 | } 72 | pubspecSb.write('\n$indent$assetsEnd'); 73 | } 74 | 75 | final String newAssets = pubspecSb.toString(); 76 | 77 | int start = yamlString.indexOf(assetsStart); 78 | if (start > -1) { 79 | final List lines = yamlString.split('\n'); 80 | final String line = 81 | lines.firstWhere((String element) => element.contains(assetsStart)); 82 | start = yamlString.indexOf(line); 83 | } 84 | final int end = yamlString.indexOf(assetsEnd); 85 | 86 | if (start > -1 && end > -1) { 87 | yamlString = 88 | yamlString.replaceRange(start, end + assetsEnd.length, newAssets); 89 | } else { 90 | final String assetsNodeS = 91 | assets.isEmpty ? '' : '\n${indent}assets:\n\n$newAssets'; 92 | 93 | if (yaml.containsKey('flutter')) { 94 | final YamlMap? flutter = yaml['flutter'] as YamlMap?; 95 | if (flutter != null) { 96 | if (flutter.containsKey('assets')) { 97 | final YamlList? assetsNode = flutter['assets'] as YamlList?; 98 | final FileSpan sourceSpan = (flutter.nodes.keys.firstWhere( 99 | (dynamic element) => 100 | element is YamlNode && element.span.text == 'assets', 101 | ) as YamlNode?) 102 | ?.span as FileSpan; 103 | 104 | final int start = sourceSpan.start.offset - sourceSpan.start.column; 105 | if (assetsNode != null) { 106 | final int end = assetsNode.nodes.last.span.end.offset; 107 | yamlString = yamlString.replaceRange( 108 | start, 109 | end, 110 | assets.isEmpty ? '' : '${indent}assets:\n\n$newAssets', 111 | ); 112 | } 113 | //Empty assets 114 | else { 115 | yamlString = yamlString.replaceRange( 116 | start, 117 | sourceSpan.end.offset + ':'.length, 118 | assetsNodeS, 119 | ); 120 | } 121 | } 122 | //miss assets: 123 | else { 124 | final int end = flutter.span.end.offset; 125 | yamlString = yamlString.replaceRange(end, end, assetsNodeS); 126 | } 127 | } 128 | //Empty flutter 129 | else { 130 | final int end = 131 | yamlString.lastIndexOf('flutter:') + 'flutter:'.length; 132 | yamlString = yamlString.replaceRange(end, end, assetsNodeS); 133 | } 134 | } 135 | //miss flutter: 136 | else { 137 | final int end = yaml.span.end.offset; 138 | yamlString = 139 | yamlString.replaceRange(end, end, '\nflutter:$assetsNodeS'); 140 | } 141 | } 142 | 143 | // if (assets.isEmpty) { 144 | // // make sure that there are no 'assets:' 145 | // yamlString = yamlString.replaceAll('assets:', '').trim(); 146 | // } 147 | 148 | yamlString = yamlString.trim(); 149 | 150 | yamlFile.writeAsStringSync(yamlString); 151 | print(green.wrap('${yamlFile.path} is changed automatically.')); 152 | } 153 | } 154 | 155 | String getIndent(YamlMap yamlMap) { 156 | if (yamlMap.containsKey('flutter')) { 157 | final YamlMap? flutter = yamlMap['flutter'] as YamlMap?; 158 | if (flutter != null && flutter.nodes.keys.first is YamlNode) { 159 | final SourceSpan sourceSpan = flutter.nodes.keys.first.span as SourceSpan; 160 | return space * sourceSpan.start.column; 161 | } 162 | } 163 | return space * 2; 164 | } 165 | -------------------------------------------------------------------------------- /lib/src/template.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:build_runner_core/build_runner_core.dart'; 4 | import 'package:mime/mime.dart'; 5 | import 'package:path/path.dart' as p; 6 | 7 | import '../args.dart'; 8 | 9 | const String headerFormatOff = '// dart format off'; 10 | const String headerLicense = '''// coverage:ignore-file 11 | // ignore_for_file: constant_identifier_names 12 | // 13 | // GENERATED CODE - DO NOT MODIFY MANUALLY 14 | // ************************************************************************** 15 | // Auto generated by https://github.com/fluttercandies/assets_generator 16 | // ************************************************************************** 17 | 18 | '''; 19 | 20 | String get classDeclare => 'abstract final class {0} {'; 21 | 22 | String get classDeclareFooter => '}\n'; 23 | 24 | String get constsArray => ''' 25 | final List {0} = [ 26 | {1}]; 27 | '''; 28 | 29 | const String previewTemplate1 = '''/// {@template assets_generator.{0}.preview} 30 | /// ![]({1}) 31 | /// {@endtemplate} 32 | 33 | '''; 34 | 35 | const String previewTemplate = '''/// {@macro assets_generator.{0}.preview} 36 | '''; 37 | 38 | const String mockClass = ''' 39 | // ignore_for_file: camel_case_types, unused_element, dangling_library_doc_comments, eol_at_end_of_file 40 | class _ {}'''; 41 | 42 | class Template { 43 | Template( 44 | this.assets, 45 | this.packageGraph, 46 | this.rule, 47 | this.class1, 48 | this.constIgnore, 49 | this.constArray, 50 | this.package, 51 | this.useKeyName, 52 | this.classPrefix, 53 | this.rootPackageName, 54 | ); 55 | 56 | final PackageNode? packageGraph; 57 | final List assets; 58 | final Rule? rule; 59 | final Class? class1; 60 | final RegExp? constIgnore; 61 | final bool? constArray; 62 | final bool package; 63 | final bool useKeyName; 64 | final bool classPrefix; 65 | final String? rootPackageName; 66 | 67 | Future generateFile( 68 | Map miss, 69 | File previewFile, 70 | ) async { 71 | final StringBuffer sb = StringBuffer(); 72 | sb.write(headerLicense); 73 | 74 | final StringBuffer arraySb = StringBuffer(); 75 | 76 | final String className = class1!.go( 77 | 'ucc', 78 | classPrefix ? packageGraph!.name : '', 79 | )!; 80 | 81 | sb.writeln(classDeclare.replaceAll('{0}', className)); 82 | 83 | // Determine if current package is root: use rootPackageName if provided, 84 | // otherwise fall back to packageGraph.isRoot 85 | final bool isRoot = rootPackageName != null 86 | ? packageGraph!.name == rootPackageName 87 | : packageGraph!.isRoot; 88 | 89 | if ((!isRoot || package) && !useKeyName) { 90 | sb.writeln(" static const String package = '${packageGraph!.name}';"); 91 | } 92 | 93 | final StringBuffer previewImageSb = StringBuffer(); 94 | for (final String asset in assets) { 95 | if (constIgnore != null && constIgnore!.hasMatch(asset)) { 96 | continue; 97 | } 98 | final String filedName = _formatFiledName(asset); 99 | String filePath = asset; 100 | if (miss.containsKey(asset)) { 101 | filePath = miss[asset]!; 102 | } 103 | 104 | final String? mimeType = lookupMimeType(asset); 105 | final bool isImage = mimeType != null && mimeType.startsWith('image/'); 106 | if (isImage) { 107 | // filePath uses POSIX-style separators in assets list; split and join 108 | // with platform-native separators so preview paths are correct on 109 | // Windows (\) and mac/Linux (/). 110 | final List segments = filePath.split('/'); 111 | final String localPath = 112 | p.joinAll([packageGraph!.path, ...segments]); 113 | 114 | previewImageSb.write( 115 | previewTemplate1 116 | .replaceAll('{0}', filedName) 117 | .replaceAll('{1}', localPath), 118 | ); 119 | } 120 | 121 | String comment = ''; 122 | if (isImage) { 123 | comment = previewTemplate.replaceAll('{0}', filedName); 124 | } 125 | 126 | // const value should be the generated path when useKeyName flag is set 127 | if (comment.isNotEmpty) { 128 | sb.write('\n $comment'); 129 | } 130 | sb.write( 131 | formatFiled( 132 | asset, 133 | (!isRoot || package) && useKeyName 134 | ? p.posix.join('packages', packageGraph!.name, asset) 135 | : asset, 136 | ), 137 | ); 138 | 139 | if (constArray!) { 140 | if (comment.isNotEmpty) { 141 | arraySb.write('\n $comment'); 142 | } 143 | arraySb.write(' $className.$filedName,\n'); 144 | } 145 | } 146 | 147 | sb.write(classDeclareFooter); 148 | 149 | if (arraySb.isNotEmpty) { 150 | sb.writeln(); 151 | sb.write( 152 | constsArray 153 | .replaceAll( 154 | '{0}', 155 | '${class1!.go('lcc', classPrefix ? packageGraph!.name : '')!}Array', 156 | ) 157 | .replaceAll('{1}', arraySb.toString()), 158 | ); 159 | } 160 | 161 | if (previewImageSb.isNotEmpty) { 162 | final String content = headerLicense + previewImageSb.toString() + mockClass; 163 | previewFile.createSync(recursive: true); 164 | previewFile.writeAsStringSync(content); 165 | } 166 | 167 | return sb.toString(); 168 | } 169 | 170 | String formatFiled(String asset, String path) { 171 | return ''' static const String ${_formatFiledName(asset)} = '$path';\n'''; 172 | } 173 | 174 | String _formatFiledName(String path) { 175 | path = path 176 | .replaceAll('/', '_') 177 | .replaceAll('.', '_') 178 | .replaceAll(' ', '_') 179 | .replaceAll('-', '_') 180 | .replaceAll('@', '_AT_'); 181 | return rule!.go(path); 182 | } 183 | } 184 | -------------------------------------------------------------------------------- /lib/src/assets_generator.dart: -------------------------------------------------------------------------------- 1 | // ignore_for_file: avoid_print 2 | 3 | import 'dart:io'; 4 | 5 | import 'package:build_runner_core/build_runner_core.dart'; 6 | import 'package:io/ansi.dart'; 7 | import 'package:path/path.dart'; 8 | 9 | import 'arg/class.dart'; 10 | import 'arg/rule.dart'; 11 | import 'arg/type.dart'; 12 | import 'format.dart'; 13 | import 'template.dart'; 14 | import 'watcher.dart'; 15 | import 'yaml.dart'; 16 | 17 | class Generator { 18 | Generator({ 19 | this.packageGraph, 20 | this.formatType = FormatType.directory, 21 | this.folder = 'assets', 22 | this.watch = true, 23 | this.output = 'lib', 24 | this.rule, 25 | this.class1, 26 | this.constIgnore, 27 | this.constArray = false, 28 | this.folderIgnore, 29 | this.package = false, 30 | this.useKeyName = false, 31 | this.classPrefix = false, 32 | this.gSuffix = false, 33 | this.rootPackageName, 34 | }); 35 | 36 | final PackageNode? packageGraph; 37 | final String? folder; 38 | final FormatType formatType; 39 | final bool watch; 40 | final String? output; 41 | final Rule? rule; 42 | final Class? class1; 43 | final RegExp? constIgnore; 44 | final bool? constArray; 45 | final RegExp? folderIgnore; 46 | final bool package; 47 | final bool useKeyName; 48 | final bool classPrefix; 49 | final bool gSuffix; 50 | final String? rootPackageName; 51 | 52 | Future go() async { 53 | if (watch) { 54 | final Watcher watcher = Watcher(await _go(), () { 55 | _go(); 56 | }); 57 | watcher.startWatch(); 58 | } else { 59 | _go(); 60 | } 61 | } 62 | 63 | Future> _go() async { 64 | final String path = packageGraph!.path; 65 | final File yamlFile = File(join(path, 'pubspec.yaml')); 66 | if (!yamlFile.existsSync()) { 67 | throw Exception('$path is not a Flutter project.'); 68 | } 69 | final Directory assetsDirectory = Directory(join(path, folder)); 70 | if (!assetsDirectory.existsSync() || assetsDirectory.listSync().isEmpty) { 71 | return []; 72 | // assetsDirectory.createSync(); 73 | } 74 | 75 | final List dirList = []; 76 | final List assets = []; 77 | 78 | findAssets(assetsDirectory, assets, dirList); 79 | 80 | // resolution image assets miss main asset entry 81 | final Map miss = checkResolutionImageAssets(assets); 82 | 83 | assets.sort((String a, String b) => a.compareTo(b)); 84 | 85 | await generateConstsFile(assets, miss); 86 | 87 | Yaml(yamlFile, assets, miss.keys.toList(), formatType).write(); 88 | 89 | return dirList; 90 | } 91 | 92 | void findAssets( 93 | Directory directory, 94 | List assets, 95 | List dirList, 96 | ) { 97 | dirList.add(directory); 98 | 99 | for (final FileSystemEntity item in directory.listSync()) { 100 | final FileStat fileStat = item.statSync(); 101 | if (folderIgnore != null && folderIgnore!.hasMatch(item.path)) { 102 | continue; 103 | } else if (fileStat.type == FileSystemEntityType.directory) { 104 | findAssets( 105 | Directory(item.path), 106 | assets, 107 | dirList, 108 | ); 109 | } else if (fileStat.type == FileSystemEntityType.file) { 110 | if (basename(item.path) != '.DS_Store') { 111 | assets.add( 112 | item.path 113 | .replaceAll('${packageGraph!.path}$separator', '') 114 | .replaceAll(separator, '/'), 115 | ); 116 | } 117 | } 118 | } 119 | } 120 | 121 | Future generateConstsFile( 122 | List assets, 123 | Map miss, 124 | ) async { 125 | final String path = packageGraph!.path; 126 | String? fileName = class1!.go('lwu', classPrefix ? packageGraph!.name : ''); 127 | 128 | if (gSuffix) { 129 | fileName = '$fileName.g'; 130 | } 131 | 132 | final File file = File(join(path, output, '$fileName.dart')); 133 | 134 | if (file.existsSync()) { 135 | file.deleteSync(recursive: true); 136 | } 137 | 138 | final File previewFile = File(join(path, output, '$fileName.preview.dart')); 139 | if (previewFile.existsSync()) { 140 | previewFile.deleteSync(recursive: true); 141 | } 142 | 143 | if (assets.isEmpty) { 144 | return; 145 | } 146 | 147 | file.createSync(recursive: true); 148 | 149 | final Template template = Template( 150 | assets, 151 | packageGraph, 152 | rule, 153 | class1, 154 | constIgnore, 155 | constArray, 156 | package, 157 | useKeyName, 158 | classPrefix, 159 | rootPackageName, 160 | ); 161 | file.writeAsStringSync( 162 | formatDart( 163 | await template.generateFile(miss, previewFile), 164 | path, 165 | ), 166 | ); 167 | if (previewFile.existsSync()) { 168 | final File gitIgnoreFile = File('$path/.gitignore'); 169 | if (!gitIgnoreFile.existsSync()) { 170 | gitIgnoreFile.createSync(recursive: true); 171 | } 172 | 173 | final String line = previewFile.path.replaceAll(path, ''); 174 | String content = await gitIgnoreFile.readAsString(); 175 | if (!content.contains(line)) { 176 | content += '\n$line'; 177 | await gitIgnoreFile.writeAsString(content); 178 | } 179 | } 180 | } 181 | 182 | Map checkResolutionImageAssets(List assets) { 183 | // miss main asset entry 184 | final Map miss = {}; 185 | if (assets.isEmpty) { 186 | return miss; 187 | } 188 | print(green.wrap('find following assets: ')); 189 | // 1.5x,2.0x,3.0x 190 | final RegExp regExp = RegExp(r'(([0-9]+).([0-9]+)|([0-9]+))x/'); 191 | // check resolution image assets 192 | final List list = assets.toList(); 193 | 194 | for (final String asset in list) { 195 | print(green.wrap(asset)); 196 | final String r = asset.replaceAllMapped(regExp, (Match match) { 197 | return ''; 198 | }); 199 | //macth 200 | if (r != asset) { 201 | if (!assets.contains(r)) { 202 | // throw Exception(red 203 | // .wrap('miss main asset entry: ${packageGraph.path}$separator$r')); 204 | assets.add(r); 205 | miss[r] = asset; 206 | } 207 | assets.remove(asset); 208 | } 209 | } 210 | return miss; 211 | } 212 | } 213 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; }; 11 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; }; 12 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; }; 13 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; }; 14 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; }; 15 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; }; 16 | /* End PBXBuildFile section */ 17 | 18 | /* Begin PBXCopyFilesBuildPhase section */ 19 | 9705A1C41CF9048500538489 /* Embed Frameworks */ = { 20 | isa = PBXCopyFilesBuildPhase; 21 | buildActionMask = 2147483647; 22 | dstPath = ""; 23 | dstSubfolderSpec = 10; 24 | files = ( 25 | ); 26 | name = "Embed Frameworks"; 27 | runOnlyForDeploymentPostprocessing = 0; 28 | }; 29 | /* End PBXCopyFilesBuildPhase section */ 30 | 31 | /* Begin PBXFileReference section */ 32 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; }; 33 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; }; 34 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; }; 35 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; }; 36 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; }; 38 | 9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; }; 39 | 9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; }; 40 | 97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 97C146FB1CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 42 | 97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 43 | 97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 44 | 97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 45 | /* End PBXFileReference section */ 46 | 47 | /* Begin PBXFrameworksBuildPhase section */ 48 | 97C146EB1CF9000F007C117D /* Frameworks */ = { 49 | isa = PBXFrameworksBuildPhase; 50 | buildActionMask = 2147483647; 51 | files = ( 52 | ); 53 | runOnlyForDeploymentPostprocessing = 0; 54 | }; 55 | /* End PBXFrameworksBuildPhase section */ 56 | 57 | /* Begin PBXGroup section */ 58 | 9740EEB11CF90186004384FC /* Flutter */ = { 59 | isa = PBXGroup; 60 | children = ( 61 | 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */, 62 | 9740EEB21CF90195004384FC /* Debug.xcconfig */, 63 | 7AFA3C8E1D35360C0083082E /* Release.xcconfig */, 64 | 9740EEB31CF90195004384FC /* Generated.xcconfig */, 65 | ); 66 | name = Flutter; 67 | sourceTree = ""; 68 | }; 69 | 97C146E51CF9000F007C117D = { 70 | isa = PBXGroup; 71 | children = ( 72 | 9740EEB11CF90186004384FC /* Flutter */, 73 | 97C146F01CF9000F007C117D /* Runner */, 74 | 97C146EF1CF9000F007C117D /* Products */, 75 | ); 76 | sourceTree = ""; 77 | }; 78 | 97C146EF1CF9000F007C117D /* Products */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | 97C146EE1CF9000F007C117D /* Runner.app */, 82 | ); 83 | name = Products; 84 | sourceTree = ""; 85 | }; 86 | 97C146F01CF9000F007C117D /* Runner */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 97C146FA1CF9000F007C117D /* Main.storyboard */, 90 | 97C146FD1CF9000F007C117D /* Assets.xcassets */, 91 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */, 92 | 97C147021CF9000F007C117D /* Info.plist */, 93 | 1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */, 94 | 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */, 95 | 74858FAE1ED2DC5600515810 /* AppDelegate.swift */, 96 | 74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */, 97 | ); 98 | path = Runner; 99 | sourceTree = ""; 100 | }; 101 | /* End PBXGroup section */ 102 | 103 | /* Begin PBXNativeTarget section */ 104 | 97C146ED1CF9000F007C117D /* Runner */ = { 105 | isa = PBXNativeTarget; 106 | buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */; 107 | buildPhases = ( 108 | 9740EEB61CF901F6004384FC /* Run Script */, 109 | 97C146EA1CF9000F007C117D /* Sources */, 110 | 97C146EB1CF9000F007C117D /* Frameworks */, 111 | 97C146EC1CF9000F007C117D /* Resources */, 112 | 9705A1C41CF9048500538489 /* Embed Frameworks */, 113 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */, 114 | ); 115 | buildRules = ( 116 | ); 117 | dependencies = ( 118 | ); 119 | name = Runner; 120 | productName = Runner; 121 | productReference = 97C146EE1CF9000F007C117D /* Runner.app */; 122 | productType = "com.apple.product-type.application"; 123 | }; 124 | /* End PBXNativeTarget section */ 125 | 126 | /* Begin PBXProject section */ 127 | 97C146E61CF9000F007C117D /* Project object */ = { 128 | isa = PBXProject; 129 | attributes = { 130 | LastUpgradeCheck = 1020; 131 | ORGANIZATIONNAME = ""; 132 | TargetAttributes = { 133 | 97C146ED1CF9000F007C117D = { 134 | CreatedOnToolsVersion = 7.3.1; 135 | LastSwiftMigration = 1100; 136 | }; 137 | }; 138 | }; 139 | buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */; 140 | compatibilityVersion = "Xcode 9.3"; 141 | developmentRegion = en; 142 | hasScannedForEncodings = 0; 143 | knownRegions = ( 144 | en, 145 | Base, 146 | ); 147 | mainGroup = 97C146E51CF9000F007C117D; 148 | productRefGroup = 97C146EF1CF9000F007C117D /* Products */; 149 | projectDirPath = ""; 150 | projectRoot = ""; 151 | targets = ( 152 | 97C146ED1CF9000F007C117D /* Runner */, 153 | ); 154 | }; 155 | /* End PBXProject section */ 156 | 157 | /* Begin PBXResourcesBuildPhase section */ 158 | 97C146EC1CF9000F007C117D /* Resources */ = { 159 | isa = PBXResourcesBuildPhase; 160 | buildActionMask = 2147483647; 161 | files = ( 162 | 97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */, 163 | 3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */, 164 | 97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */, 165 | 97C146FC1CF9000F007C117D /* Main.storyboard in Resources */, 166 | ); 167 | runOnlyForDeploymentPostprocessing = 0; 168 | }; 169 | /* End PBXResourcesBuildPhase section */ 170 | 171 | /* Begin PBXShellScriptBuildPhase section */ 172 | 3B06AD1E1E4923F5004D2608 /* Thin Binary */ = { 173 | isa = PBXShellScriptBuildPhase; 174 | buildActionMask = 2147483647; 175 | files = ( 176 | ); 177 | inputPaths = ( 178 | ); 179 | name = "Thin Binary"; 180 | outputPaths = ( 181 | ); 182 | runOnlyForDeploymentPostprocessing = 0; 183 | shellPath = /bin/sh; 184 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" embed_and_thin"; 185 | }; 186 | 9740EEB61CF901F6004384FC /* Run Script */ = { 187 | isa = PBXShellScriptBuildPhase; 188 | buildActionMask = 2147483647; 189 | files = ( 190 | ); 191 | inputPaths = ( 192 | ); 193 | name = "Run Script"; 194 | outputPaths = ( 195 | ); 196 | runOnlyForDeploymentPostprocessing = 0; 197 | shellPath = /bin/sh; 198 | shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build"; 199 | }; 200 | /* End PBXShellScriptBuildPhase section */ 201 | 202 | /* Begin PBXSourcesBuildPhase section */ 203 | 97C146EA1CF9000F007C117D /* Sources */ = { 204 | isa = PBXSourcesBuildPhase; 205 | buildActionMask = 2147483647; 206 | files = ( 207 | 74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */, 208 | 1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */, 209 | ); 210 | runOnlyForDeploymentPostprocessing = 0; 211 | }; 212 | /* End PBXSourcesBuildPhase section */ 213 | 214 | /* Begin PBXVariantGroup section */ 215 | 97C146FA1CF9000F007C117D /* Main.storyboard */ = { 216 | isa = PBXVariantGroup; 217 | children = ( 218 | 97C146FB1CF9000F007C117D /* Base */, 219 | ); 220 | name = Main.storyboard; 221 | sourceTree = ""; 222 | }; 223 | 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */ = { 224 | isa = PBXVariantGroup; 225 | children = ( 226 | 97C147001CF9000F007C117D /* Base */, 227 | ); 228 | name = LaunchScreen.storyboard; 229 | sourceTree = ""; 230 | }; 231 | /* End PBXVariantGroup section */ 232 | 233 | /* Begin XCBuildConfiguration section */ 234 | 249021D3217E4FDB00AE95B9 /* Profile */ = { 235 | isa = XCBuildConfiguration; 236 | buildSettings = { 237 | ALWAYS_SEARCH_USER_PATHS = NO; 238 | CLANG_ANALYZER_NONNULL = YES; 239 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 240 | CLANG_CXX_LIBRARY = "libc++"; 241 | CLANG_ENABLE_MODULES = YES; 242 | CLANG_ENABLE_OBJC_ARC = YES; 243 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 244 | CLANG_WARN_BOOL_CONVERSION = YES; 245 | CLANG_WARN_COMMA = YES; 246 | CLANG_WARN_CONSTANT_CONVERSION = YES; 247 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 248 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INFINITE_RECURSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_UNREACHABLE_CODE = YES; 261 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 262 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 263 | COPY_PHASE_STRIP = NO; 264 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 265 | ENABLE_NS_ASSERTIONS = NO; 266 | ENABLE_STRICT_OBJC_MSGSEND = YES; 267 | GCC_C_LANGUAGE_STANDARD = gnu99; 268 | GCC_NO_COMMON_BLOCKS = YES; 269 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 270 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 271 | GCC_WARN_UNDECLARED_SELECTOR = YES; 272 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 273 | GCC_WARN_UNUSED_FUNCTION = YES; 274 | GCC_WARN_UNUSED_VARIABLE = YES; 275 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 276 | MTL_ENABLE_DEBUG_INFO = NO; 277 | SDKROOT = iphoneos; 278 | SUPPORTED_PLATFORMS = iphoneos; 279 | TARGETED_DEVICE_FAMILY = "1,2"; 280 | VALIDATE_PRODUCT = YES; 281 | }; 282 | name = Profile; 283 | }; 284 | 249021D4217E4FDB00AE95B9 /* Profile */ = { 285 | isa = XCBuildConfiguration; 286 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 287 | buildSettings = { 288 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 289 | CLANG_ENABLE_MODULES = YES; 290 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 291 | ENABLE_BITCODE = NO; 292 | FRAMEWORK_SEARCH_PATHS = ( 293 | "$(inherited)", 294 | "$(PROJECT_DIR)/Flutter", 295 | ); 296 | INFOPLIST_FILE = Runner/Info.plist; 297 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 298 | LIBRARY_SEARCH_PATHS = ( 299 | "$(inherited)", 300 | "$(PROJECT_DIR)/Flutter", 301 | ); 302 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 303 | PRODUCT_NAME = "$(TARGET_NAME)"; 304 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 305 | SWIFT_VERSION = 5.0; 306 | VERSIONING_SYSTEM = "apple-generic"; 307 | }; 308 | name = Profile; 309 | }; 310 | 97C147031CF9000F007C117D /* Debug */ = { 311 | isa = XCBuildConfiguration; 312 | buildSettings = { 313 | ALWAYS_SEARCH_USER_PATHS = NO; 314 | CLANG_ANALYZER_NONNULL = YES; 315 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 316 | CLANG_CXX_LIBRARY = "libc++"; 317 | CLANG_ENABLE_MODULES = YES; 318 | CLANG_ENABLE_OBJC_ARC = YES; 319 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 320 | CLANG_WARN_BOOL_CONVERSION = YES; 321 | CLANG_WARN_COMMA = YES; 322 | CLANG_WARN_CONSTANT_CONVERSION = YES; 323 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 324 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 325 | CLANG_WARN_EMPTY_BODY = YES; 326 | CLANG_WARN_ENUM_CONVERSION = YES; 327 | CLANG_WARN_INFINITE_RECURSION = YES; 328 | CLANG_WARN_INT_CONVERSION = YES; 329 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 330 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 331 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 332 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 333 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 334 | CLANG_WARN_STRICT_PROTOTYPES = YES; 335 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 336 | CLANG_WARN_UNREACHABLE_CODE = YES; 337 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 338 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 339 | COPY_PHASE_STRIP = NO; 340 | DEBUG_INFORMATION_FORMAT = dwarf; 341 | ENABLE_STRICT_OBJC_MSGSEND = YES; 342 | ENABLE_TESTABILITY = YES; 343 | GCC_C_LANGUAGE_STANDARD = gnu99; 344 | GCC_DYNAMIC_NO_PIC = NO; 345 | GCC_NO_COMMON_BLOCKS = YES; 346 | GCC_OPTIMIZATION_LEVEL = 0; 347 | GCC_PREPROCESSOR_DEFINITIONS = ( 348 | "DEBUG=1", 349 | "$(inherited)", 350 | ); 351 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 352 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 353 | GCC_WARN_UNDECLARED_SELECTOR = YES; 354 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 355 | GCC_WARN_UNUSED_FUNCTION = YES; 356 | GCC_WARN_UNUSED_VARIABLE = YES; 357 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 358 | MTL_ENABLE_DEBUG_INFO = YES; 359 | ONLY_ACTIVE_ARCH = YES; 360 | SDKROOT = iphoneos; 361 | TARGETED_DEVICE_FAMILY = "1,2"; 362 | }; 363 | name = Debug; 364 | }; 365 | 97C147041CF9000F007C117D /* Release */ = { 366 | isa = XCBuildConfiguration; 367 | buildSettings = { 368 | ALWAYS_SEARCH_USER_PATHS = NO; 369 | CLANG_ANALYZER_NONNULL = YES; 370 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 371 | CLANG_CXX_LIBRARY = "libc++"; 372 | CLANG_ENABLE_MODULES = YES; 373 | CLANG_ENABLE_OBJC_ARC = YES; 374 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 375 | CLANG_WARN_BOOL_CONVERSION = YES; 376 | CLANG_WARN_COMMA = YES; 377 | CLANG_WARN_CONSTANT_CONVERSION = YES; 378 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 379 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 380 | CLANG_WARN_EMPTY_BODY = YES; 381 | CLANG_WARN_ENUM_CONVERSION = YES; 382 | CLANG_WARN_INFINITE_RECURSION = YES; 383 | CLANG_WARN_INT_CONVERSION = YES; 384 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 385 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 386 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 387 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 388 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 389 | CLANG_WARN_STRICT_PROTOTYPES = YES; 390 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 391 | CLANG_WARN_UNREACHABLE_CODE = YES; 392 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 393 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 394 | COPY_PHASE_STRIP = NO; 395 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 396 | ENABLE_NS_ASSERTIONS = NO; 397 | ENABLE_STRICT_OBJC_MSGSEND = YES; 398 | GCC_C_LANGUAGE_STANDARD = gnu99; 399 | GCC_NO_COMMON_BLOCKS = YES; 400 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 401 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 402 | GCC_WARN_UNDECLARED_SELECTOR = YES; 403 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 404 | GCC_WARN_UNUSED_FUNCTION = YES; 405 | GCC_WARN_UNUSED_VARIABLE = YES; 406 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 407 | MTL_ENABLE_DEBUG_INFO = NO; 408 | SDKROOT = iphoneos; 409 | SUPPORTED_PLATFORMS = iphoneos; 410 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 411 | TARGETED_DEVICE_FAMILY = "1,2"; 412 | VALIDATE_PRODUCT = YES; 413 | }; 414 | name = Release; 415 | }; 416 | 97C147061CF9000F007C117D /* Debug */ = { 417 | isa = XCBuildConfiguration; 418 | baseConfigurationReference = 9740EEB21CF90195004384FC /* Debug.xcconfig */; 419 | buildSettings = { 420 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 421 | CLANG_ENABLE_MODULES = YES; 422 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 423 | ENABLE_BITCODE = NO; 424 | FRAMEWORK_SEARCH_PATHS = ( 425 | "$(inherited)", 426 | "$(PROJECT_DIR)/Flutter", 427 | ); 428 | INFOPLIST_FILE = Runner/Info.plist; 429 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 430 | LIBRARY_SEARCH_PATHS = ( 431 | "$(inherited)", 432 | "$(PROJECT_DIR)/Flutter", 433 | ); 434 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 435 | PRODUCT_NAME = "$(TARGET_NAME)"; 436 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 437 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 438 | SWIFT_VERSION = 5.0; 439 | VERSIONING_SYSTEM = "apple-generic"; 440 | }; 441 | name = Debug; 442 | }; 443 | 97C147071CF9000F007C117D /* Release */ = { 444 | isa = XCBuildConfiguration; 445 | baseConfigurationReference = 7AFA3C8E1D35360C0083082E /* Release.xcconfig */; 446 | buildSettings = { 447 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 448 | CLANG_ENABLE_MODULES = YES; 449 | CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; 450 | ENABLE_BITCODE = NO; 451 | FRAMEWORK_SEARCH_PATHS = ( 452 | "$(inherited)", 453 | "$(PROJECT_DIR)/Flutter", 454 | ); 455 | INFOPLIST_FILE = Runner/Info.plist; 456 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 457 | LIBRARY_SEARCH_PATHS = ( 458 | "$(inherited)", 459 | "$(PROJECT_DIR)/Flutter", 460 | ); 461 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example; 462 | PRODUCT_NAME = "$(TARGET_NAME)"; 463 | SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; 464 | SWIFT_VERSION = 5.0; 465 | VERSIONING_SYSTEM = "apple-generic"; 466 | }; 467 | name = Release; 468 | }; 469 | /* End XCBuildConfiguration section */ 470 | 471 | /* Begin XCConfigurationList section */ 472 | 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */ = { 473 | isa = XCConfigurationList; 474 | buildConfigurations = ( 475 | 97C147031CF9000F007C117D /* Debug */, 476 | 97C147041CF9000F007C117D /* Release */, 477 | 249021D3217E4FDB00AE95B9 /* Profile */, 478 | ); 479 | defaultConfigurationIsVisible = 0; 480 | defaultConfigurationName = Release; 481 | }; 482 | 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */ = { 483 | isa = XCConfigurationList; 484 | buildConfigurations = ( 485 | 97C147061CF9000F007C117D /* Debug */, 486 | 97C147071CF9000F007C117D /* Release */, 487 | 249021D4217E4FDB00AE95B9 /* Profile */, 488 | ); 489 | defaultConfigurationIsVisible = 0; 490 | defaultConfigurationName = Release; 491 | }; 492 | /* End XCConfigurationList section */ 493 | }; 494 | rootObject = 97C146E61CF9000F007C117D /* Project object */; 495 | } 496 | --------------------------------------------------------------------------------