How to scope a ChangeNotifier to some routes using Provider?

Posted by Jennifer | Updated on

If you want to scope a ChangeNotifier to some routes using Provider? To do so, the easiest solution is to have one provider per route, such that instead of:

You have:

It is, on the other hand, not possible to have your model “automatically disposed”. provider is not able in such a situation to know that it is safe to dispose of the object.


If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.

Related Questions & Answers