I have a ChangeNotifier Subclass that I am sharing between a number of screens like this:
final value = MyChangeNotifier();
MaterialApp(
routes: {
'/list': (_) => ChangeNotifierProvider.value(value: value, child: ListScreen()),
'/detials': (_) => ChangeNotifierProvider.value(value: value, child: DetailsScreen()),
'/other_screen': (_) => OtherScreen(),
}
)
I want to dispose my ChangeNotifier once the user has left the last screen in this flow, and I want to create a new Instance of the shared ChangeNotifier once user re-enters the given flow.
Is it possible to do with Provider?