enumValueFromName<T> static method
Returns an enum value based on its string name. For example, given 'POST'
,
and the enum enum Methods { GET, POST, DELETE }
, Methods.POST
is returned.
Implementation
static T? enumValueFromName<T>(Iterable<T> enumValues, String enumName) {
return firstWhereOrNull(enumValues, (e) => e.toString().split('.').last == enumName);
}