简体   繁体   English

我需要用 itemBuilder 制作一个不可滚动的 Gridview

[英]I need to make a non-scrollable Gridview with itemBuilder

I want to create a grid view inside a listview.我想在列表视图中创建一个网格视图。 It is now being nested and not working well.它现在被嵌套并且不能正常工作。 I want to make it GridView because I want itemBuilder to view the list in Map with index.我想让它成为 GridView 因为我希望 itemBuilder 使用索引查看 Map 中的列表。

Like this像这样

return GridView.builder(
      shrinkWrap: false,
      primary: false,
      itemCount: kadakkalproducts.length,
      gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
        crossAxisCount: 2,
      ),
      itemBuilder: (BuildContext context, int index) {
        return SingleProdc(
          product_name: kadakkalproducts[index]['name'],
          product_picture: kadakkalproducts[index]['picture'],
          product_price: kadakkalproducts[index]['price'],
          product_image1: kadakkalproducts[index]['image1'],
          product_image2: kadakkalproducts[index]['image2'],
          product_des: kadakkalproducts[index]['des'],
          product_det: kadakkalproducts[index]['det'],
        );
      },
    );

I have used shrinkwrap and primary to stop nested loop.我使用了 shrinkwrap 和 primary 来停止嵌套循环。 But it doesn't work.但它不起作用。

Please help me out to stop scrolling in GridView请帮我停止在 GridView 中滚动

Add this line inside your GridView在您的 GridView 中添加此行

physics:NeverScrollableScrollPhysics()

https://api.flutter.dev/flutter/widgets/ScrollPhysics-class.html https://api.flutter.dev/flutter/widgets/ScrollPhysics-class.html

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

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