├── .github
├── ISSUE_TEMPLATE
│ ├── bug_report.md
│ └── feature_request.md
└── workflows
│ ├── cd-pub-deploy-published-release.yml
│ └── ci-open-pr.yml
├── .gitignore
├── .pubignore
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── analysis_options.yaml
├── bin
├── flutter_launcher_icons.dart
├── generate.dart
└── main.dart
├── example
├── default_example
│ ├── .metadata
│ ├── README.md
│ ├── assets
│ │ └── images
│ │ │ ├── background-test.png
│ │ │ ├── christmas-background.png
│ │ │ ├── ic_launcher.png
│ │ │ ├── icon-1024x1024.png
│ │ │ ├── icon-128x128.png
│ │ │ ├── icon-710x599-android.png
│ │ │ ├── icon-710x599-ios.png
│ │ │ ├── icon-710x599.png
│ │ │ ├── icon-foreground-432x432.png
│ │ │ └── icon-monochrome-432x432.png
│ └── pubspec.yaml
├── example.md
└── flavors
│ ├── .metadata
│ ├── README.md
│ ├── android
│ ├── .gitignore
│ ├── app
│ │ ├── build.gradle
│ │ └── src
│ │ │ ├── debug
│ │ │ └── AndroidManifest.xml
│ │ │ ├── development
│ │ │ └── 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
│ │ │ ├── integration
│ │ │ └── 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
│ │ │ ├── main
│ │ │ ├── AndroidManifest.xml
│ │ │ ├── kotlin
│ │ │ │ └── com
│ │ │ │ │ └── flutter
│ │ │ │ │ └── icons
│ │ │ │ │ ├── example_with_flavors
│ │ │ │ │ └── MainActivity.kt
│ │ │ │ │ └── flavors
│ │ │ │ │ └── MainActivity.kt
│ │ │ └── res
│ │ │ │ ├── drawable-v21
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── drawable
│ │ │ │ └── launch_background.xml
│ │ │ │ ├── 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
│ │ │ │ ├── values-night
│ │ │ │ └── styles.xml
│ │ │ │ └── values
│ │ │ │ └── styles.xml
│ │ │ ├── production
│ │ │ └── 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
│ │ │ └── profile
│ │ │ └── AndroidManifest.xml
│ ├── build.gradle
│ ├── flavors_android.iml
│ ├── gradle.properties
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ └── settings.gradle
│ ├── assets
│ └── launcher_icon
│ │ ├── demo-icon-dev.png
│ │ ├── demo-icon-int.png
│ │ └── demo-icon.png
│ ├── flavors.iml
│ ├── flutter_launcher_icons-development.yaml
│ ├── flutter_launcher_icons-integration.yaml
│ ├── flutter_launcher_icons-production.yaml
│ └── pubspec.yaml
├── flutter_launcher_icons.code-workspace
├── lib
├── abs
│ └── icon_generator.dart
├── android.dart
├── config
│ ├── config.dart
│ ├── config.g.dart
│ ├── macos_config.dart
│ ├── macos_config.g.dart
│ ├── web_config.dart
│ ├── web_config.g.dart
│ ├── windows_config.dart
│ └── windows_config.g.dart
├── constants.dart
├── custom_exceptions.dart
├── ios.dart
├── logger.dart
├── macos
│ ├── macos_icon_generator.dart
│ └── macos_icon_template.dart
├── main.dart
├── pubspec_parser.dart
├── src
│ └── version.dart
├── utils.dart
├── web
│ ├── web_icon_generator.dart
│ └── web_template.dart
├── windows
│ └── windows_icon_generator.dart
└── xml_templates.dart
├── pubspec.yaml
└── test
├── abs
├── icon_generator_test.dart
└── icon_generator_test.mocks.dart
├── all_tests.dart
├── android_test.dart
├── assets
└── app_icon.png
├── config
└── test_pubspec.yaml
├── config_test.dart
├── macos
├── macos_icon_generator_test.dart
├── macos_icon_generator_test.mocks.dart
└── macos_icon_template_test.dart
├── main_test.dart
├── package_version_test.dart
├── templates.dart
├── utils_test.dart
├── web
├── web_icon_generator_test.dart
└── web_template_test.dart
└── windows
├── windows_icon_generator_test.dart
└── windows_icon_generator_test.mocks.dart
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us fix any issues you are having
4 | title: ''
5 | labels: 'bug'
6 | assignees: ''
7 |
8 | ---
9 |
10 | ### :information_source: Info
11 |
12 |
13 |
14 |
15 | ### :speech_balloon: Description
16 |
17 |
18 |
19 |
20 | ### :scroll: Pubspec.yaml
21 |
22 |
23 | ```yaml
24 | flutter_launcher_icons:
25 | android:
26 | ios:
27 | image_path:
28 | ```
29 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea to improve Flutter Launcher Icons
4 | title: ''
5 | labels: improvement
6 | assignees: ''
7 |
8 | ---
9 |
10 | ### :speech_balloon: Description
11 |
12 |
13 |
--------------------------------------------------------------------------------
/.github/workflows/cd-pub-deploy-published-release.yml:
--------------------------------------------------------------------------------
1 | # Deploy new version to pub.dev after a new GitHub release has been published
2 | name: pub.dev auto deployment
3 |
4 | on:
5 | release:
6 | types: [published]
7 |
8 | # Allows you to run this workflow manually from the Actions tab
9 | workflow_dispatch:
10 |
11 | jobs:
12 | deploy:
13 | runs-on: ubuntu-latest
14 | steps:
15 | # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
16 | - name: Checkout repo
17 | uses: actions/checkout@v2
18 | - name: Run a one-line script
19 | uses: k-paxian/dart-package-publisher@v1.5.1
20 | with:
21 | accessToken: ${{ secrets.PUB_ACCESS_TOKEN }}
22 | refreshToken: ${{ secrets.PUB_REFRESH_TOKEN}}
--------------------------------------------------------------------------------
/.github/workflows/ci-open-pr.yml:
--------------------------------------------------------------------------------
1 | # Runs all the unit tests and the analyzer for any PR opened to merge into master branch.
2 | #
3 | # This helps ensure we avoid breaking existing functionality and stick to the rules
4 | # defined in the analysis_options.yaml file
5 | name: run tests & analyzer for new pr
6 |
7 | on:
8 | pull_request:
9 | branches: [ master ]
10 |
11 | # allows for this workflow to be run manually from the Actions tab
12 | workflow_dispatch:
13 |
14 | jobs:
15 | build:
16 | runs-on: ubuntu-latest
17 | steps:
18 | - uses: actions/checkout@v2
19 | - uses: dart-lang/setup-dart@v1.3
20 | - name: get dependencies
21 | run: dart pub get
22 | - name: run tests
23 | run: dart test test/all_tests.dart
24 | - name: run analyzer
25 | run: dart analyze
26 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Files and directories created by pub
2 | .packages
3 | .dart_tool/
4 | .pub/
5 | .idea/
6 | build/
7 |
8 | # Remove the following pattern if you wish to check in your lock file
9 | pubspec.lock
10 |
11 | # Directory created by dartdoc
12 | doc/api/
13 |
14 | .DS_Store
--------------------------------------------------------------------------------
/.pubignore:
--------------------------------------------------------------------------------
1 | # test directory
2 | /test/*
3 |
4 | # other
5 | /flutter_launcher_icons.code-workspace
6 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: dart
2 |
3 | dart:
4 | - dev
5 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## 0.14.3 (17th January 2025)
4 |
5 | - Android: Avoids creating mipmap file used by adaptive and monochrome icons if no config exist for both [#601](https://github.com/fluttercommunity/flutter_launcher_icons/pull/601)
6 |
7 | ## 0.14.2 (5th December 2024)
8 |
9 | - iOS: Fixed issue where dark and tinted icons were placed into the wrong directory [#597](https://github.com/fluttercommunity/flutter_launcher_icons/pull/597)
10 |
11 | ## 0.14.1 (24th September 2024)
12 |
13 | - Fixed README
14 |
15 | ## 0.14.0 (21st September 2024)
16 |
17 | - Android: Support for monochrome icons [#497](https://github.com/fluttercommunity/flutter_launcher_icons/pull/497)
18 |
19 | **Before**
20 |
21 |
22 |
23 | **Now**
24 |
25 |
26 |
27 | - Android: Ability to set inset for adaptive icon foreground and monochrome icon [#563](https://github.com/fluttercommunity/flutter_launcher_icons/pull/563)
28 | - iOS: Dark and Tinted icons for iOS 18+ [#569](https://github.com/fluttercommunity/flutter_launcher_icons/pull/569)
29 |
30 | ## 0.13.1 (15th April 2023)
31 |
32 | - Can now use `flutter_launcher_icons` instead of `flutter_icons` [#478](https://github.com/fluttercommunity/flutter_launcher_icons/pull/478)
33 | - Can use command `flutter pub run flutter_launcher_icons:generate` to automatically generate config file [#475](https://github.com/fluttercommunity/flutter_launcher_icons/pull/475)
34 |
35 |
36 | ## 0.13.0 (7th April 2023)
37 |
38 | - Fix remove alpha for iOS [#464](https://github.com/fluttercommunity/flutter_launcher_icons/pull/464)
39 | - Updating code style [#472](https://github.com/fluttercommunity/flutter_launcher_icons/pull/472)
40 | - Updated out of bounds dependency [#473](https://github.com/fluttercommunity/flutter_launcher_icons/pull/473)
41 |
42 | ## 0.12.0 (24th February 2023)
43 |
44 | - Updated image package and other packages [#447](https://github.com/fluttercommunity/flutter_launcher_icons/pull/447)
45 |
46 | ## 0.11.0 (27th September 2022)
47 |
48 | - Support for Macos Icons [#407](https://github.com/fluttercommunity/flutter_launcher_icons/pull/407)
49 | - Cli-improvement [#400](https://github.com/fluttercommunity/flutter_launcher_icons/pull/400)
50 | - Add `repository` and `issue_tracker` [#411](https://github.com/fluttercommunity/flutter_launcher_icons/pull/411) (thanks to [@patelpathik](https://github.com/patelpathik))
51 | - Fix indent in web/manifest.json [#407](https://github.com/fluttercommunity/flutter_launcher_icons/pull/407)
52 | - Fix the icons 50 and 57 in `contents.json` [#412](https://github.com/fluttercommunity/flutter_launcher_icons/pull/412) (thanks to [@adnanjpg](https://github.com/adnanjpg))
53 | - Fix typos [#405](https://github.com/fluttercommunity/flutter_launcher_icons/pull/405) (thanks to [@edwardmp](https://github.com/edwardmp))
54 | - Added newline to EOF [#325](https://github.com/fluttercommunity/flutter_launcher_icons/pull/325) (thanks to [@sandersaelmans](https://github.com/sandersaelmans))
55 |
56 | ## 0.10.0 (2nd August 2022)
57 |
58 | - Support for Web Icons [#374](https://github.com/fluttercommunity/flutter_launcher_icons/pull/374)
59 | - Support for Windows Icons [#382](https://github.com/fluttercommunity/flutter_launcher_icons/pull/382)
60 | - Added missing IOS icon sizes [#298](https://github.com/fluttercommunity/flutter_launcher_icons/pull/298)
61 | - Added `min_sdk_android` option [#392](https://github.com/fluttercommunity/flutter_launcher_icons/pull/392)
62 | - Added documentation for `remove_alpha_ios` [#392](https://github.com/fluttercommunity/flutter_launcher_icons/pull/392)
63 | - Fixed issue with loading config from `pubspec.yaml` [#398](https://github.com/fluttercommunity/flutter_launcher_icons/pull/398) (thanks to [@p-mazhnik](https://github.com/p-mazhnik))
64 |
65 | ## 0.9.3 (6th June 2022)
66 |
67 | - Fixes to make sure it works for Flutter v2.8 (thanks to @RatakondalaArun)
68 | - Fixed issue with incorrect version being shown
69 |
70 | ## 0.9.2 (22nd August 2021)
71 |
72 | - Fixed issue where success message printed even when exception occured (thanks to @happy-san)
73 |
74 | ## 0.9.1 (25th July 2021)
75 |
76 | - Upgrade args dependency to ^2.1.1 (thanks to @PiN73 and @comlaterra)
77 | - Upgraded `image` and `test` dependencies
78 |
79 | ## 0.9.0 (28th Feb 2021)
80 |
81 | - Null-safety support added (thanks to @SteveAlexander)
82 | - Added option to remove alpha channel for iOS icons (thanks to @SimonIT)
83 |
84 | ## 0.8.1 (2nd Oct 2020)
85 |
86 | - Fixed flavor support on windows (@slightfoot)
87 |
88 | ## 0.8.0 (12th Sept 2020)
89 |
90 | - Added flavours support (thanks to @sestegra & @jorgecoca)
91 | - Removed unassigned iOS icons (thanks to @melvinsalas)
92 | - Fixing formatting (thanks to @mreichelt)
93 |
94 | ## 0.7.5 (24th April 2020)
95 |
96 | - Fixed issue where new lines were added to Android manifest (thanks to @mreichelt)
97 | - Improvements to code quality and general tidying up (thanks to @connectety)
98 | - Fixed Android example project not running (needed to be migrated to AndroidX)
99 |
100 | ## 0.7.4 (28th Oct 2019)
101 |
102 | - Worked on suggestions from [pub.dev](https://pub.dev/packages/flutter_launcher_icons#-analysis-tab-)
103 |
104 | ## 0.7.3 (3rd Sept 2019)
105 |
106 | - Lot of refactoring and improving code quality (thanks to @connectety)
107 | - Added correct App Store icon settings (thanks to @richgoldmd)
108 |
109 | ## 0.7.2 (25th May 2019)
110 |
111 | - Reverted back using old interpolation method
112 |
113 | ## 0.7.1 (24th May 2019)
114 |
115 | - Fixed issue with image dependency not working on latest version of Flutter (thanks to @sboutet06)
116 | - Fixed iOS icon sizes which were incorrect (thanks to @sestegra)
117 | - Removed dart_config git dependency and replaced with yaml dependency
118 | - Refactoring of code
119 |
120 | ## 0.7.0 (22nd November 2018)
121 |
122 | - Now ensuring that the Android file name is valid - An error will be thrown if it doesn't meet the criteria
123 | - Fixed issue where there was a git diff when there was no change
124 | - Fixed issue where iOS icon would be generated when it shouldn't be
125 | - Added support for drawables to be used for adaptive icon backgrounds
126 | - Added support for Flutter Launcher Icons to be able to run with it's own config file (no longer necessary to add to pubspec.yaml)
127 |
128 | ## 0.6.1 (26th August 2018)
129 |
130 | - Upgraded test package
131 | - Due to issue with dart_config not working with Dart 2.1.0, now using forked version of dart_config which contains fixes from both @v3rm0n and @SPodjasek
132 |
133 | ## 0.6.0 (8th August 2018)
134 |
135 | - Moved the package to [Flutter Community](https://github.com/fluttercommunity/community)
136 |
137 | ## 0.5.2 (19th June 2018)
138 |
139 | - Previous release didn't fix adaptive icons, just prevented the error message from appearing. This should hopefully fix it!
140 |
141 | ## 0.5.1 (18th June 2018)
142 |
143 | - Fix for adaptive icons
144 |
145 | ## 0.5.0 (12th June 2018)
146 |
147 | - [Android] Support for adaptive icons added (Suggestion #23)
148 |
149 | ## 0.4.0 (9th June 2018)
150 |
151 | - Now possible to generate icons for each platform with different image paths (one for iOS icon and a separate one for Android)
152 |
153 | ## 0.3.3 (28th May 2018)
154 |
155 | - Upgraded dart image package dependency to 2.0.0 (issue #26)
156 |
157 | ## 0.3.2 (2nd May 2018)
158 |
159 | - Bug fixing
160 |
161 | ## 0.3.1 (1st May 2018)
162 |
163 | - Bug fixing
164 |
165 | ## 0.3.0 (1st May 2018)
166 |
167 | - Fixed issue where icons produced weren't the correct size (Due to images not with a 1:1 aspect r ation)
168 | - Improved quality of smaller icons produced (Thanks to PR #17 - Thank you!)
169 | - Updated console printed messages to keep them consistent
170 | - Added example folder to GitHub project
171 |
172 | ## 0.2.1 (25th April 2018)
173 |
174 | - Added extra iOS icon size (1024x1024)
175 | - Fixed iOS default icon name (Thanks to PR #15 - Thank you!)
176 | - Fixed issue #10 where creation of the icons was failing due to the target folder not existing
177 |
178 | ## 0.2.0 (18th January 2018)
179 |
180 | - Ability to create new launcher icons without replacing the old ones added (#6)
181 | - Fixed issue with launcher icons for iOS not correctly being set
182 |
183 | ## 0.0.5
184 |
185 | - Quick Fix on if statement
186 |
187 | ## 0.0.4
188 |
189 | - Fixing strong mode error
190 |
191 | ## 0.0.3
192 |
193 | - Adding flutter as a dependency so its listed as a flutter package.
194 |
195 | ## 0.0.2
196 |
197 | - Fix Doc typo
198 |
199 | ## 0.0.1
200 |
201 | - Initial version, Resizes Icon to Android sizes only.
202 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2019 Mark O'Sullivan
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.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Flutter Launcher Icons
2 |
3 | [](https://github.com/fluttercommunity/community)
4 |
5 | [](https://pub.dartlang.org/packages/flutter_launcher_icons)
6 |
7 | A command-line tool which simplifies the task of updating your Flutter app's launcher icon. Fully flexible, allowing you to choose what platform you wish to update the launcher icon for and if you want, the option to keep your old launcher icon in case you want to revert back sometime in the future.
8 |
9 | ## :book: Guide
10 |
11 | ### 1. Setup the config file
12 |
13 | Run the following command to create a new config automatically:
14 |
15 | ```shell
16 | dart run flutter_launcher_icons:generate
17 | ```
18 |
19 | This will create a new file called `flutter_launcher_icons.yaml` in your `flutter` project's root directory.
20 |
21 | If you want to override the default location or name of the config file, use the `-f` flag:
22 |
23 | ```shell
24 | dart run flutter_launcher_icons:generate -f
25 | ```
26 |
27 | To override an existing config file, use the `-o` flag:
28 |
29 | ```shell
30 | dart run flutter_launcher_icons:generate -o
31 | ```
32 |
33 | OR
34 |
35 | Add your Flutter Launcher Icons configuration to your `pubspec.yaml`.
36 | An example is shown below. More complex examples [can be found in the example projects](https://github.com/fluttercommunity/flutter_launcher_icons/tree/master/example).
37 |
38 | ```yaml
39 | dev_dependencies:
40 | flutter_launcher_icons: "^0.14.3"
41 |
42 | flutter_launcher_icons:
43 | android: "launcher_icon"
44 | ios: true
45 | image_path: "assets/icon/icon.png"
46 | min_sdk_android: 21 # android min sdk min:16, default 21
47 | web:
48 | generate: true
49 | image_path: "path/to/image.png"
50 | background_color: "#hexcode"
51 | theme_color: "#hexcode"
52 | windows:
53 | generate: true
54 | image_path: "path/to/image.png"
55 | icon_size: 48 # min:48, max:256, default: 48
56 | macos:
57 | generate: true
58 | image_path: "path/to/image.png"
59 | ```
60 |
61 | ### 2. Run the package
62 |
63 | After setting up the configuration, all that is left to do is run the package.
64 |
65 | ```shell
66 | flutter pub get
67 | dart run flutter_launcher_icons
68 | ```
69 |
70 | If you name your configuration file something other than `flutter_launcher_icons.yaml` or `pubspec.yaml` you will need to specify
71 | the name of the file when running the package.
72 |
73 | ```shell
74 | flutter pub get
75 | dart run flutter_launcher_icons -f
76 | ```
77 |
78 | Note: If you are not using the existing `pubspec.yaml` ensure that your config file is located in the same directory as it.
79 |
80 | If you encounter any issues [please report them here](https://github.com/fluttercommunity/flutter_launcher_icons/issues).
81 |
82 | In the above configuration, the package is setup to replace the existing launcher icons in both the Android and iOS project
83 | with the icon located in the image path specified above and given the name "launcher_icon" in the Android project and "Example-Icon" in the iOS project.
84 |
85 | ## :mag: Attributes
86 |
87 | Shown below is the full list of attributes which you can specify within your Flutter Launcher Icons configuration.
88 |
89 | ### Global
90 |
91 | - `image_path`: The location of the icon image file which you want to use as the app launcher icon.
92 |
93 | ### Android
94 |
95 | - `android`
96 | - `true`: Override the default existing Flutter launcher icon for the platform specified
97 | - `false`: Ignore making launcher icons for this platform
98 | - `icon/path/here.png`: This will generate a new launcher icons for the platform with the name you specify, without removing the old default existing Flutter launcher icon.
99 | - `image_path`: The location of the icon image file which you want to use as the app launcher icon
100 | - `image_path_android`: The location of the icon image file specific for Android platform (optional - if not defined then the image_path is used)
101 | - `min_sdk_android`: Specify android min sdk value
102 | **The next two attributes are only used when generating Android launcher icon**
103 |
104 | - `adaptive_icon_background`: The color (E.g. `"#ffffff"`) or image asset (E.g. `"assets/images/christmas-background.png"`) which will
105 | be used to fill out the background of the adaptive icon.
106 | - `adaptive_icon_foreground`: The image asset which will be used for the icon foreground of the adaptive icon
107 | *Note: Adaptive Icons will only be generated when both adaptive_icon_background and adaptive_icon_foreground are specified. (the image_path is not automatically taken as foreground)*
108 | - `adaptive_icon_foreground_inset`: This is used to add padding to the icon when applying an adaptive icon. The default value is `16`.
109 | - `adaptive_icon_monochrome`: The image asset which will be used for the icon
110 | foreground of the Android 13+ themed icon. For more information see [Android Adaptive Icons](https://developer.android.com/develop/ui/views/launch/icon_design_adaptive#user-theming)
111 |
112 | ### IOS
113 |
114 | - `ios`
115 | - `true`: Override the default existing Flutter launcher icon for the platform specified
116 | - `false`: Ignore making launcher icons for this platform
117 | - `icon/path/here.png`: This will generate a new launcher icons for the platform with the name you specify, without removing the old default existing Flutter launcher icon.
118 | - `image_path_ios`: The location of the icon image file specific for iOS platform (optional - if not defined then the image_path is used)
119 | - `remove_alpha_ios`: Removes alpha channel for IOS icons
120 | - `image_path_ios_dark_transparent`: The location of the dark mode icon image file specific for iOS 18+ platform. *Note: Apple recommends this icon to be transparent. For more information see [Apple Human Interface Guidelines for App Icons](https://developer.apple.com/design/human-interface-guidelines/app-icons#iOS-iPadOS)*
121 | - `image_path_ios_tinted_grayscale`: The location of the tinted mode icon image file specific for iOS 18+ platform. *Note: This icon should be an grayscale image. Use `desaturate_tinted_to_grayscale_ios: true` to automatically desaturate the image provided here.*
122 | - `desaturate_tinted_to_grayscale_ios`: Automatically desaturates tinted mode icon image to grayscale, *defaults to false*
123 | - `background_color_ios`: The color (in the format "#RRGGBB") to be used as the background when removing the alpha channel. It is used only when the `remove_alpha_ios` property is set to true. (optional - if not defined then `#ffffff` is used)
124 |
125 | ### Web
126 |
127 | - `web`: Add web related configs
128 | - `generate`: Specifies whether to generate icons for this platform or not
129 | - `image_path`: Path to web icon.png
130 | - `background_color`: Updates *background_color* in `web/manifest.json`
131 | - `theme_color`: Updates *theme_color* in `web/manifest.json`
132 |
133 | ### Windows
134 |
135 | - `windows`: Add Windows related configs
136 | - `generate`: Specifies whether to generate icons for Windows platform or not
137 | - `image_path`: Path to windows icon.png
138 | - `icon_size`: Windows app icon size. Icon size should be within this constrains *48<=icon_size<=256, defaults to 48*
139 |
140 | ### MacOS
141 |
142 | - `macos`: Add MacOS related configs
143 | - `generate`: Specifies whether to generate icons for MacOS platform or not
144 | - `image_path`: Path to macos icon.png file
145 |
146 | *Note: iOS icons should [fill the entire image](https://stackoverflow.com/questions/26014461/black-border-on-my-ios-icon) and not contain transparent borders.*
147 |
148 | ## Flavor support
149 |
150 | Create a Flutter Launcher Icons configuration file for your flavor. The config file is called `flutter_launcher_icons-.yaml` by replacing `` by the name of your desired flavor.
151 |
152 | The configuration file format is the same.
153 |
154 | An example project with flavor support enabled [has been added to the examples](https://github.com/fluttercommunity/flutter_launcher_icons/tree/master/example/flavors).
155 |
156 | ## :question: Troubleshooting
157 |
158 | Listed a couple common issues with solutions for them
159 |
160 | ### Generated icon color is different from the original icon
161 |
162 | Caused by an update to the image dependency which is used by Flutter Launcher Icons.
163 |
164 | ```txt
165 | Use #AARRGGBB for colors instead of #AABBGGRR, to be compatible with Flutter image class.
166 | ```
167 |
168 | [Related issue](https://github.com/fluttercommunity/flutter_launcher_icons/issues/98)
169 |
170 | ### Image foreground is too big / too small
171 |
172 | For best results try and use a foreground image which has padding much like [the one in the example](https://github.com/fluttercommunity/flutter_launcher_icons/blob/master/example/default_example/assets/images/icon-foreground-432x432.png).
173 |
174 | [Related issue](https://github.com/fluttercommunity/flutter_launcher_icons/issues/96)
175 |
176 | ### Dependency incompatible
177 |
178 | You may receive a message similar to the following
179 |
180 | ```log
181 | Because flutter_launcher_icons >=0.9.0 depends on args 2.0.0 and flutter_native_splash 1.2.0 depends on args ^2.1.1, flutter_launcher_icons >=0.9.0 is incompatible with flutter_native_splash 1.2.0.
182 | And because no versions of flutter_native_splash match >1.2.0 <2.0.0, flutter_launcher_icons >=0.9.0 is incompatible with flutter_native_splash ^1.2.0.
183 | So, because enstack depends on both flutter_native_splash ^1.2.0 and flutter_launcher_icons ^0.9.0, version solving failed.
184 | pub get failed (1; So, because enstack depends on both flutter_native_splash ^1.2.0 and flutter_launcher_icons ^0.9.0, version solving failed.)
185 | ```
186 |
187 | For a quick fix, you can temporarily override all references to a dependency: [See here for an example](https://github.com/fluttercommunity/flutter_launcher_icons/issues/262#issuecomment-879872076).
188 |
189 | ## :eyes: Example
190 |
191 | [](https://www.youtube.com/watch?v=RjNAxwcP3Tc)
192 |
193 | Note: This is showing a very old version (v0.0.5)
194 |
195 | ### Special thanks
196 |
197 | - Thanks to Brendan Duncan for the underlying [image package](https://pub.dev/packages/image) to transform the icons.
198 | - Big thank you to all the contributors to the project. Every PR / reported issue is greatly appreciated!
199 |
--------------------------------------------------------------------------------
/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | analyzer:
2 | strong-mode:
3 | implicit-dynamic: false
4 | errors:
5 | # treat missing required parameters as a warning (not a hint)
6 | missing_required_param: warning
7 | # treat missing returns as a warning (not a hint)
8 | missing_return: warning
9 | # allow having TODOs in the code
10 | todo: ignore
11 | exclude:
12 | - "bin/cache/**"
13 | # the following two are relative to the stocks example and the flutter package respectively
14 | # see https://github.com/dart-lang/sdk/issues/28463
15 | - "lib/i18n/stock_messages_*.dart"
16 | - "lib/src/http/**"
17 | - "example/**"
18 | - "**/*.g.dart"
19 | - "lib/src/version.dart"
20 |
21 | linter:
22 | rules:
23 | # See all available options here
24 | # https://github.com/dart-lang/linter/blob/master/example/all.yaml
25 | - always_declare_return_types
26 | - always_put_control_body_on_new_line
27 |
28 | - always_require_non_null_named_parameters
29 | - annotate_overrides
30 | - avoid_empty_else
31 | - avoid_field_initializers_in_const_classes
32 | - avoid_function_literals_in_foreach_calls
33 | - avoid_init_to_null
34 | - avoid_null_checks_in_equality_operators
35 | - avoid_relative_lib_imports
36 | - avoid_renaming_method_parameters
37 | - avoid_return_types_on_setters
38 | - avoid_returning_null_for_void
39 | - avoid_slow_async_io
40 | - avoid_types_as_parameter_names
41 | - avoid_unused_constructor_parameters
42 | - avoid_void_async
43 | - await_only_futures
44 | - camel_case_types
45 | - cancel_subscriptions
46 | - control_flow_in_finally
47 | - directives_ordering
48 | - empty_catches
49 | - empty_constructor_bodies
50 | - empty_statements
51 | - flutter_style_todos
52 | - hash_and_equals
53 | - implementation_imports
54 | - collection_methods_unrelated_type
55 | - library_names
56 | - library_prefixes
57 | - no_adjacent_strings_in_list
58 | - no_duplicate_case_values
59 | - non_constant_identifier_names
60 | - overridden_fields
61 | - package_api_docs
62 | - package_names
63 | - package_prefixed_library_names
64 | - prefer_adjacent_string_concatenation
65 | - prefer_asserts_in_initializer_lists
66 | - prefer_collection_literals
67 | - prefer_conditional_assignment
68 | - prefer_const_constructors
69 | - prefer_const_constructors_in_immutables
70 | - prefer_const_declarations
71 | - prefer_const_literals_to_create_immutables
72 | - prefer_contains
73 | - prefer_final_fields
74 | - prefer_final_locals
75 | - prefer_foreach
76 | - prefer_generic_function_type_aliases
77 | - prefer_initializing_formals
78 | - prefer_is_empty
79 | - prefer_is_not_empty
80 | - prefer_iterable_whereType
81 | - prefer_single_quotes
82 | - prefer_typing_uninitialized_variables
83 | - prefer_void_to_null
84 | - recursive_getters
85 | - slash_for_doc_comments
86 | - sort_pub_dependencies
87 | - sort_unnamed_constructors_first
88 | - test_types_in_equals
89 | - throw_in_finally
90 | - type_init_formals
91 | - unnecessary_brace_in_string_interps
92 | - unnecessary_const
93 | - unnecessary_getters_setters
94 | - unnecessary_new
95 | - unnecessary_null_aware_assignments
96 | - unnecessary_null_in_if_null_operators
97 | - unnecessary_overrides
98 | - unnecessary_parenthesis
99 | - unnecessary_statements
100 | - unnecessary_this
101 | - unrelated_type_equality_checks
102 | - use_rethrow_when_possible
103 | - valid_regexps
104 | - public_member_api_docs
105 | - require_trailing_commas
106 |
--------------------------------------------------------------------------------
/bin/flutter_launcher_icons.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_launcher_icons/constants.dart';
2 | import 'package:flutter_launcher_icons/main.dart' as flutter_launcher_icons;
3 | import 'package:flutter_launcher_icons/src/version.dart';
4 |
5 | void main(List arguments) {
6 | print(introMessage(packageVersion));
7 | flutter_launcher_icons.createIconsFromArguments(arguments);
8 | }
9 |
--------------------------------------------------------------------------------
/bin/generate.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:args/args.dart';
4 |
5 | import 'package:flutter_launcher_icons/constants.dart';
6 | import 'package:flutter_launcher_icons/src/version.dart';
7 |
8 | const _defaultConfigFileName = './flutter_launcher_icons.yaml';
9 |
10 | /// The function will be called from command line
11 | /// using the following command:
12 | /// ```sh
13 | /// flutter pub run flutter_launcher_icons:generate
14 | /// ```
15 | ///
16 | /// Calling this function will generate a flutter_launcher_icons.yaml file
17 | /// with a default config template.
18 | ///
19 | /// This command can take 2 optional arguments:
20 | /// - --override: This will override the current `flutter_launcher_icons.yaml`
21 | /// file if it exists, if not provided, the file will not be overridden and
22 | /// a message will be printed to the console.
23 | ///
24 | /// - --fileName: This flag will take a file name as an argument and
25 | /// will generate the config format in that file instead of the default
26 | /// `flutter_launcher_icons.yaml` file, if not provided,
27 | /// the default file will be used.
28 | void main(List arguments) {
29 | print(introMessage(packageVersion));
30 |
31 | final parser = ArgParser()
32 | ..addFlag('override', abbr: 'o', defaultsTo: false)
33 | ..addOption(
34 | 'fileName',
35 | abbr: 'f',
36 | defaultsTo: _defaultConfigFileName,
37 | );
38 |
39 | final results = parser.parse(arguments);
40 | final override = results['override'] as bool;
41 | final fileName = results['fileName'] as String;
42 |
43 | // Check if fileName is valid and has a .yaml extension
44 | if (!fileName.endsWith('.yaml')) {
45 | print('Invalid file name, please provide a valid file name');
46 | return;
47 | }
48 |
49 | final file = File(fileName);
50 | if (file.existsSync()) {
51 | if (override) {
52 | print('File already exists, overriding...');
53 | _generateConfigFile(file);
54 | } else {
55 | print(
56 | 'File already exists, use --override flag to override the file, or use --fileName flag to use a different file name',
57 | );
58 | }
59 | } else {
60 | try {
61 | file.createSync(recursive: true);
62 | _generateConfigFile(file);
63 | } on Exception catch (e) {
64 | print('Error creating file: $e');
65 | }
66 | }
67 | }
68 |
69 | void _generateConfigFile(File configFile) {
70 | try {
71 | configFile.writeAsStringSync(_configFileTemplate);
72 |
73 | print('\nConfig file generated successfully 🎉');
74 | print(
75 | 'You can now use this new config file by using the command below:\n\n'
76 | 'flutter pub run flutter_launcher_icons'
77 | '${configFile.path == _defaultConfigFileName ? '' : ' -f ${configFile.path}'}\n',
78 | );
79 | } on Exception catch (e) {
80 | print('Error generating config file: $e');
81 | }
82 | }
83 |
84 | const _configFileTemplate = '''
85 | # flutter pub run flutter_launcher_icons
86 | flutter_launcher_icons:
87 | image_path: "assets/icon/icon.png"
88 |
89 | android: "launcher_icon"
90 | # image_path_android: "assets/icon/icon.png"
91 | min_sdk_android: 21 # android min sdk min:16, default 21
92 | # adaptive_icon_background: "assets/icon/background.png"
93 | # adaptive_icon_foreground: "assets/icon/foreground.png"
94 | # adaptive_icon_monochrome: "assets/icon/monochrome.png"
95 |
96 | ios: true
97 | # image_path_ios: "assets/icon/icon.png"
98 | remove_alpha_channel_ios: true
99 | # image_path_ios_dark_transparent: "assets/icon/icon_dark.png"
100 | # image_path_ios_tinted_grayscale: "assets/icon/icon_tinted.png"
101 | # desaturate_tinted_to_grayscale_ios: true
102 |
103 | web:
104 | generate: true
105 | image_path: "path/to/image.png"
106 | background_color: "#hexcode"
107 | theme_color: "#hexcode"
108 |
109 | windows:
110 | generate: true
111 | image_path: "path/to/image.png"
112 | icon_size: 48 # min:48, max:256, default: 48
113 |
114 | macos:
115 | generate: true
116 | image_path: "path/to/image.png"
117 | ''';
118 |
--------------------------------------------------------------------------------
/bin/main.dart:
--------------------------------------------------------------------------------
1 | import 'flutter_launcher_icons.dart' as flutter_launcher_icons;
2 |
3 | void main(List arguments) {
4 | print(
5 | 'This command is deprecated and replaced with "flutter pub run flutter_launcher_icons"',
6 | );
7 | flutter_launcher_icons.main(arguments);
8 | }
9 |
--------------------------------------------------------------------------------
/example/default_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.
5 |
6 | version:
7 | revision: f72efea43c3013323d1b95cff571f3c1caa37583
8 | channel: stable
9 |
10 | project_type: app
11 |
12 | # Tracks metadata for the flutter migrate command
13 | migration:
14 | platforms:
15 | - platform: root
16 | create_revision: f72efea43c3013323d1b95cff571f3c1caa37583
17 | base_revision: f72efea43c3013323d1b95cff571f3c1caa37583
18 | - platform: android
19 | create_revision: f72efea43c3013323d1b95cff571f3c1caa37583
20 | base_revision: f72efea43c3013323d1b95cff571f3c1caa37583
21 | - platform: ios
22 | create_revision: f72efea43c3013323d1b95cff571f3c1caa37583
23 | base_revision: f72efea43c3013323d1b95cff571f3c1caa37583
24 | - platform: linux
25 | create_revision: f72efea43c3013323d1b95cff571f3c1caa37583
26 | base_revision: f72efea43c3013323d1b95cff571f3c1caa37583
27 | - platform: macos
28 | create_revision: f72efea43c3013323d1b95cff571f3c1caa37583
29 | base_revision: f72efea43c3013323d1b95cff571f3c1caa37583
30 | - platform: web
31 | create_revision: f72efea43c3013323d1b95cff571f3c1caa37583
32 | base_revision: f72efea43c3013323d1b95cff571f3c1caa37583
33 | - platform: windows
34 | create_revision: f72efea43c3013323d1b95cff571f3c1caa37583
35 | base_revision: f72efea43c3013323d1b95cff571f3c1caa37583
36 |
37 | # User provided section
38 |
39 | # List of Local paths (relative to this file) that should be
40 | # ignored by the migrate tool.
41 | #
42 | # Files that are not part of the templates will be ignored by default.
43 | unmanaged_files:
44 | - 'lib/main.dart'
45 | - 'ios/Runner.xcodeproj/project.pbxproj'
46 |
--------------------------------------------------------------------------------
/example/default_example/README.md:
--------------------------------------------------------------------------------
1 | # flutter_launcher_icons
2 |
3 | A new example Flutter project to quickly test flutter_launcher_icons.
4 |
5 | Before being able to run this example you need to navigate to this directory and run the following command
6 |
7 | ```
8 | flutter create .
9 | ```
10 |
--------------------------------------------------------------------------------
/example/default_example/assets/images/background-test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/default_example/assets/images/background-test.png
--------------------------------------------------------------------------------
/example/default_example/assets/images/christmas-background.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/default_example/assets/images/christmas-background.png
--------------------------------------------------------------------------------
/example/default_example/assets/images/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/default_example/assets/images/ic_launcher.png
--------------------------------------------------------------------------------
/example/default_example/assets/images/icon-1024x1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/default_example/assets/images/icon-1024x1024.png
--------------------------------------------------------------------------------
/example/default_example/assets/images/icon-128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/default_example/assets/images/icon-128x128.png
--------------------------------------------------------------------------------
/example/default_example/assets/images/icon-710x599-android.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/default_example/assets/images/icon-710x599-android.png
--------------------------------------------------------------------------------
/example/default_example/assets/images/icon-710x599-ios.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/default_example/assets/images/icon-710x599-ios.png
--------------------------------------------------------------------------------
/example/default_example/assets/images/icon-710x599.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/default_example/assets/images/icon-710x599.png
--------------------------------------------------------------------------------
/example/default_example/assets/images/icon-foreground-432x432.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/default_example/assets/images/icon-foreground-432x432.png
--------------------------------------------------------------------------------
/example/default_example/assets/images/icon-monochrome-432x432.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/default_example/assets/images/icon-monochrome-432x432.png
--------------------------------------------------------------------------------
/example/default_example/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: example
2 | description: A new Flutter project to quickly test flutter_launcher_icons.
3 |
4 | version: 1.0.0+1
5 |
6 | environment:
7 | sdk: ">=2.17.0 <3.0.0"
8 |
9 | dependencies:
10 | flutter:
11 | sdk: flutter
12 | cupertino_icons: ^1.0.3
13 | flutter_launcher_icons:
14 | path: ../..
15 |
16 | flutter_launcher_icons:
17 | # image_path: "assets/images/icon-128x128.png"
18 | image_path_android: "assets/images/icon-710x599-android.png"
19 | image_path_ios: "assets/images/icon-1024x1024.png"
20 | android: true # can specify file name here e.g. "ic_launcher"
21 | ios: true # can specify file name here e.g. "My-Launcher-Icon"
22 | adaptive_icon_background: "assets/images/christmas-background.png" # only available for Android 8.0 devices and above
23 | adaptive_icon_foreground: "assets/images/icon-foreground-432x432.png" # only available for Android 8.0 devices and above
24 | adaptive_icon_foreground_inset: 16 # only available for Android 8.0 devices and above
25 | adaptive_icon_monochrome: "assets/images/icon-monochrome-432x432.png" # only available for Android 13 devices and above
26 | min_sdk_android: 21 # android min sdk min:16, default 21
27 | remove_alpha_ios: true
28 | background_color_ios: "#ffffff"
29 | web:
30 | generate: true
31 | image_path: "assets/images/icon-1024x1024.png"
32 | background_color: "#hexcode"
33 | theme_color: "#hexcode"
34 | windows:
35 | generate: true
36 | image_path: "assets/images/icon-1024x1024.png"
37 | icon_size: 48 # min:48, max:256, default: 48
38 | macos:
39 | generate: true
40 | image_path: "assets/images/icon-1024x1024.png"
41 |
42 | dev_dependencies:
43 | flutter_test:
44 | sdk: flutter
45 |
46 | flutter:
47 | uses-material-design: true
48 |
--------------------------------------------------------------------------------
/example/example.md:
--------------------------------------------------------------------------------
1 | # flutter launcher icons examples
2 |
3 | - [default_example](https://github.com/fluttercommunity/flutter_launcher_icons/tree/master/example/default_example)
4 |
5 | - [flavors_example](https://github.com/fluttercommunity/flutter_launcher_icons/tree/master/example/flavors)
6 |
--------------------------------------------------------------------------------
/example/flavors/.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: f18b9281c2280c2646aa3d4348715ed5bb9446c8
8 | channel: beta
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/example/flavors/README.md:
--------------------------------------------------------------------------------
1 | # example_with_flavors
2 |
3 | A new Flutter project to showcase how to use different icons
4 |
5 | ## How to run this project
6 |
7 | Before being able to run this example you need to navigate to this directory and run the following command
8 |
9 | ```
10 | flutter create .
11 | ```
12 |
13 | This project has the following flavors:
14 |
15 | - production: `flutter run --flavor production`
16 | - development: `flutter run --flavor development`
17 | - integration: `flutter run --flavor integration`
18 |
--------------------------------------------------------------------------------
/example/flavors/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
--------------------------------------------------------------------------------
/example/flavors/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 28
30 |
31 | sourceSets {
32 | main.java.srcDirs += 'src/main/kotlin'
33 | }
34 |
35 | lintOptions {
36 | disable 'InvalidPackage'
37 | }
38 |
39 | defaultConfig {
40 | applicationId "com.flutter.icons.example_with_flavors"
41 | minSdkVersion 23
42 | targetSdkVersion 28
43 | versionCode flutterVersionCode.toInteger()
44 | versionName flutterVersionName
45 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
46 | }
47 |
48 | flavorDimensions "default"
49 | productFlavors {
50 | production {
51 | dimension "default"
52 | applicationIdSuffix ""
53 | manifestPlaceholders = [appName: "example_with_flavors"]
54 | }
55 | development {
56 | dimension "default"
57 | applicationIdSuffix ".dev"
58 | manifestPlaceholders = [appName: "[DEV] example_with_flavors"]
59 | }
60 | integration {
61 | dimension "default"
62 | applicationIdSuffix ".int"
63 | manifestPlaceholders = [appName: "[INT] example_with_flavors"]
64 | }
65 | }
66 |
67 | buildTypes {
68 | release {
69 | // TODO: Add your own signing config for the release build.
70 | // Signing with the debug keys for now, so `flutter run --release` works.
71 | signingConfig signingConfigs.debug
72 | }
73 | }
74 | }
75 |
76 | flutter {
77 | source '../..'
78 | }
79 |
80 | dependencies {
81 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
82 | testImplementation 'junit:junit:4.12'
83 | androidTestImplementation 'androidx.test:runner:1.1.1'
84 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
85 | }
86 |
--------------------------------------------------------------------------------
/example/flavors/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/flavors/android/app/src/development/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/development/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/development/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/development/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/development/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/development/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/development/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/development/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/development/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/development/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/integration/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/integration/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/integration/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/integration/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/integration/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/integration/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/integration/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/integration/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/integration/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/integration/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
8 |
12 |
19 |
20 |
21 |
22 |
23 |
24 |
26 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/kotlin/com/flutter/icons/example_with_flavors/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.flutter.icons.example_with_flavors
2 |
3 | import androidx.annotation.NonNull;
4 | import io.flutter.embedding.android.FlutterActivity
5 | import io.flutter.embedding.engine.FlutterEngine
6 | import io.flutter.plugins.GeneratedPluginRegistrant
7 |
8 | class MainActivity: FlutterActivity() {
9 | override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
10 | GeneratedPluginRegistrant.registerWith(flutterEngine);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/kotlin/com/flutter/icons/flavors/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.flutter.icons.flavors
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/example/flavors/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
8 |
9 |
--------------------------------------------------------------------------------
/example/flavors/android/app/src/production/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/production/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/production/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/production/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/production/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/production/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/production/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/production/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/production/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/android/app/src/production/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/example/flavors/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/example/flavors/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/flavors/android/flavors_android.iml:
--------------------------------------------------------------------------------
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 |
--------------------------------------------------------------------------------
/example/flavors/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.enableR8=true
3 | android.useAndroidX=true
4 | android.enableJetifier=true
5 |
--------------------------------------------------------------------------------
/example/flavors/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 |
--------------------------------------------------------------------------------
/example/flavors/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def flutterProjectRoot = rootProject.projectDir.parentFile.toPath()
4 |
5 | def plugins = new Properties()
6 | def pluginsFile = new File(flutterProjectRoot.toFile(), '.flutter-plugins')
7 | if (pluginsFile.exists()) {
8 | pluginsFile.withReader('UTF-8') { reader -> plugins.load(reader) }
9 | }
10 |
11 | plugins.each { name, path ->
12 | def pluginDirectory = flutterProjectRoot.resolve(path).resolve('android').toFile()
13 | include ":$name"
14 | project(":$name").projectDir = pluginDirectory
15 | }
16 |
--------------------------------------------------------------------------------
/example/flavors/assets/launcher_icon/demo-icon-dev.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/assets/launcher_icon/demo-icon-dev.png
--------------------------------------------------------------------------------
/example/flavors/assets/launcher_icon/demo-icon-int.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/assets/launcher_icon/demo-icon-int.png
--------------------------------------------------------------------------------
/example/flavors/assets/launcher_icon/demo-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/fluttercommunity/flutter_launcher_icons/f24d6bf72267db9ef7e443a283c4549c1413d914/example/flavors/assets/launcher_icon/demo-icon.png
--------------------------------------------------------------------------------
/example/flavors/flavors.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/example/flavors/flutter_launcher_icons-development.yaml:
--------------------------------------------------------------------------------
1 | flutter_launcher_icons:
2 | android: true
3 | ios: true
4 | image_path: "assets/launcher_icon/demo-icon-dev.png"
5 |
--------------------------------------------------------------------------------
/example/flavors/flutter_launcher_icons-integration.yaml:
--------------------------------------------------------------------------------
1 | flutter_launcher_icons:
2 | android: true
3 | ios: true
4 | image_path: "assets/launcher_icon/demo-icon-int.png"
5 |
--------------------------------------------------------------------------------
/example/flavors/flutter_launcher_icons-production.yaml:
--------------------------------------------------------------------------------
1 | flutter_launcher_icons:
2 | android: true
3 | ios: true
4 | image_path: "assets/launcher_icon/demo-icon.png"
--------------------------------------------------------------------------------
/example/flavors/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: example_with_flavors
2 | description: A new Flutter project.
3 | version: 1.0.0+1
4 |
5 | environment:
6 | sdk: ">=2.12.0 <3.0.0"
7 |
8 | dependencies:
9 | flutter:
10 | sdk: flutter
11 | flutter_launcher_icons:
12 | path: ../..
13 |
14 | flutter:
15 | uses-material-design: true
16 |
--------------------------------------------------------------------------------
/flutter_launcher_icons.code-workspace:
--------------------------------------------------------------------------------
1 | {
2 | "folders": [
3 | {
4 | "name": "Flutter Launcher Icons",
5 | "path": "."
6 | }
7 | ],
8 | "settings": {
9 | "[dart]": {
10 | "editor.formatOnSave": true,
11 | // "editor.formatOnType": true,
12 | "editor.rulers": [
13 | 120
14 | ],
15 | "editor.selectionHighlight": false,
16 | "editor.suggest.snippetsPreventQuickSuggestions": false,
17 | "editor.suggestSelection": "first",
18 | "editor.tabCompletion": "onlySnippets",
19 | "editor.wordBasedSuggestions": false,
20 | "files.insertFinalNewline": true
21 | },
22 | "dart.lineLength": 120,
23 | }
24 | }
--------------------------------------------------------------------------------
/lib/abs/icon_generator.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:flutter_launcher_icons/config/config.dart';
4 | import 'package:flutter_launcher_icons/config/macos_config.dart';
5 | import 'package:flutter_launcher_icons/config/web_config.dart';
6 | import 'package:flutter_launcher_icons/config/windows_config.dart';
7 | import 'package:flutter_launcher_icons/logger.dart';
8 |
9 | /// A base class to generate icons
10 | abstract class IconGenerator {
11 | /// Contains config
12 | final IconGeneratorContext context;
13 |
14 | /// Name of the platform this [IconGenerator] is created for.
15 | final String platformName;
16 |
17 | /// Creates a instance of [IconGenerator].
18 | ///
19 | /// A [context] is created and provided by [generateIconsFor],
20 | /// [platformName] takes the name of the platform that this [IconGenerator]
21 | /// is implemented for
22 | ///
23 | /// Also Refer
24 | /// - [WebIconGenerator] generate icons for web
25 | /// - [generateIconFor] generates icons for given platform
26 | IconGenerator(this.context, this.platformName);
27 |
28 | /// Creates icons for this platform.
29 | void createIcons();
30 |
31 | /// Should return `true` if this platform
32 | /// has all the requirements to create icons.
33 | /// This runs before to [createIcons]
34 | bool validateRequirements();
35 | }
36 |
37 | /// Provides easy access to user arguments and configuration
38 | class IconGeneratorContext {
39 | /// Contains configuration from configuration file
40 | final Config config;
41 |
42 | /// A logger
43 | final FLILogger logger;
44 |
45 | /// Value of `--prefix` flag
46 | final String prefixPath;
47 |
48 | /// Value of `--flavor` flag
49 | final String? flavor;
50 |
51 | /// Creates an instance of [IconGeneratorContext]
52 | IconGeneratorContext({
53 | required this.config,
54 | required this.logger,
55 | required this.prefixPath,
56 | this.flavor,
57 | });
58 |
59 | /// Shortcut for `config.webConfig`
60 | WebConfig? get webConfig => config.webConfig;
61 |
62 | /// Shortcut for `config.windowsConfig`
63 | WindowsConfig? get windowsConfig => config.windowsConfig;
64 |
65 | /// Shortcut for `config.macOSConfig`
66 | MacOSConfig? get macOSConfig => config.macOSConfig;
67 | }
68 |
69 | /// Generates Icon for given platforms
70 | void generateIconsFor({
71 | required Config config,
72 | required String? flavor,
73 | required String prefixPath,
74 | required FLILogger logger,
75 | required List Function(IconGeneratorContext context) platforms,
76 | }) {
77 | try {
78 | final platformList = platforms(
79 | IconGeneratorContext(
80 | config: config,
81 | logger: logger,
82 | prefixPath: prefixPath,
83 | flavor: flavor,
84 | ),
85 | );
86 | if (platformList.isEmpty) {
87 | // ? maybe we can print help
88 | logger.info('No platform provided');
89 | }
90 |
91 | for (final platform in platformList) {
92 | final progress =
93 | logger.progress('Creating Icons for ${platform.platformName}');
94 | logger.verbose(
95 | 'Validating platform requirements for ${platform.platformName}',
96 | );
97 | // in case a platform throws an exception it should not effect other platforms
98 | try {
99 | if (!platform.validateRequirements()) {
100 | logger.error(
101 | 'Requirements failed for platform ${platform.platformName}. Skipped',
102 | );
103 | progress.cancel();
104 | continue;
105 | }
106 | platform.createIcons();
107 | progress.finish(message: 'done', showTiming: true);
108 | } catch (e, st) {
109 | progress.cancel();
110 | logger
111 | ..error(e.toString())
112 | ..verbose(st);
113 | continue;
114 | }
115 | }
116 | } catch (e, st) {
117 | // TODO(RatakondalaArun): better error handling
118 | // stacktrace should only print when verbose is turned on
119 | // else a normal help line
120 | logger
121 | ..error(e.toString())
122 | ..verbose(st);
123 | exit(1);
124 | }
125 | }
126 |
--------------------------------------------------------------------------------
/lib/config/config.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:checked_yaml/checked_yaml.dart' as yaml;
4 | import 'package:flutter_launcher_icons/config/macos_config.dart';
5 | import 'package:flutter_launcher_icons/config/web_config.dart';
6 | import 'package:flutter_launcher_icons/config/windows_config.dart';
7 | import 'package:flutter_launcher_icons/constants.dart' as constants;
8 | import 'package:flutter_launcher_icons/custom_exceptions.dart';
9 | import 'package:flutter_launcher_icons/utils.dart' as utils;
10 | import 'package:json_annotation/json_annotation.dart';
11 | import 'package:path/path.dart' as path;
12 |
13 | part 'config.g.dart';
14 |
15 | /// A model representing the flutter_launcher_icons configuration
16 | @JsonSerializable(
17 | anyMap: true,
18 | checked: true,
19 | )
20 | class Config {
21 | /// Creates an instance of [Config]
22 | const Config({
23 | this.imagePath,
24 | this.android = false,
25 | this.ios = false,
26 | this.imagePathAndroid,
27 | this.imagePathIOS,
28 | this.imagePathIOSDarkTransparent,
29 | this.imagePathIOSTintedGrayscale,
30 | this.adaptiveIconForeground,
31 | this.adaptiveIconForegroundInset = 16,
32 | this.adaptiveIconBackground,
33 | this.adaptiveIconMonochrome,
34 | this.minSdkAndroid = constants.androidDefaultAndroidMinSDK,
35 | this.removeAlphaIOS = false,
36 | this.desaturateTintedToGrayscaleIOS = false,
37 | this.backgroundColorIOS = '#ffffff',
38 | this.webConfig,
39 | this.windowsConfig,
40 | this.macOSConfig,
41 | });
42 |
43 | /// Creates [Config] for given [flavor] and [prefixPath]
44 | static Config? loadConfigFromFlavor(
45 | String flavor,
46 | String prefixPath,
47 | ) {
48 | return _getConfigFromPubspecYaml(
49 | prefix: prefixPath,
50 | pathToPubspecYamlFile: utils.flavorConfigFile(flavor),
51 | );
52 | }
53 |
54 | /// Loads flutter launcher icons configs from given [filePath]
55 | static Config? loadConfigFromPath(String filePath, String prefixPath) {
56 | return _getConfigFromPubspecYaml(
57 | prefix: prefixPath,
58 | pathToPubspecYamlFile: filePath,
59 | );
60 | }
61 |
62 | /// Loads flutter launcher icons config from `pubspec.yaml` file
63 | static Config? loadConfigFromPubSpec(String prefix) {
64 | return _getConfigFromPubspecYaml(
65 | prefix: prefix,
66 | pathToPubspecYamlFile: constants.pubspecFilePath,
67 | );
68 | }
69 |
70 | static Config? _getConfigFromPubspecYaml({
71 | required String pathToPubspecYamlFile,
72 | required String prefix,
73 | }) {
74 | final configFile = File(path.join(prefix, pathToPubspecYamlFile));
75 | if (!configFile.existsSync()) {
76 | return null;
77 | }
78 | final configContent = configFile.readAsStringSync();
79 | try {
80 | return yaml.checkedYamlDecode(
81 | configContent,
82 | (Map? json) {
83 | if (json != null) {
84 | // if we have flutter_icons configuration ...
85 | if (json['flutter_icons'] != null) {
86 | stderr.writeln('\n⚠ Warning: flutter_icons has been deprecated '
87 | 'please use flutter_launcher_icons instead in your yaml files');
88 | return Config.fromJson(json['flutter_icons']);
89 | }
90 | // if we have flutter_launcher_icons configuration ...
91 | if (json['flutter_launcher_icons'] != null) {
92 | return Config.fromJson(json['flutter_launcher_icons']);
93 | }
94 | }
95 | return null;
96 | },
97 | allowNull: true,
98 | );
99 | } on yaml.ParsedYamlException catch (e) {
100 | throw InvalidConfigException(e.formattedMessage);
101 | } catch (e) {
102 | rethrow;
103 | }
104 | }
105 |
106 | /// Generic image_path
107 | @JsonKey(name: 'image_path')
108 | final String? imagePath;
109 |
110 | /// Returns true or path if android config is enabled
111 | final dynamic android; // path or bool
112 |
113 | /// Returns true or path if ios config is enabled
114 | final dynamic ios; // path or bool
115 |
116 | /// Image path specific to android
117 | @JsonKey(name: 'image_path_android')
118 | final String? imagePathAndroid;
119 |
120 | /// Image path specific to ios
121 | @JsonKey(name: 'image_path_ios')
122 | final String? imagePathIOS;
123 |
124 | /// IOS image_path_ios_dark_transparent
125 | @JsonKey(name: 'image_path_ios_dark_transparent')
126 | final String? imagePathIOSDarkTransparent;
127 |
128 | /// IOS image_path_ios_tinted_grayscale
129 | @JsonKey(name: 'image_path_ios_tinted_grayscale')
130 | final String? imagePathIOSTintedGrayscale;
131 |
132 | /// android adaptive_icon_foreground image
133 | @JsonKey(name: 'adaptive_icon_foreground')
134 | final String? adaptiveIconForeground;
135 |
136 | /// android adaptive_icon_foreground inset
137 | @JsonKey(name: 'adaptive_icon_foreground_inset')
138 | final int adaptiveIconForegroundInset;
139 |
140 | /// android adaptive_icon_background image
141 | @JsonKey(name: 'adaptive_icon_background')
142 | final String? adaptiveIconBackground;
143 |
144 | /// android adaptive_icon_background image
145 | @JsonKey(name: 'adaptive_icon_monochrome')
146 | final String? adaptiveIconMonochrome;
147 |
148 | /// Android min_sdk_android
149 | @JsonKey(name: 'min_sdk_android')
150 | final int minSdkAndroid;
151 |
152 | /// IOS remove_alpha_ios
153 | @JsonKey(name: 'remove_alpha_ios')
154 | final bool removeAlphaIOS;
155 |
156 | /// IOS desaturate_tinted_to_grayscale
157 | @JsonKey(name: 'desaturate_tinted_to_grayscale_ios')
158 | final bool desaturateTintedToGrayscaleIOS;
159 |
160 | /// IOS background_color_ios
161 | @JsonKey(name: 'background_color_ios')
162 | final String backgroundColorIOS;
163 |
164 | /// Web platform config
165 | @JsonKey(name: 'web')
166 | final WebConfig? webConfig;
167 |
168 | /// Windows platform config
169 | @JsonKey(name: 'windows')
170 | final WindowsConfig? windowsConfig;
171 |
172 | /// MacOS platform config
173 | @JsonKey(name: 'macos')
174 | final MacOSConfig? macOSConfig;
175 |
176 | /// Creates [Config] icons from [json]
177 | factory Config.fromJson(Map json) => _$ConfigFromJson(json);
178 |
179 | /// whether or not there is configuration for adaptive icons for android
180 | bool get hasAndroidAdaptiveConfig =>
181 | isNeedingNewAndroidIcon &&
182 | adaptiveIconForeground != null &&
183 | adaptiveIconBackground != null;
184 |
185 | /// whether or not there is configuration for monochrome icons for android
186 | bool get hasAndroidAdaptiveMonochromeConfig {
187 | return isNeedingNewAndroidIcon && adaptiveIconMonochrome != null;
188 | }
189 |
190 | /// Checks if contains any platform config
191 | bool get hasPlatformConfig {
192 | return ios != false ||
193 | android != false ||
194 | webConfig != null ||
195 | windowsConfig != null ||
196 | macOSConfig != null;
197 | }
198 |
199 | /// Whether or not configuration for generating Web icons exist
200 | bool get hasWebConfig => webConfig != null;
201 |
202 | /// Whether or not configuration for generating Windows icons exist
203 | bool get hasWindowsConfig => windowsConfig != null;
204 |
205 | /// Whether or not configuration for generating MacOS icons exists
206 | bool get hasMacOSConfig => macOSConfig != null;
207 |
208 | /// Check to see if specified Android config is a string or bool
209 | /// String - Generate new launcher icon with the string specified
210 | /// bool - override the default flutter project icon
211 | bool get isCustomAndroidFile => android is String;
212 |
213 | /// if we are needing a new Android icon
214 | bool get isNeedingNewAndroidIcon => android != false;
215 |
216 | /// if we are needing a new iOS icon
217 | bool get isNeedingNewIOSIcon => ios != false;
218 |
219 | /// Method for the retrieval of the Android icon path
220 | /// If image_path_android is found, this will be prioritised over the image_path
221 | /// value.
222 | String? getImagePathAndroid() => imagePathAndroid ?? imagePath;
223 |
224 | // TODO(RatakondalaArun): refactor after Android & iOS configs will be refactored to the new schema
225 | // https://github.com/fluttercommunity/flutter_launcher_icons/issues/394
226 | /// get the image path for IOS
227 | String? getImagePathIOS() => imagePathIOS ?? imagePath;
228 |
229 | /// Converts config to [Map]
230 | Map toJson() => _$ConfigToJson(this);
231 |
232 | @override
233 | String toString() => 'FlutterLauncherIconsConfig: ${toJson()}';
234 | }
235 |
--------------------------------------------------------------------------------
/lib/config/config.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'config.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | Config _$ConfigFromJson(Map json) => $checkedCreate(
10 | 'Config',
11 | json,
12 | ($checkedConvert) {
13 | final val = Config(
14 | imagePath: $checkedConvert('image_path', (v) => v as String?),
15 | android: $checkedConvert('android', (v) => v ?? false),
16 | ios: $checkedConvert('ios', (v) => v ?? false),
17 | imagePathAndroid:
18 | $checkedConvert('image_path_android', (v) => v as String?),
19 | imagePathIOS: $checkedConvert('image_path_ios', (v) => v as String?),
20 | imagePathIOSDarkTransparent: $checkedConvert(
21 | 'image_path_ios_dark_transparent', (v) => v as String?),
22 | imagePathIOSTintedGrayscale: $checkedConvert(
23 | 'image_path_ios_tinted_grayscale', (v) => v as String?),
24 | adaptiveIconForeground:
25 | $checkedConvert('adaptive_icon_foreground', (v) => v as String?),
26 | adaptiveIconForegroundInset: $checkedConvert(
27 | 'adaptive_icon_foreground_inset',
28 | (v) => (v as num?)?.toInt() ?? 16),
29 | adaptiveIconBackground:
30 | $checkedConvert('adaptive_icon_background', (v) => v as String?),
31 | adaptiveIconMonochrome:
32 | $checkedConvert('adaptive_icon_monochrome', (v) => v as String?),
33 | minSdkAndroid: $checkedConvert(
34 | 'min_sdk_android',
35 | (v) =>
36 | (v as num?)?.toInt() ??
37 | constants.androidDefaultAndroidMinSDK),
38 | removeAlphaIOS:
39 | $checkedConvert('remove_alpha_ios', (v) => v as bool? ?? false),
40 | desaturateTintedToGrayscaleIOS: $checkedConvert(
41 | 'desaturate_tinted_to_grayscale_ios', (v) => v as bool? ?? false),
42 | backgroundColorIOS: $checkedConvert(
43 | 'background_color_ios', (v) => v as String? ?? '#ffffff'),
44 | webConfig: $checkedConvert(
45 | 'web', (v) => v == null ? null : WebConfig.fromJson(v as Map)),
46 | windowsConfig: $checkedConvert('windows',
47 | (v) => v == null ? null : WindowsConfig.fromJson(v as Map)),
48 | macOSConfig: $checkedConvert('macos',
49 | (v) => v == null ? null : MacOSConfig.fromJson(v as Map)),
50 | );
51 | return val;
52 | },
53 | fieldKeyMap: const {
54 | 'imagePath': 'image_path',
55 | 'imagePathAndroid': 'image_path_android',
56 | 'imagePathIOS': 'image_path_ios',
57 | 'imagePathIOSDarkTransparent': 'image_path_ios_dark_transparent',
58 | 'imagePathIOSTintedGrayscale': 'image_path_ios_tinted_grayscale',
59 | 'adaptiveIconForeground': 'adaptive_icon_foreground',
60 | 'adaptiveIconForegroundInset': 'adaptive_icon_foreground_inset',
61 | 'adaptiveIconBackground': 'adaptive_icon_background',
62 | 'adaptiveIconMonochrome': 'adaptive_icon_monochrome',
63 | 'minSdkAndroid': 'min_sdk_android',
64 | 'removeAlphaIOS': 'remove_alpha_ios',
65 | 'desaturateTintedToGrayscaleIOS': 'desaturate_tinted_to_grayscale_ios',
66 | 'backgroundColorIOS': 'background_color_ios',
67 | 'webConfig': 'web',
68 | 'windowsConfig': 'windows',
69 | 'macOSConfig': 'macos'
70 | },
71 | );
72 |
73 | Map _$ConfigToJson(Config instance) => {
74 | 'image_path': instance.imagePath,
75 | 'android': instance.android,
76 | 'ios': instance.ios,
77 | 'image_path_android': instance.imagePathAndroid,
78 | 'image_path_ios': instance.imagePathIOS,
79 | 'image_path_ios_dark_transparent': instance.imagePathIOSDarkTransparent,
80 | 'image_path_ios_tinted_grayscale': instance.imagePathIOSTintedGrayscale,
81 | 'adaptive_icon_foreground': instance.adaptiveIconForeground,
82 | 'adaptive_icon_foreground_inset': instance.adaptiveIconForegroundInset,
83 | 'adaptive_icon_background': instance.adaptiveIconBackground,
84 | 'adaptive_icon_monochrome': instance.adaptiveIconMonochrome,
85 | 'min_sdk_android': instance.minSdkAndroid,
86 | 'remove_alpha_ios': instance.removeAlphaIOS,
87 | 'desaturate_tinted_to_grayscale_ios':
88 | instance.desaturateTintedToGrayscaleIOS,
89 | 'background_color_ios': instance.backgroundColorIOS,
90 | 'web': instance.webConfig,
91 | 'windows': instance.windowsConfig,
92 | 'macos': instance.macOSConfig,
93 | };
94 |
--------------------------------------------------------------------------------
/lib/config/macos_config.dart:
--------------------------------------------------------------------------------
1 | import 'package:json_annotation/json_annotation.dart';
2 |
3 | part 'macos_config.g.dart';
4 |
5 | /// The flutter_launcher_icons configuration set for MacOS
6 | @JsonSerializable(
7 | anyMap: true,
8 | checked: true,
9 | )
10 | class MacOSConfig {
11 | /// Specifies weather to generate icons for macos
12 | @JsonKey()
13 | final bool generate;
14 |
15 | /// Image path for macos
16 | @JsonKey(name: 'image_path')
17 | final String? imagePath;
18 |
19 | /// Creates a instance of [MacOSConfig]
20 | const MacOSConfig({
21 | this.generate = false,
22 | this.imagePath,
23 | });
24 |
25 | /// Creates [WebConfig] from [json]
26 | factory MacOSConfig.fromJson(Map json) => _$MacOSConfigFromJson(json);
27 |
28 | /// Creates [Map] from [WebConfig]
29 | Map toJson() => _$MacOSConfigToJson(this);
30 |
31 | @override
32 | String toString() => '$runtimeType: ${toJson()}';
33 | }
34 |
--------------------------------------------------------------------------------
/lib/config/macos_config.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'macos_config.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | MacOSConfig _$MacOSConfigFromJson(Map json) => $checkedCreate(
10 | 'MacOSConfig',
11 | json,
12 | ($checkedConvert) {
13 | final val = MacOSConfig(
14 | generate: $checkedConvert('generate', (v) => v as bool? ?? false),
15 | imagePath: $checkedConvert('image_path', (v) => v as String?),
16 | );
17 | return val;
18 | },
19 | fieldKeyMap: const {'imagePath': 'image_path'},
20 | );
21 |
22 | Map _$MacOSConfigToJson(MacOSConfig instance) =>
23 | {
24 | 'generate': instance.generate,
25 | 'image_path': instance.imagePath,
26 | };
27 |
--------------------------------------------------------------------------------
/lib/config/web_config.dart:
--------------------------------------------------------------------------------
1 | import 'package:json_annotation/json_annotation.dart';
2 |
3 | part 'web_config.g.dart';
4 |
5 | /// The flutter_launcher_icons configuration set for Web
6 | @JsonSerializable(
7 | anyMap: true,
8 | checked: true,
9 | )
10 | class WebConfig {
11 | /// Specifies weather to generate icons for web
12 | final bool generate;
13 |
14 | /// Image path for web
15 | @JsonKey(name: 'image_path')
16 | final String? imagePath;
17 |
18 | /// manifest.json's background_color
19 | @JsonKey(name: 'background_color')
20 | final String? backgroundColor;
21 |
22 | /// manifest.json's theme_color
23 | @JsonKey(name: 'theme_color')
24 | final String? themeColor;
25 |
26 | /// Creates an instance of [WebConfig]
27 | const WebConfig({
28 | this.generate = false,
29 | this.imagePath,
30 | this.backgroundColor,
31 | this.themeColor,
32 | });
33 |
34 | /// Creates [WebConfig] from [json]
35 | factory WebConfig.fromJson(Map json) => _$WebConfigFromJson(json);
36 |
37 | /// Creates [Map] from [WebConfig]
38 | Map toJson() => _$WebConfigToJson(this);
39 |
40 | @override
41 | String toString() => 'WebConfig: ${toJson()}';
42 | }
43 |
--------------------------------------------------------------------------------
/lib/config/web_config.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'web_config.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | WebConfig _$WebConfigFromJson(Map json) => $checkedCreate(
10 | 'WebConfig',
11 | json,
12 | ($checkedConvert) {
13 | final val = WebConfig(
14 | generate: $checkedConvert('generate', (v) => v as bool? ?? false),
15 | imagePath: $checkedConvert('image_path', (v) => v as String?),
16 | backgroundColor:
17 | $checkedConvert('background_color', (v) => v as String?),
18 | themeColor: $checkedConvert('theme_color', (v) => v as String?),
19 | );
20 | return val;
21 | },
22 | fieldKeyMap: const {
23 | 'imagePath': 'image_path',
24 | 'backgroundColor': 'background_color',
25 | 'themeColor': 'theme_color'
26 | },
27 | );
28 |
29 | Map _$WebConfigToJson(WebConfig instance) => {
30 | 'generate': instance.generate,
31 | 'image_path': instance.imagePath,
32 | 'background_color': instance.backgroundColor,
33 | 'theme_color': instance.themeColor,
34 | };
35 |
--------------------------------------------------------------------------------
/lib/config/windows_config.dart:
--------------------------------------------------------------------------------
1 | import 'package:json_annotation/json_annotation.dart';
2 |
3 | part 'windows_config.g.dart';
4 |
5 | /// The flutter_launcher_icons configuration set for Windows
6 | @JsonSerializable(
7 | anyMap: true,
8 | checked: true,
9 | )
10 | class WindowsConfig {
11 | /// Specifies weather to generate icons for web
12 | final bool generate;
13 |
14 | /// Image path for web
15 | @JsonKey(name: 'image_path')
16 | final String? imagePath;
17 |
18 | /// Size of the icon to generate
19 | @JsonKey(name: 'icon_size')
20 | final int? iconSize;
21 |
22 | /// Creates a instance of [WindowsConfig]
23 | const WindowsConfig({
24 | this.generate = false,
25 | this.imagePath,
26 | this.iconSize,
27 | });
28 |
29 | /// Creates [WindowsConfig] from [json]
30 | factory WindowsConfig.fromJson(Map json) => _$WindowsConfigFromJson(json);
31 |
32 | /// Creates [Map] from [WindowsConfig]
33 | Map toJson() => _$WindowsConfigToJson(this);
34 |
35 | @override
36 | String toString() => 'WindowsConfig: ${toJson()}';
37 | }
38 |
--------------------------------------------------------------------------------
/lib/config/windows_config.g.dart:
--------------------------------------------------------------------------------
1 | // GENERATED CODE - DO NOT MODIFY BY HAND
2 |
3 | part of 'windows_config.dart';
4 |
5 | // **************************************************************************
6 | // JsonSerializableGenerator
7 | // **************************************************************************
8 |
9 | WindowsConfig _$WindowsConfigFromJson(Map json) => $checkedCreate(
10 | 'WindowsConfig',
11 | json,
12 | ($checkedConvert) {
13 | final val = WindowsConfig(
14 | generate: $checkedConvert('generate', (v) => v as bool? ?? false),
15 | imagePath: $checkedConvert('image_path', (v) => v as String?),
16 | iconSize: $checkedConvert('icon_size', (v) => (v as num?)?.toInt()),
17 | );
18 | return val;
19 | },
20 | fieldKeyMap: const {'imagePath': 'image_path', 'iconSize': 'icon_size'},
21 | );
22 |
23 | Map _$WindowsConfigToJson(WindowsConfig instance) =>
24 | {
25 | 'generate': instance.generate,
26 | 'image_path': instance.imagePath,
27 | 'icon_size': instance.iconSize,
28 | };
29 |
--------------------------------------------------------------------------------
/lib/constants.dart:
--------------------------------------------------------------------------------
1 | // ignore_for_file: public_member_api_docs
2 |
3 | import 'package:path/path.dart' as path;
4 |
5 | /// Relative path to android resource folder
6 | String androidResFolder(String? flavor) =>
7 | "android/app/src/${flavor ?? 'main'}/res/";
8 |
9 | /// Relative path to android colors.xml file
10 | String androidColorsFile(String? flavor) =>
11 | "android/app/src/${flavor ?? 'main'}/res/values/colors.xml";
12 |
13 | const String androidManifestFile = 'android/app/src/main/AndroidManifest.xml';
14 | const String androidGradleFile = 'android/app/build.gradle';
15 | const String androidLocalPropertiesFile = 'android/local.properties';
16 |
17 | /// Relative path to flutter.gradle from flutter sdk path
18 | const String androidFlutterGardlePath =
19 | 'packages/flutter_tools/gradle/flutter.gradle';
20 |
21 | /// Default min_sdk value for android
22 | /// https://github.com/flutter/flutter/blob/master/packages/flutter_tools/gradle/flutter.gradle#L35-L37
23 | const int androidDefaultAndroidMinSDK = 21;
24 | const String androidFileName = 'ic_launcher.png';
25 | const String androidAdaptiveForegroundFileName = 'ic_launcher_foreground.png';
26 | const String androidAdaptiveBackgroundFileName = 'ic_launcher_background.png';
27 | const String androidAdaptiveMonochromeFileName = 'ic_launcher_monochrome.png';
28 | String androidAdaptiveXmlFolder(String? flavor) =>
29 | androidResFolder(flavor) + 'mipmap-anydpi-v26/';
30 | const String androidDefaultIconName = 'ic_launcher';
31 |
32 | const String iosDefaultIconFolder =
33 | 'ios/Runner/Assets.xcassets/AppIcon.appiconset/';
34 | const String iosAssetFolder = 'ios/Runner/Assets.xcassets/';
35 | const String iosConfigFile = 'ios/Runner.xcodeproj/project.pbxproj';
36 | const String iosDefaultIconName = 'Icon-App';
37 |
38 | // web
39 | /// favicon.ico size
40 | const int kFaviconSize = 16;
41 |
42 | /// Relative web direcotry path
43 | String webDirPath = path.join('web');
44 |
45 | /// Relative web icons directory path
46 | String webIconsDirPath = path.join(webDirPath, 'icons');
47 |
48 | /// Relative web manifest.json file path
49 | String webManifestFilePath = path.join(webDirPath, 'manifest.json');
50 | // TODO(RatakondalaArun): support for other images formats
51 | /// Relative favicon.png path
52 | String webFaviconFilePath = path.join(webDirPath, 'favicon.png');
53 |
54 | /// Relative index.html file path
55 | String webIndexFilePath = path.join(webDirPath, 'index.html');
56 |
57 | /// Relative pubspec.yaml path
58 | String pubspecFilePath = path.join('pubspec.yaml');
59 |
60 | // Windows
61 | /// Relative path to windows directory
62 | String windowsDirPath = path.join('windows');
63 |
64 | /// Relative path to windows resources directory
65 | String windowsResourcesDirPath =
66 | path.join(windowsDirPath, 'runner', 'resources');
67 |
68 | /// Relative path to windows icon file path
69 | String windowsIconFilePath = path.join(windowsResourcesDirPath, 'app_icon.ico');
70 |
71 | /// Default windows icon size for flutter
72 | ///
73 | const int windowsDefaultIconSize = 48;
74 |
75 | // MacOS
76 |
77 | /// Relative path to macos folder
78 | final macOSDirPath = path.join('macos');
79 |
80 | /// Relative path to macos icons folder
81 | final macOSIconsDirPath =
82 | path.join(macOSDirPath, 'Runner', 'Assets.xcassets', 'AppIcon.appiconset');
83 |
84 | /// Relative path to macos contents.json
85 | final macOSContentsFilePath = path.join(macOSIconsDirPath, 'Contents.json');
86 |
87 | const String errorMissingImagePath =
88 | 'Missing "image_path" or "image_path_android" + "image_path_ios" within configuration';
89 | const String errorMissingPlatform =
90 | 'No platform specified within config to generate icons for.';
91 | const String errorMissingRegularAndroid =
92 | 'Adaptive icon config found but no regular Android config. '
93 | 'Below API 26 the regular Android config is required';
94 | const String errorMissingMinSdk =
95 | 'Cannot not find minSdk from android/app/build.gradle or android/local.properties'
96 | ' Specify minSdk in your flutter_launcher_config.yaml with "min_sdk_android"';
97 | const String errorIncorrectIconName =
98 | 'The icon name must contain only lowercase a-z, 0-9, or underscore: '
99 | 'E.g. "ic_my_new_icon"';
100 |
101 | String introMessage(String currentVersion) => '''
102 | ════════════════════════════════════════════
103 | FLUTTER LAUNCHER ICONS (v$currentVersion)
104 | ════════════════════════════════════════════
105 | ''';
106 |
--------------------------------------------------------------------------------
/lib/custom_exceptions.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter_launcher_icons/utils.dart';
2 |
3 | /// Exception to be thrown whenever we have an invalid configuration
4 | class InvalidConfigException implements Exception {
5 | /// Constructs instance
6 | const InvalidConfigException([this.message]);
7 |
8 | /// Message for the exception
9 | final String? message;
10 |
11 | @override
12 | String toString() {
13 | return generateError(this, message);
14 | }
15 | }
16 |
17 | /// Exception to be thrown whenever using an invalid Android icon name
18 | class InvalidAndroidIconNameException implements Exception {
19 | /// Constructs instance of this exception
20 | const InvalidAndroidIconNameException([this.message]);
21 |
22 | /// Message for the exception
23 | final String? message;
24 |
25 | @override
26 | String toString() {
27 | return generateError(this, message);
28 | }
29 | }
30 |
31 | /// Exception to be thrown whenever no config is found
32 | class NoConfigFoundException implements Exception {
33 | /// Constructs instance of this exception
34 | const NoConfigFoundException([this.message]);
35 |
36 | /// Message for the exception
37 | final String? message;
38 |
39 | @override
40 | String toString() {
41 | return generateError(this, message);
42 | }
43 | }
44 |
45 | /// Exception to be thrown whenever there is no decoder for the image format
46 | class NoDecoderForImageFormatException implements Exception {
47 | /// Constructs instance of this exception
48 | const NoDecoderForImageFormatException([this.message]);
49 |
50 | /// Message for the exception
51 | final String? message;
52 |
53 | @override
54 | String toString() {
55 | return generateError(this, message);
56 | }
57 | }
58 |
59 | /// A exception to throw when given [fileName] is not found
60 | class FileNotFoundException implements Exception {
61 | /// Creates a instance of [FileNotFoundException].
62 | const FileNotFoundException(this.fileName);
63 |
64 | /// Name of the file
65 | final String fileName;
66 |
67 | @override
68 | String toString() {
69 | return generateError(this, '$fileName file not found');
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/lib/logger.dart:
--------------------------------------------------------------------------------
1 | import 'package:cli_util/cli_logging.dart';
2 |
3 | export 'package:cli_util/cli_logging.dart' show Progress;
4 |
5 | /// Flutter Launcher Icons Logger
6 | class FLILogger {
7 | late Logger _logger;
8 |
9 | /// Returns true if this is a verbose logger
10 | final bool isVerbose;
11 |
12 | /// Gives access to internal logger
13 | Logger get rawLogger => _logger;
14 |
15 | /// Creates a instance of [FLILogger].
16 | /// In case [isVerbose] is `true`,
17 | /// it logs all the [verbose] logs to console
18 | FLILogger(this.isVerbose) {
19 | final ansi = Ansi(Ansi.terminalSupportsAnsi);
20 | _logger =
21 | isVerbose ? Logger.verbose(ansi: ansi) : Logger.standard(ansi: ansi);
22 | }
23 |
24 | /// Logs error messages
25 | void error(Object? message) => _logger.stderr('⚠️' + message.toString());
26 |
27 | /// Prints to console if [isVerbose] is true
28 | void verbose(Object? message) => _logger.trace(message.toString());
29 |
30 | /// Prints to console
31 | void info(Object? message) => _logger.stdout(message.toString());
32 |
33 | /// Shows progress in console
34 | Progress progress(String message) => _logger.progress(message);
35 | }
36 |
--------------------------------------------------------------------------------
/lib/macos/macos_icon_generator.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 | import 'dart:io';
3 |
4 | import 'package:flutter_launcher_icons/abs/icon_generator.dart';
5 | import 'package:flutter_launcher_icons/constants.dart' as constants;
6 | import 'package:flutter_launcher_icons/custom_exceptions.dart';
7 | import 'package:flutter_launcher_icons/macos/macos_icon_template.dart';
8 | import 'package:flutter_launcher_icons/utils.dart' as utils;
9 | import 'package:image/image.dart';
10 | import 'package:path/path.dart' as path;
11 |
12 | /// A [IconGenerator] implementation for macos
13 | class MacOSIconGenerator extends IconGenerator {
14 | static const _iconSizeTemplates = [
15 | MacOSIconTemplate(16, 1),
16 | MacOSIconTemplate(16, 2),
17 | MacOSIconTemplate(32, 1),
18 | MacOSIconTemplate(32, 2),
19 | MacOSIconTemplate(128, 1),
20 | MacOSIconTemplate(128, 2),
21 | MacOSIconTemplate(256, 1),
22 | MacOSIconTemplate(256, 2),
23 | MacOSIconTemplate(512, 1),
24 | MacOSIconTemplate(512, 2),
25 | ];
26 |
27 | /// Creates a instance of [MacOSIconGenerator]
28 | MacOSIconGenerator(IconGeneratorContext context) : super(context, 'MacOS');
29 |
30 | @override
31 | void createIcons() {
32 | final imgFilePath = path.join(
33 | context.prefixPath,
34 | context.config.macOSConfig!.imagePath ?? context.config.imagePath,
35 | );
36 |
37 | context.logger
38 | .verbose('Decoding and loading image file at $imgFilePath...');
39 | final imgFile = utils.decodeImageFile(imgFilePath);
40 | if (imgFile == null) {
41 | context.logger.error('Image File not found at give path $imgFilePath...');
42 | throw FileNotFoundException(imgFilePath);
43 | }
44 |
45 | context.logger.verbose('Generating icons $imgFilePath...');
46 | _generateIcons(imgFile);
47 | context.logger.verbose('Updating contents.json');
48 | _updateContentsFile();
49 | }
50 |
51 | @override
52 | bool validateRequirements() {
53 | context.logger.verbose('Checking $platformName config...');
54 | final macOSConfig = context.macOSConfig;
55 |
56 | if (macOSConfig == null || !macOSConfig.generate) {
57 | context.logger
58 | ..verbose(
59 | '$platformName config is missing or "flutter_icons.macos.generate" is false. Skipped...',
60 | )
61 | ..verbose(macOSConfig);
62 | return false;
63 | }
64 |
65 | if (macOSConfig.imagePath == null && context.config.imagePath == null) {
66 | context.logger
67 | ..verbose({
68 | 'flutter_launcher_icons.macos.image_path': macOSConfig.imagePath,
69 | 'flutter_launcher_icons.image_path': context.config.imagePath,
70 | })
71 | ..error(
72 | 'Missing image_path. Either provide "flutter_launcher_icons.macos.image_path" or "flutter_launcher_icons.image_path"',
73 | );
74 |
75 | return false;
76 | }
77 |
78 | // this files and folders should exist to create macos icons
79 | final enitiesToCheck = [
80 | path.join(context.prefixPath, constants.macOSDirPath),
81 | path.join(context.prefixPath, constants.macOSIconsDirPath),
82 | path.join(context.prefixPath, constants.macOSContentsFilePath),
83 | ];
84 |
85 | final failedEntityPath = utils.areFSEntiesExist(enitiesToCheck);
86 | if (failedEntityPath != null) {
87 | context.logger.error(
88 | '$failedEntityPath this file or folder is required to generate $platformName icons',
89 | );
90 | return false;
91 | }
92 |
93 | return true;
94 | }
95 |
96 | void _generateIcons(Image image) {
97 | final iconsDir = utils.createDirIfNotExist(
98 | path.join(context.prefixPath, constants.macOSIconsDirPath),
99 | );
100 |
101 | for (final template in _iconSizeTemplates) {
102 | final resizedImg = utils.createResizedImage(template.scaledSize, image);
103 | final iconFile = utils.createFileIfNotExist(
104 | path.join(context.prefixPath, iconsDir.path, template.iconFile),
105 | );
106 | iconFile.writeAsBytesSync(encodePng(resizedImg));
107 | }
108 | }
109 |
110 | void _updateContentsFile() {
111 | final contentsFilePath =
112 | File(path.join(context.prefixPath, constants.macOSContentsFilePath));
113 | final contentsConfig =
114 | jsonDecode(contentsFilePath.readAsStringSync()) as Map;
115 | contentsConfig
116 | ..remove('images')
117 | ..['images'] = _iconSizeTemplates
118 | .map