Dart Loops : For Loop

Dart Loops : For Loop

ยท

1 min read

  • In dart there are total 5 types of Loops.

    1. For Loop

    2. For....in Loop

    3. For Each Loop

    4. While Loop

    5. 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--).

ย