writeClassEncode method

  1. @override
void writeClassEncode(
  1. ObjcOptions generatorOptions,
  2. Root root,
  3. Indent indent,
  4. Class klass,
  5. Set<String> customClassNames,
  6. Set<String> customEnumNames, {
  7. required String dartPackageName,
})
override

Writes a single class encode method to indent.

Implementation

@override
void writeClassEncode(
  ObjcOptions generatorOptions,
  Root root,
  Indent indent,
  Class klass,
  Set<String> customClassNames,
  Set<String> customEnumNames, {
  required String dartPackageName,
}) {
  indent.write('- (NSArray *)toList ');
  indent.addScoped('{', '}', () {
    indent.write('return');
    indent.addScoped(' @[', '];', () {
      for (final NamedType field in klass.fields) {
        indent.writeln(
            '${_arrayValue(customClassNames, customEnumNames, field)},');
      }
    });
  });
}