RenderFlex在底部溢出了13个像素



我知道这种问题很容易解决,但我已经尝试了一切,但仍然得到这个错误。我有一个图像网格。当我点击其中一个,它应该打开一个新的页面,与该图像和它的描述。

下面是来自网格视图的代码:

itemBuilder: (BuildContext context, int index) {
Post post = _posts[index];
List<PostView> postViews = [];
postViews.add(PostView(
currentUserId: 'sKfZaqDFiFWuU2QQlW6ka3KddlD2',
post: post,
author: _profileUser,
));
return GestureDetector(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => Container(
height: MediaQuery.of(context).size.height,
color: whiteColor,
child: Column(
children: postViews,
),
),
),
),
);
},

这是Postview页面代码:

@override
Widget build(BuildContext context) {
return Material(
child: Column(
children: <Widget>[
Stack(
children: <Widget>[
Container(
//height: MediaQuery.of(context).size.height * 0.75,

child: ClipRRect(
borderRadius: BorderRadius.only(
topLeft: Radius.zero,
topRight: Radius.zero,
bottomLeft: Radius.circular(30.0),
bottomRight: Radius.circular(30.0),
),
child: Image(
image: CachedNetworkImageProvider(widget.post.imageUrl),
fit: BoxFit.cover,
),
),
),
SizedBox(height: 20),
Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
GestureDetector(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (_) => ProfileScreen(
currentUserId: widget.currentUserId,
userId: widget.post.authorId,
),
),
),
child: Row(
children: [
CircleAvatar(
radius: 15,
backgroundImage: widget.author.profileImageUrl.isEmpty
? AssetImage('assets/images/user.png')
: CachedNetworkImageProvider(
widget.author.profileImageUrl),
),
SizedBox(width: 7),
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
widget.author.username,
style: TextStyle(
color: Colors.black.withOpacity(0.55),
fontSize: 16,
fontWeight: FontWeight.w600,
),
),
],
),
],
),
),
Text(
'4 days ago',
style: TextStyle(
color: Colors.black.withOpacity(0.55),
fontWeight: FontWeight.w200,
),
)
],
),
),
Padding(
padding: EdgeInsets.symmetric(horizontal: 15),
child: Column(
children: [
Row(
children: [
Text(
'Description',
style: TextStyle(
color: blackColor,
fontSize: 18,
fontWeight: FontWeight.w700,
),
),
],
),
SizedBox(height: 5),
Row(
children: [
Text(
widget.post.caption,
style: TextStyle(
color: Colors.black.withOpacity(0.4),
fontWeight: FontWeight.w600,
letterSpacing: 0.2,
),
),
],
),
],
),
),

请帮我修复它。如果您需要更多的代码,请告诉我。

尝试在postview页面中包装Stack with Expanded widget。

谢谢大家。我能修好它。

return GestureDetector(
onTap: () => Navigator.push(
context,
MaterialPageRoute(
builder: (context) => SingleChildScrollView(
child: Container(
constraints: BoxConstraints(
minHeight: MediaQuery.of(context).size.height,
maxHeight: double.infinity,
),
color: whiteColor,
child: PostView(
currentUserId: 'sKfZaqDFiFWuU2QQlW6ka3KddlD2',
post: post,
author: _profileUser,
),
),
),
),
),
);

约束在这种情况下非常有用。

最新更新