ListTile可以设置边框吗?(扑)

Zma*_*hak 16 styling flutter

如何为ListTile小部件设置边框?文档中没有它的属性“装饰”。所以我不能像往常一样为这个元素应用边框。我也无法将 ListTile 的属性(如标题、副标题、前导、尾随)包装在 Container 中,因为它不起作用。然而,如果没有任何巧妙的方法来设置带有边框的 ListTile 样式,那可能会很奇怪......

Var*_*yan 42

ListTile 具有“shape”属性。要添加边框,您只需添加这行代码即可。无需将其包裹在卡片或容器中。

 shape: RoundedRectangleBorder(
    side: BorderSide(color: Colors.black, width: 1),
    borderRadius: BorderRadius.circular(5),
  ), 
Run Code Online (Sandbox Code Playgroud)

快乐编码...


小智 14

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(),
    ),
),
Run Code Online (Sandbox Code Playgroud)


Rav*_*til 6

尝试下面的代码。

Card(
  shape: RoundedRectangleBorder(
    side: BorderSide(
      color: Colors.green.shade300,
    ),
    borderRadius: BorderRadius.circular(15.0)
  ),
  child: ListTile(
    leading: Text('Name'),
    title: Text('Username')
  )
)
Run Code Online (Sandbox Code Playgroud)