在列中添加行时出现错误。我收到以下错误消息:
def ping(self,hostname):
time_check = datetime.now()
data = ""
while not "Success" in data:
time.sleep(1)
data = self.pingCheck("ping 10.10.10.1 count 5")
if (datetime.now()-time_check).seconds > 100:
return False
return True
这也是我的代码供参考:
I/flutter ( 6449): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 6449): The following assertion was thrown during performLayout():
I/flutter ( 6449): BoxConstraints forces an infinite width.
I/flutter ( 6449): These invalid constraints were provided to RenderAnimatedOpacity's layout() function
答案 0 :(得分:14)
错误原因:
TextField
沿水平方向扩展,Row
也沿水平方向扩展,因此我们需要限制TextField
的宽度,可以采用多种方法。
使用Expanded
Row(
children: <Widget>[
Expanded(child: TextField()),
// more widgets
],
)
使用Flexible
Row(
children: <Widget>[
Flexible(child: TextField()),
// more widgets
],
)
将其包装在Container
或SizedBox
中并提供width
Row(
children: <Widget>[
SizedBox(width: 100, child: TextField()),
// more widgets
],
)
答案 1 :(得分:13)
如果您在function getAnchorTags(link, image) {
let anchors = ($('<a/>', {
'href': link
})).html('<img src="'+image+'">');
return anchors;
}
$(function () {
$(rowEblock().append(getEblock()).appendTo('.panel-footer'));
$('#anchorAppender').append(getAnchorTags('#','image_src_path'), getAnchorTags('#','image_src_path'), getAnchorTags('#','image_src_path'));
});
内部使用TextField
,则需要使用Row
或Flexible
。
此答案此处提供了更多详细信息。
答案 2 :(得分:2)
仅当您尝试为width
,height
或Row
的父对象定义无限Column
和Container
时,才会发生这种情况想要使用所有空间的TextField
。
要解决此问题,您应该用TextField
或Flexible
包装Expanded
。
执行此操作可以解决上述问题。
Expanded(
child: txtFirstName,
),
Flexible(
child: txtLastName,
),
完整示例
Column(
children: <Widget>[
imgHeader,
lblSignUp,
txtEmail,
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Expanded(
child: txtFirstName,
),
Flexible(
child: txtLastName,
),
],
),
],
)