ListTile:扩展尾随区域下方的字幕边界
ListTile: Extending subtitle bounds below trailing area
以上视图是这段代码的结果:
ListTile(
leading: Container(color: Colors.blue, child: Text("leading")),
title: Container(color: Colors.green, child: Text("title")),
subtitle: Container(color: Colors.red, child: Text("subtitle")),
trailing: Container(color: Colors.yellow, child: Text("trailing")),
)
我正在尝试扩展红色 'subtitle' 的区域,使其一直延伸到 'triling' 的末尾,但我不想使用肮脏的技巧,例如完全删除 'trailing'并使用一行。
更新
这是我需要的:
填充应该可以很好地设置边界,这样
ListTile(
leading: Container(color: Colors.blue, child: Text("leading")),
title: Container(color: Colors.green, child: Text("title")),
subtitle: Padding(
//upper bound
padding: const EdgeInsets.only(top: 10),
child:Container(color: Colors.red, child: Text("subtitle")),
),
trailing: Container(color: Colors.yellow, child: Text("trailing")),
)
参考文档:
To show right-aligned metadata, consider using a [Row]
with [CrossAxisAlignment.baseline] alignment whose first item is
[Expanded] and whose second child is the metadata text, instead of
using the [trailing]
我避免使用尾随。按照评论中给出的建议解决了这个问题。
ListTile(title: Row(children: [ Expanded(main), Text('trailing') ]));
以上视图是这段代码的结果:
ListTile(
leading: Container(color: Colors.blue, child: Text("leading")),
title: Container(color: Colors.green, child: Text("title")),
subtitle: Container(color: Colors.red, child: Text("subtitle")),
trailing: Container(color: Colors.yellow, child: Text("trailing")),
)
我正在尝试扩展红色 'subtitle' 的区域,使其一直延伸到 'triling' 的末尾,但我不想使用肮脏的技巧,例如完全删除 'trailing'并使用一行。
更新
这是我需要的:
填充应该可以很好地设置边界,这样
ListTile(
leading: Container(color: Colors.blue, child: Text("leading")),
title: Container(color: Colors.green, child: Text("title")),
subtitle: Padding(
//upper bound
padding: const EdgeInsets.only(top: 10),
child:Container(color: Colors.red, child: Text("subtitle")),
),
trailing: Container(color: Colors.yellow, child: Text("trailing")),
)
参考文档:
To show right-aligned metadata, consider using a [Row] with [CrossAxisAlignment.baseline] alignment whose first item is [Expanded] and whose second child is the metadata text, instead of using the [trailing]
我避免使用尾随。按照评论中给出的建议解决了这个问题。
ListTile(title: Row(children: [ Expanded(main), Text('trailing') ]));