writeEnum method
void
writeEnum(
- ObjcOptions generatorOptions,
- Root root,
- Indent indent,
- Enum anEnum, {
- 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.write('typedef NS_ENUM(NSUInteger, $enumName) ');
indent.addScoped('{', '};', () {
enumerate(anEnum.members, (int index, final EnumMember member) {
addDocumentationComments(
indent, member.documentationComments, _docCommentSpec);
// Capitalized first letter to ensure Swift compatibility
indent.writeln(
'$enumName${member.name[0].toUpperCase()}${member.name.substring(1)} = $index,');
});
});
_writeEnumWrapper(indent, enumName);
}