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 mapArg = arg as Map;
var calculateListenVariables = listenVariables == null;
var resultListenVariables = listenVariables ?? <String>{};
var processedMapArg = {};
if (_isJsonWidgetData(mapArg)) {
// The entry has a "type" and one of: "child", "children", "args". This
// means the item is most likely a JsonWidgetData class, so we should
// not process the args yet. We should wait until the actual
// JsonWidgetData gets built.
return ProcessedArg(value: arg, listenVariables: resultListenVariables);
}
mapArg.keys.forEach((key) {
var processedKeyArg = _processKey(registry, key, listenVariables);
var processedValueArg =
registry.processArgs(mapArg[key], listenVariables);
processedMapArg[processedKeyArg.value] = processedValueArg.value;
if (calculateListenVariables) {
resultListenVariables.addAll(processedKeyArg.listenVariables.toList());
resultListenVariables.addAll(
processedValueArg.listenVariables.toList(),
);
}
});
return ProcessedArg(
value: processedMapArg,
listenVariables: resultListenVariables,
);
}