-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Closed
Description
samples/provider_shopper/lib/main.dart
Line 32 in b7ec38a
| CartModel(catalog, previousCart), |
I was implementing a little test project with official Flutter doc about state management and looking at your awesome example. Thank you a lot btw.
While reading the ChangeNotifierProxyProvider documentation, I found this :
/// - **DON'T** create the [ChangeNotifier] inside `update` directly.
///
/// This will cause your state to be lost when one of the values used updates.
/// It will also cause uncesserary overhead because it will dispose the
/// previous notifier, then subscribes to the new one.
///
/// Instead reuse the previous instance, and update some properties or call
/// some methods.
So, if creating a new ChangeNotifier inside update callback is a bad practice as the doc says, you could change a bit the sample behavior here or add a little comment.