enumToList<T extends Object> function
Convert enum
to the list of strings
Pass in the enum
values to the first argument,
for example TestEnum.values
The withUnderscores
parameter acts accordingly to
enumToString implementation.
enum TestEnum { valueOne, valueTwo }
final enumList = enumToList(TestEnum.values);
enumList == ['value_one', 'value_two']; // true
final enumList = enumToList(TestEnum.values, camelCase: true);
enumList == ['valueOne', 'valueTwo']; // true
Implementation
List<String> enumToList<T extends Object>(Iterable<T> enumValues,
{bool withUnderscores = true}) {
return enumValues
.map((t) => enumToString(t, withUnderscores: withUnderscores))
.toList();
}