d2hasValue function
Implementation
String d2hasValue(String expression) {
RegExp hasValueRegex = RegExp(r'd2:hasValue\(([^)]+)\)');
String replaceHasValue(Match match) {
String content = match.group(1)?.trim() ?? '';
if (content.trim().contains("''")) {
return '1 == 0';
} else {
return '1 == 1';
}
}
return expression
.replaceAll('d2:hasValue(' ')', '1 == 0')
.replaceAllMapped(hasValueRegex, (match) => replaceHasValue(match));
}