【问题标题】:GirdView do not scroll to the page scroll effect of the SingleChildScrollView?GridView不滚动到SingleChildScrollView的页面滚动效果?
【发布时间】:2021-05-05 01:01:19
【问题描述】:
SingleChildScrollView(
        child: Column(
          children: [
            Container(
              height: 200.0,
              width: double.infinity,
              color: myBlue.withOpacity(.6),
              child: TopCarouselSlider(bgColor: null),
            ),
            //
            Container(
              height: MediaQuery.of(context).size.width * 1,
              width: MediaQuery.of(context).size.width * 0.90,
              color: myBlue.withOpacity(.5),
              // 
              child: GridView.count(
                mainAxisSpacing: 8,
                crossAxisSpacing: 8,
                crossAxisCount: 2,
                children: [
                  Container(
                    height: 200.0,
                    width: 150.0,
                    color: myAccent,
                  ),
                  Container(
                    height: 150.0,
                    width: 150.0,
                    color: myAccent,
                  ),
                  Container(
                    height: 150.0,
                    width: 150.0,
                    color: myAccent,
                  ),
                  Container(
                    height: 150.0,
                    width: 150.0,
                    color: myAccent,
                  )
                ],
              ),
            ),
           
          ],
        ),
      ),

问题:如果我尝试在 GridView 区域内使用滑动手势滚动页面,我不会获得滚动效果。这是否意味着在 SingleChildScrollView 中,Grid 或 List 的通常效果滚动不起作用? 请注意,我也尝试使用 GridView.Builder,但结果相同。想不出解决办法!

提前感谢您的帮助

【问题讨论】:

  • 我试试你的代码,它工作。您会尝试在 GridView 中添加更多子项进行测试吗?

标签: flutter dart


【解决方案1】:

您可以使用NestedScrollViewCustomScrollView 来做到这一点,它可以与 sliverGrid 和 SliverList 一起使用,但问题是您不能添加像 Container 这样的普通 RenderBox 小部件作为 Sliver 的父级,

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-28
    • 2018-08-05
    • 2015-10-11
    相关资源
    最近更新 更多