小编Aji*_*tta的帖子

Flutter:当互联网改变其状态时,考虑取消“处置”期间的任何活动工作

当互联网关闭时,我收到以下消息。

E/flutter (26162): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: This widget has been unmounted, so the State no longer has a context (and should be considered defunct).
E/flutter (26162): Consider canceling any active work during "dispose" or using the "mounted" getter to determine if the State is still active.
Run Code Online (Sandbox Code Playgroud)

它显示了我的代码这一部分的消息。

@override
  void initState() {
    super.initState();
    try {
      InternetAddress.lookup('google.com').then((result) {
        if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
          // internet conn available

          Navigator.of(context).pushReplacement(MaterialPageRoute(
            builder: (context) =>
                (Constants.prefsMobile.getString("mobile") == null
                    ? Login()
                    // : SignupPayoutPassword(signupdata: [])),
                    : Home(signindata: …
Run Code Online (Sandbox Code Playgroud)

dispose flutter

3
推荐指数
1
解决办法
2万
查看次数

标签 统计

dispose ×1

flutter ×1