Dart Loop
Dart has for
and while
loops.
For loops
Use for ... in ...
to loop through values without using array/list index.
List<String> a = ['1', '2', '3'];
for (var c in a) {
print(c);
}
If you need both the index and value, use indexed
List<String> a = ['1', '2', '3'];
for (var (i, c) in a.indexed) {
print('$i $c');
}
Output:
0 1
1 2
2 3