flutter - Flutter单选按钮文本“kg”对齐问题?
问题描述
正如您在上图中看到的“kg”文字有很大的差距。但高度 text field
小部件是完美的。它显示以下错误。
小部件库捕获的异常
ParentDataWidget 的使用不正确。
请让我知道有什么问题
(我是新来的颤振)
Material(
elevation: 30.0,
shadowColor: Colors.grey,
child: Container(
height: 100,
width: 375,
decoration: BoxDecoration(
border: Border.all(
color: Colors.blue,
),
),
alignment: Alignment.topCenter,
child: SizedBox(
height: 300,
width: 500,
child: Expanded(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 300,
child: SingleChildScrollView(
child: TextField(
controller: weightcon,
style: TextStyle(
color: Colors.black,
fontSize: 30,
),
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Weight',
focusedBorder: OutlineInputBorder(
borderRadius:
BorderRadius.circular(0.0),
borderSide: BorderSide(
color: Colors.black,
width: 2.0,
),
),
enabledBorder: OutlineInputBorder(
borderRadius:
BorderRadius.circular(0.0),
borderSide: BorderSide(
// color: Colors.redAccent[100],
color: Colors.black54,
width: 2.0,
),
),
),
onChanged: (weightval) {
print('First text field: $weightval');
globals.weightvalue =
double.parse(weightval);
},
),
),
),
SizedBox(
width: 5,
),
Container(
height: 130,
width: 30,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 30,
height: 50,
child: Flexible(
child: SizedBox(
child: Radio(
value: 0,
groupValue: 1,
onChanged: (value) {},
)),
)),
SizedBox(
width: 30,
),
SizedBox(
child: Flexible(
child: Text("KG"),
),),
Flexible(
child: SizedBox(
width: 30,
height: 25,
child: Radio(
value: 1,
groupValue: 1,
onChanged: (value) {},
)),
),
SizedBox(
width: 30,
),
SizedBox(
child: Flexible(
child: Text("LB"),
),),
],
),
),
],
),
),
),
),
),
解决方案
去掉radioButton的sizedbox高度,高度占用多余空间
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
SizedBox(
width: 30,
child: Flexible(
child: SizedBox(
child: Radio(
value: 0,
groupValue: 1,
onChanged: (value) {},
)),
)),
SizedBox(
width: 30,
),
SizedBox(
child: Flexible(
child: Text("KG"),
),),
Flexible(
child: SizedBox(
width: 30,
child: Radio(
value: 1,
groupValue: 1,
onChanged: (value) {},
)),
),
SizedBox(
width: 30,
),
SizedBox(
child: Flexible(
child: Text("LB"),
),),
],
),
),
],
),
输出
推荐阅读
- vue.js - vue.js - 背景图像覆盖在桌面视口大小上的问题
- javascript - 通过 XMLHttpReques 发布数据不返回 json 值
- android - 房间数据库抛出 SQLiteDatabaseCorruptException
- python-2.7 - Python:将两个json文件中的数据有条件地组合成一个csv文件
- javascript - 身份验证和 Redux/Router 的问题
- visual-studio-code - 使用 Move to a new file 作为默认导出重构 JavaScript 函数
- javascript - 消除用户选择文件的可能性
- avro - 如何将 avsc 文件转换为 avdl 文件?
- sql - 使用 SQL 将相关表展平为多列
- python-3.x - 使用 Python 3 和 matplotlib 动态生成条形图