Last updated:
0 purchases
enume
Enume - useful enum extensions for dart #
Code generation for a Name-Method and TypedEnums, which allows to assign specific values each of the enumerated types.
Setup #
dependencies:
# add enume to your dependencies
enume:
dev_dependencies:
# add the enume_generator to your dev_dependencies
enume_generator:
copied to clipboard
Usage #
Name #
Generates a name getter method that returns the name of this enum constant, exactly as declared in its enum declaration.
@Enume()
enum Animal {
dog,
cat,
fish,
fox,
}
// Example
print(Animal.dog.name); // "dog"
copied to clipboard
Value #
Generates a value getter method that returns the associated annoted value. (Currently only literals are supported!)
@Enume(nameMethod: false)
enum HttpStatus {
@Value(200, name: 'code')
@Value('OK')
ok,
@Value(400, name: 'code')
@Value('Bad Request')
badRequest,
@Value(407, name: 'code')
@Value('Proxy Authentication Required')
conflict,
}
// Example
print(HttpStatus.ok.value); // 20
print(HttpStatus.conflict.code); // "Proxy Authentication Required"
copied to clipboard
Roadmap #
Support for all Built-in types and maybe dynamics
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.