runCodeEmitter function

Future<void> runCodeEmitter(
  1. Library library,
  2. File file
)

Implementation

Future<void> runCodeEmitter(Library library, File file) async {
  final emitter = DartEmitter(orderDirectives: true);
  final code =
      DartFormatter(fixes: StyleFix.all).format('${library.accept(emitter)}');

  if (!await file.exists()) {
    await file.create(recursive: true);
  }

  await file.writeAsString(code);
}