ListTile可以设置边框吗? (颤抖)

问题描述 投票:0回答:3

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

flutter styling
3个回答
27
投票

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

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

快乐编码...


8
投票
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(),
    ),
),

5
投票

尝试下面的代码。

Card(
  shape: RoundedRectangleBorder(
    side: BorderSide(
      color: Colors.green.shade300,
    ),
    borderRadius: BorderRadius.circular(15.0)
  ),
  child: ListTile(
    leading: Text('Name'),
    title: Text('Username')
  )
)
© www.soinside.com 2019 - 2024. All rights reserved.