#Enumeration

Enum base class

This class is created as a workaround to issue 88 in dart language, since enums have not yet arrived.

example:

class Isolation extends Enum {

  const static Isolation READ_COMMITTED = const Isolation('READ_COMMITTED');
  const static Isolation REPEATABLE_READ = const Isolation('REPEATABLE_READ');
  const static Isolation SERIALIZABLE = const Isolation('SERIALIZABLE');

  final List<Isolation> values = const [READ_COMMITTED, REPEATABLE_READ, SERIALIZABLE];

  const Isolation._(String name) : super._(name);
  String toString() => name;
}

and then you could use it inside a switch

var isolation = Isolation.READ_COMMITED;
switch(isolation) {
  case Isolation.READ_COMMITED:
    print('isolation has been commited');
    break;
  case Iolation.REPETABLE_READ:
    print('isolation is repetable read');
    break;
  case Isolation.SERIALIZABLE:
    print('isolation is serializable');
    break;
}

you can also conver a string into enum:

var isolation = Isolation.valueOf('READ_COMMITED');

and finally you could get all the values of the enum:

var isolations = Isolation.values;

Libraries

enumeration