Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:core
  3. EnumByName extension
EnumByName
description

EnumByName<T extends Enum> extension

Access enum values by name.

Extensions on a collection of enum values,intended for use on thevalues list of an enum type,which allows looking up a value by its name.

Since enum classes are expected to be relatively small,lookup ofbyName is performed by linearly iterating through the valuesand comparing their name to the provided name.If a more efficient lookup is needed, perhaps because the lookup operationhappens very often, consider building a map instead usingasNameMap:

static myEnumNameMap = MyEnum.values.asNameMap();

and then use that for lookups.

on
Annotations
  • @Since.new("2.15")

Methods

asNameMap()Map<String,T>

Available onIterable<T>, provided by theEnumByName extension

Creates a map from the names of enum values to the values.
byName(Stringname)→ T

Available onIterable<T>, provided by theEnumByName extension

Finds the enum value in this list with namename.
  1. Dart
  2. dart:core
  3. EnumByName extension
dart:core library

[8]ページ先頭

©2009-2025 Movatter.jp