import 'package:SEFER/constant/box_name.dart'; import 'package:SEFER/main.dart'; import 'package:get/get.dart'; import 'package:google_sign_in/google_sign_in.dart'; class GoogleSignInHelper { static final GoogleSignIn _googleSignIn = GoogleSignIn( scopes: [ 'email', 'profile', ], ); static Future signIn() async { try { final GoogleSignInAccount? googleUser = await _googleSignIn.signIn(); getDriverInfo(); // Get.to(() => AiPage()); return googleUser; } catch (error) { print('Google Sign-In error: $error'); return null; } } static Future signOut() async { try { await _googleSignIn.signOut(); } catch (error) { print('Google Sign-Out error: $error'); } } static GoogleSignInAccount? getCurrentUser() { return _googleSignIn.currentUser; } static String? getDriverInfo() { final GoogleSignInAccount? user = _googleSignIn.currentUser; box.write(BoxName.driverID, user!.id); box.write(BoxName.emailDriver, user.email); box.write(BoxName.nameDriver, user.displayName); box.write(BoxName.driverPhotoUrl, user.photoUrl); print('emailDriver =${box.read(BoxName.emailDriver)}'); return user.displayName; } }