簡體   English   中英

底部溢出 13 個像素的 RenderFlex

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

我知道這類問題很容易解決,但我已經嘗試了所有方法,但仍然出現此錯誤。 我有一個圖像網格。 當我單擊其中一個時,它應該會打開一個包含該確切圖像及其描述的新頁面。

這是網格視圖中的一段代碼:

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

請幫我修復它。 如果您需要更多代碼,請告訴我。

嘗試將 Stack 與 Expanded 小部件包裝在 postview 頁面中。

感謝你們。 我能夠修復它。

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

約束在這種情況下非常有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM