createLegacyImageList function
Create the image list for the Contents.json file for Xcode versions below Xcode 14
Implementation
List<Map<String, dynamic>> createLegacyImageList(String fileNamePrefix) {
const List<Map<String, dynamic>> imageConfigurations = [
{
'size': '20x20',
'idiom': 'iphone',
'scales': ['2x', '3x'],
},
{
'size': '29x29',
'idiom': 'iphone',
'scales': ['1x', '2x', '3x'],
},
{
'size': '40x40',
'idiom': 'iphone',
'scales': ['2x', '3x'],
},
{
'size': '57x57',
'idiom': 'iphone',
'scales': ['1x', '2x'],
},
{
'size': '60x60',
'idiom': 'iphone',
'scales': ['2x', '3x'],
},
{
'size': '20x20',
'idiom': 'ipad',
'scales': ['1x', '2x'],
},
{
'size': '29x29',
'idiom': 'ipad',
'scales': ['1x', '2x'],
},
{
'size': '40x40',
'idiom': 'ipad',
'scales': ['1x', '2x'],
},
{
'size': '50x50',
'idiom': 'ipad',
'scales': ['1x', '2x'],
},
{
'size': '72x72',
'idiom': 'ipad',
'scales': ['1x', '2x'],
},
{
'size': '76x76',
'idiom': 'ipad',
'scales': ['1x', '2x'],
},
{
'size': '83.5x83.5',
'idiom': 'ipad',
'scales': ['2x'],
},
{
'size': '1024x1024',
'idiom': 'ios-marketing',
'scales': ['1x'],
},
];
final List<Map<String, dynamic>> imageList = <Map<String, dynamic>>[];
for (final config in imageConfigurations) {
final size = config['size']!;
final idiom = config['idiom']!;
final List<String> scales = config['scales'];
for (final scale in scales) {
final filename = '$fileNamePrefix-$size@$scale.png';
imageList.add(
ContentsImageObject(
size: size,
idiom: idiom,
filename: filename,
scale: scale,
).toJson(),
);
}
}
return imageList;
}