Switch Case Example Program in Dart


The code defines an enumeration type called status with three possible values: Yes, No, and Cancel. It then uses a switch statement to check which value is assigned to status.Yes.

Since status.Yes is assigned to the first possible value of the status enumeration, the code will execute the code block associated with case status.Yes: .

Source Code

enum status{Yes,No,Cancel}
void main(){
 switch(status.Yes)
 {
  case status.Yes:
     print('User Pressed Yes');
     break;
  case status.No:
     print('User Pressed No');
     break;
  case status.Cancel:
     print('User Pressed Cancel');
     break;
 }

}
To download raw file Click Here

Output

User Pressed Yes