byNameOrNull method

T? byNameOrNull(
  1. String name, [
  2. String? extra
])

Finds the enum value in this list with name name.

Goes through this collection looking for an enum with name name, as reported by EnumName.name. Returns the first value with the given name or null if none found.

Implementation

T? byNameOrNull(String name, [String? extra]) {
  for (var value in this) {
    if (value.name == name || value.name == extra) return value;
  }
  return null;
}