简体   繁体   中英

Using ListTile and getting exception: RenderBox was not laid out

I am trying to use ListTile() inside Column and Rows but it is throwing an exception:

Exception caught by rendering library 
The following assertion was thrown during performLayout():
BoxConstraints forces an infinite width.

This is the code:

          Row(
            children: <Widget>[
              Column(
                children: <Widget>[
                  Card()
                ],
              ),
              Column(
                children: <Widget>[
                  Card(
                    child: ListTile(),
                  )
                ],
              )
            ],
          ),

How can we solve this?

Use Expanded widget

       Row(
            children: <Widget>[
              Column(
                children: <Widget>[
                  Card()
                ],
              ),
              Expanded(
                child: Column(
                  children: <Widget>[
                    Card(
                      child: ListTile(),
                    )
                  ],
                ),
              )
            ],
          ),

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM