bindValue method
dynamic
bindValue(
- String exp
)
override
Implementation
@override
dynamic bindValue(String exp) {
if (currentMatch(exp)) {
for (var key in parameters.keys) {
if (key == exp) {
return parameters[key];
}
}
// Carrying ”#(“ indicates value conversion to a string
final isStringValue = exp.startsWith('#(');
dynamic processed = exp.substring(2, exp.length - 1);
if (processed.startsWith('\${')) {
processed = processed.substring(2, processed.length - 1);
}
for (var key in parameters.keys) {
if (key == processed) {
return parameters[key];
}
}
if (processed.contains('.')) {
List<String> expList = processed.split('.');
for (var key in parameters.keys) {
if (expList.first == '\$$key' || expList.first == key) {
dynamic obj = parameters[key];
dynamic modelValue;
if (obj is BaseModel) {
var json = obj.toJson();
modelValue = json;
} else if (obj is Map) {
modelValue = obj;
}
if (modelValue != null) {
expList.removeAt(0);
for (var k in expList) {
modelValue = modelValue[k];
}
// If conversion to a string is not explicitly indicated, the original type is returned
processed = isStringValue ? '$modelValue' : modelValue;
}
}
}
} else {
for (var key in parameters.keys) {
processed = processed.replaceAll('\$$key', '${parameters[key]}');
}
}
return processed;
} else if (parentMatch(exp)) {
return parent!.bindValue(exp);
}
return exp;
}