formatLibrary static method

String formatLibrary(
  1. Library library, {
  2. bool orderDirectives = false,
  3. required bool useNullSafetySyntax,
})

Implementation

static String formatLibrary(Library library,
    {bool orderDirectives = false, required bool useNullSafetySyntax}) {
  final emitter = DartEmitter(
    allocator: CustomAllocator(),
    orderDirectives: orderDirectives,
    useNullSafetySyntax: useNullSafetySyntax,
  );
  final libraryOutput = DartFormatter().format(
      '// GENERATED CODE - DO NOT MODIFY BY HAND\n\n\n'
      '// ignore_for_file: prefer_initializing_formals, library_private_types_in_public_api\n\n'
      '${library.accept(emitter)}\n\n'
      'T _throwStateError<T>(String message) => throw StateError(message);\n\n');
  return libraryOutput;
}