如何为 ListTile 小部件设置边框?文档中没有“decoration”属性,因此我无法像通常一样为此元素应用边框。我也无法将 ListTile 的属性(例如 title、subtitle、leading、trailing 等)包装在 Container 中,因为这样不起作用。然而,如果没有任何巧妙的方法来为 ListTile 添加样式边框,那么这可能会非常奇怪...
ListTile有一个“shape”属性。要添加边框,您只需添加这行代码即可。无需将其包装在卡片或容器中。
shape: RoundedRectangleBorder(
side: BorderSide(color: Colors.black, width: 1),
borderRadius: BorderRadius.circular(5),
),
愉快的编码...
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(),
),
),
尝试以下代码。
Card(
shape: RoundedRectangleBorder(
side: BorderSide(
color: Colors.green.shade300,
),
borderRadius: BorderRadius.circular(15.0),
),
child: ListTile(
leading: Text('Name'),
title: Text('Username'),
),
),
ListTile
的方式,但我建议只需用Container
(或Card
)进行包装。 - tim-montague