Dart Enumeration

In this tutorial you will learn about the Dart Enumeration and its application with practical example.

Dart Enumeration

An enumeration is a set of predefined named values, called as members. Enumerations are useful when we want deal with limited set of values for variable. For example you can think of the colors of a traffic light can only be one of three colors– red, yellow or green.

Table Of Contents

Defining an enumeration

In Dart, enumeration can be declared using the enum keyword followed by a list of the individual members enclosed between pair of curly brackets {}.

Syntax:-

Example:-

Let’s define an enumeration for days of week –

Example:-

Output:-

dart_enum_enumeration_example

In this tutorial we have learn about the Dart Enumeration and its application with practical example. I hope you will like this tutorial.