简体   繁体   English

无法使用 ListView.builder() 滚动

[英]Cant scroll with ListView.builder()

I was wondering if anyone had an issue where they use a ListView.builder() and then it doesn't want to scroll我想知道是否有人在使用 ListView.builder() 时遇到问题,然后它不想滚动

                   return ListView.builder(
                        scrollDirection: Axis.vertical,
                        shrinkWrap: true,
                       
                        itemCount: widget.product.category.length,
                       
                        itemBuilder: (context, index) {
                          final item = widget.product.category[index];

                          return ListTile(title: Text(item));
                        },
                      )

I'd suggest you do the following:我建议您执行以下操作:

  1. Remove shrinkWrap and make sure the value passed to itemCount is large enough to make the widget scroll.移除 shrinkWrap 并确保传递给 itemCount 的值足够大以使小部件滚动。
  2. If you place the list view inside a vertically scrolling list, it's not going to scroll... In this case, you should probably be using slivers如果您将列表视图放在垂直滚动列表中,它不会滚动...在这种情况下,您可能应该使用 slivers

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

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