rknell / flutterEnumsToString

Better conversion of ENUMs to string for Flutter / Dart
Other
85 stars 23 forks source link

Feature Request: .toList() #6

Closed codegrue closed 4 years ago

codegrue commented 4 years ago

I would love to see you add a method to convert an enum type to a list of strings. Working code is:

List<String> toList<T>(List<T> enumValues) {
  List<String> enumList = enumValues.map((t) => EnumToString.parse(t)).toList();
  return enumList;
}
enum TestEnum { testValue1, testValue2 };

EnumToString.toList(TestEnum.values);
//result = 'testValue1','testValue2',
codegrue commented 4 years ago

Created a pull request with this code.

rknell commented 4 years ago

Thanks for the pull request. Publishing new version now.