enumValue<T extends Enum> method

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

The enum value named by string property name, or the declared default (then the first value) when absent or unrecognized. An unrecognized name (a newer writer or a typo) is reported, since serialize rebuilds from the live value and a save would silently replace it.

Implementation

T enumValue<T extends Enum>(String name, List<T> values) {
  final raw = string(name);
  for (final candidate in values) {
    if (candidate.name == raw) return candidate;
  }
  debugPrint(
    'fscene: unrecognized $name value "$raw" on ${_spec.type}; '
    'using ${values.first.name}.',
  );
  return values.first;
}