auth_service.dart (638B)
1 import 'package:firebase_auth/firebase_auth.dart'; 2 import 'package:google_sign_in/google_sign_in.dart'; 3 4 class AuthService { 5 // Google Sign In 6 signInWithGoogle() async { 7 final GoogleSignInAccount? gUser = await GoogleSignIn().signIn(); 8 9 // Obtain auth details from request 10 final GoogleSignInAuthentication gAuth = await gUser!.authentication; 11 12 // Create a new credential for user 13 final credential = GoogleAuthProvider.credential( 14 accessToken: gAuth.accessToken, 15 idToken: gAuth.idToken, 16 ); 17 18 // Finally, lets sign in 19 return await FirebaseAuth.instance.signInWithCredential(credential); 20 } 21 }