writeDataClass method

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

Writes a single data class to indent.

Implementation

@override
void writeDataClass(
  KotlinOptions generatorOptions,
  Root root,
  Indent indent,
  Class classDefinition, {
  required String dartPackageName,
}) {
  final List<String> generatedMessages = <String>[
    ' Generated class from Pigeon that represents data sent in messages.'
  ];
  if (classDefinition.isSealed) {
    generatedMessages.add(
        ' This class should not be extended by any user class outside of the generated file.');
  }
  indent.newln();
  addDocumentationComments(
      indent, classDefinition.documentationComments, _docCommentSpec,
      generatorComments: generatedMessages);
  _writeDataClassSignature(indent, classDefinition);
  if (classDefinition.isSealed) {
    return;
  }
  indent.addScoped(' {', '}', () {
    writeClassDecode(
      generatorOptions,
      root,
      indent,
      classDefinition,
      dartPackageName: dartPackageName,
    );
    writeClassEncode(
      generatorOptions,
      root,
      indent,
      classDefinition,
      dartPackageName: dartPackageName,
    );
  });
}