简体   繁体   English

Firebase UI Auth 处理来自 SignInScreen (Flutter) 隐式导航的注册操作

[英]Firebase UI Auth handle Registration action from implicit navigation from SignInScreen (Flutter)

I have a sign in screen from SignInScreen widget as shown below.我有一个来自SignInScreen小部件的登录屏幕,如下所示。

在此处输入图像描述

However, if a user does not have an account he can register himself by clicking Register on the screen which will lead me to this page:但是,如果用户没有帐户,他可以通过单击屏幕上的“注册”来注册自己,这将引导我进入此页面:

在此处输入图像描述

In the documentation, it is called internal navigation: https://github.com/firebase/flutterfire/blob/master/packages/flutterfire_ui/doc/auth/integrating-your-first-screen.md#disabling-internal-navigation在文档中称为内部导航: https://github.com/firebase/flutterfire/blob/master/packages/flutterfire_ui/doc/auth/integrating-your-first-screen.md#disabling-internal-navigation

The problem I have right now is once a user register, the user did not receive any notification that his account is successfully registered nor the app will automatically redirect him to the email verification or even back to the sign in page.我现在遇到的问题是一旦用户注册,用户没有收到任何他的帐户已成功注册的通知,应用程序也不会自动将他重定向到 email 验证甚至返回登录页面。

How do I handle a registration action from the SignInScreen widget?如何处理来自 SignInScreen 小部件的注册操作?

Below is the code I have for the SignInScreen widget:下面是我为 SignInScreen 小部件编写的代码:

import 'package:firebase_ui_auth/firebase_ui_auth.dart';
import 'package:flutter/material.dart';

class LoginScreen extends StatelessWidget {
  const LoginScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return SignInScreen(
      actions: [
        AuthStateChangeAction<SignedIn>((context, state) {
          if (!state.user!.emailVerified) {
            Navigator.pushNamed(context, '/verify-email');
          } else {
            Navigator.pushReplacementNamed(context, '/profile');
          }
        }),
      ],
    );
  }
}

Solved it by rebuilding my app instead of using hot reload, not sure why it happens though.通过重建我的应用程序而不是使用热重载来解决它,但不确定为什么会发生。

I have experienced similar behavior - actually it was due to bug (AuthStateChangeAction was not triggered after registration) and it was resolved just recently (firebase_ui_auth version 1.1.8 has been just published).我遇到过类似的行为——实际上是由于错误(注册后未触发 AuthStateChangeAction),最近才解决(firebase_ui_auth 版本 1.1.8 刚刚发布)。

It was also possible to work it around by listening to Firebase auth instance directly but now it is no longer necessary.也可以通过直接监听 Firebase 身份验证实例来解决这个问题,但现在不再需要了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM