【发布时间】:2020-04-08 05:26:01
【问题描述】:
我正在编写一个颤振应用程序,但是当我想在 Android 模拟器 (Ctrl+F5) 上对其进行测试时,我收到了一个无法修复的错误。这是其中的一部分:
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)
正如您在最后一行看到的,它说错误的原因是D:/flutterProjects/test_project/test_project/lib/screens/all_obj_screen.dart 中的ListView。问题是我在那个文件中没有ListView(目前,但我以前有过)并且那个路径甚至不再存在了!
如果有帮助,这是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,
),
),
);
}
}
所以我认为问题不在于我的代码,而在于 Visual Studio Code。如何解决这个问题?
编辑: 我曾尝试在 Visual Studio Code 和 Android Studio 上运行该应用程序,但问题是一样的。 我也尝试重新安装 IDE 和颤振,但没有运气。
【问题讨论】:
-
我的 Flutter 应用遇到了同样的问题,如果你热重启应用,它会消失,直到你完全重启应用,你必须再次热重启它。但是,您可以运行
flutter clean,它应该会消失。 -
嗯,它可能是某种缓存构建吗?清理缓存、重新安装、关闭并重新打开.. 等等?
-
@Benjamin 我尝试热重载甚至使用flutter clean,但问题仍然存在
-
@PFuster 我已经尝试过做所有这些事情......
-
我会在 Flutter GitHub here 中提出问题。
标签: android flutter visual-studio-code