BoxConstraints 强制无限高度[错误]
BoxConstraints forces an infinite height[error]
这是我的代码..
我收到错误消息说 'BoxConstraints forces an infinite height.' 然后是描述,我是 flutter 的新手,我没有办法解决这个问题。
body:SingleChildScrollView(
child: Stack(
fit: StackFit.expand,
children: [
Image(
color: Colors.black12,
colorBlendMode: BlendMode.darken,
image: AssetImage('images/Alone.jpg'),
fit: BoxFit.cover,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Show('Alone is Stronger', 'y'),
],
)
],
),
),
这是我的显示小部件。
Widget Show(String x,String y){
return
Container(
margin: EdgeInsets.fromLTRB(10, 5, 10, 2),
width: 400,
decoration: BoxDecoration(
color: Colors.white10,
borderRadius: BorderRadius.circular(10),
),
padding: EdgeInsets.all(10),
child: Text(
'$x',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.yellowAccent,
),
),
);
}
这里已经有很多相同问题的问题,但我不知道问题出在哪里。
提前致谢
根据您的 code-snippet,我了解到您正试图了解 body
的背景。
SingleChildScrollView
提供无限高度,而 Stack
是它的 child 并使用 parent 大小,它将获得无限高度并通过错误。
在您的情况下,小部件结构将是
body: Stack(
fit: StackFit.expand,
children: [
Image(
color: Colors.black12,
colorBlendMode: BlendMode.darken,
image: AssetImage('images/Alone.jpg'),
fit: BoxFit.cover,
),
SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Show('Alone is Stronger', 'y'),
],
))
],
),
这是我的代码.. 我收到错误消息说 'BoxConstraints forces an infinite height.' 然后是描述,我是 flutter 的新手,我没有办法解决这个问题。
body:SingleChildScrollView(
child: Stack(
fit: StackFit.expand,
children: [
Image(
color: Colors.black12,
colorBlendMode: BlendMode.darken,
image: AssetImage('images/Alone.jpg'),
fit: BoxFit.cover,
),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Show('Alone is Stronger', 'y'),
],
)
],
),
),
这是我的显示小部件。
Widget Show(String x,String y){
return
Container(
margin: EdgeInsets.fromLTRB(10, 5, 10, 2),
width: 400,
decoration: BoxDecoration(
color: Colors.white10,
borderRadius: BorderRadius.circular(10),
),
padding: EdgeInsets.all(10),
child: Text(
'$x',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
color: Colors.yellowAccent,
),
),
);
}
这里已经有很多相同问题的问题,但我不知道问题出在哪里。 提前致谢
根据您的 code-snippet,我了解到您正试图了解 body
的背景。
SingleChildScrollView
提供无限高度,而 Stack
是它的 child 并使用 parent 大小,它将获得无限高度并通过错误。
在您的情况下,小部件结构将是
body: Stack(
fit: StackFit.expand,
children: [
Image(
color: Colors.black12,
colorBlendMode: BlendMode.darken,
image: AssetImage('images/Alone.jpg'),
fit: BoxFit.cover,
),
SingleChildScrollView(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Show('Alone is Stronger', 'y'),
],
))
],
),