Flutter注销导致应用程序崩溃

igsr9ssn  于 2022-12-19  发布在  Flutter
关注(0)|答案(1)|浏览(124)

在我的菜单中,我有一个注销调用。它不像我想要的那样工作。注销是活动的,因为当我启动应用程序时,我必须再次登录。但应用程序不显示登录屏幕。应用程序崩溃,我失去了与设备的连接。
我做了一些研究,但没有找到解决办法。请,你能帮忙吗?谢谢。

ListTile(
                    dense: true,
                    leading: ConstrainedBox(
                      constraints: const BoxConstraints(
                        minWidth: iconSize,
                        minHeight: iconSize,
                        maxWidth: iconSize,
                        maxHeight: iconSize,
                      ), //child: Image.asset('assets/icons/someday.png', fit: BoxFit.cover),
                    ),
                    title: Transform(transform: Matrix4.translationValues(
                        distanceEntreTextAndIcon, alignementTextWithIcon, 0.0),
                      child: const Text('Log Out'),
                    ),
                    onTap: ()  {
                      try {

                        FirebaseAuth.instance.signOut().then((value) => Navigator.pushAndRemoveUntil(
                            context, MaterialPageRoute(builder: (context) => LoginSignupScreen()), (
                            route) => false));

                      } catch (e) {
                        print(e.toString());
                        return;
                      }
                    }
                ),
t9aqgxwy

t9aqgxwy1#

试试这个

///you don't need .of(context) not unless you are in a stateless widget like showDialog
onTap:(){
 Navigator.of(context).pop();
FirebaseAuth.instance.signOut().then((value) => Navigator.pushAndRemoveUntil(
        context, MaterialPageRoute(builder: (context) => LoginSignupScreen()), (
        route) => false));
}

相关问题