convertFromString<T> static method

T? convertFromString<T>(
  1. List<T> enumValues,
  2. String value
)

Implementation

static T? convertFromString<T>(List<T> enumValues, String value) {
  try {
    return enumValues.singleWhere((enumItem) =>
        convertToString(enumItem).toLowerCase() == value.toLowerCase());
  } on StateError catch (_) {
    return null;
  }
}