JsonModel constructor Null safety

JsonModel(
  1. String fileName,
  2. List<DartDeclaration> dartDeclarations,
  3. [String? relativePath]
)

Implementation

JsonModel(String fileName, List<DartDeclaration> dartDeclarations, [String? relativePath]) {
  this.fileName = fileName;
  className = fileName.toTitleCase();
  constructor = dartDeclarations.toConstructor(className);
  mixinClass = dartDeclarations.where((element) => element.mixinClass != null).map((element) => element.mixinClass).join(', ');
  declaration = dartDeclarations.toDeclarationStrings(className);
  copyWith = dartDeclarations.toCopyWith(className);
  cloneFunction = dartDeclarations.toCloneFunction(className);
  jsonFunctions = dartDeclarations.toJsonFunctions(className);
  equalsDeclarations = dartDeclarations.toEqualsDeclarationString();
  hashDeclarations = dartDeclarations.toHashDeclarationString();
  imports = dartDeclarations.toImportStrings(relativePath);
  enums = dartDeclarations.getEnums(className);
  nestedClasses = dartDeclarations.getNestedClasses();

  final extendsClass = dartDeclarations.where((element) => element.extendsClass != null).toList();
  if(extendsClass.isNotEmpty) {
    this.extendsClass = extendsClass[0].extendsClass;
  }
}