renameDirectory function
Implementation
Future<void> renameDirectory(String oldPath, String newPath) async {
try {
final directory = Directory(oldPath);
// Check if the directory exists
if (await directory.exists()) {
// Rename (move) the directory
await directory.rename(newPath);
print('Directory $oldPath renamed $newPath successfully.');
} else {
print('Directory $oldPath does not exist.');
}
} catch (e) {
print('Error renaming directory: $e');
}
}