generateAndroidImages function
Generate splash images for the Android
Implementation
Future<void> generateAndroidImages({
String? imageSource,
String? color,
}) async {
if (imageSource == null) {
log('No images were provided. Skipping generating Android images');
return;
}
const androidResDir = CmdStrings.androidResDirectory;
/// Create splash images with the provided image in mipmap directories
for (final mipmap in AndroidMipMaps.values) {
final mipmapFolder = '$androidResDir/${mipmap.folder}';
final directory = Directory(mipmapFolder);
if (!(await directory.exists())) {
log("${mipmap.folder} folder doesn't exists. Creating it...");
await Directory(mipmapFolder).create(recursive: true);
}
final imagePath = '$mipmapFolder/${AndroidStrings.splashImagePng}';
final file = File(imagePath);
if (await file.exists()) {
await file.delete();
}
final sourceImage = File(imageSource);
if (await sourceImage.exists()) {
/// Creating a splash image from the provided asset source
sourceImage.copySync(imagePath);
} else {
throw SplashMasterException(message: 'Image path not found');
}
log("Splash image added to ${mipmap.folder}");
}
}