Skip to content

[ Provider Doc ] ChangeNotifier inside update #245

@tperraut

Description

@tperraut

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions