美文网首页
Flutter - Dart -流程控制 ifelse whil

Flutter - Dart -流程控制 ifelse whil

作者: rainy66 | 来源:发表于2024-07-07 09:27 被阅读0次

    if

      if (true) {
        print('maybe1');
      }
    
    
    

    if else

     int a = 1;
      String b = ' ';
      if (a == 1) {
        b = 'maybe2';
      } else {
        b = 'maybe3';
      }
      print(b);
    
    

    for

     for (var i = 0; i < 10; i++) {
        print(i);
        if (i == 1) {
          break;
        }
        if (i == 2) {
          continue;
        }
     }
    
    
    

    while

    int day = 0;
      while (day < 7) {
        print(day);
        day++;
        if (day == 2) {
          break;
        }
        if (day == 4) {
          continue;
        }
      }
    
    
    

    do while

     int time = 0;
        do {
          print(time);
          time++;
          if (time == 3) {
            break;
          }
          if (time == 5) {
            continue;
          }
        } while (time < 7);
    
    
    

    switch

     String date = 'Mon';
    
        switch (date) {
          case 'Mon':
            print(date);
            break;
          case 'Tus':
            print(date);
          break; 
          case 'Wes':
          case 'Thr':
          case 'Fti':
          print(date);
          break;
          default:
          print(date);
        }
    

    相关文章

      网友评论

          本文标题:Flutter - Dart -流程控制 ifelse whil

          本文链接:https://www.haomeiwen.com/subject/cyfofjtx.html