byName method Null safety

T byName(
  1. String name
)

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. Such a value must be found.

Implementation

T byName(String name) {
  for (var value in this) {
    if (value._name == name) return value;
  }
  throw ArgumentError.value(name, "name", "No enum value with that name");
}