Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What is difference between AutoDisposeChangeNotifierProvider vs ChangeNotifierProvider #1

Closed
dyardy opened this issue Jun 5, 2022 · 1 comment
Labels
question Further information is requested

Comments

@dyardy
Copy link

dyardy commented Jun 5, 2022

I was not familiar with AutoDisposeChangeNotifierProvider and am finding it bit challenging to find the difference. Both seem to work

// final AutoDisposeChangeNotifierProvider<ThemeModeState> themeProvider =
//     ChangeNotifierProvider.autoDispose(
//         (AutoDisposeChangeNotifierProviderRef<ThemeModeState> ref) {
//   return ThemeModeState();
// });

final themeProvider = ChangeNotifierProvider<ThemeModeState>((ref){
  return ThemeModeState();
});

@anfeichtinger anfeichtinger added the question Further information is requested label Jun 5, 2022
@anfeichtinger
Copy link
Owner

Their usage is pretty much the same. From the documentation I got, that the AutoDisposeChangeNotifierProvider will destroy their state when no-longer listened to, while the ChangeNotifierProvider will keep it's last state. For that Provider.autoDispose is used. More info can be found in the Riverpod Documentation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants