簡體   English   中英

Flutter:Google 登錄彈出窗口不會出現在 select 帳戶中

[英]Flutter : Google Login pop up wont appear to select an account

我創建了一個登錄屏幕,當用戶按下登錄按鈕時,它會調用事件 LoginButtonOnPressedEvent。 下面是我的 LoginBloc class 中的 onLoginButtonOnPressedEvent function。

 Future<void> _onLoginButtonPressedEvent(
  LoginButtonPressedEvent event, Emitter<LoginScreenState> emit) async {
  GoogleSignIn _googleSignIn = GoogleSignIn(scopes: ['email']);
  GoogleSignInAccount? user = _googleSignIn.currentUser;
  await _googleSignIn.signIn();
  emit(LoginScreenState(user: user));
  print("USER DETAILS  : ${user}");
}

我在我的 LoginScreen 中觸發此事件,如下所示,其中 RippleButton 是我制作的自定義按鈕。

RippleButton(
          onTap: () {
            context.read<LoginScreenBloc>().add(LoginButtonPressedEvent());
          },
        ),

當我點擊按鈕時,不會顯示 select 一個帳戶的彈出窗口,而是屏幕變得有點暗,然后 go 恢復正常。

以下是與調用事件相關的日志

I/ContentCaptureHelper(30073): Setting logging level to OFF
I/flutter (30073): USER DETAILS  : null
I/et_schedule_ap(30073): Background concurrent copying GC freed 2871953(94MB) AllocSpace 
objects, 9(308KB) LOS objects, 87% free, 3450KB/27MB, paused 142us,42us total 104.801ms
W/et_schedule_ap(30073): Reducing the number of considered missed Gc histogram windows 
from 171 to 100

請幫忙!!!

確保你“注銷”因為它第一次出現但如果你還沒有登錄“注銷”之后會出現

GoogleSignIn().signOut();

只需使用這個: -

Future<void> _onLoginButtonPressedEvent() async {
  GoogleSignIn _googleSignIn = GoogleSignIn();
  try {
    GoogleSignInAccount? result = await _googleSignIn.signIn();

    name = result!.displayName;
    email = result.email;
    password = result.id;
     
    print(result);
  } catch (error) {
    print(error);
  }
}

要顯示谷歌登錄彈出窗口,只需調用signOut()

_googleSignIn.signOut();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM