skip to Main Content

Here’s a question, how do you make a Container widget have a shadow on the inside. I tried using BoxShadow but this is not the widget I am looking for. What I want is a shadow inside the Container and I want this Container to have an image. This image would appear blackish. Please help me find this. Thank you.

2

Answers


  1. I guess you need a ColorFilter over your Image:

                     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…

    Login or Signup to reply.
  2. 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),
                ),
              ],
            ),
        )
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search