Enumeration Example Program in Dart


The code defines an enum days that contains a list of weekdays - Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, and Sunday.

The print(days.values) statement prints all the values of the enum, which is an iterable containing all the weekdays in the order they were defined in the enum.

The print(days.Saturday) statement prints the value Saturday, which is one of the constants defined in the days enum.

In summary, the code demonstrates how to define and use enums in Dart, which can be useful for representing a set of related, constant values.

Source Code

enum days {
  Monday,
  Tuesday,
  Wednesday,
  Thursday,
  Friday,
  Saturday,
  Sunday
}
void main()
{
  print(days.values);
  print(days.Saturday);
}
To download raw file Click Here

Output

days.Monday, days.Tuesday, days.Wednesday, days.Thursday, days.Friday, days.Saturday, days.Sunday]
days.Saturday