for…in 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.
Syntax:
for (var in expression) { // Body of loop }
Example:
Dart
void main() { var w3wiki = [ 1, 2, 3, 4, 5 ]; for ( int i in w3wiki) { print(i); } } |
Output:
1 2 3 4 5
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
Contact Us