bizz84 / bizz84/firebase_auth_demo_flutter

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

Open
#69 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
674
Forks
172
PR merge metrics
No merged PRs in 30d

Description

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');
}
}
}

Contributor guide

No contributing guide indexed for this repository

Research direction

Start from the validateAndSubmit() snippet and the signInWithEmailAndPassword call shown in the issue. Compare the returned AuthResult with the FirebaseUser assignment and confirm the demonstrated user access resolves the type error; done when the example compiles and prints the signed-in user's uid.

Written by the indexing model from the issue text.

Assessment

Tech stack
dart, flutter
Domain
authentication, mobile
Issue type
Bug
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.