googleLogin method
Google login it will return usercredential if successful, else null
Implementation
Future<UserCredential?> googleLogin() async {
final GoogleSignIn googleSignIn = GoogleSignIn();
final GoogleSignInAccount? googleSignInAccount =
await googleSignIn.signIn();
if (googleSignInAccount != null) {
final GoogleSignInAuthentication googleSignInAuthentication =
await googleSignInAccount.authentication;
final AuthCredential authCredential = GoogleAuthProvider.credential(
idToken: googleSignInAuthentication.idToken,
accessToken: googleSignInAuthentication.accessToken);
// Getting users credential
UserCredential userCredential =
await auth.signInWithCredential(authCredential);
return userCredential;
} else {
return null;
}
}