removeDirectory function

Future<void> removeDirectory(
  1. String dirPath
)

Implementation

Future<void> removeDirectory(String dirPath) async {
  try {
    final directory = Directory(dirPath);

    // Check if the directory exists
    if (await directory.exists()) {
      // Delete the directory recursively (including all its contents)
      await directory.delete(recursive: true);
      print('Directory $dirPath deleted successfully.');
    } else {
      print('Directory $dirPath does not exist.');
    }
  } catch (e) {
    print('Error deleting directory: $e');
  }
}