Add methods or values to enum in dart

前端 未结 8 960
刺人心
刺人心 2020-12-14 05:21

In java when you are defining an enum you can do something similar to the following. Is this possible in Dart?

enum blah {
  one(1), two(2);
  final num valu         


        
8条回答
  •  抹茶落季
    2020-12-14 06:12

    Dart enums are used only for the simplest cases. If you need more powerful or more flexible enums, use classes with static const fields like shown in https://stackoverflow.com/a/15854550/217408

    This way you can add whatever you need.

提交回复
热议问题