Keys in Flutter helfen dem Framework, Widgets über Rebuilds hinweg korrekt zu identifizieren und zu bewahren — besonders wichtig für stateful Widgets in Listen, die neu angeordnet, hinzugefügt oder entfernt werden. Das Verständnis für Keys verhindert subtile, verwirrende Bugs.
Was Keys tun
During rebuilds, Flutter MATCHES new widgets to existing elements/state by POSITION and
TYPE. Usually this works fine. But when widgets of the SAME TYPE are reordered/added/
removed in a list, position-matching gets confused → state attaches to the WRONG widget.
→ KEYS give widgets a stable IDENTITY so Flutter matches them correctly across changes.
