Question: In Java when you are defining an enum, you can do something similar to the following, i.e. add members to an `enum`. Is this possible in Dart?

```dart
enum Foo {
  one(1), two(2);
  final num value;
  Foo(this.value);
}

```

Answer: 
It may not be "Effective Dart" , I add a static method inside a Helper class ( there is no companion object in Dart) .

In your `color.dart` file

```
enum Color {
  red,
  green,
  blue
}

class ColorHelper{

  static String getValue(Color color){
    switch(color){
      case Color.red: 
        return "Red";
      case Color.green: 
        return "Green";
      case Color.blue: 
        return "Blue";  
      default:
        return "";
    }
  }

}

```

Since the method is in the same file as the enum, one import is enough

```
import 'package:.../color.dart';

...
String colorValue = ColorHelper.getValue(Color.red);

```
extension is good, but it cannot add static methods. If you want to do something like MyType.parse(string), consider using a class with static const fields instead (as Günter Zöchbauer suggested before).

Here is an example

```
class PaymentMethod {
  final String string;
  const PaymentMethod._(this.string);

  static const online = PaymentMethod._('online');
  static const transfer = PaymentMethod._('transfer');
  static const cash = PaymentMethod._('cash');

  static const values = [online, transfer, cash];

  static PaymentMethod parse(String value) {
    switch (value) {
      case 'online':
        return PaymentMethod.online;
        break;
      case 'transfer':
        return PaymentMethod.transfer;
        break;
      case 'cash':
        return PaymentMethod.cash;
      default:
        print('got error, invalid payment type $value');
        return null;
    }
  }

  @override
  String toString() {
    return 'PaymentMethod.$string';
  }
}

```

I found this much handier than using a helper function.

```
final method = PaymentMethod.parse('online');
assert(method == PaymentMethod.online);

```