Reputation: 73
I am working on a chat app and want to allow users to register using email and password. For some reason, I am getting the error below - is this implementation incorrect? I am not sure why i am getting "Error: A value of type 'AuthResult' can't be assigned to a variable of type 'FirebaseUser'."
class _RegistrationState extends State<Registration> {
String email;
String password;
final FirebaseAuth _auth = FirebaseAuth.instance;
Future<void> registerUser() async {
FirebaseUser user = await _auth.createUserWithEmailAndPassword(
email: email,
password: password,
);
Upvotes: 0
Views: 101
Reputation: 80944
createUserWithEmailAndPassword
returns Future<AuthResult>
, you can check here:
To solve the issue do the following:
final FirebaseUser user = (await _auth.createUserWithEmailAndPassword(
email: email,
password: password,
))
.user;
add the field user
which is of type FirebaseUser
Upvotes: 1