How can I iterate through two lists in parallel in Dart?
Take a look at the quiver
package's zip
function.
You could write this as:
var a = [1, 2, 3];
var b = [4, 5, 6];
var c = [];
for (var pair in zip([a, b])) {
c.add(new Foo(pair[0], pair[1]));
}
Now that we have list comprehensions in dart:
final c = [for(int i = 0; i<a.length; i+= 1) Foo(a[i], b[i])];