toCloneDeclaration method

String toCloneDeclaration()

Implementation

String toCloneDeclaration() {
  return checkNestedTypes(type!, (String cleanedType, bool isList, bool isListInList, bool isModel) {
    if (isListInList) {
      return '$name: $name${isNullable ? '?' : ''}.map((x) => x.map((y) => y.clone()).toList()).toList()';
    } else if (isList) {
      if (isModel) {
        return '$name: $name${isNullable ? '?' : ''}.map((e) => e.clone()).toList()';
      } else {
        return '$name: $name${isNullable ? '?' : ''}.toList()';
      }
    } else if (isModel) {
      return '$name: $name${isNullable ? '?' : ''}.clone()';
    } else {
      return '$name: $name';
    }
  });
}