简体   繁体   English

单个 flutter 屏幕上的两个列表 GridViewBuilder 和 ListViewBuilder

[英]Two list GridViewBuilder and ListViewBuilder on a single flutter screen

I'm fresh new to flutter, so I'm trying to merge two different list.我是 flutter 的新手,所以我正在尝试合并两个不同的列表。 The first list is GridView.builder() and second is ListView.builder() .第一个列表是GridView.builder() ,第二个是ListView.builder() The first grid list scroll horizontal and second list view scroll vertical.第一个网格列表水平滚动,第二个列表视图垂直滚动。 When user scroll the second list the hole screen start scrolling.当用户滚动第二个列表时,孔屏幕开始滚动。

You can Wrap your ListView.builder() and GridView.builder() with a Column() and a SingleChildScrollView() This way you can warp multiple scroll views within a Column(), just make sure to set the physics to NeverScrollablePhysics() if the scroll Direction is the same.您可以用Column()SingleChildScrollView()包裹ListView.builder()GridView.builder()这样您就可以在 Column() 中扭曲多个滚动视图,只需确保将物理设置为NeverScrollablePhysics()如果滚动方向相同。

SingleChildScrollView(
   child: Column(
      children :[ 
          GrdiView.builder(
              axis: Axis.Horizontal
              itemBuilder:(_, index){
                     ...
                  }
               ),
           ListView.builder(
              physics: NeverScrollableScrollPhysics()
              shrinkWarp: true,
               itemBuilder:(_, index){
                     ...
                  }
                ),
              ],
           ),
      );

Hope this solves your issue.希望这能解决您的问题。

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

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