在 `Row` 内渲染 ListTile 时出现错误 `Failedassertion: line 1687 pos 12: 'hasSize'`

2024-01-17

我在颤动中有以下代码。

Widget build(BuildContext context) {
    return Center(
      child: Card(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: <Widget>[
            Row(
              children: <Widget>[
                SizedBox(
                    height: 100,
                    child: ListTile(
                      leading: IconButton(
                        iconSize: 30,
                        icon: roundImage(post.userPicture, Icon(Icons.person)),
                        onPressed: () {},
                      ),
                      subtitle: Text(this.post.message),
                    )),
              ],
            ),
          ],
        ),
      ),
    );
  }

但我收到这个错误:

════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderPhysicalShape#7713c relayoutBoundary=up3
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1687 pos 12: 'hasSize'
The relevant error-causing widget was
    Card 

我已经添加了SizedBox in the Row但它仍然抱怨hasSize错误。我该如何解决这个问题?


目前尚不清楚您想要实现什么目标,但不要使用SizedBox你可以尝试包裹在里面Expanded or Flexible小部件。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

在 `Row` 内渲染 ListTile 时出现错误 `Failedassertion: line 1687 pos 12: 'hasSize'` 的相关文章

随机推荐