createAdaptiveIcons function

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

Implementation

void createAdaptiveIcons(
  Config config,
  String? flavor,
) {
  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 = 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(
      config,
      backgroundConfig,
      flavor,
    );
  } else {
    updateColorsXmlFile(backgroundConfig, flavor);
  }
}