parse static method
Implementation
static List<JsonWidgetParams>? parse(String? data) {
List<JsonWidgetParams>? params;
if (data?.isNotEmpty == true) {
params = [];
var funName = functionRegex.firstMatch(data!)?.group(1);
if (funName?.isNotEmpty == true) {
data = functionRegex.firstMatch(data)?.group(2);
params.add(JsonWidgetParams(
isFunction: true,
key: funName,
));
var matches = paramsRegex.allMatches(data!);
for (var match in matches) {
var group = match.group(0);
if (group?.trim().isNotEmpty == true) {
if (group!.startsWith('!{{') && group.endsWith('}}')) {
params.add(
JsonWidgetParams(
isStatic: true,
isVariable: true,
key: group.substring(3, group.length - 2).trim(),
),
);
} else if (group.startsWith('{{') && group.endsWith('}}')) {
params.add(
JsonWidgetParams(
isVariable: true,
key: group.substring(2, group.length - 2).trim(),
),
);
} else {
params.add(JsonWidgetParams(key: group.trim()));
}
}
}
} else {
var group = varRegex.stringMatch(data);
if (group?.isNotEmpty == true) {
params.add(
JsonWidgetParams(
isStatic: group!.startsWith('!'),
isVariable: true,
key: group
.substring(group.startsWith('!') ? 3 : 2, group.length - 2)
.trim(),
),
);
} else {
params.add(JsonWidgetParams(key: data));
}
}
}
return params;
}