createIcons method

  1. @override
void createIcons(
  1. Map<String, dynamic> config,
  2. String? flavor
)
override

Create all icons for the current platform based on the contents of config and the flavor.

Implementation

@override
void createIcons(Map<String, dynamic> config, String? flavor) {
  printStatus('Creating adaptive icons Android');

  // Retrieve the necessary Flutter Launcher Icons configuration from the pubspec.yaml file
  final String backgroundConfig = config['adaptive_icon_background'];
  final String foregroundImagePath = config['adaptive_icon_foreground'];
  final Image? foregroundImage =
      decodeImage(File(foregroundImagePath).readAsBytesSync());
  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 {
    createAdaptiveIconMipmapXmlFile(config, flavor);
    updateColorsXmlFile(backgroundConfig, flavor);
  }
}