getEnum<T> static method

T getEnum<T>(
  1. String enumName,
  2. List<T> values
)

Implementation

static T getEnum<T>(String enumName, List<T> values) {
  var cleanedName = reCase(enumName);
  for (var i = 0; i < values.length; i++) {
    if (cleanedName == getName(values[i])) {
      return values[i];
    }
  }
  throw Exception("$cleanedName doesn't exist in the list of enums $values");
}