I have a Container with a BoxShadow decoration at the top of a page, and below the Container is a ListView with a number of Cards in it. I want the top Container to have a drop shadow that appears in front of the items in the ListView, but this is what I get:

The drop shadow seems to appear behind the Cards instead of in front of it. This is the code:
Widget _buildBody(BuildContext context, ChecklistModel model){
return Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Container(
decoration: BoxDecoration(
color: Colors.red.shade200,
boxShadow: [BoxShadow(
color: Colors.red.shade200,
offset: Offset(0, 10),
blurRadius: 10,
spreadRadius: 10
)]
),
child: ListTile(
title: Text(''),
)
),
Expanded(child: Padding(
padding: const EdgeInsets.all(10),
child: _buildCheckpointListView(context, model))
)
],
)
);
}
I also tried replacing the Container with a Card, but that didn't work either.
color: The color property takes Color class as the object to decide the color of the shadow. offset: Offset class is the object given to this property which controls the extent to which the shadow will be visible.
Step 1: Add the Container widget. Step 2: Add the decoration parameter (inside Container) and assign the BoxDecoration class. Step 3: Add the boxShadow parameter (inside BoxDecoration) and assign the BoxShadow class. Step 4: Add the blurRadius parameter (inside BoxShadow) and set the value to 25.
In Flutter, the overlay lets you print visual elements on top of other widgets by inserting them into the overlay's stack. You insert a widget into the overlay using an OverlayEntry and you use Positioned and AnimatedPositioned to choose where the entry is positioned within the overlay.
Give a bottom margin to the container to introduce some empty space between container and bottom siblings. Like this :
Container(
margin: EdgeInsets.only(bottom: 20),
decoration: BoxDecoration(
color: Colors.red.shade200,
boxShadow: [BoxShadow(
color: Colors.red.shade200,
offset: Offset(0, 10),
blurRadius: 10,
spreadRadius: 10
)]
),
child: ListTile(
title: Text(''),
)
),
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With