toEnum<T> method
Implementation
T toEnum<T>(List<T> values, {bool throwIfInvalid = true}) {
return values.firstWhere(
(e) => e.toString().toLowerCase().split(".").last == toLowerCase(),
orElse: () => throwIfInvalid
? throw const FormatException("Invalid enum value")
: values.first);
}