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
