resolveValue function
Resolves text to a value that keeps its type.
When text is a single whole {{ name }} token (ignoring surrounding
whitespace), the matched variable is returned as-is — an int, bool,
List, Map, etc. survive instead of being stringified. This is for
non-string fields fed by a variable (a numeric size, a boolean flag).
Implementation
Object? resolveValue(String text, Map<String, dynamic>? variables) {
final whole = _wholeTokenPattern.firstMatch(text.trim());
if (whole != null && variables != null) {
final key = whole.group(1)!;
if (variables.containsKey(key)) {
return variables[key];
}
}
return interpolateVariables(text, variables);
}