pathDiff function

PathDiff pathDiff(
  1. String? oldPath,
  2. String newPath
)

Computes the PathDiff between oldPath (may be null) and newPath.

Implementation

PathDiff pathDiff(String? oldPath, String newPath) {
  final oldEntries = _entries(oldPath);
  final newEntries = _entries(newPath);
  final oldSet = oldEntries.toSet();
  final newSet = newEntries.toSet();
  final added = newEntries.where((e) => !oldSet.contains(e)).toList();
  final removed = oldEntries.where((e) => !newSet.contains(e)).toList();
  return PathDiff(added, removed, oldPath == null || oldPath != newPath);
}