简体   繁体   English

Flutter 页面刷新问题 | ListView 显示错误“BOTTOM OVERFLOWED BY 98 PIXEL”

[英]Flutter Page refresh problem | ListView showing a error “BOTTOM OVERFLOWED BY 98 PIXEL”

I am working a messaging app based on firebase.我正在开发一个基于 firebase 的消息应用程序。 I am a having problem in the home page.我的主页有问题。 I created the home page to show the last message, the user name, and the profile pic of the user who send the message.我创建了主页以显示最后一条消息、用户名和发送消息的用户的个人资料图片。 But when I am getting back from the chatscreen only the last message is updating.但是当我从聊天屏幕回来时,只有最后一条消息正在更新。 And the last message did not showing the correct user who send the message.最后一条消息没有显示发送消息的正确用户。 But after hot reload it is showing correctly.但是热重载后它显示正确。 And the ListView builder did not scrolling.并且 ListView 构建器没有滚动。 It is showing a error "BOTTOM OVERFLOWED BY 98 PIXEL".它显示错误“BOTTOM OVERFLOWED BY 98 PIXEL”。 How can I fixed those problems?我该如何解决这些问题?

  Widget chatRoomsList() {
return StreamBuilder(
  stream: chatRoomsStream,
  builder: (context, snapshot) {
    return snapshot.hasData
        ? ListView.builder(
            itemCount: snapshot.data.docs.length,
            shrinkWrap: true,
            itemBuilder: (context, index) {
              DocumentSnapshot ds = snapshot.data.docs[index];
              return ChatRoomListTile(ds.id, ds["lastMessage"], myUserName);
            })
        : Center(child: CircularProgressIndicator());
  },
);
}

ChatRoomList Tile:聊天室列表磁贴:

class _ChatRoomListTileState extends State<ChatRoomListTile> {
  String profilePicUrl = "", name = "", username = "";

  getThisUserInfo() async {
    username =
        widget.chatRoomId.replaceAll(widget.myUserName, "").replaceAll("_", "");
    QuerySnapshot querySnapshot = await DatabaseMethods().getUserInfo(username);
    print("something the data we are getting ${querySnapshot.docs[0].id}");
    name = "${querySnapshot.docs[0]["name"]}";
    profilePicUrl = querySnapshot.docs[0]["imgUrl"];
    setState(() {});
  }

  @override
  void initState() {
    getThisUserInfo();
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: () {
        before going to charRoom
         Navigator.push(
             context,
            MaterialPageRoute(
               builder: (context) => ChatScreen(
                 username,
                 name,
               ),
            ));
      },

      child: Row(
        crossAxisAlignment: CrossAxisAlignment.baseline,
        children: [
          ClipRRect(
            borderRadius: BorderRadius.circular(30),
            child: Image.network(
              profilePicUrl,
              height: 40,
              width: 40,
            ),
          ),
          SizedBox(width: 12),
          Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              Text(name,
                  style: TextStyle(
                    fontSize: 16,
                    color: Colors.white,
                  )),
              SizedBox(height: 3),

              Container(
                width: 200,
                child: Text(
                  widget.lastMessage,
                  style: TextStyle(
                    fontSize: 16,
                    color: HexColor("#E6F4F7"),
                  ),
                  overflow: TextOverflow.visible,
                  softWrap: false,
                ),
              ),
              SizedBox(height: 30),
            ],
          ),
        ],
      ),
    );
  }
}

Full home page code: https://github.com/Monzim/messengerClone/blob/main/lib/views/home.dart完整主页代码: https://github.com/Monzim/messengerClone/blob/main/lib/views/home.dart

在此处输入图像描述

I just updated my answer you can put this code into your Home class我刚刚更新了我的答案,您可以将此代码放入您的Home class

  Column(
    children: [
      Row(
        children: [
           ...// Your Child
        ],
      ),
      isSearching ? Expanded(child: searchUserList()) : Expanded(child: chatRoomsList(),
    ],
  ),

暂无
暂无

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

相关问题 Flutter 滚动问题 - RenderFlex 底部溢出 192 像素 - Flutter scroll issue - A RenderFlex overflowed by 192 pixels on the bottom 无限像素溢出底部? - BOTTOM OVERFLOWED BY Infinity PIXELS? 如何正确编写以下引发此错误的代码(A RenderFlex 在底部溢出 126 像素。) - How to write the following code correctly which is throwing this error (A RenderFlex overflowed by 126 pixels on the bottom.) listview.separator 在颤动中显示空白屏幕 - listview.separator showing blank screen in flutter Flutter 为 ListView 异步构建小部件的问题 - Flutter problem with building widgets for ListView asynchronous Flutter 错误:引发了另一个异常:'DiagnosticsProperty 的实例<void> '.重定向到该页面时显示空白屏幕</void> - Flutter Error: Another exception was thrown: Instance of 'DiagnosticsProperty<void>' .It is showing a blank screen when redirected to that page 在Listview中显示来自Firebase的数据时出错 - Error with showing data from Firebase in Listview 当我更新 ListView 上的列表时,Flutter 页面不会重新加载 - Flutter page does not reload when I update the list on the ListView "<i>How can I refresh an individual List Tile in a Listview.builder?<\/i>如何刷新 Listview.builder 中的单个列表磁贴?<\/b> <i>Flutter<\/i>扑<\/b>" - How can I refresh an individual List Tile in a Listview.builder? Flutter AngularFire浏览器刷新给出错误页面未找到 - AngularFire browser Refresh gives error page not Found
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM