[英]Stack Widget Error when using SingleChildScrollView
I have this code as profile screen which I need it to be able to fill a text like "HELLO" on this code example.我有这个代码作为配置文件屏幕,我需要它能够在这个代码示例中填充像“HELLO”这样的文本。 But when I put a lot of text in it, the screen become overflow.
但是当我在里面放很多文字时,屏幕就会溢出。 The problem is everytime I put SingleChildScrollView to avoid the overflow, I got another error instead.
问题是每次我放置SingleChildScrollView以避免溢出时,我都会遇到另一个错误。 Please tell me how I can fix this problem.
请告诉我如何解决这个问题。
@override
Widget build(BuildContext context) {
return Container(
child: SafeArea(
child: FutureBuilder<Profile>(
future: dataService.getHttp(),
builder: ...
),
),
);
}
Widget _buildView(detail) {
return Stack(
alignment: Alignment.center,
children: <Widget>[
Column(
children: <Widget>[
Container(
height: 200.0,
child: Center(
child: Image.network(
'https://i.imgur.com/2F3Al82.jpg',
fit: BoxFit.cover,
height: double.infinity,
width: double.infinity,
),
),
),
Padding(
padding: EdgeInsets.fromLTRB(0.0, 50.0, 0.0, 0.0),
),
Expanded(
child: Container(
color: Colors.white,
child: Column(
children: <Widget>[
Text('HELLO'),
]
),
)
),
],
),
Positioned(
top: 150.0,
child: Container(
height: 100.0,
width: 100.0,
decoration: BoxDecoration(
shape: BoxShape.circle,
image: new DecorationImage(
fit: BoxFit.fill,
image: NetworkImage('https://i.imgur.com/2F3Al82.jpg'),
),
),
),
)
],
);
}
this is the error这是错误
You are getting this error because of the Expanded
widget.由于
Expanded
小部件,您会收到此错误。 SingleChildScrollView
allows for infinite height and expanded will take up as much space as it can these two thing are incompatible if you remove the Expanded
widget it should work. SingleChildScrollView
允许无限高度,并且展开将占用尽可能多的空间,如果您删除它应该工作的Expanded
小部件,这两个东西是不兼容的。 If you want some space around that container I suggest the Containers
margin property.如果您想在该容器周围留出一些空间,我建议您使用
Containers
边距属性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.