📱 Supabase Authentication Demo (Flutter)
This Flutter project demonstrates the basic usage of Supabase Authentication with:
- ✅ Email/Password Sign Up
- ✅ Email/Password Login
- ✅ Email Verification Check
- ✅ Google Sign-In
- ✅ Phone Number OTP Verification
🚀 Features
- Sign in with Google
- Sign up & Sign in with Email/Password
- Check if Email is Verified
- Verify Phone Number OTP
- Option to check for Phone Verification after Login
🛠 Setup Guide
1️⃣ Prerequisites
- Flutter SDK installed
- Supabase project created — https://app.supabase.com/
- Google Cloud Project with OAuth Consent configured — https://console.cloud.google.com/
2️⃣ Configure Supabase
Add the package to your pubspec.yaml file:
dependencies:
flutter:
sdk: flutter
supabase_flutter: <latest version>
google_sign_in: <latest version>
supabase_auth_package: <latest version>
✅ In main.dart:
Supabase.initialize(
url: 'your-supabase-url',
anonKey: 'your-anon-key',
);
✅ Email/Password Sign-In Example
await _authRepo.signInUsingEmailPassword(
email: 'user@example.com',
password: 'your-password',
checkPhoneVerification: false,
);
✅ Google Sign-In Example
Future<void> _signInWithGoogle() async {
final googleService = GoogleAuthService(
supabaseClient: Supabase.instance.client,
googleSignIn: GoogleSignIn(
serverClientId: 'your-google-server-client-id', // Replace with your client ID
),
);
await googleService.signIn();
}
✅ Email/Password Sign-Up Example
Future<void> _signUpWithEmail() async {
await _authRepo.signUpUsingEmailPassword(
email: 'user@example.com', // Replace with user email
password: 'your-password', // Replace with user password
);
}
✅ Check Email Verification Example
Future<void> _checkEmailVerification() async {
await _authRepo.checkEmailVerify(
email: 'user@example.com', // Replace with user email
password: 'your-password', // Replace with user password
);
}
✅ Verify Phone OTP Example
Future<void> _checkOtpVerification() async {
await _authRepo.verifyOTP(
countryCode: '91', // Country Code (e.g., India = 91)
phoneNumber: '9876543210', // User phone number without country code
otp: '123456', // OTP received by user
);
}
Libraries
- supabase_auth_pack
- A Calculator.