createAdaptiveBackgrounds function

void createAdaptiveBackgrounds(
  1. Map<String, dynamic> yamlConfig,
  2. String adaptiveIconBackgroundImagePath,
  3. String? flavor
)

creates adaptive background using png image

Implementation

void createAdaptiveBackgrounds(Map<String, dynamic> yamlConfig,
    String adaptiveIconBackgroundImagePath, String? flavor) {
  final String filePath = adaptiveIconBackgroundImagePath;
  final Image? image = decodeImage(File(filePath).readAsBytesSync());
  if (image == null)
    return;

  // creates a png image (ic_adaptive_background.png) for the adaptive icon background in each of the locations
  // it is required
  for (AndroidIconTemplate androidIcon in adaptiveForegroundIcons) {
    saveNewImages(androidIcon, image,
        constants.androidAdaptiveBackgroundFileName, flavor);
  }

  // Creates the xml file required for the adaptive launcher icon
  // FILE LOCATED HERE:  res/mipmap-anydpi/{icon-name-from-yaml-config}.xml
  if (isCustomAndroidFile(yamlConfig)) {
    File(constants.androidAdaptiveXmlFolder(flavor) +
            getNewIconName(yamlConfig) +
            '.xml')
        .create(recursive: true)
        .then((File adaptiveIcon) {
      adaptiveIcon.writeAsString(xml_template.icLauncherDrawableBackgroundXml);
    });
  } else {
    File(constants.androidAdaptiveXmlFolder(flavor) +
            constants.androidDefaultIconName +
            '.xml')
        .create(recursive: true)
        .then((File adaptiveIcon) {
      adaptiveIcon.writeAsString(xml_template.icLauncherDrawableBackgroundXml);
    });
  }
}