【发布时间】:2021-11-12 12:30:00
【问题描述】:
Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Material(
elevation: 30.0,
shadowColor: Colors.grey,
child: SizedBox(
width: 300,
child: TextField(
controller: heightcon,
style: TextStyle(
color: Colors.black,
fontSize: 30,
),
decoration: InputDecoration(
border: OutlineInputBorder(),
hintText: 'Height',
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.black54,
width: 2.0,
),
),
),
onChanged: (heightval) {
print('First text field: $heightval');
globals.heightvalue = double.parse(heightval);
},
),
),
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Flexible(
child: SizedBox(
child: Radio(
value: 1,
groupValue: 1,
onChanged: (value) {},
)),
),
SizedBox(
width: 10,
),
SizedBox(
child: Flexible(
child: Text("Radio 1"),
)),
Flexible(
child: SizedBox(
child: Radio(
value: 1,
groupValue: 1,
onChanged: (value) {},
)),
),
SizedBox(
width: 10,
),
SizedBox(
child: Flexible(
child: Text("Radio 1"),
))
],
),
],
),
错误显示如下:
════════ 渲染库捕获的异常═══════════════════════════════ RenderBox 未布置:RenderFlex#c7c48 relayoutBoundary=up1 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE 'package:flutter/src/rendering/box.dart': 断言失败:第 1930 行第 12 行:'hasSize'
相关的导致错误的小部件是 脚手架 lib\main.dart:25 ══════════════════════════════════════════════════ ══════════════════════════════
【问题讨论】:
-
请向我们展示您的代码!错误来自错误消息所说的内容,您的行不知道它应该有多大!您可以将其放在
SizedBox中并以像素为单位指定大小,或者您可以查看用Expanded小部件围绕您的 Row 是否有帮助 -
我只是编辑这个问题描述添加我的代码。
-
谢谢你 h8moss 我已经通过你的友好回答解决了我的问题
-
很高兴你解决了它!
标签: flutter visual-studio-code radio-button row textfield