generic_enum_annotation 0.0.7 generic_enum_annotation: ^0.0.7 copied to clipboard
Defines annotations processed by source code generating library generic_enum_builder.
Generic Enum Annotation #
Introduction #
This library defines annotation classes (with const constructor). These are used to annotate classes that extend GenericEnum
.
GenericEnum
is a base class for creating generic classes with a fixed set of static constant instances.
These classes appear to the user like a Dart enum
would. For example, generic enums can be used in
switch
statements, to initialize variables, or as default parameters in functions and constructors.
The annotations defined in this library are:
@GenerateMap()
: Requests the generation of aBuiltMap
containing the enum values and static const instances.@GenerateJson()
: Requests the generation of the methods_toJson
andfromJson
Important: @GenerateJson()
requires @GenerateMap()
since the fromJson
function uses the
BuiltMap to retrieve generic enum instances based on their value.
Examples #
The package generic_enum_example provides a complete example on how to define and build
generic enumeration classes. As a starting point users could clone this repository, add
their own generic enum classes to the folder lib
and build the library.
Features and #
Please file feature requests and bugs at the issue tracker.