颤振条件渲染。不起作用?我确实尝试了很多方法,但是找不到任何解决方案。我想在data[index].status
不为空时呈现窗口小部件。我的代码对我不起作用。
Row(
children:<widget>[
if (data[index].status = null)
{
Container(
child: Text('somthing'),
)
}
else
{
Container(
decoration: BoxDecoration(
color: Colors.red[700],
borderRadius:
BorderRadius.circular(20)),
padding: EdgeInsets.symmetric(
vertical: 6, horizontal: 8),
child: Text(
data[index].status,
style: TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.normal,
fontFamily: 'Raleway'),
),
),
}
]
)
您正在将data[index].status
值设置为null。
您正在使用=
而不是==
您的代码应为
Row(
children:<widget>[
if (data[index].status == null) // note the ==
{
Container(
child: Text('somthing'),
)
}
else
{
Container(
decoration: BoxDecoration(
color: Colors.red[700],
borderRadius:
BorderRadius.circular(20)),
padding: EdgeInsets.symmetric(
vertical: 6, horizontal: 8),
child: Text(
data[index].status,
style: TextStyle(
fontSize: 15,
color: Colors.white,
fontWeight: FontWeight.normal,
fontFamily: 'Raleway'),
),
),
}
]
)