Dart EnumeratioAn enumeration is a set of values called as elements, members, etc. This is essential when we carried out the operation with the limited set of values available for variable. For example - you can think of the days of the month can only be one of the seven days - Sun, Mon, Tue, Wed, Thur, Fri, Sat. Initializing an EnumerationThe enumeration is declared using the enum keyword, followed by the comma-separated list of the valid identifiers. This list is enclosed within the curly braces {}. The syntax is given below. Syntax - Here, the enum_name denotes the enum type name and list of the identifiers enclosed within the curly bracket. Each of the identifier in the enumeration list has its index position. The index of the first enumeration is 0; the second enumeration is 1, and so on. Example - Let's define an enumeration for months of the year. Let's say programming example - Example - Output: JavaTpoint - Dart Enumeration [EnumofYear.January, EnumofYear.February, EnumofYear.March, EnumofYear.April, EnumofYear.May, EnumofYear.June, EnumofYear.July, EnumofYear.August, EnumofYear.September, EnumofYear.October, EnumofYear.November, EnumofYear.December] value: EnumofYear.January, index: 0 value: EnumofYear.February, index: 1 value: EnumofYear.March, index: 2 value: EnumofYear.April, index: 3 value: EnumofYear.May, index: 4 value: EnumofYear.June, index: 5 value: EnumofYear.July, index: 6 value: EnumofYear.August, index: 7 value: EnumofYear.September, index: 8 value: EnumofYear.October, index: 9 value: EnumofYear.November, index: 10 value: EnumofYear.December, index: 11 Example - 2 Output: [Process_Status.none, Process_Status.running, Process_Status.stopped, Process_Status.paused] value: Process_Status.none, index: 0 value: Process_Status.running, index: 1 value: Process_Status.stopped, index: 2 value: Process_Status.paused, index: 3 running: Process_Status.running, 1 running index: Process_Status.running Next TopicDart Control Flow Statement |