GenerateValueExtension constructor

const GenerateValueExtension({
  1. required Type valueType,
  2. required Set<String> values,

Annotation requesting the generation of the extension <EnumName>Value.

  • valueType: The type of the mapped enum values. Use the function getType<T>() to pass a parameterized type e.g. valueType: getType<List<int>>().
  • values: The enum values of type valueType encoded as a String.

Note: Value entries are copied verbatim to the getter. The values must represent a literal or a constant value. The number of entries must match the number of enum instances.

Values of type String must be enclosed with escaped quotation marks! Examples:

  • Integer: {'0', '1', '2',}
  • String: {'\'zero\'', '\'one\'', '\'two\'',}
  • class A: {'const A(3.0)', 'const A(4.0)',}


const GenerateValueExtension({
  required this.valueType,
  required this.values,