do..while loop

The body of the loop will be executed first and then the condition is tested.
 

Syntax: 

 do{
    text expression;
    // Body of loop
}while(condition);

Example: 
 

Dart




void main()
{
    var w3wiki = 4;
    int i = 1;
    do {
        print('Hello Geek');
        i++;
    } while (i <= w3wiki);
}


Output: 
 

Hello Geek
Hello Geek
Hello Geek
Hello Geek

 



Dart – Loops

A looping statement in Dart or any other programming language is used to repeat a particular set of commands until certain conditions are not completed. There are different ways to do so. They are: 
 

  • for loop
  • for… in loop
  • for each loop
  • while loop
  • do-while loop

Similar Reads

for loop

For loop in Dart is similar to that in Java and also the flow of execution is the same as that in Java.Syntax:...

for…in loop

...

for each … loop

For…in loop in Dart takes an expression or object as an iterator. It is similar to that in Java and its execution flow is also the same as that in Java....

while loop

...

do..while loop

The for-each loop iterates over all elements in some container/collectible and passes the elements to some specific function....

Contact Us