跳过x帧!该应用程序可能在其主线程上做过多的工作.此错误表示什么意思,以及如何解决? [英] Skipped x frames! The application may be doing too much work on its main thread. What does this error signify and how to solve this?

查看:85
本文介绍了跳过x帧!该应用程序可能在其主线程上做过多的工作.此错误表示什么意思,以及如何解决?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在Flutter应用中使用firbase进行身份验证.用户登录并进入身份验证"屏幕后,将显示此错误. 我正在使用具有简单逻辑的google_signin插件.

I'm trying to do authentication with firbase in my Flutter app. Once the user is signed in and goes to the Authenticted screen, this error shows up. I'm using google_signin plugin with simple logics.

    bool isAuth = false;

  //check if the user is signed in
  @override
  void initState() {
    super.initState();
    googleSignIn.onCurrentUserChanged.listen((account) {
      handleSignIn(account);
    }, onError: (err) {
      print("Error signing in: $err");
    });
    //maintain the signin
    googleSignIn.signInSilently(suppressErrors: false).then((account) {
      handleSignIn(account);
    }).catchError((err) {
      print("Error signing in: $err");
    });
  }

  handleSignIn(GoogleSignInAccount account) {
    if (account != null) {
      print('User signed in!: $account');
      setState(() {
        isAuth = true;
      });
    } else {
      setState(() {
        isAuth = false;
      });
    }
  }

  //sign in using google
  login() {
    googleSignIn.signIn();
  }

  logout() {
    googleSignIn.signOut();
  }

  Widget buildAuthScreen() {
    return Center(
      child: RaisedButton(
        child: Text("LogOut"),
        onPressed: logout(),
      ),
    );
  }

然后,unauth屏幕具有用于登录的基本登录布局...

then the unauth screen has basic login layout for signining in...

推荐答案

如果您没有在main中执行任何不必要的操作,则可以忽略它.

If you are not doing anything unnecessary in your main, you can just ignore it.

跳过的帧数取决于:

  • 启动时需要初始化的静态变量和顶级变量的数量.

  • The number of static and top-level variables that need initiation on startup.

将要执行计算工作的CPU的速度,例如在启动时解析JSON.

Speed of the CPU that will be doing computational work, like parsing JSONs at startup.

用于启动数据库和共享首选项的设备存储的速度.

Speed of the device storage for initiating databases and shared preferences.

您是否正在使用应用的调试版本或发布版本.

Whether you're using a debug or release build of your app.

在应用启动之前需要一些必要数据的情况下,网络连接的速度.

The speed of the network connection in case of needing some necessary data before the app starts up.

您使用的是仿真器还是物理设备.

Whether you're using an emulator or a physical device.

主页中小部件树的大小.

The size of the widget tree in your home page.

这篇关于跳过x帧!该应用程序可能在其主线程上做过多的工作.此错误表示什么意思,以及如何解决?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆