E/flutter ( 2033): Although this node is not marked as needing layout, its size is not set. E/flutter ( 2033): A RenderBox object must have an explicit size before it can be hit-tested. Make sure that the RenderBox in question sets its size during layout.
它的原因是 ListView 放到 Column/Row 中导致。可能你觉得自己没使用 ListView,你仔细检查一下代码,可能某个 Widget 子控件使用了 ListView。根据提示,我们需要为 ListView 设置一个 Size。
ListView 使用 Expanded 包裹,里面用 SizedBox 或 Container 设置 height 属性就行。
return Expanded( child: Container( margin: EdgeInsets.only(left: 12.w), height: double.infinity, child: ListView()));
本文由老郭种树原创,转载请注明:https://guozh.net/a-renderbox-object-must-have-an-explicit-size-before-it-can-be-hit-tested/