I have implemented the following login method and I am trying to use the isNewUser
function to push a new screen:
Future<void> googleLogin() async {
try {
final googleUser = await GoogleSignIn().signIn();
if (googleUser == null) return;
final googleAuth = await googleUser.authentication;
final authCredential = GoogleAuthProvider.credential(
accessToken: googleAuth.accessToken,
idToken: googleAuth.idToken,
);
UserCredential userCredential =
await FirebaseAuth.instance.signInWithCredential(authCredential);
if (userCredential.additionalUserInfo!.isNewUser) {
return const SignUpNewUser();
}
} on FirebaseAuthException catch (e) {
AlertDialog(
title: const Text("Error"),
content: Text('Failed to sign in with Google: ${e.message}'),
);
}
}
I get the following error:
A value of type 'SignUpNewUser' can't be returned from the method 'googleLogin' because it has a return type of 'Future<void>'.
I'm pretty sure that I placed it in the correct spot to implement the function, but I have no idea how to do it in a Future.