2

When you click on the button, a window appears with a choice of Google account, I choose and instead of switching to a new page, I get an error. Error in the screenshot

My code:

import 'package:google_sign_in/google_sign_in.dart';

GoogleSignIn googleAuth = GoogleSignIn();
final FirebaseAuth _fAuth = FirebaseAuth.instance;
final GoogleSignIn _gSignIn = GoogleSignIn();

 Future<FirebaseUser> _signInGoogle() async {
    GoogleSignInAccount googleSignInAccount = await _gSignIn.signIn();
    GoogleSignInAuthentication authentication = await googleSignInAccount.authentication;

    var signInWithGoogle = signInWithGoogle;
    FirebaseUser user = await _fAuth.signInWithGoogle(
      idToken: authentication.idToken,
      accessToken: authentication.accessToken
    );
    return user;
  }


onPressed:() async {
  await _signInGoogle();                            
 Navigator.of(context).pushReplacementNamed('/home_screen');
} 

enter image description here

enter image description here

enter image description here

Max
  • 1,141
  • 2
  • 11
  • 34

1 Answers1

1

Did you add your SHA fingerprint?

Please check my answer for a similar question for how to do it: https://stackoverflow.com/a/54479992/679553

Gazihan Alankus
  • 11,256
  • 7
  • 46
  • 57