堆叠2张图像时未对齐抖动

时间:2020-09-17 08:41:47

标签: flutter flutter-layout

我有这张下图

the design

我正在尝试在带有堆栈的图像末尾显示图标,但这是我得到的

enter image description here

我尝试过的代码

      Stack(
            children: [
              Expanded(
                flex: 0,
                child: Image.network(
                  Urls.ImageUrl+vendorModel.cover_photo,
                  height: 80,
                  fit: BoxFit.fitWidth,
                ),
                //radius: 52.5,
              ),
              Column(
                mainAxisAlignment: MainAxisAlignment.end,
                crossAxisAlignment: CrossAxisAlignment.end,
                children: [
                  Icon(Icons.favorite,color: Colors.red,),
                ],
              ),
            ],
          ),

1 个答案:

答案 0 :(得分:2)

您不需要使用Expanded小部件

尝试一下:

Row(
          children: [
            IntrinsicHeight(
              child: Stack(
                alignment: Alignment.bottomRight,
                children: [
                  Image.network(
                    Urls.ImageUrl+vendorModel.cover_photo,
                    height: 80,
                    fit: BoxFit.fitWidth,
                  ),
                  Icon(
                    Icons.favorite,
                    color: Colors.red
                  ),
                ],
              ),
            ),
            SizedBox(width: 8,),
            Column(children: [
              Text('text1'),
              Text('text2'),
              Text('text3'),
              Text('text4')
            ],mainAxisSize: MainAxisSize.min,)
          ],
        )