Adding Google authentication to your Flutter app is one of the easiest ways to provide a fast, secure, and user-friendly login experience. With Firebase Authentication and Google Sign-In, you can integrate login functionality in just a few steps.

In this guide, you’ll learn how to implement Google Sign-In in Flutter step by step.


Why Use Google Sign-In in Flutter?

  • ✅ Fast login (no signup form)
  • ✅ Secure authentication
  • ✅ Trusted by users
  • ✅ Easy integration with Firebase

Prerequisites

Before starting, make sure you have:

  • Flutter installed
  • Firebase project created
  • Android Studio setup
  • SHA-1 key generated

Step 1: Create Firebase Project

  1. Go to Firebase Console
  2. Click Add Project
  3. Enter project name and create

Step 2: Add Android App

  • Add your package name
  • Add SHA-1 key
  • Download google-services.json
  • Place it in:
android/app/

Step 3: Enable Google Authentication

  • Go to Firebase Console
  • Click Authentication → Sign-in Method
  • Enable Google

Step 4: Add Dependencies

dependencies:
firebase_core: latest_version
firebase_auth: latest_version
google_sign_in: latest_version

Run:

flutter pub get

Step 5: Initialize Firebase

await Firebase.initializeApp();

Step 6: Google Sign-In Code

Future<User?> signInWithGoogle() async {
final GoogleSignInAccount? user = await GoogleSignIn().signIn(); if (user == null) return null; final GoogleSignInAuthentication auth = await user.authentication; final credential = GoogleAuthProvider.credential(
accessToken: auth.accessToken,
idToken: auth.idToken,
); final result =
await FirebaseAuth.instance.signInWithCredential(credential); return result.user;
}

Step 7: Add Login Button

ElevatedButton(
onPressed: () async {
final user = await signInWithGoogle();
print(user?.email);
},
child: Text("Sign in with Google"),
)

Step 8: Logout

await GoogleSignIn().signOut();
await FirebaseAuth.instance.signOut();

Common Errors & Fixes

❌ API Exception (10)

👉 Check SHA-1 and package name

❌ Login Cancelled

👉 Handle null user properly

❌ Firebase Not Initialized

👉 Call Firebase.initializeApp()


Pro Tips

  • Use StreamBuilder for auth state
  • Store user data in Firestore
  • Add loading indicator
  • Use clean architecture

Conclusion

Implementing Google Login in Flutter using Firebase is simple and powerful. It improves user experience and boosts app engagement.

Start integrating today and make your app more professional 🚀

Categories: Flutter

1 Comment

  • Flutter CI/CD: Complete Guide with Architecture Diagram (2026) - Dheeraj Hitech · March 19, 2026 at 5:10 pm

    […] Integration and Continuous Deployment (CI/CD) has become essential for modern Flutter development. It helps automate testing, building, […]

    Leave a Reply

    Avatar placeholder

    Your email address will not be published. Required fields are marked *