Flutter SingleChildScrollView使UI变为白色
我试图使我的UI可滚动,但当我添加SingleChildScrollView时,我得到了一个白色屏幕,根本没有显示任何内容。我应该从一开始就删除该列?使用容器?我已经在internet上搜索了,但我不知道要添加什么。 这是我的代码,请告诉我我可以删除或添加什么使它工作Flutter SingleChildScrollView使UI变为白色,flutter,scroll,Flutter,Scroll,我试图使我的UI可滚动,但当我添加SingleChildScrollView时,我得到了一个白色屏幕,根本没有显示任何内容。我应该从一开始就删除该列?使用容器?我已经在internet上搜索了,但我不知道要添加什么。 这是我的代码,请告诉我我可以删除或添加什么使它工作 class _UserProfilesState extends State<UserProfiles> { @override @override Widget build(BuildContext c
class _UserProfilesState extends State<UserProfiles> {
@override
@override
Widget build(BuildContext context) {
return Scaffold(
body: SingleChildScrollView(
child: Column(
children: <Widget>[
Expanded(
child: Stack(
children: <Widget>[
Padding(
padding:
EdgeInsets.symmetric(horizontal: 10.0, vertical: 40.0),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: <Widget>[
IconButton(
icon: Icon(Icons.arrow_back),
iconSize: 30.0,
color: Colors.black,
onPressed: () => Navigator.pop(context),
),
])),
Positioned(
left: 24,
top: MediaQuery.of(context).size.height / 6.5 - 28,
child: Container(
height: 84,
width: 84,
//profilepic
child: CircleAvatar(
radius: 10,
backgroundImage: NetworkImage(widget.avatarUrl != null
? widget.avatarUrl
: "https://icon-library.com/images/add-image-icon/add-image-icon-14.jpg"),
),
),
),
Positioned(
right: 24,
top: MediaQuery.of(context).size.height / 6.5 + 16,
child: Row(
children: <Widget>[
Container(
height: 32,
width: 100,
child: RaisedButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => ChatScreen(
serviceProviderId:
widget.serviceProviderId,
userName: widget.userName,
avatarUrl: widget.avatarUrl,
)));
},
color: Colors.black,
textColor: Colors.white,
child: Text(
"Message",
style: TextStyle(fontWeight: FontWeight.bold),
)),
),
SizedBox(
width: 16,
),
Container(
height: 32,
width: 32,
decoration: BoxDecoration(
image: DecorationImage(
image: NetworkImage(
"https://lh3.googleusercontent.com/Kf8WTct65hFJxBUDm5E-EpYsiDoLQiGGbnuyP6HBNax43YShXti9THPon1YKB6zPYpA"),
fit: BoxFit.cover),
shape: BoxShape.circle,
color: Colors.blue),
),
],
),
),
Positioned(
left: 24,
top: MediaQuery.of(context).size.height / 4.3,
bottom: 0,
right: 0,
child: Container(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text(widget.userName,
style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 22,
)),
SizedBox(
height: 4,
),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
widget.address == "default"
? "No Address yet"
: "${widget.address}",
style: TextStyle(
color: Colors.black,
fontSize: 12,
),
)),
Padding(
padding: const EdgeInsets.all(1.0),
child: Text(
"${widget.categoryName}",
style: TextStyle(
color: Colors.black,
fontSize: 12,
),
)),
],
),
))
],
))
],
),
),
);
}
}
class\u用户档案状态扩展状态{
@凌驾
@凌驾
小部件构建(构建上下文){
返回脚手架(
正文:SingleChildScrollView(
子:列(
儿童:[
扩大(
子:堆栈(
儿童:[
填充物(
衬垫:
边缘组。对称(水平:10.0,垂直:40.0),
孩子:排(
mainAxisAlignment:mainAxisAlignment.spaceBetween,
儿童:[
图标按钮(
图标:图标(图标。箭头返回),
iconSize:30.0,
颜色:颜色,黑色,
onPressed:()=>Navigator.pop(上下文),
),
])),
定位(
左:24,
顶部:MediaQuery.of(context).size.height/6.5-28,
子:容器(
身高:84,
宽度:84,
//剖面图
孩子:圆环星(
半径:10,
背景图像:NetworkImage(widget.avatarUrl!=null
?widget.avatarUrl
: "https://icon-library.com/images/add-image-icon/add-image-icon-14.jpg"),
),
),
),
定位(
右:24,
顶部:MediaQuery.of(context).size.height/6.5+16,
孩子:排(
儿童:[
容器(
身高:32,
宽度:100,
孩子:升起按钮(
已按下:(){
导航器.of(上下文).push(MaterialPageRoute(
生成器:(上下文)=>ChatScreen(
serviceProviderId:
widget.serviceProviderId,
用户名:widget.userName,
avatarUrl:widget.avatarUrl,
)));
},
颜色:颜色,黑色,
textColor:Colors.white,
子:文本(
“信息”,
样式:TextStyle(fontWeight:fontWeight.bold),
)),
),
大小盒子(
宽度:16,
),
容器(
身高:32,
宽度:32,
装饰:盒子装饰(
图像:装饰图像(
图片:NetworkImage(
"https://lh3.googleusercontent.com/Kf8WTct65hFJxBUDm5E-EpYsiDoLQiGGbnuyP6HBNax43YShXti9THPon1YKB6zPYpA"),
安装:BoxFit.盖),
形状:BoxShape.circle,
颜色:颜色。蓝色),
),
],
),
),
定位(
左:24,
顶部:MediaQuery.of(context).size.height/4.3,
底部:0,
右:0,,
子:容器(
子:列(
crossAxisAlignment:crossAxisAlignment.start,
儿童:[
文本(widget.userName,
样式:TextStyle(
颜色:颜色,黑色,
fontWeight:fontWeight.bold,
尺寸:22,
)),
大小盒子(
身高:4,
),
填充物(
填充:常数边集全部(1.0),
子:文本(
widget.address==“默认”
“还没有地址”
:“${widget.address}”,
样式:TextStyle(
颜色:颜色,黑色,
尺寸:12,
),
)),
填充物(
填充:常数边集全部(1.0),
子:文本(
“${widget.categoryName}”,
样式:TextStyle(
颜色:颜色,黑色,
尺寸:12,
),
)),
],
),
))
],
))
],
),
),
);
}
}
用户界面变为白色的原因是SingleChildScrollView
允许it child尽可能多地占用空间。在您的列中
,您的一个孩子是已展开的
,已展开的
试图占据尽可能多的空间。你让你的用户界面占用了无限多的时间