process method
ProcessedArg
process(
- JsonWidgetRegistry registry,
- dynamic arg,
- Set<
String> ? listenVariables
override
Process passed arg
into ProcessedArg.
The registry
is giving functions and variables information context for
the processing.
Passed listenVariables
is the information about variables that
JsonWidgetData depends on. Passing that should be make the
ArgProcessor to stop calculating these variable names. It is
treated as a optimization.
ProcessedArg contains info about arg
real value and variable names
that it depends on.
Implementation
@override
ProcessedArg process(
JsonWidgetRegistry registry,
dynamic arg,
Set<String>? listenVariables,
) {
var calculateListenVariables = listenVariables == null;
var resultListenVariables = listenVariables ?? <String>{};
var regexpMatch = _matchRegexp.firstMatch(arg.toString())!;
var expression = Expression.tryParse(regexpMatch.group(1)!);
if (expression != null) {
var evaluator =
ArgsExpressionEvaluator(registry, calculateListenVariables);
arg = evaluator.evaluate(expression);
if (calculateListenVariables) {
resultListenVariables = evaluator.listenVariables;
}
}
return ProcessedArg(
listenVariables: resultListenVariables,
value: arg,
);
}