0Pricing
Dart Academy · Lesson

Iterating Entries, Keys, and Values

Loop a map and use putIfAbsent.

Looping a Map

Sometimes you need to visit every pair in a Map. Dart gives you several clean ways to walk through it. 🚶

Just the Keys

The keys property gives an iterable of every key. Loop it when you only care about the labels.

var m = {'a': 1, 'b': 2};
for (var k in m.keys) {
  print(k);
}

All lessons in this course

  1. Sets and Guaranteed Uniqueness
  2. Set Operations: union, intersection, difference
  3. Maps as Key-Value Stores
  4. Iterating Entries, Keys, and Values
← Back to Dart Academy