enumValue<T> static method
Returns one of the values of the specified enum T, from the specified string.
The string must match the name of the enum value, excluding the enum type name (the part of its toString after the dot).
The first argument must be the values list for that enum; this is the
list of values that is searched.
For example, enumValue<TileMode>(TileMode.values, source, ['tileMode']) ?? TileMode.clamp reads the tileMode key of source, and looks for the
first match in TileMode.values, defaulting to TileMode.clamp if
nothing matches; thus, the string mirror would return TileMode.mirror.
Implementation
static String? enumValue<T>(T? key) {
if (key == null) return null;
return key.toString().split('.').last;
}