Ramses Aldama Ramses Aldama - 3 years ago 109
Dart Question

Iterating over a complex collection in Dart

I would like to be able to iterate over this collection.

import "package:collection/collection.dart";

main() {
EqualityMap edges = new EqualityMap.from(const ListEquality(), {
[1, 'a']: [2, 3],
[2, 'a']: [2],
[3, 'b']: [4, 3],
[4, 'c']: [5]
});
}


I am doing a recursive function so this is not allowed.

edges.keys.forEach((m) {
// some more code
return something;
});


Is it possible to achieve something similar to this?

for(var edge in edges)

Answer Source

Something like this should work:

for (var edgeKey in edges.keys) {
  var edge = edges[edgeKey];
  // do something
}
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download