checkFileExists function

bool checkFileExists(
  1. BuildContext context,
  2. String path
)

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: const 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: const Text('OK'),
            ),
          ],
        );
      },
    );

    return false;
  } else {
    return true;
  }
}