checkFileExists function
Implementation
bool checkFileExists(BuildContext context, String path) {
var file = File(path);
if (!file.existsSync()) {
// Show a popup message if the file does not exist
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text('File Not Found'),
content: Text('The file you specified does not exist\n\n'
' $path\n\n'
'Please correct the filename path and try again.'),
actions: [
TextButton(
onPressed: () {
Navigator.of(context).pop(); // Close the dialog
},
child: Text('OK'),
),
],
);
},
);
return false;
} else {
return true;
}
}