toImportStrings method

String toImportStrings(
  1. String? relativePath
)

Implementation

String toImportStrings(String? relativePath) {
  var imports = where((element) => element.imports.isNotEmpty)
      .map((e) => e.getImportStrings(relativePath))
      .where((element) => element.isNotEmpty)
      .fold<List<String>>(<String>[], (prev, current) => prev..addAll(current));

  var nestedImports = where((element) => element.nestedClasses.isNotEmpty)
      .map((e) => e.nestedClasses.map((jsonModel) => jsonModel.imports).toList())
      .fold<List<String>>(<String>[], (prev, current) => prev..addAll(current));

  imports.addAll(nestedImports);

  return imports.join('\n');
}