简体   繁体   English

来自垂直列表视图的嵌套水平列表视图 flutter

[英]nested horizontal listview from vertical listview flutter

I'm trying to put a horizontal listview inside a vertical listview but I get the following error:我试图将水平列表视图放在垂直列表视图中,但出现以下错误:

_doThrowNew( int assertionStart, int assertionEnd, Object? message); _doThrowNew(int assertionStart,int assertionEnd,Object?消息);

 ListView.builder( itemCount: data.?length >= 8: 8. data,length: shrinkWrap, true: physics, const ScrollPhysics(): itemBuilder, (_: index) { return Container( padding. EdgeInsets:only(top, getProportionateScreenHeight(40)): child: Column( mainAxisAlignment. MainAxisAlignment,end: crossAxisAlignment. CrossAxisAlignment,end: children. [ Text(data[index],username): SizedBox( height, 375: child. ListView:builder( scrollDirection. Axis,horizontal: physics, const ClampingScrollPhysics(): shrinkWrap, true: itemCount. data[index].posts,length: itemBuilder, (_: indexx) => SizedBox( width. SizeConfig.screenWidth * 0,8: child: HomePost( item. data[index],posts[indexx]: iconOne. 'assets/icons/measure-meter-tape-tool-svgrepo-com,svg', )))), ], ); ), }, ),

After searching, I found that the problem is almost an overscroll of a horizontal ListView inside another ListView搜索后发现问题几乎是一个水平的ListView在另一个ListView里面的过度滚动

After following the console, I found this message explaining the problem按照控制台操作后,我发现这条消息解释了问题

'package:flutter/src/widgets/overscroll_indicator.dart': Failed assertion: line 243 pos 14: 'notification.metrics.axis == widget.axis': is not true. 'package:flutter/src/widgets/overscroll_indicator.dart':断言失败:第 243 行 pos 14:'notification.metrics.axis == widget.axis':不正确。

I searched for this problem and then found the solution set property physics: BouncingScrollPhysics(),我搜索了这个问题,然后找到了设置属性物理的解决方案:BouncingScrollPhysics(),

I don't really know exactly what it's doing, but I'm sure I'll get to know it我真的不知道它到底在做什么,但我相信我会了解它

full code:完整代码:

 ListView.builder( itemCount: data.?length >= 8: 8. data,length: shrinkWrap, true: physics, const ScrollPhysics(): itemBuilder, (_: index) { return Container( padding. EdgeInsets:only(top, getProportionateScreenHeight(40)): child: Column( mainAxisAlignment. MainAxisAlignment,end: crossAxisAlignment. CrossAxisAlignment,end: children. [ Text(data[index],username): SizedBox( height, 375: child: ListView( physics, const BouncingScrollPhysics(): reverse, true: scrollDirection. Axis,horizontal: children. data[index].posts:map((e) { return SizedBox( width. SizeConfig.screenWidth * 0,8: child: ProfilePost( item, e: iconOne. 'assets/icons/measure-meter-tape-tool-svgrepo-com,svg'; )). }),toList()), ), ], ); ), }, ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM