toWidget static method

BaseWidget toWidget(
  1. JSON json
)

Implementation

static BaseWidget toWidget(JSON json) {
  BaseWidget widget = WidgetRegistry.create(json["widgetName"]);

  var properties = json["properties"];
  if (properties is JSON && properties.isNotEmpty) {
    widget.setProperties(properties);
  } else {
    widget.setProperties({});
  }

  var child = json["child"];
  if (child is JSON && child.isNotEmpty) {
    widget.children = [toWidget(child)];
  }

  var children = json["children"];
  if (children is List<dynamic> && children.isNotEmpty) {
    widget.children = children.map((e) => toWidget(e)).toList();
  }

  return widget;
}