跳过 x 帧!应用程序可能在其主线程上做了太多工作。这个错误意味着什么以及如何解决这个问题?

2024-01-29

我正在尝试在我的 Flutter 应用程序中使用 firbase 进行身份验证。用户登录并进入“已验证”屏幕后,就会显示此错误。 我正在使用具有简单逻辑的 google_sign_in 插件。

    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 屏幕具有用于登录的基本登录布局...


如果你没有做任何不必要的事情main,你可以忽略它。

跳帧数取决于:

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

  • 执行计算工作(例如在启动时解析 JSON)的 CPU 速度。

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

  • 无论您使用的是应用程序的调试版本还是发布版本。

  • 应用程序启动前需要一些必要数据时的网络连接速度。

  • 无论您使用的是模拟器还是物理设备。

  • 主页中小部件树的大小。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

跳过 x 帧!应用程序可能在其主线程上做了太多工作。这个错误意味着什么以及如何解决这个问题? 的相关文章

随机推荐