generateCode method

void generateCode(
  1. String className
)

Generate the dart code

Implementation

void generateCode(String className) {
  stopWatch();
  writeText('Start writing records');
  resourceFile.deleteSync(recursive: true);
  resourceFile.createSync(recursive: true);

  final StringBuffer source = StringBuffer();
  final Template template = Template(className);
  source.write(template.license);
  source.write(template.classDeclare);
  for (final String path in allImageList) {
    source.write(template.formatFiled(path, projectRootPath, isPreview));
  }
  source.write(template.classDeclareFooter);

  final Stopwatch sw = Stopwatch();
  sw.start();
  final String formattedCode = formatFile(source.toString());
  sw.stop();
  print('Formatted records in ${sw.elapsedMilliseconds}ms');
  sw.reset();
  resourceFile.writeAsString(formattedCode);
  sw.stop();
  writeText('End writing records ${sw.elapsedMilliseconds}');
}