createIcons function
create the ios icons
Implementation
void createIcons(Config config, String? flavor) {
// TODO(p-mazhnik): support prefixPath
final String? filePath = config.getImagePathIOS();
if (filePath == null) {
throw const InvalidConfigException(errorMissingImagePath);
}
// decodeImageFile shows error message if null
// so can return here if image is null
Image? image = decodeImage(File(filePath).readAsBytesSync());
if (image == null) {
return;
}
if (config.removeAlphaIOS && image.hasAlpha) {
image = image.convert(numChannels: 3);
}
if (image.hasAlpha) {
print(
'\nWARNING: Icons with alpha channel are not allowed in the Apple App Store.\nSet "remove_alpha_ios: true" to remove it.\n',
);
}
String iconName;
final dynamic iosConfig = config.ios;
if (flavor != null) {
final String catalogName = 'AppIcon-$flavor';
printStatus('Building iOS launcher icon for $flavor');
for (IosIconTemplate template in iosIcons) {
saveNewIcons(template, image, catalogName);
}
iconName = iosDefaultIconName;
changeIosLauncherIcon(catalogName, flavor);
modifyContentsFile(catalogName);
} else if (iosConfig is String) {
// If the IOS configuration is a string then the user has specified a new icon to be created
// and for the old icon file to be kept
final String newIconName = iosConfig;
printStatus('Adding new iOS launcher icon');
for (IosIconTemplate template in iosIcons) {
saveNewIcons(template, image, newIconName);
}
iconName = newIconName;
changeIosLauncherIcon(iconName, flavor);
modifyContentsFile(iconName);
}
// Otherwise the user wants the new icon to use the default icons name and
// update config file to use it
else {
printStatus('Overwriting default iOS launcher icon with new icon');
for (IosIconTemplate template in iosIcons) {
overwriteDefaultIcons(template, image);
}
iconName = iosDefaultIconName;
changeIosLauncherIcon('AppIcon', flavor);
}
}