bigEquals function
Check for equality of multiple data types
Implementation
@Deprecated('Use \'deepEquals\' instead.')
bool bigEquals(var a, var b) {
bool listEquals<T>(List<T>? a, List<T>? b) {
if (a == null) {
return b == null;
}
if (b == null || a.length != b.length) {
return false;
}
if (identical(a, b)) {
return true;
}
for (int index = 0; index < a.length; index += 1) {
if (!bigEquals(a[index], b[index])) {
return false;
}
}
return true;
}
bool mapEquals<T, U>(Map<T, U>? a, Map<T, U>? b) {
//using brackets only works for primitive types
getMapValue(Map m, var key) {
List keyList = m.keys.toList();
List valueList = m.values.toList();
for (int i = 0; i < keyList.length; i++) {
if (bigEquals(keyList[i], key)) {
return valueList[i];
}
}
return null;
}
if (a == null) {
return b == null;
}
if (b == null || a.length != b.length) {
return false;
}
if (identical(a, b)) {
return true;
}
for (final T key in a.keys.toList()) {
if (!bigContains(b.keys.toList(), key) ||
!bigEquals(getMapValue(b, key), getMapValue(a, key))) {
return false;
}
}
return true;
}
bool setEquals<T>(Set<T>? a, Set<T>? b) {
if (a == null) {
return b == null;
}
if (b == null || a.length != b.length) {
return false;
}
if (identical(a, b)) {
return true;
}
for (var value1 in a) {
int count = 0;
for (var value2 in b) {
if (bigEquals(value1, value2)) {
count++;
}
}
if (count != 1) {
return false;
}
}
return true;
}
try {
if (a is List && b is List) {
return listEquals(a, b);
}
if (a is Map && b is Map) {
return mapEquals(a, b);
}
if (a is Set && b is Set) {
return setEquals(a, b);
}
if (a is Queue && b is Queue) {
return listEquals(a.toList(), b.toList());
}
if (a is Iterable && b is Iterable) {
if (a.runtimeType != b.runtimeType) {
return false;
}
return listEquals(a.toList(), b.toList());
}
return a == b;
} catch (e) {
return false;
}
}