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