toEnumValueString method
get the String representation of the enum value,
or null
if the enum was not valid
Implementation
String? toEnumValueString(List enumValues) {
final enumIndex = (type as InterfaceType)
.element
.fields
.where((element) => element.isEnumConstant)
.toList()
.indexWhere((element) => element.computeConstantValue() == this);
if (enumIndex == -1) {
return null;
} else {
return enumValues[enumIndex].toString();
}
}