enumValue<T extends Enum> static method

T? enumValue<T extends Enum>(
  1. List<T> values,
  2. String value
)

The one of values whose name matches value, ignoring case, - and _ (tonal-spot gives tonalSpot); null when none does.

Implementation

static T? enumValue<T extends Enum>(List<T> values, String value) {
  final wanted = canonical(value);
  for (final candidate in values) {
    if (canonical(candidate.name) == wanted) {
      return candidate;
    }
  }
  return null;
}