flutter 行未显示在列表中

hvvq6cgz  于 2023-01-14  发布在  Flutter
关注(0)|答案(2)|浏览(105)

我正在尝试为论坛页面创建一个列表视图,但是对于尾随行和forumdata.getnop和其他数据无法显示在列表平铺下的行,我该如何修复?类没有错误,因为删除高度为19的大小框只会使其出现溢出错误。
当前应用程序图像:-

代码:-

Container(
margin: const EdgeInsets.symmetric(vertical: 20.0),
height: 900.0,
child: ListView.separated(
physics: NeverScrollableScrollPhysics(),
itemCount: forumdata.getfLength(),
separatorBuilder: (BuildContext context, int index) =>
    const Divider(),
itemBuilder: (BuildContext context, int index) {
  return ListTile(
    onTap: () {
      Navigator.of(context).push(
        MaterialPageRoute(
            builder: (context) => ThreadPageScreen(
                  index: index,
                )),
      );
    },
    visualDensity: VisualDensity(vertical: 4),
    leading: CircleAvatar(
      backgroundColor:
          Color(forumdata.getfcolor(index)),
      child: Icon(
        forumdata.getIcon(index),
        color: Color(forumdata.geticolor(index)),
      ),
    ),
    trailing: SizedBox(
            width: 300,
            height: 300,
            child: Padding(
              padding:
                  EdgeInsets.only(left: 20),
              child: Column(
                children: [
                  Container(
                    child: Align(
                      alignment: Alignment.centerLeft,
                      child: Text(
                        forumdata.getTitle(index),
                        maxLines: 1,
                        style: TextStyle(
                            fontWeight: FontWeight.bold,
                            fontSize: 15,
                            color: Colors.blue),
                      ),
                    ),
                  ),
                  Container(
                    child: Align(
                      alignment: Alignment.centerLeft,
                      child: Text(
                        forumdata.getDesc(index),
                        maxLines: 2,
                      ),
                    ),
                  ),
                  Padding(
                    padding: EdgeInsets.only(left: 20),
                        child: SizedBox(
                          width: 300,
                          height: 19,
                          child: Row(
                            children: [
                              Container(
                                child: Padding(
                                  padding:
                                      EdgeInsets.only(
                                          bottom: 20),
                                    child: Row(
                                      children: [
                                        Text(
                                          forumdata
                                                  .getnop(
                                                      index)
                                                  .toString() +
                                              " posts " +
                                              " ",
                                          style:
                                              TextStyle(
                                            color: Colors
                                                .grey,
                                            fontSize: 3,
                                          ),
                                        ),
                                        CircleAvatar(
                                          child: Image
                                              .network(
                                            userdata.getProfileIcon(
                                                forumdata
                                                    .getuser(index)),
                                          ),
                                        ),
                                        Text(
                                          " " +
                                              forumdata
                                                  .getDateTime(
                                                      index),
                                          style:
                                              TextStyle(
                                            color: Colors
                                                .grey,
                                          ),
                                        ),
                                      ],
                                    ),
                                  ),
                                ),
                            ],
                          ),
                        ),
                  ),
                ],
              ),
          ),
        ),
  );
wj8zmpe1

wj8zmpe11#

快速浏览一下,从这段代码中:

SizedBox(
        width: 300,
        height: 19,
        child: Row(children: [
          Container(
              child:
                  Padding(padding: EdgeInsets.only(bottom: 20), 
                  child: Row(

SizedBox的高度为19,第二个Row上方的padding20,因此底部填充完全隐藏了row

cmssoen2

cmssoen22#

trailing: SizedBox(
  width: 300,
  height: 300,
  child: Padding(

///替换为

title: SizedBox(
  width: MediaQuery.of(context).size.width,
  child: Padding(

相关问题