generate function Null safety

String generate(
  1. Properties properties
)

Generates a helper library which works with Protobuf message types compiled into Dart.

Implementation

String generate(Properties properties) {
    var knownTypes = KnownTypesFactory(properties);
    var code = Library((b) =>
        b.body..add(createViolationFactory(properties.standardPackage))
              ..addAll(knownTypes.generateValues())
              ..add(knownTypes.generateClass())
              ..add(knownTypes.generateAccessor())
    );
    var emitter = DartEmitter(allocator: Allocator.simplePrefixing(), useNullSafetySyntax: true);
    var formatter = DartFormatter();
    return formatter.format(code.accept(emitter).toString());
}