如何在单页#flutter中显示网格视图和其他视图



如何在同一页面中添加网格视图和其他视图
我尝试使用listview,但它显示错误

I/flutter(10293(:引发了另一个异常:"package:flatt/src/rendering/sliver_multi_box_adaptor.dart":失败断言:第461行位置12:"child.hasSize":不为真。I/flutter(10293(:引发了另一个异常:NoSuchMethodError:getter对null调用了"scrollOffsetCorrection"。I/flutter(10293(:引发了另一个异常:NoSuchMethodError:方法对null调用了"debugAssertIsValid"。I/flutter(10293(:另一个引发了异常:NoSuchMethodError:getter"visible"为调用空

body:ListView(
children: <Widget>[
Text("checking"),
Container(
child: GridView.count(
crossAxisCount: 3,
childAspectRatio: .6,
children: _list.map((p) => ProductManagment(p)).toList(),
),
) 
],
)

另一次尝试

body:ListView(
children: <Widget>[
Text("checking"),
GridView.count(
crossAxisCount: 3,
childAspectRatio: .6,
children: _list.map((p) => ProductManagment(p)).toList(),
) 
],
)

再次出现错误

I/flutter(10293(:引发另一个异常:RenderBox未布局:RenderCustomPaint#f955c relayoutBoundary=up6 NEEDS-PAINTI/flutter(10293(:引发另一个异常:RenderBox未布局:RenderRepaintBoundary#a9147 relayoutBoundary=up5 NEEDS-PAINTI/flutter(10293(:引发另一个异常:RenderBox未布局:RenderRepaintBoundary#4a4c9 relayoutBoundary=up4 NEEDS-PAINTI/flutter(10293(:引发了另一个异常:"package:flutter/src/rendering/sliver_multi_box_adaptor.dart":断言失败:行461 pos 12:"child.hasSize":不为true。I/flutter(10293(:引发了另一个异常:NoSuchMethodError:在null上调用了getter"scrollOffsetCorrection"。I/flutter(10293(:引发了另一个异常:NoSuchMethodError:在null上调用了方法"debugAssertIsValid"。I/flutter(10293(:引发了另一个异常:NoSuchMethodError:在null上调用了getter"visible"。

我认为您应该只设置Container的高度,或者通过Expanded小部件扭曲它。告诉我发生了什么?。可能是大小丢失了,这就是错误发生的原因。

编辑:

body:ListView(
children: <Widget>[
Text("checking"),
Container(
height: 300.0
child: GridView.count(
crossAxisCount: 3,
childAspectRatio: .6,
children: _list.map((p) => ProductManagment(p)).toList(),
),
) 
],
)

设定高度:容器内300.0(您可以根据需要设置高度/宽度,或尝试使用扩展小部件(

最新更新