deleteFilesSync 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

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