createIcons method
Create all icons for the current platform based on
the contents of config
and the flavor
.
Implementation
@override
void createIcons(Map<String, dynamic> config, String? flavor) {
final String filePath = config['image_path_macos'] ?? config['image_path'];
final Image? image = decodeImage(File(filePath).readAsBytesSync());
if (image == null)
return;
String iconName;
final dynamic macosConfig = config['macos'];
// If the MacOS configuration is a string then the user has specified a new icon to be created
// and for the old icon file to be kept
if (flavor != null) {
final String catalogName = 'AppIcon-$flavor';
printStatus('Building macOs launcher icon for $flavor');
for (IconTemplate template in macosIcons) {
_saveNewIcons(template, image, catalogName);
}
iconName = windowsDefaultIconName;
_changeMacosLauncherIcon(catalogName, flavor);
_modifyContentsFile(catalogName);
} else if (macosConfig is String) {
final String newIconName = macosConfig;
printStatus('Adding new macOS launcher icon');
for (IconTemplate template in macosIcons) {
_saveNewIcons(template, image, newIconName);
}
iconName = newIconName;
_changeMacosLauncherIcon(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 macOS launcher icon with new icon');
for (IconTemplate template in macosIcons) {
_overwriteDefaultIcons(template, image);
}
iconName = windowsDefaultIconName;
_changeMacosLauncherIcon('AppIcon', flavor);
}
}