0

I'm really confusing that what is ref.watch(authUserFutureProvider);//here below detecting.

When final user = FirebaseAuth.instance.currentUser; // here set appropriately, ref.watch(authUserFutureProvider);//here detect the changes in the provider.

However, if I intentionally make user == null with FirebaseAuth.instance.signOut(); and execute authEmail(ref) with ref.refresh(authEmailFutureProvider);, ref.watch(authUserFutureProvider);//here do not detect any changes and nothing has been done in //do something when ref.watch() detected changes

I wonder why this happen and what kind of changes in FutureProvider should be detected.

Thanks for your helpful advises.

Future<bool> authEmail(ref) async {
 try {
    final user = FirebaseAuth.instance.currentUser; // here
    await user?.sendEmailVerification();
    return true; 
 }on FirebaseAuthException catch (e){
   //do somthing
   return false
 }
//Declared Globally
final authEmailFutureProvider = FutureProvider<bool>((ref) async => authEmail(ref),);

class Test extends ConsumerWidget {

final authC = ref.watch(authUserFutureProvider);//here
      authC.when(
      //do something when ref.watch() detected changes
      )
}
return Scaffold(
        body: Padding(
        //omit
         Align(
                  child: SizedBox(
                    width: double.infinity,
                    child: TextButton(
                      onPressed: () {
                        ref.refresh(authEmailFutureProvider);
                      }
          )
        //omit
        )
SugiuraY
  • 311
  • 1
  • 9

0 Answers0