checkFiles method
Implementation
Future<void> checkFiles(String folderPath, List<String> extensions) async {
duplicateGroups.clear();
final dir = Directory(folderPath);
if (!await dir.exists()) {
print('Directory does not exist: $folderPath');
return;
}
final allFiles = await _listFilesRecursively(dir, extensions);
final Map<String, List<String>> hashMap = {};
for (final file in allFiles) {
final hash = await _getFileHash(file);
if (hash == null) {
continue;
}
if (!hashMap.containsKey(hash)) {
hashMap[hash] = [];
}
hashMap[hash]!.add(file.path);
}
// Keep only groups with duplicates
duplicateGroups = {
for (var entry in hashMap.entries)
if (entry.value.length > 1) entry.key: entry.value,
};
}