populateProperty method

TableRow populateProperty(
  1. List<Inspectable> owners,
  2. String propertyName,
  3. int level
)

Implementation

TableRow populateProperty(
  List<Inspectable> owners,
  String propertyName,
  int level,
) {
  TableRow toReturn;
  EditorBase? editor;

  if (!keys.containsKey(propertyName)) {
    keys[propertyName] = GlobalKey();
  }
  Key? k = keys[propertyName];

  var property = owners[0].getProperty(propertyName) as InspectableProperty;
  //dynamic t = property.getValue(owners[0]);
  Type type = property.type;
  var editorBuilder = editors[type];
  if (editorBuilder == null && type is Enum) {
    type = Enum;
    editorBuilder = editors[type];
  }
  if (editorBuilder != null) {
    editor = editorBuilder(
      key: k,
      owners: owners,
      propertyName: propertyName,
      customData: widget.customData,
      onUpdatedProperty: propertyUpdated,
    );
  } else {
    editor = EditorBase(
      key: k,
      owners: owners,
      propertyName: propertyName,
      customData: widget.customData,
      onUpdatedProperty: propertyUpdated,
    );
  }

  toReturn = TableRow(
    key: UniqueKey(),
    children: [
      Padding(
        padding: EdgeInsets.only(left: 4.0, right: 4.0 + level * 4.0),
        child: Align(
          alignment: Alignment.centerRight,
          child: Text(propertyName),
        ),
      ),
      Padding(
        padding: const EdgeInsets.only(left: 4.0, right: 4.0),
        child: editor.getWidget(context),
      ),
    ],
  );

  /*if (property.getSubProperties != null) {
    var subProperties = property.getSubProperties!(obj);
    toReturn.addAll(populateProperties(obj, subProperties, level+1));
  }*/

  return toReturn;
}