How to working loop in Dart
- list
var list = [1, 2, 3, 4, 5, 6];
- using for each method
list.forEach((element) {
print(element);
});
- using for Loop
for (int i = 0; i < list.length; i++) {
var e = list[i];
print(e);
}
- enhanced for Loop
for (var e in <List>[list]) {
print(e);
}
- using while Loop
var i = 0;
while (i < list.length) {
print(list[i]);
i++;
}