writeEnum method

  1. @override
void writeEnum(
  1. ObjcOptions generatorOptions,
  2. Root root,
  3. Indent indent,
  4. Enum anEnum, {
  5. required String dartPackageName,
})
override

Writes a single Enum to indent. This is needed in most generators.

Implementation

@override
void writeEnum(
  ObjcOptions generatorOptions,
  Root root,
  Indent indent,
  Enum anEnum, {
  required String dartPackageName,
}) {
  final String enumName =
      _enumName(anEnum.name, prefix: generatorOptions.prefix);
  indent.newln();
  addDocumentationComments(
      indent, anEnum.documentationComments, _docCommentSpec);
  indent.writeln(
      '@implementation ${_enumName(enumName, prefix: '', box: true)}');
  indent.writeScoped('- (instancetype)initWithValue:($enumName)value {', '}',
      () {
    indent.writeln('self = [super init];');
    indent.writeScoped('if (self) {', '}', () {
      indent.writeln('_value = value;');
    });

    indent.writeln('return self;');
  });
  indent.writeln('@end');
}