firebase_auth_demo_flutter
firebase_auth_demo_flutter copied to clipboard
AuthResult can't be assigned to a variable of type 'FirebaseUSer'
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'); } } }