In dart there are total 5 types of Loops.
For Loop
For....in Loop
For Each Loop
While Loop
Do.....While Loop
In this section we will see about Dart " For....in Loop " .
The for..in loop is similar to for loop but different in its syntax.
It iterates through an object's properties. The Dart for..in loop accepts an expression as iterator and iterates through the elements one at a time in sequence.
The variable var holds the values of the iteration. The for…in will execute until elements remain in iterators.
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.
Dart For In Loop Flow Diagram
Syntax
for (var in expression) { //statement(s) }
// for ..in loop
List planetList = ["Mercury", "Venus", "Earth", "Mars"];
for (String planet in planetList) {
print(planet);
}
}