EnumAssist constructor

const EnumAssist({
  1. bool? createJsonConv,
  2. bool? createName,
  3. bool? createDescription,
  4. bool? createToInt,
  5. bool? createReadable,
  6. bool? createSerialized,
  7. SerializedFormat? serializedFormat,
  8. bool? useDocCommentAsDescription,
  9. bool? useIntValueForSerialization,
})

Annotation to assist enums with generating code.

Generated Methods

  • map

    • Is the equivalent to pattern matching
  • maybeMap

    • Same as map, but doesn't require all callbacks to be specified
    • Returns orElse value, or null if MaybeExtension.allowNulls is true
  • name

    • Returns the name of the enum value
    • Formats the field to capital case unless overridden with @EnumValue.name
  • toInt

    • Returns the int value of the enum field
  • description

    • Returns the description of the enum field
    • Uses the doc comment of the field unless overridden with @EnumValue.description or @EnumAssist.useDocCommentAsDescription is set to false (either annotation or build.yaml file)
    • Uses the @EnumValue.description if overridden in annotation
  • serialized

    • Returns the serialized value of the enum field, the default format is the name of the enum value
    • Uses the @EnumValue.serialized if overridden in annotation
    • Can be formatted via @EnumAssist.serializedFormat (either annotation or build.yaml file)

Generated Classes

optionally generated, prevent generation via @EnumAssist.createJsonConv
(either annotation or build.yaml file)

Classes extend JsonConverter, from json_serializable for conversion

  • ExampleConv

    • Convert non-nullable fields to and from json
    • Can annotate fields in model class's fields
      @ExampleConv()
  • _ExampleNullableConv (private class)

    • Convert nullable fields to and from json
    • Can annotate fields in model classes
      @ExampleConv.nullable

Implementation

const EnumAssist({
  this.createJsonConv,
  this.createName,
  this.createDescription,
  this.createToInt,
  this.createReadable,
  this.createSerialized,
  this.serializedFormat,
  this.useDocCommentAsDescription,
  this.useIntValueForSerialization,
});