createAdaptiveIcons function
Implementation
void createAdaptiveIcons(
FlutterLauncherIconsConfig flutterLauncherIconsConfig,
String? flavor,
) {
utils.printStatus('Creating adaptive icons Android');
// Retrieve the necessary Flutter Launcher Icons configuration from the pubspec.yaml file
final String? backgroundConfig =
flutterLauncherIconsConfig.adaptiveIconBackground;
final String? foregroundImagePath =
flutterLauncherIconsConfig.adaptiveIconForeground;
if (backgroundConfig == null || foregroundImagePath == null) {
throw const InvalidConfigException(errorMissingImagePath);
}
final Image? foregroundImage = utils.decodeImageFile(foregroundImagePath);
if (foregroundImage == null) {
return;
}
// Create adaptive icon foreground images
for (AndroidIconTemplate androidIcon in adaptiveForegroundIcons) {
overwriteExistingIcons(
androidIcon,
foregroundImage,
constants.androidAdaptiveForegroundFileName,
flavor,
);
}
// Create adaptive icon background
if (isAdaptiveIconConfigPngFile(backgroundConfig)) {
_createAdaptiveBackgrounds(
flutterLauncherIconsConfig,
backgroundConfig,
flavor,
);
} else {
createAdaptiveIconMipmapXmlFile(flutterLauncherIconsConfig, flavor);
updateColorsXmlFile(backgroundConfig, flavor);
}
}