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),
            ),
       
        ],
      ),
    );
原文地址:https://www.cnblogs.com/liuys635/p/14684576.html