flutter - Flutter:前导字母而不是 ListTile 的图标
问题描述
我认为这张图片对我想要存档的内容是不言自明的:
ListTile(
// leading: Icon(Icons.attach_money), <-- this works but I need the currency icon dynamic
leading: Text(
"€",
style: TextStyle(
fontSize: 20,
),
),
title: Text(translate('options.currency')),
subtitle: Text(translate('options.currency_help')),
onTap: () {
showCurrencyPicker(
context: context,
searchHint: translate('options.search_currency'),
showFlag: true,
showCurrencyName: true,
showCurrencyCode: true,
onSelect: (Currency currency) {
print('Select currency: ${currency.name}');
},
favorite: [_options['currency']],
);
},
),
我可以展示它,但我不确定如何正确居中
解决方案
您可以添加一个 SizedBox,并像这样放置文本
ListTile(
leading: SizedBox(
height: 100.0, //desired height
width: 100.0, //desired width
child: Text("£", //any currency you want
style: TextStyle(
fontSize: 20,
),
),
),
title: ...,
subtitle: ...
),
推荐阅读
- python - 如果满足条件,则从列表列表中删除列表
- node.js - Laravel Echo 监听器没有在听
- c++ - int64_t 在机器字大小等于 32 位的计算机上如何工作?
- excel - 具有重要意义的平均值
- nlog - NLog - 文件轮换 - 序列问题
- javascript - 如果你在一个promise中有一个promise,你需要两个catch吗?
- python - 找不到 MQTT python 应用程序不订阅或接收消息的原因
- batch-file - 根据部分文件夹名称递增文件夹名称
- ionic4 - How to change color of button text in popover in ionic 4
- html - justify content center property in bootstrap not working to center contents in a row