0

When I user ref.read(authLoadingProvider.notifier).update((state) => false); like below, flutter returns error like

The getter 'notifier' isn't defined for the type 'FutureProvider<bool?>'. Try importing the library that defines 'notifier', correcting the name to the name of an existing getter, or defining a getter or field named 'notifier'.dartundefined_getter

How can I fix it?

final authLoadingProvider = FutureProvider<bool?>((ref) async => false); 
// declared globally

void currentUserNotNull(User? user, ref) async {
  try {
    var user = FirebaseAuth.instance.currentUser;
    await user?.reload();
    ref.read(authLoadingProvider.notifier).update((state) => false);
  } on FirebaseAuthException catch (e) {
//
  }
}
SugiuraY
  • 311
  • 1
  • 9
  • thanks for your helpful comment ! Reading the doc, I found that `FutureProvider((ref) async => false); ` should not be false but to be FutureObject. So i`FutureProvider((ref) async => SomethingReturnsFutureObjectFunction());` must be correct and `read() or watch() ` detect the changing against the FutureObject. – SugiuraY Nov 09 '22 at 03:42
  • By the way, finally, I just want to display loading Indicator during `await user?.reload();` above my code, and felt `FutureBuilder & loading-snapshot` is not best choice and actually choose FutureProvider. Generally how should I do display loading indicator like this simple case ? – SugiuraY Nov 09 '22 at 03:45
  • FutureProvider is not the right tool for that. please review and understand all the riverpod providers and its differences from the official doc [here](https://riverpod.dev/docs/providers/provider) – john Nov 09 '22 at 03:46
  • if you want help with that, you may want to reconstruct your question, otherwise, because of how your question is constructed, we cant help. – john Nov 09 '22 at 03:51
  • Ok thanks for your advise and I'm gonna do in that way ! – SugiuraY Nov 09 '22 at 04:02

0 Answers0