EnumIndex<E> class
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 = EnumIndex(Vote.values);
index.lookupBySimpleName('yea'); // returns Vote.yea
index.toSimpleName(Vote.nay); // returns 'nay'
Constructors
-
EnumIndex.new(List<
E> enumValues) -
Creates an index of
enumValues.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
lookupBySimpleName(
String simpleName) → E -
Given a
simpleNamefinds the corresponding enum value. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toSimpleName(
E enumValue) → String -
Returns the simple name for
enumValue. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited