EnumIndex<E> class Null safety

Indexes a list of enum values by simple name.

In Dart enum names are prefixed with enum class name. For example, for enum Vote { yea, nay }, Vote.yea.toString() produces "Vote.yea" rather than just "yea" - the simple name. This class provides methods for getting and looking up by simple names.

Example:

enum Vote { yea, nay }
final index = new EnumIndex(Vote.values);
index.lookupBySimpleName('yea'); // returns Vote.yea
index.toSimpleName(Vote.nay); // returns 'nay'

Constructors

EnumIndex(List<E> enumValues)
Creates an index of enumValues.

Properties

hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited

Methods

lookupBySimpleName(String simpleName) → E
Given a simpleName finds the corresponding enum value.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
inherited
toSimpleName(E enumValue) String
Returns the simple name for enumValue.
toString() String
Returns a string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator. [...]
inherited