'Update Key value of Provider package?

I have a page that goes after the main page which has its own ChangeNotifierProvider. The key given in the main method of the first page is a static String stored in the ChangeNotifierProvider class that I use in the second page.

When I update this String key before Navigator.pop() into the first page, coming back to the second page still has the same old values.

I heard changing the key lets you refresh the Provider stored values, so how do I do it? Or else how can I make sure everything is reset once I click a certain button to go back?



Solution 1:[1]

I had thought that there was such a function like this in Provider but no, would've been useful.

For now my solution was to create constructor methods that set everything back, so I can call them before I navigate.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jiehfeng