首页 > 解决方案 > GridView builder和carousal不会在颤动中滚动

问题描述

我正在尝试滚动屏幕​​的整个主体,我有一个旋转和网格视图,但我不能这样做:这是我到目前为止所做的:

Scaffold(
  appBar: const TopNavBar(),
  // here i am adding SingleScrollChildView() widget to scroll the whole page, instead of just grid widget, but it gives error
  body: Column(
    children: [
      MainCarousal(), // carousal widget from carousel_slider
      Flexible(
         child: GridView.builder(
         itemCount: state.products.length,
         gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount(
                    crossAxisCount: 2,
                  ),
         itemBuilder: (listContext, index){
             return Container(
                    decoration: BoxDecoration(
                          color: const Color(0xffeeeeee),
                          borderRadius: BorderRadius.circular(10),
                      ),
                    );
                      child: Text(state.products[index].name),
                   );
         ),
      ),

代码本身没有错误,并且滚动适用于网格数据。但我想向下滚动整个页面,以便网格项可见。但是当我添加SingleScrollView到该列时,它给了我错误:

RenderFlex 子项具有非零弹性,但传入的高度约束是无界的。

标签: flutterdartflutter-layout

解决方案


推荐阅读