recreate method
Recreates the data object based on the updated values and function responces from the registry. This should only be called within the framework itself, external code should not need to call this.
Implementation
JsonWidgetData recreate([JsonWidgetRegistry? newRegistry]) {
var registry = newRegistry ?? this.registry;
var builder = registry.getWidgetBuilder(type);
var dynamicParamsResult = registry.processArgs(args, listenVariables);
List<JsonWidgetData>? children;
if (originalChild is String) {
var values = registry.processArgs(originalChild, listenVariables).value;
if (values is String) {
try {
values = json.decode(values);
} catch (e) {
// no-op
}
}
if (values is List) {
children = List<JsonWidgetData>.from(
values.map(
(e) => JsonWidgetData.fromDynamic(
e,
registry: registry,
),
),
);
} else {
children = <JsonWidgetData>[
JsonWidgetData.fromDynamic(
values,
registry: registry,
)!
];
}
} else if (originalChildren is String) {
var values =
registry.processArgs(originalChildren, listenVariables).value;
if (values is String) {
try {
values = json.decode(values);
} catch (e) {
// no-op
}
}
if (values is List) {
children = List<JsonWidgetData>.from(
values.map(
(e) => JsonWidgetData.fromDynamic(
e,
registry: registry,
),
),
);
} else {
children = <JsonWidgetData>[
JsonWidgetData.fromDynamic(
values,
registry: registry,
)!
];
}
} else {
children = this.children;
}
return JsonWidgetData(
args: args,
builder: () {
return builder(
registry
.processArgs(args ?? <String, dynamic>{}, listenVariables)
.value,
registry: registry,
)!;
},
children: children?.map((child) => child.recreate()).toList(),
listenVariables: dynamicParamsResult.listenVariables,
id: id,
originalChild: originalChild,
originalChildren: originalChildren,
registry: registry,
type: type,
);
}