Skip to content

Commit d314ca8

Browse files
refactor: can now use flutter_launcher_icons key in pubspec instead of flutter_icons
1 parent f954a34 commit d314ca8

30 files changed

+655
-536
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.13.1 (15th April 2023)
4+
5+
- Can now use `flutter_launcher_icons` instead of `flutter_icons` [#478](https://github.com/fluttercommunity/flutter_launcher_icons/pull/478)
6+
7+
38
## 0.13.0 (7th April 2023)
49

510
- Fix remove alpha for iOS [#464](https://github.com/fluttercommunity/flutter_launcher_icons/pull/464)

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ An example is shown below. More complex examples [can be found in the example pr
1515

1616
```yaml
1717
dev_dependencies:
18-
flutter_launcher_icons: "^0.13.0"
18+
flutter_launcher_icons: "^0.13.1"
1919

20-
flutter_icons:
20+
flutter_launcher_icons:
2121
android: "launcher_icon"
2222
ios: true
2323
image_path: "assets/icon/icon.png"

example/default_example/.metadata

+38-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,45 @@
11
# This file tracks properties of this Flutter project.
22
# Used by Flutter tool to assess capabilities and perform upgrades etc.
33
#
4-
# This file should be version controlled and should not be manually edited.
4+
# This file should be version controlled.
55

66
version:
7-
revision: ce40de69b7b4f89c66d19c8dbd3bd86ae30f1bc6
8-
channel: dev
7+
revision: f72efea43c3013323d1b95cff571f3c1caa37583
8+
channel: stable
99

1010
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'

example/default_example/pubspec.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
flutter_launcher_icons:
1414
path: ../..
1515

16-
flutter_icons:
16+
flutter_launcher_icons:
1717
# image_path: "assets/images/icon-128x128.png"
1818
image_path_android: "assets/images/icon-710x599-android.png"
1919
image_path_ios: "assets/images/icon-1024x1024.png"

lib/abs/icon_generator.dart

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import 'dart:io';
22

3-
import 'package:flutter_launcher_icons/flutter_launcher_icons_config.dart';
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';
47
import 'package:flutter_launcher_icons/logger.dart';
58

69
/// A base class to generate icons
@@ -34,7 +37,7 @@ abstract class IconGenerator {
3437
/// Provides easy access to user arguments and configuration
3538
class IconGeneratorContext {
3639
/// Contains configuration from configuration file
37-
final FlutterLauncherIconsConfig config;
40+
final Config config;
3841

3942
/// A logger
4043
final FLILogger logger;
@@ -65,7 +68,7 @@ class IconGeneratorContext {
6568

6669
/// Generates Icon for given platforms
6770
void generateIconsFor({
68-
required FlutterLauncherIconsConfig config,
71+
required Config config,
6972
required String? flavor,
7073
required String prefixPath,
7174
required FLILogger logger,

lib/android.dart

+16-16
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import 'dart:io';
55
import 'package:flutter_launcher_icons/constants.dart';
66
import 'package:flutter_launcher_icons/constants.dart' as constants;
77
import 'package:flutter_launcher_icons/custom_exceptions.dart';
8-
import 'package:flutter_launcher_icons/flutter_launcher_icons_config.dart';
8+
import 'package:flutter_launcher_icons/config/config.dart';
99
import 'package:flutter_launcher_icons/utils.dart' as utils;
1010
import 'package:flutter_launcher_icons/xml_templates.dart' as xml_template;
1111
import 'package:image/image.dart';
@@ -35,12 +35,12 @@ List<AndroidIconTemplate> androidIcons = <AndroidIconTemplate>[
3535
];
3636

3737
void createDefaultIcons(
38-
FlutterLauncherIconsConfig flutterLauncherIconsConfig,
38+
Config config,
3939
String? flavor,
4040
) {
4141
utils.printStatus('Creating default icons Android');
4242
// TODO(p-mazhnik): support prefixPath
43-
final String? filePath = flutterLauncherIconsConfig.getImagePathAndroid();
43+
final String? filePath = config.getImagePathAndroid();
4444
if (filePath == null) {
4545
throw const InvalidConfigException(errorMissingImagePath);
4646
}
@@ -49,9 +49,9 @@ void createDefaultIcons(
4949
return;
5050
}
5151
final File androidManifestFile = File(constants.androidManifestFile);
52-
if (flutterLauncherIconsConfig.isCustomAndroidFile) {
52+
if (config.isCustomAndroidFile) {
5353
utils.printStatus('Adding a new Android launcher icon');
54-
final String iconName = flutterLauncherIconsConfig.android;
54+
final String iconName = config.android;
5555
isAndroidIconNameCorrectFormat(iconName);
5656
final String iconPath = '$iconName.png';
5757
for (AndroidIconTemplate template in androidIcons) {
@@ -89,16 +89,16 @@ bool isAndroidIconNameCorrectFormat(String iconName) {
8989
}
9090

9191
void createAdaptiveIcons(
92-
FlutterLauncherIconsConfig flutterLauncherIconsConfig,
92+
Config config,
9393
String? flavor,
9494
) {
9595
utils.printStatus('Creating adaptive icons Android');
9696

9797
// Retrieve the necessary Flutter Launcher Icons configuration from the pubspec.yaml file
9898
final String? backgroundConfig =
99-
flutterLauncherIconsConfig.adaptiveIconBackground;
99+
config.adaptiveIconBackground;
100100
final String? foregroundImagePath =
101-
flutterLauncherIconsConfig.adaptiveIconForeground;
101+
config.adaptiveIconForeground;
102102
if (backgroundConfig == null || foregroundImagePath == null) {
103103
throw const InvalidConfigException(errorMissingImagePath);
104104
}
@@ -120,12 +120,12 @@ void createAdaptiveIcons(
120120
// Create adaptive icon background
121121
if (isAdaptiveIconConfigPngFile(backgroundConfig)) {
122122
_createAdaptiveBackgrounds(
123-
flutterLauncherIconsConfig,
123+
config,
124124
backgroundConfig,
125125
flavor,
126126
);
127127
} else {
128-
createAdaptiveIconMipmapXmlFile(flutterLauncherIconsConfig, flavor);
128+
createAdaptiveIconMipmapXmlFile(config, flavor);
129129
updateColorsXmlFile(backgroundConfig, flavor);
130130
}
131131
}
@@ -156,13 +156,13 @@ void updateColorsXmlFile(String backgroundConfig, String? flavor) {
156156
/// Creates the xml file required for the adaptive launcher icon
157157
/// FILE LOCATED HERE: res/mipmap-anydpi/{icon-name-from-yaml-config}.xml
158158
void createAdaptiveIconMipmapXmlFile(
159-
FlutterLauncherIconsConfig flutterLauncherIconsConfig,
159+
Config config,
160160
String? flavor,
161161
) {
162-
if (flutterLauncherIconsConfig.isCustomAndroidFile) {
162+
if (config.isCustomAndroidFile) {
163163
File(
164164
constants.androidAdaptiveXmlFolder(flavor) +
165-
flutterLauncherIconsConfig.android +
165+
config.android +
166166
'.xml',
167167
).create(recursive: true).then((File adaptiveIcon) {
168168
adaptiveIcon.writeAsString(xml_template.icLauncherXml);
@@ -180,7 +180,7 @@ void createAdaptiveIconMipmapXmlFile(
180180

181181
/// creates adaptive background using png image
182182
void _createAdaptiveBackgrounds(
183-
FlutterLauncherIconsConfig flutterLauncherIconsConfig,
183+
Config config,
184184
String adaptiveIconBackgroundImagePath,
185185
String? flavor,
186186
) {
@@ -203,10 +203,10 @@ void _createAdaptiveBackgrounds(
203203

204204
// Creates the xml file required for the adaptive launcher icon
205205
// FILE LOCATED HERE: res/mipmap-anydpi/{icon-name-from-yaml-config}.xml
206-
if (flutterLauncherIconsConfig.isCustomAndroidFile) {
206+
if (config.isCustomAndroidFile) {
207207
File(
208208
constants.androidAdaptiveXmlFolder(flavor) +
209-
flutterLauncherIconsConfig.android +
209+
config.android +
210210
'.xml',
211211
).create(recursive: true).then((File adaptiveIcon) {
212212
adaptiveIcon.writeAsString(xml_template.icLauncherDrawableBackgroundXml);

0 commit comments

Comments
 (0)