firebase_auth_demo_flutter icon indicating copy to clipboard operation
firebase_auth_demo_flutter copied to clipboard

AuthResult can't be assigned to a variable of type 'FirebaseUSer'

Open Mauratay opened this issue 4 years ago • 0 comments

void validateAndSubmit() async { if (validateAndSave()) { try{ FirebaseUser user = await FirebaseAuth.instance .signInWithEmailAndPassword(email: _email, password: _password); print('Signed in: ${user.uid}'); } catch(e){ print('Error: ${e}') } } }

Error: A value of type 'AuthResult' can't be assigned to a variable of type 'FirebaseUser'. FirebaseUser user = await FirebaseAuth.instance (firebase_auth-0.16.1)

Solution:

void validateAndSubmit() async { if (validateAndSave()) { try { FirebaseUser user = (await FirebaseAuth.instance .signInWithEmailAndPassword(email: _email, password: _password)) .user; print('Signed in: ${user.uid}'); } catch (e) { print('Error: $e'); } } }

Mauratay avatar Aug 06 '20 21:08 Mauratay