updateContentJson function
Update the content json file with the generated splash_image in iOS.
Implementation
Future<void> updateContentJson(
List<Image> images,
) async {
const iosAssetsFolder = CmdStrings.iosAssetsDirectory;
final file = File('$iosAssetsFolder/${IOSStrings.iosContentJson}');
IosContentJsonDm iosContentJsonDm;
if (await file.exists()) {
final jsonString = await file.readAsString();
final json = jsonDecode(jsonString);
iosContentJsonDm = IosContentJsonDm.fromJson(json);
} else {
iosContentJsonDm = const IosContentJsonDm(
images: [],
info: Info(author: 'xcode', version: 1),
);
}
final updatedIosContentJson = iosContentJsonDm.copyWith(images: images);
final encodedContentJson = encoder.convert(updatedIosContentJson);
await file.writeAsString(encodedContentJson);
log('Updated Contents.json.');
}