Key dalam Flutter membantu framework mengenal pasti dan mengekalkan widget dengan betul merentas rebuild — amat penting untuk stateful widget dalam list yang disusun semula, ditambah, atau dibuang. Memahami bila key diperlukan menghalang pepijat yang halus dan mengelirukan.
Apa yang key lakukan
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.
