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 loops " .
The for loop is an implementation of a definite loop.
The for loop executes the code block for a specified number of times.
For loop in Dart is similar to that in Java and also the flow of execution is the same as that in Java.
void main() {
// FOR Loop
for (int i = 1; i <= 10; i++) {
if ( i % 2 == 0) {
print(i);
}
}
The for loop has total three parts:
the initializer (i=num), the condition ( i>=1) and the final expression (i--).
ย