Search code examples
flutterdartelevationcard

How to remove elevation shadow from one side without removing elevation itself in flutter from Card or Material widget?


How can I remove top-side elevation shadow inside Card or Material widget.

I used Material widget to container and given a value for elevation. it reflects to my container in all side. But i want only left, bottom and right side elevation shadow. how can i get it or remove top side elevation shadow. Example from Material or Card Widget will be useful.

Material(
  elevation: 3,
  child: Container(
    height: 100,
    width: 300,
  ),
)

Example picture


Solution

  • For that, you just have to bring the shadow a little bit down by increasing the y-axis of the offset property just like this:

    Container(
      height: 100.0,
      width: 300.0,
        decoration: BoxDecoration(
          borderRadius: BorderRadius.circular(20.0),
          color: Colors.white,
          boxShadow: [
            BoxShadow(
              spreadRadius: 2,
              blurRadius: 3,
              offset: Offset(0, 6),
              color: Colors.black38
            )
          ]
        ),
      ),
    

    Here's the output:

    enter image description here