supabase_auth_package 0.0.2
supabase_auth_package: ^0.0.2 copied to clipboard
A Flutter package for Supabase authentication, supporting email/password and Google Sign-In.
π± 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
);
}