简体   繁体   English

当我打开我的 flutter 应用程序时,它总是显示登录屏幕几秒钟,即使我已经在上次会话中登录。 在那个主页之后?

[英]When I open my flutter app it always shows Sign In screen for few seconds, even if I already signed In in my last session. And after that Main page?

final _navigatorKey = GlobalKey<NavigatorState>();

class MainApp extends StatefulWidget {
  const MainApp({Key? key}) : super(key: key);

  @override
  _MainAppState createState() => _MainAppState();
}

class _MainAppState extends State<MainApp> {

  @override

  Widget build(BuildContext context) {

    return GetMaterialApp(

        localizationsDelegates: context.localizationDelegates,

        supportedLocales: context.supportedLocales,

        locale: context.locale,

        navigatorKey: _navigatorKey,

        color: Colors.white,

        getPages: router.routes,

        initialRoute: SignInPageRoute,

        routingCallback: (routing) {

          final _navigationService = locator<NavigationService>();

          final _authService = locator<AuthService>();

          if (routing!.current == SignInPageRoute) {

            WidgetsBinding.instance!.addPostFrameCallback(
              (_) {
                bool isLoggedIn = _authService.isLoggedIn();
                if (isLoggedIn) {
                  _navigationService.offAllTo(MainPageRoute);
                } else {
                  return;
                }
              },
            );
          }
        });
  }
}

试试这个

bool isLoggedIn = await _authService.isLoggedIn();

暂无
暂无

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

相关问题 Android:当我打开应用程序时,它会显示一个白色屏幕几秒钟 - Android : When I open the app it shows a white screen for a few seconds Google登录,当我关闭我的应用程序时,它将再次显示Google登录页面 - Google sign in,when i close my app it again shows Google Sign in page 当我运行我的应用程序时,android 仿真器总是显示空白黑屏 - android emultater always shows a blank black screen when i run my app 我的android应用显示了一个视频,并且必须一直运行,但是几个小时后我的应用停止了 - My android app shows a video and must be always running, but after few hours my app is stopped 运行我的颤振应用程序时显示白色空白屏幕 - White blank screen is displayed when I run my flutter app 生成登录APK后,我打开Android Studio更新我的应用程序(我对这2个文件的处理) - I Open Android Studio For Update My App After Generate Sign APK (What I do with these 2 files) 几秒钟后,我使用 Future.delayed() 切换到新屏幕,但它一遍又一遍地跳转到该页面 - I use Future.delayed() to switch to a new screen after a few seconds but it jumps to that page over and over again 使用 firebase google 登录后,如何在 Flutter 应用程序中保存或保留要在我的设置页面中使用的数据 - How to save or keep data to be used in my settings page after sign in using firebase google sign in, in flutter app 我的信标在didRangeBeaconsInRegion上的几秒钟后消失了,但是我靠近我的信标 - My beacon disappears after few seconds on didRangeBeaconsInRegion but i am near to my beacon 当我打开它时,Android Webview 应用程序显示黑屏 - Android Webview app shows black screen when i open it
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM