isEqualsSetDeep function

bool isEqualsSetDeep(
  1. Set? set1,
  2. Set? set2, {
  3. ValueEquality? valueEquality,
})

Same as isEqualsListDeep but for Set.

Implementation

bool isEqualsSetDeep(Set? set1, Set? set2, {ValueEquality? valueEquality}) {
  if (identical(set1, set2)) return true;

  if (set1 == null || set2 == null) return false;

  var length = set1.length;
  if (length != set2.length) return false;

  var l1 = set1.toList();
  var l2 = set2.toList();

  l1.sort();
  l2.sort();

  return isEqualsListDeep(l1, l2, valueEquality: valueEquality);
}