writeDataClass method
void
writeDataClass(
- SwiftOptions generatorOptions,
- Root root,
- Indent indent,
- Class klass, {
- required String dartPackageName,
override
Writes a single data class to indent
.
Implementation
@override
void writeDataClass(
SwiftOptions 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> generatedComments = <String>[
' Generated class from Pigeon that represents data sent in messages.'
];
indent.newln();
addDocumentationComments(
indent, klass.documentationComments, _docCommentSpec,
generatorComments: generatedComments);
indent.write('struct ${klass.name} ');
indent.addScoped('{', '}', () {
getFieldsInSerializationOrder(klass).forEach((NamedType field) {
_writeClassField(indent, field);
});
indent.newln();
writeClassDecode(
generatorOptions,
root,
indent,
klass,
customClassNames,
customEnumNames,
dartPackageName: dartPackageName,
);
writeClassEncode(
generatorOptions,
root,
indent,
klass,
customClassNames,
customEnumNames,
dartPackageName: dartPackageName,
);
});
}