I'm getting an error “Error type 'AuthResult' is not a subtype of type 'FirebaseUser' in type cast” when I'm trying to login or signup

后端 未结 6 1361
执笔经年
执笔经年 2021-01-11 10:00

I\'m making a flutter app for my college project, where I\'m adding a login and signup page and authenticating it via Firebase, and when I click login the debug console says

6条回答
  •  说谎
    说谎 (楼主)
    2021-01-11 10:26

    signInWithEmailAndPassword returns AuthResult and AuthResult class contains instance variable user of type FirebaseUser. So You have to change your code as following way.

    FirebaseUser userDetails = (await FirebaseAuth.instance
              .signInWithEmailAndPassword(Credentialsxxx)).user;
    print('sign in : ${userDetails.uid}');
    

提交回复
热议问题