fromString<T> static method

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

Implementation

static T? fromString<T>(List<T> enumValues, String value) {
  try {
    return enumValues.singleWhere(
      (dynamic enumItem) =>
          EnumToString.convertToString(enumItem).toLowerCase() ==
          value.toLowerCase(),
    );
  } on Exception {
    return null;
  }
}