يحتوي Flutter على عدة أساليب لإدارة الحالة — من المدمجة (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
