Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to set a border for ListTile? (Flutter)

How to set a border for ListTile widget? Here is no property "decoration" for it in docs. So I can't apply border for this element as usual. I also can't wrap ListTile's properties like title, subtitle, leading, trailing in Container because it doesn't work. However it could be really strange if here is no any cunning way to style ListTile with a border...

like image 289
Zmagarochak Avatar asked Sep 13 '25 14:09

Zmagarochak


2 Answers

ListTile has "shape" property. To add border you can simply add this line of code. There is no need to wrap it in card or container.

 shape: RoundedRectangleBorder(
    side: BorderSide(color: Colors.black, width: 1),
    borderRadius: BorderRadius.circular(5),
  ), 

Happy coding...

like image 172
V Nikoyan Avatar answered Sep 15 '25 04:09

V Nikoyan


const ListTile(
    leading: Icon(
        Icons.question_answer_outlined,
        color: Colors.blue,
        size: 25,
    ),
    title: Text('TEXTO'),
    trailing: Icon(
        Icons.arrow_forward_ios,
        color: Colors.black26,
        size: 15,
    ),
    shape: Border(
        bottom: BorderSide(),
    ),
),
like image 20
user19847602 Avatar answered Sep 15 '25 05:09

user19847602