android - Flutter ListTile 与单选按钮 3 在一行
问题描述
我正在尝试使用单选按钮广告 ListTile 添加 3 个带有标题的单选按钮,但每个单选按钮的标题都溢出并出现在两行中。如何让它出现在一行中?
这是图片
这是我用于显示 3 个图块的代码。
Padding(
padding: EdgeInsets.only(left: 5, right: 5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text("Gender",
style: TextStyle(fontSize: 19),),
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Expanded(
child:ListTile(
title: const Text('Female'),
leading: Radio(
fillColor: MaterialStateColor.resolveWith((states) => Color(0XFFB63728)),
value: Gender.female,
groupValue: _gen,
onChanged: (Gender? value) {
setState(() {
_gen = value;
});
},
),
),
),
Expanded(
child: ListTile(
title: const Text('Male'),
leading: Radio(
fillColor: MaterialStateColor.resolveWith((states) => Color(0XFFB63728)),
value: Gender.male,
groupValue: _gen,
onChanged: (Gender? value) {
setState(() {
_gen = value;
});
},
),
),),
Expanded(
child:ListTile(
title: const Text('Other'),
leading: Radio(
fillColor: MaterialStateColor.resolveWith((states) => Color(0XFFB63728)),
value: Gender.other,
groupValue: _gen,
onChanged: (Gender? value) {
setState(() {
_gen = value;
});
},
),
),
),
],
)
解决方案
在 ListTile 中添加 contentPadding 属性:
ListTile(
contentPadding: EdgeInsets.all(0),
contentPadding 设置 0 删除前导和标题之间的额外空格。
更多信息:https ://api.flutter.dev/flutter/material/ListTile/contentPadding.html
推荐阅读
- c# - MORYX 应用程序在启动时崩溃
- regex - Reprocess data with strings and Numbers in Google Sheets Or Excel
- microsoft-graph-api - Microsoft. Graph OnlineMeeting Get Status And Force Termination
- python - Python UDP 套接字;当源停止时仍然接收数据;为什么?
- entity-framework-6 - FluentMigrator 中的 NotMapped 和 AsNoTracking 等效项
- reactjs - Background image with JS React and Semantic-ui
- node.js - Node.js dynamic update Raphael path via socket.io
- flutter - 在正文中颤动两个小部件?
- composition - 带有 type-graphql 的 typeorm 组合:需要 mixins 吗?
- reactjs - 带有 Typescript 和 ThemeProvider 的 StyledComponents。什么是正确的类型?