State Management
- Allows
state managing inside of a flutter app using a store
- Applies the
Single Source of Truth principle
Notifier / Cubit
- It's the class that contain state and manages it
- Upon change, these new values are notified to those who subscribed
- State notification (tell to other widgets that the state has changed)
notifyListeners() (for ChangeNotifier)
emit() (for Cubit)
Provider / BlocProvider
- It's the
store that monitors the state of a notifier/cubit
- Every
listener inside the provider is a singleton containing all the current values
- Every
listener is attached to a notifier that holds the data to be monitored
Consumer / BlocBuilder
- Piece of code that will
subscribe to a value from the store
- The widgets subscribing will automatically build and reload upon changes on the state
Provider.of / BuildContext.read
- Access the state from the store once
- No subscribing or auto reload
- It can also just invoke a method from the store