toEnum<T> function

T? toEnum<T>(
  1. String? key,
  2. List<T> values
)

Returns an Enum Type given a String name

Implementation

T? toEnum<T>(String? key, List<T> values) {
  try {
    return values.firstWhereOrNull((v) => key == fromEnum(v));
  } catch (e) {
    return null;
  }
}