Search code examples
flutterdartshadowelevationlisttile

How can i add a shadow in ListTile flutter like 'elevation'


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

enter image description here

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,
                          ),
                        ),

Solution

  •           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,
                                ),
                              ),
                              Container(
    boxShadow: [
          BoxShadow(
            color: Colors.grey.withOpacity(0.5),
            spreadRadius: 5,
            blurRadius: 7,
            offset: Offset(0, 3),
          ),
        ]
                              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,
                              ),
                            ),