google / enum_class.dart Goto Github PK
View Code? Open in Web Editor NEWDeleted, use built_value instead.
Home Page: https://github.com/google/built_value.dart
License: BSD 3-Clause "New" or "Revised" License
Deleted, use built_value instead.
Home Page: https://github.com/google/built_value.dart
License: BSD 3-Clause "New" or "Revised" License
BuiltSet is used for the "values" method, so it will always be needed for an EnumClass.
It should be possible to declare instance fields -- perhaps as getters -- and initialize them in the constant declarations.
Currently, the top level symbols clash.
Mixins exposing enum constants are useful for e.g. angular templates.
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.
With v0.0.3 the generator complains if you reuse generated identifiers across files, which should be fine.
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.
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)
Enum classes can't be abstract as they need to be instantiated.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.