enume 1.1.0 copy "enume: ^1.1.0" to clipboard
enume: ^1.1.0 copied to clipboard

Enume - collection of useful enum extensions for dart. Like a Name-Method and TypedEnums for the ability to assign specific values each of the enumerated types.

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:  

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"

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"

Roadmap #

  • Support for all Built-in types and maybe dynamics
8
likes
140
points
76
downloads

Publisher

unverified uploader

Weekly Downloads

Enume - collection of useful enum extensions for dart. Like a Name-Method and TypedEnums for the ability to assign specific values each of the enumerated types.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on enume