checkImageExists function

String? checkImageExists({
  1. required Map<String, dynamic> config,
  2. required String parameter,
})

Implementation

String? checkImageExists(
    {required Map<String, dynamic> config, required String parameter}) {
  String image = config[parameter] ?? '';
  if (image.isNotEmpty && !File(image).existsSync()) {
    print('The file "$image" set as the parameter "$parameter" was not found.');
    exit(1);
  }

  if (image.isNotEmpty && p.extension(image).toLowerCase() != '.png') {
    print('Unsupported file format: ' +
        image +
        '  Your image must be a PNG file.');
    exit(1);
  }
  return image == '' ? null : image;
}