如何在 flutter 中的 StaggeredGridView 中使用堆栈小部件?

How to use stack widget inside a StaggeredGridView in flutter?

om/cFMse.png

为什么当我在 StaggeredGridView 中使用堆栈小部件时图像变得奇怪的大小。当我从网格视图中删除堆栈时,布局看起来非常好。我是否以错误的方式使用布局?

new StaggeredGridView.countBuilder(
                crossAxisCount: 2,
                crossAxisSpacing: 10,
                mainAxisSpacing: 10,
                itemCount:model.hit.length,
                itemBuilder: (context, index) {
                  return
                    Stack(
                     children: [
                       Container(
                         decoration: BoxDecoration(
                             color: Colors.transparent,
                             borderRadius: BorderRadius.all(Radius.circular(35))),
                         child:
                         ClipRRect(
                             borderRadius: BorderRadius.all(Radius.circular(35)),
                             child:FadeInImage.memoryNetwork(
                               placeholder: kTransparentImage, image: model.hit[index]['largeImageURL'],fit: BoxFit.cover,)

                         ),


                       )
                     ],
                    );

                },
                staggeredTileBuilder: (index) {
                  return new StaggeredTile.count(1, index.isEven ? 1.2 : 1.8);
                })

尝试将 StackFit.expand 参数传递给 Stack

return
    Stack(
       fit: StackFit.expand, /// <-- expand to the size of the parent constraint
       children: [
          Container(
            decoration: BoxDecoration(
              color: Colors.transparent,
              borderRadius: BorderRadius.all(Radius.circular(35))),
              child: ClipRRect(
                 borderRadius: BorderRadius.all(Radius.circular(35)),
                 child:FadeInImage.memoryNetwork(
                   placeholder: kTransparentImage, image: model.hit[index]['largeImageURL'],fit: BoxFit.cover,)
                 ),
             )
        ],
);