11/10/1
This commit is contained in:
@@ -90,15 +90,28 @@ class GoogleSignInHelper {
|
||||
final GoogleSignInAccount? googleUser = await _googleSignIn.signIn();
|
||||
|
||||
if (googleUser != null) {
|
||||
// Handle sign-up and store user information
|
||||
await _handleSignUp(googleUser);
|
||||
|
||||
// Add detailed debug print statements
|
||||
// Retrieve driverID and emailDriver with added validation
|
||||
final driverID = box.read(BoxName.driverID)?.toString() ?? 'Unknown ID';
|
||||
final emailDriver =
|
||||
box.read(BoxName.emailDriver)?.toString() ?? 'Unknown Email';
|
||||
|
||||
// Debug print statements
|
||||
print('Driver ID: $driverID');
|
||||
print('Driver Email: $emailDriver');
|
||||
|
||||
// Check if driverID is a valid numeric string
|
||||
// if (driverID != 'Unknown ID' && int.tryParse(driverID) != null) {
|
||||
await Get.find<LoginDriverController>()
|
||||
.loginUsingCredentials(driverID, emailDriver);
|
||||
// }
|
||||
// else {
|
||||
// print('Invalid driverID format: $driverID');
|
||||
// Get.snackbar('Login Error', 'Invalid driver ID format.',
|
||||
// backgroundColor: AppColor.redColor);
|
||||
// }
|
||||
}
|
||||
|
||||
return googleUser;
|
||||
@@ -110,6 +123,13 @@ class GoogleSignInHelper {
|
||||
}
|
||||
}
|
||||
|
||||
static Future<void> _handleSignUp(GoogleSignInAccount user) async {
|
||||
// Store driver information
|
||||
box.write(BoxName.driverID,
|
||||
user.id ?? 'Unknown ID'); // Ensure there's a fallback value
|
||||
box.write(BoxName.emailDriver, user.email ?? 'Unknown Email');
|
||||
}
|
||||
|
||||
// Method to handle Google Sign-Out
|
||||
static Future<void> signOut() async {
|
||||
try {
|
||||
@@ -145,16 +165,4 @@ class GoogleSignInHelper {
|
||||
static GoogleSignInAccount? getCurrentUser() {
|
||||
return _googleSignIn.currentUser;
|
||||
}
|
||||
|
||||
// Method to handle sign-up process
|
||||
static Future<void> _handleSignUp(GoogleSignInAccount user) async {
|
||||
// Store driver information
|
||||
box.write(BoxName.driverID, user.id);
|
||||
box.write(BoxName.emailDriver, user.email);
|
||||
// box.write(BoxName.nameDriver, user.displayName);
|
||||
// box.write(BoxName.driverPhotoUrl, user.photoUrl);
|
||||
|
||||
// Perform any additional sign-up tasks or API calls here
|
||||
// For example, you can send the user data to your server for registration
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user