如何在 flutter 中为小部件添加阴影?

2024-01-11

如何向小部件添加阴影,如下图所示?

This https://stackoverflow.com/questions/52173205/how-can-put-image-inside-the-image-in-flutter/52178364#52178364是我当前的小部件代码。


查看盒子阴影 https://docs.flutter.io/flutter/painting/BoxShadow-class.html and 盒子装饰 https://api.flutter.dev/flutter/painting/BoxDecoration-class.html

A Container可以采取BoxDecoration(脱离您最初发布的代码)这需要boxShadow

return Container(
  margin: EdgeInsets.only(left: 30, top: 100, right: 30, bottom: 50),
  height: double.infinity,
  width: double.infinity,
  decoration: BoxDecoration(
    color: Colors.white,
    borderRadius: BorderRadius.only(
      topLeft: Radius.circular(10),
        topRight: Radius.circular(10),
        bottomLeft: Radius.circular(10),
        bottomRight: Radius.circular(10)
    ),
    boxShadow: [
      BoxShadow(
        color: Colors.grey.withOpacity(0.5),
        spreadRadius: 5,
        blurRadius: 7,
        offset: Offset(0, 3), // changes position of shadow
      ),
    ],
  ),
)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何在 flutter 中为小部件添加阴影? 的相关文章