LoginController

PHOTO EMBED

Tue May 17 2022 09:13:26 GMT+0000 (UTC)

Saved by @Vesko_devv #dart

class LoginController extends GetxController {
  HomeController homeController = Get.find<HomeController>(); //nalazimo HomeController

  @override
  void onInit() {
    super.onInit();
  }

  @override
  void onReady() {
    super.onReady();
  }

  @override
  void onClose() {} 
// login funkcija koja handluje sign in preko google-a i nju pozivamo na klik registracije iz view-a
  void login() async { 
    CustomFullScreenDialog.showDialog();
    GoogleSignInAccount? googleSignInAccount =
        await homeController.googleSign.signIn();
    if (googleSignInAccount == null) {
      CustomFullScreenDialog.cancelDialog();
    } else {
      GoogleSignInAuthentication googleSignInAuthentication =
          await googleSignInAccount.authentication;

      OAuthCredential oAuthCredential = GoogleAuthProvider.credential(
          accessToken: googleSignInAuthentication.accessToken,
          idToken: googleSignInAuthentication.idToken);

      await homeController.firebaseAuth.signInWithCredential(oAuthCredential);
      CustomFullScreenDialog.cancelDialog();
    }
  }
}
content_copyCOPY