updateColorsXmlFile function

void updateColorsXmlFile(
  1. String backgroundConfig,
  2. String? flavor
)

Retrieves the colors.xml file for the project.

If the colors.xml file is found, it is updated with a new color item for the adaptive icon background.

If not, the colors.xml file is created and a color item for the adaptive icon background is included in the new colors.xml file.

Implementation

void updateColorsXmlFile(String backgroundConfig, String? flavor) {
  final File colorsXml = File(constants.androidColorsFile(flavor));
  if (colorsXml.existsSync()) {
    utils.printStatus(
      'Updating colors.xml with color for adaptive icon background',
    );
    updateColorsFile(colorsXml, backgroundConfig);
  } else {
    utils.printStatus('No colors.xml file found in your Android project');
    utils.printStatus(
      'Creating colors.xml file and adding it to your Android project',
    );
    createNewColorsFile(backgroundConfig, flavor);
  }
}