Row 或者Colunm 与 ListView ListTile等搭配报错,解决方案

 Row 或者 Colunm,与ListView 、ListTile等组件搭配错误,直接在Row 或者Colunm的子组件中使用Expand组件即可

这是正确的,不报错的

return Container(
      child: Row(
        children: <Widget>[
          Expanded(
            child:  ListTile(
              title: Text(titleName,style: TextStyle(color: Colors.black,fontWeight: FontWeight.w500,fontSize: 16.0),),
              subtitle: Text(subTitle),
            ),
          )
        ],
      ),
    );

 

这是错误的,

 return Container(
      child: Row(
        children: <Widget>[
           ListTile(
              title: Text(titleName,style: TextStyle(color: Colors.black,fontWeight: FontWeight.w500,fontSize: 16.0),),
              subtitle: Text(subTitle),
            ),
       
        ],
      ),
    );

 

posted @ 2021-04-21 11:44  技术研究与问题解决  阅读(308)  评论(0)    收藏  举报