createDefaultIcons function

void createDefaultIcons(
  1. Config config,
  2. String? flavor
)

Implementation

void createDefaultIcons(
  Config config,
  String? flavor,
) {
  utils.printStatus('Creating default icons Android');
  // TODO(p-mazhnik): support prefixPath
  final String? filePath = config.getImagePathAndroid();
  if (filePath == null) {
    throw const InvalidConfigException(errorMissingImagePath);
  }
  final Image? image = utils.decodeImageFile(filePath);
  if (image == null) {
    return;
  }
  final File androidManifestFile = File(constants.androidManifestFile);
  if (config.isCustomAndroidFile) {
    utils.printStatus('Adding a new Android launcher icon');
    final String iconName = config.android;
    isAndroidIconNameCorrectFormat(iconName);
    final String iconPath = '$iconName.png';
    for (AndroidIconTemplate template in androidIcons) {
      _saveNewImages(template, image, iconPath, flavor);
    }
    overwriteAndroidManifestWithNewLauncherIcon(iconName, androidManifestFile);
  } else {
    utils.printStatus(
      'Overwriting the default Android launcher icon with a new icon',
    );
    for (AndroidIconTemplate template in androidIcons) {
      overwriteExistingIcons(
        template,
        image,
        constants.androidFileName,
        flavor,
      );
    }
    overwriteAndroidManifestWithNewLauncherIcon(
      constants.androidDefaultIconName,
      androidManifestFile,
    );
  }
}