Flutter 错误:The method ‘>‘ was called on null

不说废话,直接上方法:

一般是ListView 搭配 Row 或者 Colunm错误,直接在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),
            ),
       
        ],
      ),
    );

猜你喜欢

转载自blog.csdn.net/zww986736788/article/details/108117852