You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello community! This statement from the documentation regarding ChangeNotifierProxyProvider seems somewhat questionable to me:
DON'T create the ChangeNotifier inside update directly ... Instead reuse the previous instance
There are cases when updating an existing notifier with new data is simply meaningless. A good example is authentication. If the first ChangeNotifierProvider gives User? value, and then the dependent provider creates either AnonInfo or UserInfo ChangeNotifier's.
I assume it's safe to do it like update: (context, userProv, _) => user.value == null ? AnonInfo() : UserInfo() but it contradicts the documentation.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello community! This statement from the documentation regarding
ChangeNotifierProxyProvider
seems somewhat questionable to me:There are cases when updating an existing notifier with new data is simply meaningless. A good example is authentication. If the first ChangeNotifierProvider gives
User?
value, and then the dependent provider creates eitherAnonInfo
orUserInfo
ChangeNotifier's.I assume it's safe to do it like
update: (context, userProv, _) => user.value == null ? AnonInfo() : UserInfo()
but it contradicts the documentation.What is the right way to solve this?
Beta Was this translation helpful? Give feedback.
All reactions