Git Product home page Git Product logo

enum_class.dart's Introduction

Enum Classes for Dart

Enum Classes are now available from built_value.

enum_class.dart's People

Contributors

davidmorgan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

enum_class.dart's Issues

Fail on dynamic fields

We check the field type to match static const fields of the enum type; if someone forgot to put a field, it might not be clear why it's not being recognized. Dynamic fields are bad anyway, so forbid them.

Allow a class per enum value

When there's a lot of code in the enum, it would sometimes be nicer to have a different class representing each enum value than to use lots of switch statements.

Support instance fields

It should be possible to declare instance fields -- perhaps as getters -- and initialize them in the constant declarations.

enum_class_generator doesn't work in watch mode

Note: You will need to upgrade to version 0.3.0+6 of the build package to see these errors (watch mode was broken for the example previously)

To repro, you can just change example/tool/build.dart to call watch instead of build. If you make edits to example/lib/test_enum.dart then you will get errors like:

[SEVERE] example|lib/test_enum.dart: Error running EnumClassGenerator for class TestEnum extends EnumClass.
Please make the following changes to use EnumClass:

1. Generated identifier "_$yes" is used multiple times in test_enum, change to something else.
2. Generated identifier "_$no" is used multiple times in test_enum, change to something else.
3. Generated identifier "_$maybe" is used multiple times in test_enum, change to something else.
4. Generated identifier "_$values" is used multiple times in test_enum, change to something else.
5. Generated identifier "_$valueOf" is used multiple times in test_enum, change to something else.
#0      EnumClassGenerator.generate.<generate_async_body> (package:enum_class_generator/enum_class_generator.dart:63:7)
#1      Future.Future.microtask.<anonymous closure> (dart:async/future.dart:144)
#2      StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:206:15)
#3      StackZoneSpecification.registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:125:48)
#4      _rootRun (dart:async/zone.dart:946)
#5      _CustomZone.run (dart:async/zone.dart:826)
#6      _CustomZone.runGuarded (dart:async/zone.dart:724)
#7      _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:751)
#8      StackZoneSpecification._run (package:stack_trace/src/stack_zone_specification.dart:206:15)
#9      StackZoneSpecification.registerCallback.<anonymous closure> (package:stack_trace/src/stack_zone_specification.dart:125:48)
#10     _rootRun (dart:async/zone.dart:950)
#11     _CustomZone.run (dart:async/zone.dart:826)
#12     _CustomZone.runGuarded (dart:async/zone.dart:724)
#13     _CustomZone.bindCallback.<anonymous closure> (dart:async/zone.dart:751)
#14     _microtaskLoop (dart:async/schedule_microtask.dart:41)
#15     _startMicrotaskLoop (dart:async/schedule_microtask.dart:50)
#16     _runPendingImmediateCallback (dart:isolate-patch/isolate_patch.dart:96)
#17     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:149)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.