gpt4 book ai didi

flutter - 将ListView.Builder滚动方向从水平更改为垂直时出现错误

转载 作者:行者123 更新时间:2023-12-03 04:52:04 26 4
gpt4 key购买 nike

这是代码

当scrollDirection:Axis.horizo​​natal时,此代码可以正常工作,但是当我创建scrollDirection:Axis.verticle时,这给了我以下代码以下错误:

  Widget build(BuildContext context) {
return Scaffold(

body: SingleChildScrollView(
physics: BouncingScrollPhysics(),
child: SafeArea(
child: Column(
children: <Widget>[
FadeAnimation(1.4, HeaderWidget()),
SizedBox(height: 30),
FadeAnimation(1.8,SearchWidget()),
SizedBox(height: 30,),
FadeAnimation(1.8,Text(
'Here is the list of items',
style: TextStyle(color: Colors.grey[800],
fontWeight: FontWeight.w900,
fontStyle: FontStyle.italic,
fontFamily: 'Open Sans',),
)),
SizedBox(height: 30,),
Container(
height: 130,
child: shopDetailsList.length==0?new Text("Data no available"):SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(),
child: SizedBox(
height: 130,
child: new ListView.builder(
itemCount: shopDetailsList.length,
scrollDirection: Axis.vertical,<--------------------
itemBuilder: (_,index){

return ShopDetailsUI(shopDetailsList[index].Name,shopDetailsList[index].ShopName,shopDetailsList[index].ShopNumber,shopDetailsList[index].ShopState,shopDetailsList[index].ShopStreet,shopDetailsList[index].ShopType);
},
),
),
),
),
),


],
),
),

)

);

错误

在performLayout()期间引发了以下断言:
布局期间,为 RenderStack对象赋予了无限大小。

这可能意味着它是一个试图尽可能大的渲染对象,但是它被放置在另一个渲染对象中,允许其子代选择自己的大小。
提供不受限制的高度限制的最接近的祖先是:RenderIndexedSemantics#94b2c relayoutBoundary = up3 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
... parentData:index = 0; layoutOffset = 0.0(可以使用大小)
...约束:BoxConstraints(w = 411.4,0.0 <= h <= Infinity)
...语义边界
...大小:MISSING
...索引:0
应用于RenderStack的约束为:BoxConstraints(w = 391.4,0.0 <= h <= Infinity)
给出的确切大小是:Size(391.4,Infinity)

最佳答案

由于您提供的代码中缺少某些定义,因此我尝试复制您的问题没有取得任何成功。但是,我进行了测试,将这些类(例如FadeAnimation类)替换为固定大小的小部件,并且代码正常工作。

作为一般提示,请尝试将代码分解为较小的部分,并简化您认为不需要的代码。例如,您可以尝试仅使用顶级窗口小部件运行该应用程序,然后逐步添加其子级。
这样,您应该能够自我诊断问题出在哪里。

最后,我认为您真的不需要ConstrainedBox小部件,因为嵌套SizedBox已经限制了其高度。希望这可以帮助。

关于flutter - 将ListView.Builder滚动方向从水平更改为垂直时出现错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61205091/

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