Flutter 滑动组件互相嵌套问题

滑动组件互相嵌套问题

  • 如果listview/singlechildscrollview 嵌套gridview,将两个组件的shrinkwrap设置为true,并且gridview无法滚动 physics: new NeverScrollableScrollPhysics()。比如
return SingleChildScrollView(
        child: Column(crossAxisAlignment: CrossAxisAlignment.center, children: [
      GridView.builder(
          itemCount: 4,
          physics: NeverScrollableScrollPhysics(),
          shrinkWrap: true,
          gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
              crossAxisCount: 2,
              mainAxisExtent: 55,
              mainAxisSpacing: 15,
              crossAxisSpacing: 15),
          itemBuilder: (context, index) {
            return Container();
          }),
    ]));
  • 由于SingleChildScrollView无shrinkWrap属性则不设置
posted @ 2021-11-18 16:07  R1cardo  阅读(407)  评论(0编辑  收藏  举报