toTemplateString method

String toTemplateString()

Implementation

String toTemplateString() {
  return '''
enum $enumName { ${values.map((e) => valueName(e)).toList().join(', ')} }

extension ${enumName}Ex on $enumName{
String? get value => $enumValuesMapName.reverse[this];
}

final $enumValuesMapName = $converterName({
${valuesForTemplate()}
});


class $converterName<$valueType, O> {
final Map<$valueType, O> map;
Map<O, $valueType>? reverseMap;

$converterName(this.map);

Map<O, $valueType> get reverse => reverseMap ??= map.map((k, v) => MapEntry(v, k));
}
''';
}