【问题标题】:Vertical viewport was given unbounded height flutter/dart垂直视口被赋予了无限的高度颤动/飞镖
【发布时间】:2022-01-14 11:18:18
【问题描述】:

这是我的代码:

 @override
 Widget build(BuildContext context) {
    return ListView(children: [
       Card(
          child: Row(
             children: [
                 ListTile(
                     title: Text(publicacion.title),
                    subtitle: Text(publicacion.body),
                 )
             ],
          )),
     ]);
  }

肯定是有些溢出,但我无法修复它,我找不到方法.. 我尝试实现 ListView.builder,但我不知道在哪里安装它

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    尝试添加您的 Inside Row 小部件,用 ExpandedFlexible 包裹它,参考我的答案 hereherehere 希望对您有所帮助

    参考Expandedhere

    试试下面的代码希望对你有帮助。

        ListView(
                shrinkWrap: true,
                children: [
                  Card(
                    child: Row(
                      children: [
                        Expanded(
                          child: ListTile(
                            title: Text(
                                'publicacion.titlepublicacion.titlepublicacion.titlepublicacion.titlepublicacion.titlepublicacion.title'),
                            subtitle: Text(
                                'publicacion.bodypublicacion.titlepublicacion.titlepublicacion.titlepublicacion.titlepublicacion.titlepublicacion.title'),
                          ),
                        )
                      ],
                    ),
                  ),
                ],
              ),
    

    您的结果屏幕->

    【讨论】:

      【解决方案2】:

      Row 小部件造成了这个问题,只需删除 Row 小部件,它应该可以正常工作。

      @override
        Widget build(BuildContext context) {
          return ListView(children: [
            Card(
                child: ListTile(
                  title: Text(publicacion.title),
                  subtitle: Text(publicacion.body),
                )),
          ]);
        }
      

      【讨论】:

        猜你喜欢
        • 2019-07-30
        • 2019-11-05
        • 1970-01-01
        • 1970-01-01
        • 2019-01-15
        • 1970-01-01
        • 2023-04-04
        • 2020-06-06
        • 1970-01-01
        相关资源
        最近更新 更多