dart 抖动-小部件调整大小时图像阴影失败

vfh0ocws  于 2023-05-11  发布在  其他
关注(0)|答案(1)|浏览(151)

我想做这样的布局,图像周围有阴影:

我用一个容器围绕图像,用一个BoxDecoration来画阴影。当列收缩时,图像应调整大小。
但阴影不会随图像调整大小:

有人能帮帮我吗
下面是我的代码:

Column(mainAxisAlignment: MainAxisAlignment.center, children: [
            Text(...)             
            ),
          ]),
          Expanded(
              child: Padding(
            padding: const EdgeInsets.symmetric(vertical: 15.0),
            child: Container(
                decoration: BoxDecoration(
                  border: Border.all(width: 2.0),
                  boxShadow: [
                    BoxShadow(
                      color: Color.fromARGB(255, 0, 0, 0),
                      spreadRadius: 0,
                      blurRadius: 0,
                      offset: Offset(5, 5), 
                    ),
                  ],
                ),
                child: Image.asset("images/myimage.png")),
          )),
          Text("..."),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              IconButton(...),
              IconButton(...),
            ],
          ),
        ],
      ),
dgenwo3n

dgenwo3n1#

Column(
  mainAxisAlignment: MainAxisAlignment.center,
  children: [
    Text(...),
    Expanded(
      child: Padding(
        padding: const EdgeInsets.symmetric(vertical: 15.0),
        child: Container(
          decoration: BoxDecoration(
            border: Border.all(width: 2.0),
            boxShadow: [
              BoxShadow(
                color: Color.fromARGB(255, 0, 0, 0),
                spreadRadius: 0,
                blurRadius: 10,
                offset: Offset(5, 5),
              ),
            ],
          ),
          child: ClipRRect(
            borderRadius: BorderRadius.circular(10),
            child: Image.asset(
              "images/myimage.png",
              fit: BoxFit.cover,
            ),
          ),
        ),
      ),
    ),
    Text("..."),
    Row(
      mainAxisAlignment: MainAxisAlignment.center,
      children: [
        IconButton(...),
        IconButton(...),
      ],
    ),
  ],
),

相关问题