isStructSame method
Implementation
bool isStructSame(ValueDef other, {bool debug = false}) {
if (childrenDef is List<ValueDef> && other.childrenDef is List<ValueDef>) {
var thisFirst = (childrenDef as List<ValueDef>).first;
var otherFirst = (other.childrenDef as List<ValueDef>).first;
return thisFirst.isStructSame(otherFirst);
} else if (childrenDef is Map<String, ValueDef> &&
other.childrenDef is Map<String, ValueDef>) {
var thisKeyList = (childrenDef as Map<String, ValueDef>).entries;
var otherKeyList = (other.childrenDef as Map<String, ValueDef>).entries;
var isLengthSame = thisKeyList.length == otherKeyList.length;
if (isLengthSame) {
var isSame = !thisKeyList.any((element) {
var thisKey = element.key;
var thisValue = element.value;
var findOther = otherKeyList
.firstWhereOrNull((element) => element.key == thisKey);
if (findOther != null) {
var isSame = thisValue.isStructSame(findOther.value);
return !isSame;
} else {
return true;
}
});
return isSame;
}
} else if (type == other.type && key == other.key) {
return true;
}
return false;
}