EnumAssist class

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
Annotations
  • @Target({TargetKind.enumType})

Constructors

EnumAssist({bool? createJsonConv, bool? createName, bool? createDescription, bool? createToInt, bool? createReadable, bool? createSerialized, SerializedFormat? serializedFormat, bool? useDocCommentAsDescription, bool? useIntValueForSerialization})
Annotation to assist enums with generating code.
const

Properties

createDescription bool?
Whether to create the description for this enum
final
createJsonConv bool?
Whether to create a json converter for this enum
final
createName bool?
Whether to create the name for this enum
final
createReadable bool?
Whether to create the readable for this enum
final
createSerialized bool?
Whether to create the serialized for this enum
final
createToInt bool?
Whether to create the toInt for this enum
final
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
serializedFormat SerializedFormat?
The format of the enum value when serialized.
final
useDocCommentAsDescription bool?
Whether to use the doc comment of the enum for the description method.
final
useIntValueForSerialization bool?
Whether to use the toInt value of the enum field for toJson/fromJson & serialized method.
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited