flutterstyling

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...


Solution

  • 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...