【发布时间】:2019-12-23 16:52:03
【问题描述】:
有时 animals.relatives 为空,因此 t.name 返回导致问题的 null
我尝试了 if else 语句并尝试 catch,但我猜它在小部件中不起作用?我不知道为什么它不起作用
Column(
children: <Widget>[
Text(animals.name),
Text(animals.desc),
Text("Relatives :"),
Row(
children: animals.relatives.map((t) =>
FilterChip(
label: Text(t.name),onSelected: (b){}))
.toList(),
),
]),
如果 t.name 为空,我希望其上方的行和文本不显示
【问题讨论】: