writeDataClass method

  1. @override
void writeDataClass(
  1. ArkTSOptions generatorOptions,
  2. Root root,
  3. Indent indent,
  4. Class klass, {
  5. required String dartPackageName,
})
override

Writes a single data class to indent.

Implementation

@override
void writeDataClass(
    ArkTSOptions generatorOptions, Root root, Indent indent, Class klass,
    {required String dartPackageName}) {
  final Set<String> customClassNames =
      root.classes.map((Class x) => x.name).toSet();
  final Set<String> customEnumNames =
      root.enums.map((Enum x) => x.name).toSet();

  const List<String> generatedMessages = <String>[
    ' Generated class from Pigeon that represents data sent in messages.'
  ];
  indent.newln();
  addDocumentationComments(
      indent, klass.documentationComments, _docCommentSpec,
      generatorComments: generatedMessages);

  indent.write('export class ${klass.name} ');
  indent.addScoped('{', '}', () {
    for (final NamedType field in getFieldsInSerializationOrder(klass)) {
      _writeClassField(generatorOptions, root, indent, field);
      indent.newln();
    }

    _writeClassBuilder(generatorOptions, root, indent, klass);
    writeClassEncode(
      generatorOptions,
      root,
      indent,
      klass,
      customClassNames,
      customEnumNames,
      dartPackageName: dartPackageName,
    );
    writeClassDecode(
      generatorOptions,
      root,
      indent,
      klass,
      customClassNames,
      customEnumNames,
      dartPackageName: dartPackageName,
    );
  });
}