customObjects property

List<ValueDef> get customObjects

Implementation

List<ValueDef> get customObjects {
  var objects = <ValueDef>[];
  if (depth != 0 && type == ClassType.tObject) {
    objects.add(this);
  }

  if (childrenDef is List<ValueDef>) {
    var childrenObject = (childrenDef as List<ValueDef>)
        .map((e) => e.customObjects)
        .expand((element) => element)
        .toList();

    // 一個一個加, 重複的去除
    childrenObject.forEach((outerE) {
      var isExist = objects.any((innerE) {
        var result = innerE.isStructSame(outerE);
        if (innerE.key == 'ios') {
          print('$result');
        }
        return result;
      });

      if (!isExist) {
        objects.add(outerE);
      }
    });
  } else if (childrenDef is Map<String, ValueDef>) {
    var childrenObject = (childrenDef as Map<String, ValueDef>)
        .entries
        .map((e) => e.value.customObjects)
        .expand((element) => element)
        .toList();

    childrenObject.forEach((outerE) {
      var isExist = objects.any((innerE) {
        var result = innerE.isStructSame(outerE);
        return result;
      });

      if (!isExist) {
        objects.add(outerE);
      }
    });
  }
  return objects;
}