简体   繁体   English

容器小部件内的阴影 - Flutter

[英]Shadow inside Container widget - Flutter

Here's a question, how do you make a Container widget have a shadow on the inside.这里有一个问题,你如何让一个Container widget在里面有一个阴影。 I tried using BoxShadow but this is not the widget I am looking for.我尝试使用BoxShadow但这不是我要找的小部件。 What I want is a shadow inside the Container and I want this Container to have an image .我想要的是Container内部的阴影,我希望这个Container有一个image This image would appear blackish.image会显得偏黑。 Please help me find this.请帮我找到这个。 Thank you.谢谢你。

I guess you need a ColorFilter over your Image:我猜你需要一个 ColorFilter 在你的图像上:

                 Container(
                  decoration: BoxDecoration(
                    image: new DecorationImage(
                      fit: BoxFit.cover,
                      colorFilter: ColorFilter.mode(
                          Colors.black.withOpacity(0.2), BlendMode.dstATop),
                      image: new NetworkImage(
                        'https://wallpaperaccess.com/full/777518.jpg',
                      ),
                    ),

You can try fiddling with the opacity and BlendMode to get the desired result...您可以尝试摆弄不透明度和 BlendMode 以获得所需的结果......

Container(
      height: 120,
      width: 120,
      decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.circular(10),
          boxShadow: [
            BoxShadow(
              color: Colors.white10, // select your color
              spreadRadius: 3,
              blurRadius: 5,
              offset: const Offset(2, 2),
            ),
            BoxShadow(
              color: Colors.grey.withOpacity(0.2),// select your color
              spreadRadius: 3,
              blurRadius: 5,
              offset: const Offset(-1, -1),
            ),
          ],
        ),
    )

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM