createLaunchBackgroundColorSet function
Create a color set for the launch screen background color with light and dark variants.
Implementation
Future<void> createLaunchBackgroundColorSet({
required String lightColor,
required String darkColor,
}) async {
const directoryPath =
'${CmdStrings.iosAssetCatalogDirectory}/${IOSStrings.launchBackgroundColorSetDirectory}';
final directory = Directory(directoryPath);
if (!await directory.exists()) {
await directory.create(recursive: true);
}
final file = File('$directoryPath/${IOSStrings.iosContentJson}');
final json = {
'info': {
'author': 'xcode',
'version': 1,
},
'colors': [
{
'idiom': 'universal',
'color': {
'color-space': 'srgb',
'components': {
'red': _hexToDecimal(lightColor.substring(1, 3)),
'green': _hexToDecimal(lightColor.substring(3, 5)),
'blue': _hexToDecimal(lightColor.substring(5, 7)),
'alpha': '1.000',
},
},
},
{
'idiom': 'universal',
'appearances': [
{
IOSStrings.appearanceKey: IOSStrings.appearanceLuminosity,
IOSStrings.appearanceValueKey: IOSStrings.appearanceDark,
}
],
'color': {
'color-space': 'srgb',
'components': {
'red': _hexToDecimal(darkColor.substring(1, 3)),
'green': _hexToDecimal(darkColor.substring(3, 5)),
'blue': _hexToDecimal(darkColor.substring(5, 7)),
'alpha': '1.000',
},
},
},
],
};
await file.writeAsString(encoder.convert(json));
}