简体   繁体   English

Flutter:ListView 内的 ListView 不滚动

[英]Flutter: ListView inside ListView don't scroll

I want to nest a ListView inside a ListView.我想在 ListView 中嵌套一个 ListView。

Here's the code:这是代码:

return ScrollablePositionedList.builder(
    itemScrollController: itemScrollController,
    itemPositionsListener: itemPositionListener,
    itemCount: widget.favouritesCategories.length,
    itemBuilder: (BuildContext context, int index) {
      return CategoryPublicationList(favouriteCategory: widget.favouritesCategories[index]);
    });

This ListView work fine but这个 ListView 工作正常,但

return ListView.builder(
        shrinkWrap: true,
        itemCount: publications.length,
        itemBuilder: (BuildContext context, int index) {
          return PublicationWidget(publication: publications[index]);
      });

Insided ListView don't scroll.内部 ListView 不滚动。 Can somebody help me, please?有人可以帮我吗?

我想要的用户界面

If you want to have the inner ListView be scrollable independently of the main scroll view, you should use NestedScrollView .如果你想让内部ListView可以独立于主滚动视图滚动,你应该使用NestedScrollView

Please check more info here在此处查看更多信息

it will not work, only 1 ListView will work, You can use SliverWidget, make a CustomScrollView and within that you can use nested scroll using SliverList.它不起作用,只有 1 个 ListView 起作用,您可以使用 SliverWidget,制作一个 CustomScrollView,在其中您可以使用 SliverList 使用嵌套滚动。

https://www.woolha.com/tutorials/flutter-customscrollview-with-slivers-examples https://www.woolha.com/tutorials/flutter-customscrollview-with-slivers-examples

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

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