Flutter ਕੋਲ ਕਈ state management ਦੀਆਂ ਪਹੁੰਚਾਂ ਹਨ — ਬਿਲਟ-ਇਨ (setState, InheritedWidget) ਤੋਂ ਲੈ ਕੇ ਪ੍ਰਸਿੱਧ ਲਾਇਬ੍ਰੇਰੀਆਂ (Provider, Riverpod, Bloc, GetX) ਤੱਕ। ਮੁੱਖ ਵਿਕਲਪਾਂ, ਉਨ੍ਹਾਂ ਦੀ ਫ਼ਿਲਾਸਫ਼ੀ, ਅਤੇ ਵਿਚਾਰ-ਵਟਾਂਦਰੇ ਨੂੰ ਸਮਝਣਾ ਐਪ ਲਈ ਸਹੀ ਪਹੁੰਚ ਚੁਣਨ ਵਿੱਚ ਮਦਦ ਕਰਦਾ ਹੈ।
ਬਿਲਟ-ਇਨ ਪਹੁੰਚਾਂ
setState → local state in a StatefulWidget (simple; doesn't scale to shared state)
InheritedWidget → built-in way to share state down the tree (the foundation many
libraries build on; verbose to use directly)
Provider — ਸਧਾਰਨ ਅਤੇ ਸਿਫਾਰਸ਼ ਕੀਤਾ
PROVIDER → official-recommended, built on InheritedWidget; simple, widely used:
→ provide state at a point in the tree; descendants "watch"/consume it
→ ChangeNotifier holds state and notifies listeners → UI rebuilds on change
→ good for many apps; gentle learning curve
