State management ਇਸ ਗੱਲ ਨੂੰ ਦਰਸਾਉਂਦੀ ਹੈ ਕਿ ਇੱਕ ਐਪ ਆਪਣੇ data (state) ਨੂੰ ਕਿਵੇਂ ਪ੍ਰਬੰਧਿਤ ਕਰਦੀ ਹੈ ਅਤੇ ਅਪਡੇਟ ਕਰਦੀ ਹੈ ਅਤੇ UI ਵਿੱਚ ਤਬਦੀਲੀਆਂ ਨੂੰ ਪ੍ਰਤੀਬਿੰਬਿਤ ਕਰਦੀ ਹੈ। ਜਿਵੇਂ-ਜਿਵੇਂ ਐਪਸ ਵੱਡੀਆਂ ਹਨ, state ਨੂੰ ਚੰਗੀ ਤਰ੍ਹਾਂ ਪ੍ਰਬੰਧਿਤ ਕਰਨਾ ਮਹੱਤਵਪੂਰਨ ਹੋ ਜਾਂਦਾ ਹੈ, ਅਤੇ Flutter built-in ਮਕੈਨਿਜ਼ਮ (setState) ਅਤੇ ਬਹੁਤ ਸਾਰੀਆਂ ਲਾਇਬ੍ਰੇਰੀਆਂ (Provider, Riverpod, Bloc) ਪ੍ਰਦਾਨ ਕਰਦਾ ਹੈ।
State ਕੀ ਹੈ
STATE = data that can change and affects the UI:
→ UI state: is a checkbox checked? what's in a text field? is a menu open?
→ app state: the logged-in user, items in a cart, fetched data
→ When state changes, the UI must UPDATE to reflect it.
