updateContentJson function
Update the content json file with the generated splash_image
in iOS.
Implementation
Future<void> updateContentJson(
List<Image> images,
) async {
if (images.isEmpty) {
log('No images were generated. Skipping Updating Contents.json.');
return;
}
const iosAssetsFolder = CmdStrings.iosAssetsDirectory;
final file = File('$iosAssetsFolder/${IOSStrings.iosContentJson}');
final jsonString = await file.readAsString();
final json = jsonDecode(jsonString);
final iosContentJsonDm = IosContentJsonDm.fromJson(json);
final updatedIosContentJson = iosContentJsonDm.copyWith(images: images);
final encodedContentJson = encoder.convert(updatedIosContentJson);
await file.writeAsString(encodedContentJson);
log('Updated Contents.json.');
}