createIconsFromConfig function
Loads the config file from the arguments passed to the program. Generate launcher icons base on config file.
Implementation
Future<void> createIconsFromConfig(Map<String, dynamic> config,
[String? flavor]) async {
if (!isImagePathInConfig(config)) {
throw const InvalidConfigException(errorMissingImagePath);
}
if (!hasPlatformConfig(config)) {
throw const InvalidConfigException(errorMissingPlatform);
}
if (isNeedingNewAndroidIcon(config) || hasAndroidAdaptiveConfig(config)) {
final int minSdk = android_icons_launcher.minSdk();
if (minSdk == 0) {
throw const InvalidConfigException(errorMissingMinSdk);
}
if (minSdk < 26 &&
hasAndroidAdaptiveConfig(config) &&
!hasAndroidConfig(config)) {
throw const InvalidConfigException(errorMissingRegularAndroid);
}
}
if (isNeedingNewAndroidIcon(config)) {
android_icons_launcher.createDefaultIcons(config, flavor);
}
if (hasAndroidAdaptiveConfig(config)) {
android_icons_launcher.createAdaptiveIcons(config, flavor);
}
if (isNeedingNewIOSIcon(config)) {
ios_icons_launcher.createIcons(config, flavor);
}
if (isNeedingNewMacOSIcon(config)) {
macos_icons_launcher.createIcons(config, flavor);
}
if (isNeedingNewWindowsIcon(config)) {
windows_icons_launcher.createIcons(config, flavor);
}
if (isNeedingNewLinuxIcon(config)) {
linux_icons_launcher.createIcons(config, flavor);
}
if (isNeedingNewWebIcon(config)) {
web_icons_launcher.createIcons(config, flavor);
}
}