dart GridView无限滚动循环进度指示器位置

kjthegm6  于 2022-12-15  发布在  其他
关注(0)|答案(1)|浏览(104)

在我的gridView中有一个显示CircularProgressIndicator()的条件,但是它显示不正确,在gridView元素中,我需要它显示在gridView下面。我如何正确显示CircularProgressIndicator()

Widget buildCatalog(List<Product> product) => GridView.builder(
    gridDelegate: SliverGridDelegateWithMaxCrossAxisExtent(
      // mainAxisExtent: ,
        maxCrossAxisExtent: 300,
        childAspectRatio: MediaQuery.of(context).size.width*1.22 /
            (MediaQuery.of(context).size.height),
        crossAxisSpacing: 10,
        mainAxisSpacing: 10),
    controller: sController,
    itemCount: product.length + 1,
    itemBuilder: (context, index) {
      if (index < product.length) {
      final media = product[index].media?.map((e) => e.toJson()).toList();
      final photo = media?[0]['links']['local']['thumbnails']['350'];
        final productItem = product[index];
        return GestureDetector(
          onTap: () {
          },
          child: Container(
            child: Column(
              children: <Widget>[
                InkWell(
                  child: Container(
                    margin: EdgeInsets.only(top: 5),
                    child: Image.network(...)
                    ),
                  ),
                ),
                SizedBox(
                  height: 10,
                ),
                Text(
                  '${productItem.name}\n',
                  textAlign: TextAlign.center,
                  maxLines: 2,
                  overflow: TextOverflow.ellipsis,
                  style: TextStyle(fontSize: 14),
                ),
                // Spacer(),
                SizedBox(height: 8),
                Text('${productItem.price} ₸',
                    textAlign: TextAlign.start,
                    style: TextStyle(fontSize: 20, color: Colors.red)),
                SizedBox(height: 5),
                buildButton(index, productItem.id),
              ],
            ),
          ),
        );
      }
      return const Center(child: CircularProgressIndicator(),);
    },
  );

kupeojn6

kupeojn61#

将其 Package 到行小部件中,并将mainAzixSize设置为最大值

相关问题