Cheile în Flutter ajută framework-ul să identifice corect și să păstreze widget-urile în timpul reconstruirilor — deosebit de important pentru widget-urile cu stare în liste care sunt reordonate, adăugate sau eliminate. Înțelegerea când sunt necesare cheile previne bug-uri subtile și confuze.
Ce fac cheile
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.
