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 1501
执笔经年
执笔经年 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:18

    I had same error and changed code to:

    FirebaseUser user = (await _firebaseAuth.signInWithEmailAndPassword(email: email, password: password)).user;
    

    The app works as expected on a real device, without an error in the console, but Visual Studio Code shows red underline at the end below user and outputs an error:

    The getter 'user' isn't defined for the class 'FirebaseUser'. Try importing the library that defines 'user', correcting the name to the name of an existing getter, or defining a getter or field named 'user'.

    [Solution] Restart VS Code. VS Code uses the old library until restart.

提交回复
热议问题