I\'m implementing the google sign in method in my project using Firebase Google sign in option, when the add the below line in my code its throwing me the error like:
Simple solution (caused by a type change):
Firebase has recently changed its type 'FirebaseUser' (which is depreciated now) type to 'User'. Try renaming the same in your code and that should be the solution. In my case it worked for most of the same errors.
Best
The method firebaseAuth.signInWithCredential(credential)
returns a value of type AuthResult
, therefore you need to do the following :
AuthResult userDetails = await _firebaseAuth.signInWithCredential(credential);
The other alternative and the better one for your code, is since signInWithCredential
returns AuthResult
and since class AuthResult
contains instance variable user
of type FirebaseUser
, then you can do the following:
FirebaseUser userDetails = (await _firebaseAuth.signInWithCredential(credential)).user;
https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_auth/firebase_auth/lib/src/auth_result.dart#L18