getClassName static method

String getClassName(
  1. List<ModelClassName> listClassName,
  2. String suffix,
  3. String name,
  4. bool root,
  5. bool created,
  6. String parent, [
  7. String? parentList,
])

Implementation

static String getClassName(List<ModelClassName> listClassName, String suffix,
    String name, bool root, bool created, String parent,
    [String? parentList]) {
  if (root) listClassName.clear();
  String apiClassName = root ? '$suffix$name' : '$name$suffix';

  if (listClassName.firstWhereOrNull((element) =>
          element.className == apiClassName &&
          element.parent == parent &&
          element.parentList == parentList &&
          element.created) !=
      null) {
    apiClassName = apiClassName;
  } else if (listClassName.firstWhereOrNull((element) =>
          element.className == apiClassName && element.created) !=
      null) {
    for (var element in geekLetter) {
      final newClassApiName = element + apiClassName;

      if (listClassName.firstWhereOrNull((element) =>
              element.className == newClassApiName &&
              element.parent == parent &&
              element.parentList == parentList &&
              element.created) !=
          null) {
        apiClassName = newClassApiName;
        break;
      }

      if (listClassName.firstWhereOrNull((element) =>
              element.className == newClassApiName &&
              element.parent == parent &&
              !element.created) !=
          null) {
        apiClassName = newClassApiName;
        break;
      }

      if (listClassName.firstWhereOrNull((element) =>
              element.className == newClassApiName &&
              element.parent != parent) ==
          null) {
        apiClassName = newClassApiName;
        break;
      }
    }
  }

  final modelClassName = ModelClassName(
    className: apiClassName,
    parent: parent,
    created: created,
    parentList: parentList,
  );
  listClassName.remove(modelClassName);
  listClassName.add(modelClassName);

  return apiClassName;
}