AppState class

Central application state manager that handles user-scoped WIC benefits balances and shopping basket data.

This ChangeNotifier persists data to FirebaseFirestore and derives sensible default caps for each WIC category when first encountered. APL (Approved Product List) documents do NOT carry caps - they are managed entirely within this state.

Usage: Wire this into your app via ChangeNotifierProxyProvider in main.dart to automatically sync with FirebaseAuth state changes.

Inheritance

Constructors

AppState.new({FirebaseFirestore? db})

Properties

balances Map<String, Map<String, dynamic>>
User-specific WIC benefit balances by category.
getter/setter pair
balancesLoaded bool
Public getter for _balancesLoaded.
no setter
basket List<Map<String, dynamic>>
The user's current shopping basket.
final
hashCode int
The hash code for this object.
no setterinherited
hasListeners bool
Whether any listeners are currently registered.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addItem({required String upc, required String name, required String category}) bool
Adds one item to the basket and updates balances.
addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
canAdd(String categoryRaw) bool
Returns true if another item from the given category can be added.
decrementItem(String upc) → void
Decreases the quantity of an existing basket item by 1.
dispose() → void
Discards any resources used by the object. After this is called, the object is not in a usable state and should be discarded (calls to addListener will throw after the object is disposed).
inherited
incrementItem(String upc) → void
Increases the quantity of an existing basket item by 1.
loadUserState() Future<void>
Loads user-specific balances and basket from FirebaseFirestore.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
toString() String
A string representation of this object.
inherited
updateUser(User? user) → void
Updates the internal user reference and triggers state reload.

Operators

operator ==(Object other) bool
The equality operator.
inherited