ListDifference<T> constructor
ListDifference<T> ({})
Implementation
ListDifference({
List<T> initialValues = const [],
List<T> currentValues = const [],
this.containsValidator,
}) {
final List<T> initial = initialValues.removeDuplicates();
final List<T> current = currentValues.removeDuplicates();
if (!listEquals(initial, current)) {
if (initial.isEmpty) {
added.addAll(current);
} else {
for (final item in initial) {
if (!_validator(current, item)) removed.add(item);
}
for (final item in current) {
if (!_validator(initial, item)) added.add(item);
}
}
equals.addAll(currentValues.where((e) => _validator(initialValues, e)));
} else {
equals.addAll(current);
}
}