List ([1, 2, 3]), Map ({'a': 1}) und Set ({1, 2}). Methoden: add, remove, length, contains, map, where, reduce, sort. Mit Collection-if und Spread (...) baust du Listen direkt im Literal, was in Flutter-Oberflächen oft vorkommt.
Bei Maps liefert der Zugriff null, wenn der Schlüssel fehlt.
final zahlen = [5, 2, 9, 4];
zahlen.add(7);
zahlen.sort();
print(zahlen.where((z) => z.isEven).toList()); // [2, 4]
final punkte = {'mia': 10, 'tom': 7};
punkte['lea'] = 12;
print(punkte['xyz']); // null
bool admin = true;
final menue = ['Start', if (admin) 'Verwaltung', ...zahlen.take(2)];
print(menue);Merke
wherefiltert,mapwandelt umCollection-if und Spread
...Map-Zugriff auf fehlenden Schlüssel liefert null
Aufgabe
Zähle in einem Satz, wie oft jedes Wort vorkommt.