Do While Loop in Dart

Do While Loop

Do while loop is used to run a block of code multiple times. The loop’s body will be executed first, and then the condition is tested.

Syntax

do
{
    statement1;
    statement2;
    .

}while(condition);

Example

void main() {
  var shots = 5;
  int i = 0;
  do {
    //execute atleast once whether the condition is true or not
    print('$shots:jeet');
    i++;
  } while (i != shots); //condition is false
}

Output

5:jeet
5:jeet
5:jeet
5:jeet
5:jeet

Exited.