updateUser method
- User? user
Updates the internal user reference and triggers state reload.
This is called by the ChangeNotifierProxyProvider in main.dart
whenever the FirebaseAuth state changes. If user is null,
all data is cleared. Otherwise, loadUserState is called in the
background to fetch persisted data.
Side effects:
- Clears balances and basket if logged out
- Calls notifyListeners to rebuild widgets
- Initiates loadUserState for logged-in users
Implementation
void updateUser(User? user) {
_uid = user?.uid;
if (_uid == null) {
_clear();
notifyListeners();
return;
}
_balancesLoaded = false;
// fire-and-forget load; UI can check balancesLoaded
// ignore: discarded_futures
loadUserState();
notifyListeners();
}