简体   繁体   English

Flutter 显示旧错误

[英]Flutter showing old errors

I was writing a flutter application but when I want to test it on the Android Emulator (Ctrl+F5) I get an unfixable error.我正在编写一个 flutter 应用程序,但是当我想在 Android Emulator (Ctrl+F5) 上测试它时,我遇到了一个无法修复的错误。 This is part of it:这是其中的一部分:

I/flutter (13782): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (13782): The following assertion was thrown during performResize():
I/flutter (13782): Vertical viewport was given unbounded height.
I/flutter (13782): Viewports expand in the scrolling direction to fill their container. In this case, a vertical
I/flutter (13782): viewport was given an unlimited amount of vertical space in which to expand. This situation
I/flutter (13782): typically happens when a scrollable widget is nested inside another scrollable widget.
I/flutter (13782): If this widget is always nested in a scrollable widget there is no need to use a viewport because
I/flutter (13782): there will always be enough vertical space for the children. In this case, consider using a Column
I/flutter (13782): instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size
I/flutter (13782): the height of the viewport to the sum of the heights of its children.
I/flutter (13782):
I/flutter (13782): The relevant error-causing widget was:
I/flutter (13782):   ListView  (file:///D:/flutterProjects/test_project/test_project/lib/screens/all_obj_screen.dart:19:18)

As you can see in the last line it says the cause of the error is a ListView in D:/flutterProjects/test_project/test_project/lib/screens/all_obj_screen.dart .正如您在最后一行中看到的,它说错误的原因是D:/flutterProjects/test_project/test_project/lib/screens/all_obj_screen.dartListView The problem is that I have no ListView in that file (at the moment, but I had it previously) and that path does not even exist anymore!问题是我在那个文件中没有ListView (目前,但我以前有它)而且那个路径甚至不存在了!

If it can help, this is the all_obj_screen.dart file:如果有帮助,这是all_obj_screen.dart文件:

class AllObjScreen extends StatefulWidget {
  @override
  _AllObjScreenState createState() => _AllObjScreenState();
}

class _AllObjScreenState extends State<AllObjScreen> {
  @override
  Widget build(BuildContext context) {
    final objects = Provider.of<Objs>(context);

    return Center(
      child: Text(
        '${objects.items.length}',
        style: TextStyle(
          color: Colors.white,
          fontSize: 25,
        ),
      ),
    );
  }
}

So I am thinking that the problem is not my code but something about Visual Studio Code.所以我认为问题不在于我的代码,而在于 Visual Studio Code。 How to fix this problem?如何解决这个问题?

EDIT: I have tried to run the app on both Visual Studio Code and on Android Studio but the problem is the same.编辑:我尝试在 Visual Studio Code 和 Android Studio 上运行该应用程序,但问题是相同的。 I have also tried to reinstall the IDE and flutter but no luck at all.我也试过重新安装 IDE 和 flutter,但根本没有运气。

I have the same problem since version 1.12.自 1.12 版以来,我遇到了同样的问题。 Rebooting device clears logs but I hope Flutter will correct this in future versions.重启设备会清除日志,但我希望 Flutter 能在未来的版本中纠正这个问题。 This just happend using android devices.这只是使用 android 设备发生的。 In iOS works correctly.在 iOS 中工作正常。

Try:尝试:

flutter logs -c

(to clear logs, run in the project directory) (要清除日志,请在项目目录中运行)

After cleaning process, then press CTRL + C and answer Y for the question follow.清洁过程后,然后按 CTRL + C 并为以下问题回答 Y。 Hope it will help.希望它会有所帮助。 Thx谢谢

The short answer: Delete that device (emulator) and create another new one.简短的回答:删除该设备(模拟器)并创建另一个新设备。

在此处输入图片说明

The long story:长长的故事:

I had the same exact issue!我有同样的问题! The code was perfect and suddenly without any change I get a big list of errors based on events that shouldn't be fired!代码是完美的,突然间没有任何变化,我得到了一大堆基于不应该被触发的事件的错误!

I tried flutter clean and it didn't solve the issue and tried everything even I deleted all the code that handles the wrongly fired event and I had no luck with that errors which keep coming again and again while no code to generate them!!.我尝试了flutter clean但它没有解决问题并尝试了所有方法,即使我删除了处理错误触发事件的所有代码,但我对那些不断出现的错误没有运气,而没有代码来生成它们!!

Until I thought about trying another emulator and the magic happened!直到我想尝试另一个模拟器,然后奇迹发生了! No errors!没有错误!

you can see it: https://github.com/flutter/flutter/issues/46815 .你可以看到它: https : //github.com/flutter/flutter/issues/46815 This issue is fixed in flutter version 1.12.13+hotfix8.此问题已在 flutter 1.12.13+hotfix8 版本中修复。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM