Flutter Tutorial

Loop

void main() {

  // start/initialization : condition : increment/decrement
  // statements
  for (int i=0; i <= 100; i = i+1) {
    if (i == 50) {
      continue;
    }
    if (i == 50) {
      break;
    }
    print('Dokane gesi $i');
  }
  print('Loop is done');

  List<String> studentList = ['Rakib', 'Sakib', 'Farhan', 'Omi'];
  Map<int, String> studentMap = {
    1 : 'Rafi',
    2 : 'Shafi',
    3 : 'Sourov'
  };

  for (int i=0; i < studentList.length; i++) {
    print('Student name $i => ${studentList[i]}');
  }

  // // ForIn
  for (String item in studentList) {
    print(item);
  }

  for (String item in studentMap.values) {
    print(item);
  }

  String name = 'Rafat';
  int age = 23;
  String userDetails = 'Name : $name Age : $age';
  print(userDetails);

  // start/initialization : condition : increment/decrement

  int i = 0;

  while (i <= 10) {
    print('Current value is $i');
    i = i+1;
  }

}
Scroll to Top