writeClassEncode method

  1. @override
void writeClassEncode(
  1. DartOptions generatorOptions,
  2. Root root,
  3. Indent indent,
  4. Class classDefinition, {
  5. required String dartPackageName,
})
override

Writes a single class encode method to indent.

Implementation

@override
void writeClassEncode(
  DartOptions generatorOptions,
  Root root,
  Indent indent,
  Class classDefinition, {
  required String dartPackageName,
}) {
  indent.write('Object encode() ');
  indent.addScoped('{', '}', () {
    indent.write(
      'return <Object?>',
    );
    indent.addScoped('[', '];', () {
      for (final NamedType field
          in getFieldsInSerializationOrder(classDefinition)) {
        indent.writeln('${field.name},');
      }
    });
  });
}