I need to add a shadow in my items listTile elements in flutter, but i could not do that with BoxShadow because it is only possible in Container
this is my listTile:
child: ListTile(
leading: const Icon(Icons.flight_land),
tileColor: Colors.black.withOpacity(0.5),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
side: BorderSide(
color: Colors.black,
),
),
title: Text(
snapshot
.data!.docChanges[index].doc['nameCourse'],
style: TextStyle(
fontSize: 20,
//COLOR DEL TEXTO TITULO
color: Colors.blueAccent,
),
),
contentPadding: EdgeInsets.symmetric(
vertical: 8,
horizontal: 16,
),
),
CodePudding user response:
You can wrap your ListTile
widget with Material
widget and give it shadow.
For example:
Material(
elevation: 20.0,
shadowColor: Colors.blueGrey,
...
),
CodePudding user response:
You can't add a shadow to the ListTile itself. So a solution can be to wrap it with a container like so
Container(
decoration: BoxDecoration(
color: Colors.white, // Your desired background color
borderRadius: BorderRadius.circular(15),
boxShadow: [
BoxShadow(color: Colors.black.withOpacity(0.3), blurRadius: 15),
]
),
child: ListTile(
leading: const Icon(Icons.flight_land),
tileColor: Colors.black.withOpacity(0.5),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(15),
side: const BorderSide(
color: Colors.black,
),
),
title: const Text(
'Text',
style: TextStyle(
fontSize: 20,
//COLOR DEL TEXTO TITULO
color: Colors.blueAccent,
),
),
contentPadding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
),
),