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