generic_enum_builder 0.1.8

  • Readme
  • Changelog
  • Example
  • Installing
  • 61

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() or @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.0.1 #

Initial Version of the library.

0.0.2 #

Added code generator tests.

0.0.3 #

Added Dart docs.

0.0.4 #

Added library keyword.

0.0.5 #

Added Travis badge.

0.0.6 #

Removed toJson generator.

0.0.7 #

Modified _fromJson.

0.0.8 #

Corrected syntax error in json_generator.dart.

0.1.0 #

Generators now use a prefix for fcts and vars.

0.1.1 #

Removed dependency on build_collection. Used an unmodifiable map instead.

0.1.2 #

Included dependency on latest versions of generic_enum and generic_enum_annotation.

0.1.3 #

Added class IdentifierGenerator.

0.1.4 #

Added builder identifierBuilder.

0.1.5 #

Added Dart docs to generated variables and functions.

0.1.6 #

Upgraded dependencies.

0.1.7 #

Annotating with @GenerateFromJson() now generates a fromJson function and a value-instance map.

0.1.8 #

Upgraded dependency on generic_enum.

example/README.md

Generic Enum Builder #

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.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  generic_enum_builder: ^0.1.8

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:generic_enum_builder/generic_enum_builder.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
21
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
61
Learn more about scoring.

We analyzed this package on Apr 3, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
analyzer ^0.39.4 0.39.5
build ^1.2.2 1.2.2
dart_style ^1.3.3 1.3.3
generic_enum ^0.1.7 0.1.9
generic_enum_annotation ^0.1.5 0.1.5
meta ^1.1.8 1.1.8
source_gen ^0.9.4+6 0.9.5
Transitive dependencies
_fe_analyzer_shared 2.0.0
args 1.6.0
async 2.4.1
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
csslib 0.16.1
glob 1.2.0
html 0.14.0+3
js 0.6.1+1
json_annotation 3.0.1
logging 0.11.4
node_interop 1.0.3
node_io 1.0.1+2
package_config 1.9.3
path 1.6.4
pedantic 1.9.0
pub_semver 1.4.4
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
watcher 0.9.7+14
yaml 2.2.0
Dev dependencies
build_runner ^1.7.4
source_gen_test ^0.1.0+6
test ^1.12.0