generic_enum_builder 0.1.2 copy "generic_enum_builder: ^0.1.2" to clipboard
generic_enum_builder: ^0.1.2 copied to clipboard

outdated

Source code generator processing annotated generic_enum classes. It builds a value-instance map and json-serialization functions.

Generic Enum Builder #

Build Status

Introduction #

GenericEnumBuilder contains source code generating classes based on source_gen and analyzer. The provided builder can be configured to build generic enumeration classes supporting json-serialization.

Generic enumeration classes appear to the user like a Dart enum would. For example, generic enums can be used in switch statements, as annotations, to initialize variables, or as default parameters in functions and constructors.

Configuration #

To use this library the following configuration steps are required:

  1. Include generic_enum, generic_enum_annotation as dependencies in your pubspec.yaml file. Include generic_enum_builder, source_gen, build_runner as dev_dependencies.
  2. Create a class extending GenericEnum. See generic_enum#boilerplate.
  3. Annotate the class with @GenerateValueMap() and @GenerateFromJson().
  4. Configure the build targets. Amend the generate_for entry to point to the folder containing your generic enum classes. In your local build.yaml file add the following builders:
    targets:
      $default:
        builders:
          # Configure the builder `pkg_name|builder_name`
          generic_enum_builder|map_builder:
            # Only run this builder on the specified input.
            enabled: true
            generate_for:
              - lib/*.dart
          # Configure the builder `pkg_name|builder_name`
          generic_enum_builder|json_builder:
            # Only run this builder on the specified input.
            enabled: true
            generate_for:
              - lib/*.dart
    

Building #

If you are using Flutter, build the project by running the command:

$ flutter packages pub run build_runner build --delete-conflicting-outputs

If you are using the Dart SDK use:

$ pub run build_runner build --delete-conflicting-outputs

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 bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
0
pub points
0%
popularity

Publisher

verified publishersimphotonics.com

Source code generator processing annotated generic_enum classes. It builds a value-instance map and json-serialization functions.

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

analyzer, build, dart_style, generic_enum, generic_enum_annotation, meta, source_gen

More

Packages that depend on generic_enum_builder