fix
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:get/get.dart';
|
import 'package:get/get.dart';
|
||||||
import 'package:google_sign_in/google_sign_in.dart';
|
|
||||||
import 'package:intl/date_symbol_data_local.dart';
|
import 'package:intl/date_symbol_data_local.dart';
|
||||||
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
import 'package:prosappco/src/authentication/authentication_repository.dart';
|
||||||
import 'package:prosappco/src/screens/calendar.dart';
|
import 'package:prosappco/src/screens/calendar.dart';
|
||||||
@@ -25,10 +24,6 @@ import 'package:prosappco/src/screens/solicitudes.dart';
|
|||||||
import 'firebase_options.dart';
|
import 'firebase_options.dart';
|
||||||
|
|
||||||
void main() async {
|
void main() async {
|
||||||
GoogleSignIn googleSignIn = GoogleSignIn(
|
|
||||||
clientId:
|
|
||||||
'245204384533-glsp6hf14uqvtn52jrn1f9ds3k3too8v.apps.googleusercontent.com');
|
|
||||||
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
await initializeDateFormatting('es_MX', null);
|
await initializeDateFormatting('es_MX', null);
|
||||||
|
|||||||
@@ -14,9 +14,7 @@ class AuthenticationRepository extends GetxController {
|
|||||||
final _auth = FirebaseAuth.instance;
|
final _auth = FirebaseAuth.instance;
|
||||||
late final Rx<User?> firebaseUser;
|
late final Rx<User?> firebaseUser;
|
||||||
final firebase = FirebaseFirestore.instance;
|
final firebase = FirebaseFirestore.instance;
|
||||||
final GoogleSignIn googleSignIn = GoogleSignIn(
|
final GoogleSignIn googleSignIn = GoogleSignIn();
|
||||||
clientId:
|
|
||||||
'245204384533-glsp6hf14uqvtn52jrn1f9ds3k3too8v.apps.googleusercontent.com');
|
|
||||||
// final _userRef = firebase
|
// final _userRef = firebase
|
||||||
var verificationId = ''.obs;
|
var verificationId = ''.obs;
|
||||||
|
|
||||||
@@ -128,15 +126,29 @@ class AuthenticationRepository extends GetxController {
|
|||||||
Future<void> signInWithGoogle() async {
|
Future<void> signInWithGoogle() async {
|
||||||
try {
|
try {
|
||||||
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
|
final GoogleSignInAccount? googleUser = await GoogleSignIn().signIn();
|
||||||
final GoogleSignInAuthentication googleAuth =
|
|
||||||
await googleUser!.authentication;
|
if (googleUser != null) {
|
||||||
final credential = GoogleAuthProvider.credential(
|
final GoogleSignInAuthentication googleAuth =
|
||||||
accessToken: googleAuth.accessToken,
|
await googleUser.authentication;
|
||||||
idToken: googleAuth.idToken,
|
final OAuthCredential credential = GoogleAuthProvider.credential(
|
||||||
);
|
accessToken: googleAuth.accessToken,
|
||||||
await FirebaseAuth.instance.signInWithCredential(credential);
|
idToken: googleAuth.idToken,
|
||||||
|
);
|
||||||
|
|
||||||
|
await FirebaseAuth.instance.signInWithCredential(credential);
|
||||||
|
|
||||||
|
// Continúa con el flujo de la aplicación después del inicio de sesión exitoso
|
||||||
|
// Por ejemplo, redirecciona a la siguiente pantalla
|
||||||
|
firebaseUser.value != null
|
||||||
|
? Get.offAll(ServiceScreen())
|
||||||
|
: Get.to(LoginScreen());
|
||||||
|
} else {
|
||||||
|
// El usuario canceló el inicio de sesión con Google
|
||||||
|
// Puedes manejarlo según tus necesidades
|
||||||
|
print('Error');
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print('Error - ${e}');
|
print('Error - $e');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user