Skip to content

Dart package that provides a better way (java-like) to write enums

License

Notifications You must be signed in to change notification settings

Mai-Lapyst/dart_better_enum

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

better_enum

Package that provides a better way (java-like) to write enums

Getting Started

To use the new enum-class, you actualy have to write a class by yourself. Example:

import 'package:better_enum/better_enum.dart'

class Meter extends Enum<int> {
  // Internal constructor to prevent other code to create new 
  // instances of our enum.
  // Name is optional, and the base-class also has functionality
  // to work without a name.
  const Meter._internal(int val, {String name}): super(val, name);

  // example how to create a named Enum instance. The name is used
  // only for the toString() method.
  static const Meter HIGH = const Meter._internal(100, name: "HIGH");
  static const Meter MIDDLE = const Meter._internal(50);
  static const Meter LOW = const Meter._internal(10);
}

About

Dart package that provides a better way (java-like) to write enums

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages