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

Zha*_* Yi 7 flutter

我在颤振中有以下代码。

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),
                    )),
              ],
            ),
          ],
        ),
      ),
    );
  }
Run Code Online (Sandbox Code Playgroud)

但我收到此错误:

???????? 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 
Run Code Online (Sandbox Code Playgroud)

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

dha*_*kar 14

目前尚不清楚您要实现的目标,但SizedBox您可以尝试将其包裹在内部ExpandedFlexible小部件中,而不是使用。


Cod*_*oet 7

我尝试为您的宽度添加 200SizedBox并且它起作用了。

尽管Expanded按照@dhanasekar 的建议使用也很有效。