!children.any((Widget child)=> child == null)不正确

时间:2018-07-22 15:49:52

标签: null dart flutter children

构建行并根据我拥有的特定列表中的值用不同的图标填充行时,出现此错误(the actual error on running in emulator的图像)。 这是代码的一部分: (请注意,在两种情况下我都将返回一些小部件!)

 new Container(
          padding: new EdgeInsets.fromLTRB(0.0, 19.0, 0.0, 19.0),
          child: new Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children:
              (ballwiseDetails.length==0)?(List<Widget>.generate(6,(index) {
                setState(() {
                  return new Icon(Icons.add);
                });
              })):
                  List<Widget>.generate(ballwiseDetails.length,(index) {
                setState(() {
                  (index >= (6 * (overNumber - 1)))
                      ? (getIcon(ballwiseDetails[index].ball["TypeOfBall"])):null;
                });
              })
              ))

getIcon方法:-

Container getIcon(case_Each_Ball ib) {
String text = "O";
switch (ib) {
  case case_Each_Ball.dot:
    text = "O";
    break;
  case case_Each_Ball.Singles:
    text = "1";
    break;
  case case_Each_Ball.Doubles:
    text = "2";
    break;
  case case_Each_Ball.Triples:
    text = "3";
    break;
  case case_Each_Ball.Four:
    text = "4";
    break;
  case case_Each_Ball.Six:
    text = "6";
    break;
  case case_Each_Ball.WD:
    text = "WD";
    break;
  case case_Each_Ball.WD4:
    text = "4WD";
    break;
  case case_Each_Ball.Five:
    text = "5";
    break;
  case case_Each_Ball.OUT:
    text = "OUT";
    break;
  case case_Each_Ball.NB:
    text = "NB";
    break;
  default:
}
return new Container(
  decoration: new BoxDecoration(
      shape: BoxShape.circle,
      color: (ib == case_Each_Ball.OUT)
          ? Colors.red[800]
          : Colors.yellow[800]),
  child: Padding(
    padding: const EdgeInsets.all(8.0),
    child: new Text(text),
  ),
);

}

1 个答案:

答案 0 :(得分:0)

使您的最后一个Low条件不返回select[id=incident.urgency] option[value=1] + option,而是返回一个空的else

null