简体   繁体   English

底部溢出 13 个像素的 RenderFlex

[英]A RenderFlex overflowed by 13 pixels on the bottom

I know this kind of problems are easy to fix but I have tried everything and yet still getting this error.我知道这类问题很容易解决,但我已经尝试了所有方法,但仍然出现此错误。 I have a grid of images.我有一个图像网格。 When I click one of them, it should open a new page with that exact image and its descriptions.当我单击其中一个时,它应该会打开一个包含该确切图像及其描述的新页面。

Here is the piece of code from grid view:这是网格视图中的一段代码:

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,
                            ),
                          ),
                        ),
                      ),
                    );
                  },

This is the Postview page code:这是 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,
                      ),
                    ),
                  ],
                ),
              ],
            ),
          ),

Kindly help me fix it.请帮我修复它。 If you need more of the code, let me know.如果您需要更多代码,请告诉我。

Try just wrap the Stack with Expanded widget in postview page.尝试将 Stack 与 Expanded 小部件包装在 postview 页面中。

Thank you guys.感谢你们。 I was able to fix it.我能够修复它。

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,
                              ),
                            ),
                          ),
                        ),
                      ),
                    );

Constraint were really useful in this situation.约束在这种情况下非常有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM