User authentication is a core feature of most mobile applications. Instead of creating another username and password system, you can let users sign in securely with their Google accounts.
In this tutorial, you'll learn how to integrate Google Sign-In into a Flutter application using the official Flutter plugin.
Why Use Google Sign-In?
Google authentication provides several benefits:
- 🔐 Secure OAuth 2.0 authentication
- ⚡ One-tap login experience
- 👤 Access basic profile information
- 📱 Works on Android, iOS, and Web
- 🚀 Quick integration with Firebase Authentication
Prerequisites
Before you begin, make sure you have:
- Flutter SDK installed
- Android Studio or VS Code
- A Google Cloud project
- Android emulator or physical device
Step 1: Add the Dependency
Open your pubspec.yaml file and add the Google Sign-In package.
dependencies:
flutter:
sdk: flutter
google_sign_in: ^7.1.1
Install the package:
flutter pub get
Step 2: Configure Your Android App
- Create a project in the Google Cloud Console.
- Enable the required authentication APIs.
- Configure the OAuth consent screen.
- Create an OAuth client ID for Android.
- Register your application's package name and SHA-1 certificate fingerprint.
These steps allow Google to verify your application's identity during authentication.
Step 3: Import the Package
import 'package:google_sign_in/google_sign_in.dart';
Step 4: Initialize Google Sign-In
Create a Google Sign-In instance.
final GoogleSignIn googleSignIn = GoogleSignIn();
Step 5: Sign In
Call the sign-in method when the user taps the login button.
Future<void> signIn() async {
try {
final user = await googleSignIn.signIn();
if (user != null) {
print(user.displayName);
print(user.email);
}
} catch (e) {
print(e);
}
}
Create a simple login button.
ElevatedButton(
onPressed: signIn,
child: const Text("Sign in with Google"),
)
Step 6: Sign Out
Signing out is just as simple.
Future<void> signOut() async {
await googleSignIn.signOut();
}
Best Practices
- Store authentication tokens securely.
- Handle sign-in failures gracefully.
- Display meaningful loading indicators.
- Keep users signed in between app launches.
- Protect backend APIs using verified ID tokens.
Common Use Cases
Google Sign-In is widely used in:
- Social networking apps
- E-commerce platforms
- Productivity tools
- Learning applications
- Healthcare systems
- Enterprise business apps
Conclusion
Google Sign-In provides a fast and secure authentication experience while reducing friction for new users. With just a few steps, you can integrate Google's OAuth authentication into your Flutter application and give users a familiar login experience.
For production applications, consider combining Google Sign-In with Firebase Authentication to simplify user management, session handling, and backend integration.

SDK Flutter: https://github.com/v-modal/vmodal_sdk_flutter
SDK Android: https://github.com/v-modal/vmodal_sdk_android
Discord: https://discord.gg/K72z28KUx
Tags
flutter dart authentication google firebase mobiledevelopment


Top comments (0)