gpt4 book ai didi

flutter - 如何在单页中显示 GridView 和其他 View #flutter

转载 作者:IT王子 更新时间:2023-10-29 07:12:58 25 4
gpt4 key购买 nike

如何在同一个页面中添加 GridView 和其他 View ?
我尝试使用 ListView ,但它显示错误

I/flutter (10293): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 461 pos 12: 'child.hasSize': is not true. I/flutter (10293): Another exception was thrown: NoSuchMethodError: The getter 'scrollOffsetCorrection' was called on null. I/flutter (10293): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null. I/flutter (10293): Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null

  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): Another exception was thrown: RenderBox was not laid out: RenderCustomPaint#f955c relayoutBoundary=up6 NEEDS-PAINT I/flutter (10293): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#a9147 relayoutBoundary=up5 NEEDS-PAINT I/flutter (10293): Another exception was thrown: RenderBox was not laid out: RenderRepaintBoundary#4a4c9 relayoutBoundary=up4 NEEDS-PAINT I/flutter (10293): Another exception was thrown: 'package:flutter/src/rendering/sliver_multi_box_adaptor.dart': Failed assertion: line 461 pos 12: 'child.hasSize': is not true. I/flutter (10293): Another exception was thrown: NoSuchMethodError: The getter 'scrollOffsetCorrection' was called on null. I/flutter (10293): Another exception was thrown: NoSuchMethodError: The method 'debugAssertIsValid' was called on null. I/flutter (10293): Another exception was thrown: NoSuchMethodError: The getter 'visible' was called on null.

最佳答案

我认为您应该设置 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。 (您可以根据需要设置高度/宽度或尝试使用Expanded 小部件)

关于flutter - 如何在单页中显示 GridView 和其他 View #flutter,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53722274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com