deleteFilesSync static method

void deleteFilesSync({
  1. required String filePath,
})

Deletes a file from the specified path.

Parameters:

  • filePath: The path to the file. Throws:
  • Exception with message ⚠️ Failed to delete file on failure.

Implementation

static void deleteFilesSync({required String filePath}) {
  try {
    print('🗑️ Deleting file $filePath...');
    final file = File(filePath);
    if (file.existsSync()) {
      file.deleteSync();
      print('✅ File deleted successfully: $filePath');
    }
  } catch (_) {
    throw Exception('⚠️ Failed to delete: $filePath');
  }
}