Dart

5 Dart Switch Case

void main() {
  String day = 'Monday';

  switch (day) {
    case 'Sunday':
      print('It\'s Sunday, time to relax!');
      break;
    case 'Monday':
      print('It\'s Monday, the start of the work week.');
      break;
    case 'Tuesday':
      print('It\'s Tuesday, the second day of the work week.');
      break;
    case 'Wednesday':
      print('It\'s Wednesday, middle of the week.');
      break;
    case 'Thursday':
      print('It\'s Thursday, almost the weekend.');
      break;
    case 'Friday':
      print('It\'s Friday, the end of the work week.');
      break;
    case 'Saturday':
      print('It\'s Saturday, time to enjoy the weekend!');
      break;
    default:
      print('Not a valid day.');
  }
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *