createMipmapXmlFile function
Implementation
void createMipmapXmlFile(
Config config,
String? flavor,
) {
utils.printStatus('Creating mipmap xml file Android');
String xmlContent = '';
if (config.hasAndroidAdaptiveConfig) {
if (isAdaptiveIconConfigPngFile(config.adaptiveIconBackground!)) {
xmlContent +=
' <background android:drawable="@drawable/ic_launcher_background"/>\n';
} else {
xmlContent +=
' <background android:drawable="@color/ic_launcher_background"/>\n';
}
xmlContent += '''
<foreground>
<inset
android:drawable="@drawable/ic_launcher_foreground"
android:inset="${config.adaptiveIconForegroundInset}%" />
</foreground>
''';
}
if (config.hasAndroidAdaptiveMonochromeConfig) {
xmlContent += '''
<monochrome>
<inset
android:drawable="@drawable/ic_launcher_monochrome"
android:inset="${config.adaptiveIconForegroundInset}%" />
</monochrome>
''';
}
late File mipmapXmlFile;
if (config.isCustomAndroidFile) {
mipmapXmlFile = File(
constants.androidAdaptiveXmlFolder(flavor) + config.android + '.xml',
);
} else {
mipmapXmlFile = File(
constants.androidAdaptiveXmlFolder(flavor) +
constants.androidDefaultIconName +
'.xml',
);
}
mipmapXmlFile.create(recursive: true).then((File adaptiveIconFile) {
adaptiveIconFile.writeAsString(
xml_template.mipmapXmlFile.replaceAll('{{CONTENT}}', xmlContent),
);
});
}