enum_class_generator 0.1.0 copy "enum_class_generator: ^0.1.0" to clipboard
enum_class_generator: ^0.1.0 copied to clipboard

discontinued
outdatedDart 1 only

Dart classes as enums. This library is the dev dependency.

Enum Classes for Dart #

Enum Classes are an extension to Dart that uses code generation to give common enum functionality to classes.

Features #

  • Constants have name and toString, can be used in switch statements, and are real classes that you can add code to
  • Generated values method that returns all the enum values in a BuiltSet (immutable set)
  • Generated valueOf method that takes a String

Using Enum Classes #

Enum Classes use the source_gen library for code generation. The typical way to use it is via a build.dart tool that you create for your project. When you run it, all the generated files are updated.

Here's what you need to do to use Enum Classes:

  1. Add a library dependency on enum_class to your pubspec.yaml
  2. Add a dev dependency on enum_class_generator to your pubspec.yaml
  3. Create a build.dart for your project. See example, below.
  4. Run pub run tools/build.dart whenever you need to update the generated files.
  5. To make an Enum Class, import package:enum_class/enum_class.dart then extend EnumClass.

See this example for a full project with a build.dart and an enum.

Features and bugs #

Please file feature requests and bugs at the issue tracker.

0
likes
0
pub points
0%
popularity

Publisher

unverified uploader

Dart classes as enums. This library is the dev dependency.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

analyzer, build, built_collection, enum_class, quiver, source_gen

More

Packages that depend on enum_class_generator