Flutter: How to listen to the FirebaseUser is Email verified boolean?

后端 未结 8 728
走了就别回头了
走了就别回头了 2021-01-01 20:38

My Idea: I want to use the Firebase Auth Plugin in Flutter to register the users. But before they can access the App, they have to verify their Email addres

8条回答
  •  遥遥无期
    2021-01-01 21:12

    In order for the app to recognise if the user has verified their email you can achieve this with a simple user.reload.

    In order to test it yourself implement a button with onPressed code:

     FlatButton(
        child: Text("check"),
        textColor: Colors.white,
        onPressed: () async {
        try {
          FirebaseUser user = await _firebaseAuth.currentUser();
          await user.reload();
          user = await _firebaseAuth.currentUser();
            print( user.isEmailVerified); 
            
    
         } catch (e) {
          return e.message;
        }
    }),
    

提交回复
热议问题